From 726dcb93ea5ca53fddd0579b6f48c5be93edf61e Mon Sep 17 00:00:00 2001
From: jmcchesn <jmcchesn@aps.anl.gov>
Date: Fri, 2 Sep 2022 14:02:23 -0500
Subject: [PATCH] cleaning up

---
 iexcode/instruments/AD_utilities.py          |  18 +-
 iexcode/instruments/ARPES.py                 |   5 +-
 iexcode/instruments/IEX_BL_config.py         |   3 +-
 iexcode/instruments/Kappa.py                 | 192 ++++++++---------
 iexcode/instruments/Kappa_det.py             |  13 +-
 iexcode/instruments/MPA.py                   |   4 +-
 iexcode/instruments/VLS_PGM.py               |  81 +++----
 iexcode/instruments/cameras.py               |  10 +-
 iexcode/instruments/cheatsheet.txt           | 142 -------------
 iexcode/instruments/conversions_constants.py |   1 -
 iexcode/instruments/m3r.py                   |  16 +-
 iexcode/instruments/resolution.py            |  16 +-
 iexcode/instruments/scalers.py               |   4 +-
 iexcode/instruments/scanRecord.py            |   2 +-
 iexcode/instruments/shutters.py              |  37 ++--
 iexcode/instruments/slits.py                 | 209 +++++++++----------
 iexcode/instruments/staff.py                 |   7 +-
 iexcode/instruments/storage_ring.py          |   4 +-
 iexcode/instruments/utilities.py             |   1 -
 iexcode/instruments/xrays.py                 |  38 ++--
 iexcode/launch_all.py                        |   3 +
 iexcode/launch_staff.py                      |   5 +
 iexcode/launch_xrays.py                      |   4 +
 23 files changed, 348 insertions(+), 467 deletions(-)
 delete mode 100644 iexcode/instruments/cheatsheet.txt

diff --git a/iexcode/instruments/AD_utilities.py b/iexcode/instruments/AD_utilities.py
index 6990582..a10c752 100644
--- a/iexcode/instruments/AD_utilities.py
+++ b/iexcode/instruments/AD_utilities.py
@@ -12,6 +12,8 @@ from os import listdir,mkdir,chown,system,chmod,path
 from time import sleep
 
 from epics import caget, caput
+
+import iexcode.instruments.cfg as iex
 from iexcode.instruments.files_and_folders import get_next_fileNumber
 
 
@@ -54,12 +56,10 @@ def AD_EnableStats(ADplugin):
     caput(ADplugin+"ComputeCentroid","Yes")
     
 
-def AD_SaveFileSetup(ADplugin,mda,**kwargs):
+def AD_SaveFileSetup(ADplugin,**kwargs):
     """    
     ADplugin = "29id_ps1:TIFF1:" which IOC and which filesaving plugin
             (ADplugin=$(P)$(SavePlugin))
-    uses to get the current MDA directory and then set the path to one up + /dtype
-    MDA_CurrentDirectory(scanIOC=None)
     
     **kwargs (defaults)
         scanIOC = BL_ioc()
@@ -73,12 +73,10 @@ def AD_SaveFileSetup(ADplugin,mda,**kwargs):
         FileTemplate="%s%s_%4.4d."+ext; format for filename first %s = filepath, second %s = prefix
         
     """
-    fp=path.dirname(mda.filepath())
-    kwargs.setdefault("userpath",fp)
+    kwargs.setdefault("userpath",path.dirname(iex.BL.mda.filepath()))
     kwargs.setdefault("subfolder",ADplugin.split(":")[-2][:-1])
 
     kwargs.setdefault("prefix",ADplugin.split(":")[-2][:-1])
-    extDict={"TIFF":".tif","HDF":"h5"}
     kwargs.setdefault("ext",ADplugin.split(":")[-2][:-1])
     kwargs.setdefault("FileTemplate","%s%s_%4.4d."+kwargs["ext"])
     
@@ -231,7 +229,7 @@ def AD_snap(ADplugin,**kwargs):
         
 
 
-def AD_ScanTrigger(ADplugin,mda,**kwargs):
+def AD_ScanTrigger(ADplugin,**kwargs):
     """
     Add Triggering of AreaDetector to scanIOC
     ADplugin = "29idc_ps1:TIFF1:" (ADplugin=$(P)$(SavePlugin))
@@ -248,11 +246,11 @@ def AD_ScanTrigger(ADplugin,mda,**kwargs):
     kwargs.setdefault("R","cam1:")
     kwargs.setdefault("detTrig",2)
     
-    scanPV=mda.ioc+"scan"+str(kwargs["scanDIM"])    
+    scanPV=iex.BL.mda.ioc+"scan"+str(kwargs["scanDIM"])    
     trigger=".T"+str(kwargs["detTrig"])+"PV"
     caput(scanPV+trigger,kwargs["P"]+kwargs["R"]+"Acquire",wait=True,timeout=5*60)
     
-def ADplugin_ScanSetup(ADplugin,mda, **kwargs):
+def ADplugin_ScanSetup(ADplugin, **kwargs):
     """
     stop the acquisition, puts in ImageMode=Single
     enables saving
@@ -285,7 +283,7 @@ def ADplugin_ScanSetup(ADplugin,mda, **kwargs):
     AD_SaveFileSetup(ADplugin,**kwargs)
     AD_ScanTrigger(ADplugin, **kwargs)
     trigger=".T"+str(kwargs["detTrig"])+"PV"
-    scanPV=mda.ioc+"scan"+str(kwargs["scanDIM"])  
+    scanPV=iex.BL.mda.ioc+"scan"+str(kwargs["scanDIM"])  
     print("WARNING: you need to need to disable saving and clear the trigger by hand after the scan")
     print("\tAD_FreeRun("+ADplugin+"); caput("+scanPV+trigger+",'')")
 
diff --git a/iexcode/instruments/ARPES.py b/iexcode/instruments/ARPES.py
index 8656d25..ad85205 100644
--- a/iexcode/instruments/ARPES.py
+++ b/iexcode/instruments/ARPES.py
@@ -17,7 +17,8 @@ from iexcode.instruments.utilities import *
 from iexcode.instruments.userCalcs import userStringSeq_clear, userStringSeq_pvs
 
 from iexcode.instruments.Motors import Motors
-from iexcode.instruments.current_amplifiers import *
+from iexcode.instruments.current_amplifiers import Keithley, _Keithley_pv, ca_reset_all, _ca_live_sequence
+
 from iexcode.instruments.valves import branch_valve_close
 from iexcode.instruments.shutters import branch_shutter_close
 
@@ -287,7 +288,7 @@ def ARPES_get_all(verbose=True):
                 print(key+" = "+beamline_info[key])
             print("-----------------------------------------------------------")   
      
-     if verbose:   
+    if verbose:   
         print("\n===========================================================")
 
     return vals
diff --git a/iexcode/instruments/IEX_BL_config.py b/iexcode/instruments/IEX_BL_config.py
index aadf0de..7117b9d 100644
--- a/iexcode/instruments/IEX_BL_config.py
+++ b/iexcode/instruments/IEX_BL_config.py
@@ -11,9 +11,9 @@ it makes the default stuff work
 this will prompt for the endstation and will set the default parameters, look at the 
 init kwargs to see which defaults you can change.
 """
+
 #For new endstation modify here:
 endstations_list = ['ARPES','Kappa']   
-
 class Beamline_Config:
     """
     used for defining which endstation in which you are running
@@ -158,6 +158,7 @@ def get_all(verbose=True):
     returns the current beamline and endstation setting
 
     """
+    vals={}
     vals.update(iex.BL.endstation_get(verbose))
     
     return vals
diff --git a/iexcode/instruments/Kappa.py b/iexcode/instruments/Kappa.py
index e5942a5..cca859d 100644
--- a/iexcode/instruments/Kappa.py
+++ b/iexcode/instruments/Kappa.py
@@ -25,17 +25,17 @@ from iexcode.instruments.shutters import branch_shutter_close
 #branch specific
 from iexcode.instruments.slits import slit3D_get
 #endstation specific
-from iexcode.instruments.kappa_det import Kappa_Detector
+from iexcode.instruments.kappa_det import kappa_Detector
 from iexcode.instruments.scalers import scaler_cts
 from iexcode.instruments.MPA import MPA
 from iexcode.instruments.spec_stuff import folders_spec
 
 default_ioc = '29idKappa:'
 #############################################################################
-def Kappa_init(*userName,**kwargs):
+def kappa_init(*userName,**kwargs):
     """
     used to intialize the Endstation class which carries scanRecord, logging ... parameters
-    returns global detectors relavent to this endstation (tey,d3,d4,mesh,Kappa_scaler_pv,tth_pv,tthdet)
+    returns global detectors relavent to this endstation (tey,d3,d4,mesh,kappa_scaler_pv,tth_pv,tthdet)
 
         *userName is an optional parameter, will be prompted if set_folders=True
 
@@ -54,11 +54,11 @@ def Kappa_init(*userName,**kwargs):
     #motors
     physical_motors = ['x','y','z','tth','kth','kap','kphi']
     pseudo_motors = ['th','chi','phi']
-    global Kappa_Motors
-    Kappa_Motors = Motors('Kappa',_Kappa_motor_dictionary(),physical_motors,pseudo_motors)
+    global kappa_Motors
+    kappa_Motors = Motors('kappa',_kappa_motor_dictionary(),physical_motors,pseudo_motors)
 
     #endstation
-    iex.BL = Beamline_Config('Kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['mode'],Kappa_Motors)
+    iex.BL = Beamline_Config('kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['mode'],kappa_Motors)
 
     #setting folders
     if kwargs['set_folders']:
@@ -70,36 +70,36 @@ def Kappa_init(*userName,**kwargs):
             else:
                 user_name = userName[0]
         print(user_name)
-        folders_Kappa(user_name,**kwargs)
+        folders_kappa(user_name,**kwargs)
 
         #update for default scanRecord advanced parameters
-        iex.BL.mda.log('Kappa',user_name,_Kappa_log_header(),_Kappa_log_entries)
+        iex.BL.mda.log('kappa',user_name,_kappa_log_header(),_kappa_log_entries)
 
     #global detectors
-    global tey,d3,d4,mesh,Kappa_scaler_pv,tth_pv,tthdet
+    global tey,d3,d4,mesh,kappa_scaler_pv,tth_pv,tthdet
     tey = SRS("29idMZ0:scaler1.S2", '29idd:A1')
     d3 = SRS("29idMZ0:scaler1.S3", '29idd:A2')
     d4 = SRS("29idMZ0:scaler1.S4", '29idd:A3')
     mesh = SRS("29idMZ0:scaler1.S14", '29idd:A4')
-    Kappa_scaler_pv = '29idMZ0:scaler1.CNT'
-    tth_pv = _Kappa_motor_dictionary('tth')[3]
+    kappa_scaler_pv = '29idMZ0:scaler1.CNT'
+    tth_pv = _kappa_motor_dictionary('tth')[3]
     iex.mpa = MPA()
-    tthdet = Kappa_Detector(Kappa_Motors)
+    tthdet = kappa_Detector(kappa_Motors)
     
     #resetting everything
     if kwargs['reset']:
-        Kappa_reset(**kwargs)
+        kappa_reset(**kwargs)
 
     #enable cameras
     _enable_endstation_cameras()
 
-    print ('Kappa initalized')
+    print ('kappa initalized')
     #return any detectors or other parameters that you want access to from jupyter
-    return tey,d3,d4,mesh,Kappa_scaler_pv,tth_pv,tthdet
+    return tey,d3,d4,mesh,kappa_scaler_pv,tth_pv,tthdet
 ##############################################################################################################
 ##############################                    detectors and motors                ##############################
 ##############################################################################################################
-def _Kappa_detector_list():
+def _kappa_detector_list():
     """
     list of detectors to trigger 
 
@@ -109,7 +109,7 @@ def _Kappa_detector_list():
     return ca_list
 
 
-def _Kappa_detector_dictionary(**kwargs):
+def _kappa_detector_dictionary(**kwargs):
     """
     returns a dictionary of the default detectors
 
@@ -182,11 +182,11 @@ def _Kappa_detector_dictionary(**kwargs):
     return det_dict
 
 
-def _Kappa_motor_dictionary(name):
+def _kappa_motor_dictionary(name):
     """
     motor_dictionary = {name:[rbv,val,spmg,pv]} for physical and psuedo/Euler motors
     usage:
-        KappaS_PVmotor('x') => ['29idKappa:m2.RBV', '29idKappa:m2.VAL', '29idKapp:m2.SPMG','29idKappa:m2']
+        kappa_PVmotor('x') => ['29idKappa:m2.RBV', '29idKappa:m2.VAL', '29idKapp:m2.SPMG','29idKappa:m2']
     """
     motor_nums={
         'x':2,
@@ -213,7 +213,7 @@ def _Kappa_motor_dictionary(name):
     
     return motor_dictionary
 
-def Kappa_extra_pvs():
+def kappa_extra_pvs():
     """
     used to get the PV associated with a given pnuemonic
 
@@ -227,17 +227,17 @@ def Kappa_extra_pvs():
     }
     return d
 
-def Kappa_kth_offset_get():
+def kappa_kth_offset_get():
     caget("29idKappa:userCalcOut1.G")
 
-def Kappa_kth_offset_set(val):
+def kappa_kth_offset_set(val):
     caput("29idKappa:userCalcOut1.G",val)
 
 
 #############################################################################################################
 ##############################                 setting folder                   ##############################
 ##############################################################################################################
-def folders_Kappa(user_name,**kwargs):
+def folders_kappa(user_name,**kwargs):
     """
     Create and sets (if create_only=False) all the folders the current run and ARPES user 
     Sets the FileName for logging to be "UserName/YYYYMMDD_log.txt using logname_Set()"
@@ -268,7 +268,7 @@ def folders_Kappa(user_name,**kwargs):
         # Set up MDA folder:
         folder_mda(run,iex.BL.folder,user_name,iex.BL.prefix,iex.BL.ioc)
         #logfile_name_set(iex.BL.endstation)
-        #logfile_header(iex.BL.endstation,iex.BL.ioc,Kappa_log_header())
+        #logfile_header(iex.BL.endstation,iex.BL.ioc,kappa_log_header())
 
 
         # Set up SPEC folder:
@@ -279,9 +279,9 @@ def folders_Kappa(user_name,**kwargs):
 
     #resetting
     if 'reset':
-        Kappa_reset()
+        kappa_reset()
 
-def Kappa_reset():
+def kappa_reset():
     """
     resets scanRecord, current amplifiers, mono limits and lakeshore
     """
@@ -289,10 +289,10 @@ def Kappa_reset():
     if iex.BL.mode=='staff':
         iex.BL.mda.detector_dictionary = staff_detector_dictionary()
     else:
-         iex.BL.mda.detector_dictionary = _Kappa_detector_dictionary()
-    iex.BL.mda.trigger_dictionary = _Kappa_trigger_dictionary()
-    iex.BL.mda.scan_before_sequence = _Kappa_scan_before_sequence()
-    iex.BL.mda.scan_after_sequence = _Kappa_scan_after_sequence()    
+         iex.BL.mda.detector_dictionary = _kappa_detector_dictionary()
+    iex.BL.mda.trigger_dictionary = _kappa_trigger_dictionary()
+    iex.BL.mda.scan_before_sequence = _kappa_scan_before_sequence()
+    iex.BL.mda.scan_after_sequence = _kappa_scan_after_sequence()    
     
     #resetting the scanRecord
     print("resetting the scanRecord - "+iex.BL.ioc)
@@ -319,20 +319,20 @@ def Kappa_reset():
 ##############################################################################################################
 ##############################                    get all                 ##############################
 ##############################################################################################################
-def Kappa_get_all(verbose=True):
+def kappa_get_all(verbose=True):
     """
-    returns a dictionary with the current status of the Kappa endstation and exit slit
+    returns a dictionary with the current status of the kappa endstation and exit slit
     """
     vals = {}
 
     if verbose:
         print("\n===========================================================")
     #sample postion
-    motor_dictionary = _Kappa_motor_dictionary()
+    motor_dictionary = _kappa_motor_dictionary()
     for motor in motor_dictionary.keys():
-        vals[motor]=Kappa_Motors.get(motor,verbose=False)
+        vals[motor]=kappa_Motors.get(motor,verbose=False)
     #endstation/branch pvs
-    extra_pvs = Kappa_extra_pvs()
+    extra_pvs = kappa_extra_pvs()
     for key in extra_pvs.keys():
         vals.update(key,caget(extra_pvs[key]))
     if iex.BL.xrays:
@@ -358,22 +358,22 @@ def Kappa_get_all(verbose=True):
 ##############################################################################################################
 ##############################                         logging                  ##############################
 ##############################################################################################################
-def _Kappa_log_header():
+def _kappa_log_header():
     """
     header for the log file
     """
     h = "scan,motor,start,stop,step,x,y,z,tth,kth,kap,kphi,TA,TB,"
     h += "hv,exit_slit,GRT,ID_SP,ID_RBV,ID_Mode,ID_QP,TEY,mesh,det_name,mpa_HV,m3r_centroid,time,comment"
-    header_list = {'Kappa':h}
+    header_list = {'kappa':h}
     return header_list 
 
-def _Kappa_log_entries():
+def _kappa_log_entries():
     """
     enstation info for log file
 
     Previously: scanlog
     """
-    vals = Kappa_get_all(verbose=False)
+    vals = kappa_get_all(verbose=False)
     x = vals['x']
     y = vals['y']
     z = vals['z']
@@ -398,9 +398,9 @@ def _Kappa_log_entries():
     return entry_list,pv_list,format_list
 
 ##############################################################################################################
-##############################             Kappa scanRecord           ##############################
+##############################             kappa scanRecord           ##############################
 ##############################################################################################################
-def _Kappa_scan_before_sequence(scan_ioc,scan_dim,**kwargs):
+def _kappa_scan_before_sequence(scan_ioc,scan_dim,**kwargs):
     """
     writes the user string sequence to happen at the beginning of a scan
     returns before_scan_pv = pv for userStringSeq for before scan
@@ -427,7 +427,7 @@ def _Kappa_scan_before_sequence(scan_ioc,scan_dim,**kwargs):
 
     return before_scan_proc
 
-def _Kappa_scan_after_sequence(scan_ioc,scan_dim,**kwargs):
+def _kappa_scan_after_sequence(scan_ioc,scan_dim,**kwargs):
     """
     writes the user string sequence to happen at the end of a scan
     returns after_scan_pv = pv for userStringSeq for after scan
@@ -471,13 +471,13 @@ def _Kappa_scan_after_sequence(scan_ioc,scan_dim,**kwargs):
 
     if kwargs['snake']:
         snake_dim = scan_dim - 1
-        #snake_proc= Kappa_snake_pv(snake_dim,enable=True)
-        #caput(after_scan_pv+".LNK10",Kappa_snake_pv()+"PP NMS")
+        #snake_proc= kappa_snake_pv(snake_dim,enable=True)
+        #caput(after_scan_pv+".LNK10",kappa_snake_pv()+"PP NMS")
         #caput(after_scan_pv+".D10",1)
 
     return after_scan_proc
 
-def _Kappa_detector_triggers_sequence(scan_ioc,scan_dim,**kwargs):    # do we need to add 29idb:ca5 ???
+def _kappa_detector_triggers_sequence(scan_ioc,scan_dim,**kwargs):    # do we need to add 29idb:ca5 ???
     """
     """
     kwargs.setdefault(seq_num,8)
@@ -487,14 +487,14 @@ def _Kappa_detector_triggers_sequence(scan_ioc,scan_dim,**kwargs):    # do we ne
        
     #clear the userStringSeq
     userStringSeq_clear(scan_ioc,seq_num=kwargs['seq_num'])
-    caput(detector_triggers_pv+".DESC","Kappa_Trigger1")
+    caput(detector_triggers_pv+".DESC","kappa_Trigger1")
 
-    scaler_pv = Kappa_scaler_pv()
+    scaler_pv = kappa_scaler_pv()
 
     caput(detector_triggers_pv+".LNK" +str(1),scaler_pv)
     caput(detector_triggers_pv+".WAIT"+str(1),"After"+str(last))
     
-    ca_list = _Kappa_detector_list()
+    ca_list = _kappa_detector_list()
     last = len(ca_list)
     for i,ca in enumerate(ca_list):
         ca_pv = _Keithley_pv(ca[0], ca[1])+':read.PROC CA NMS'
@@ -503,12 +503,12 @@ def _Kappa_detector_triggers_sequence(scan_ioc,scan_dim,**kwargs):    # do we ne
 
     return detector_triggers_proc
 
-def _Kappa_trigger_dictionary(scan_ioc,scan_dim,**kwargs):
+def _kappa_trigger_dictionary(scan_ioc,scan_dim,**kwargs):
     """
     need to do something
     """
     trigger_dictionary = {
-        1:_Kappa_detector_triggers_sequence(scan_ioc,scan_dim,**kwargs),
+        1:_kappa_detector_triggers_sequence(scan_ioc,scan_dim,**kwargs),
     }
     return trigger_dictionary
 
@@ -516,17 +516,17 @@ def _Kappa_trigger_dictionary(scan_ioc,scan_dim,**kwargs):
 
 
 ##############################################################################################################
-##############################        Kappa  Motor Scan Set Up        ##############################
+##############################        kappa  Motor Scan Set Up        ##############################
 ##############################################################################################################
 
-def Kappa_sample_Euler_list():
+def kappa_sample_Euler_list():
     """
     returns list of motor names used by mvsample
     """
     motor_list = ['th','chi','phi']
     return motor_list
 
-def Kappa_4c_mprint():
+def kappa_4c_mprint():
     """
     returns the dictionary of the current sample position in 4c units 
     
@@ -535,26 +535,26 @@ def Kappa_4c_mprint():
     Previously: diffracto?
     """
     positions={}
-    motors=Kappa_sample_Euler_list()
+    motors=kappa_sample_Euler_list()
     for motor in motors:
-        positions.update(motor,_Kappa_motor_dictionary()(motor)[0])
+        positions.update(motor,_kappa_motor_dictionary()(motor)[0])
     return positions
 
-def Kappa_4c_move(th_chi_phi_list):
+def kappa_4c_move(th_chi_phi_list):
     """
     moves the sample in 4c (Euler) units
     Previously: mv4C
     """
-    motor_list=Kappa_sample_Euler_list()
+    motor_list=kappa_sample_Euler_list()
     for motor,i in enumerate(motor_list):
-        Kappa_Motors.move(motor,motor_list[i],wait=True,verbose=False)
+        kappa_Motors.move(motor,motor_list[i],wait=True,verbose=False)
     
     for motor,i in enumerate(motor_list):
-        Kappa_Motors.get(motor,verbose=True)
+        kappa_Motors.get(motor,verbose=True)
 
 def _SmarAct_motor_list():
     """
-    returns a list of the motor names for the SmarAct motors in the Kappa
+    returns a list of the motor names for the SmarAct motors in the kappa
     """
     return ['x','y','z']
 
@@ -564,7 +564,7 @@ def _SmarAct_motors_home():
 
     Previously: Home_SmarAct_Motor
     """
-    motor_dictionary = _Kappa_motor_dictionary()
+    motor_dictionary = _kappa_motor_dictionary()
     for motor in _SmarAct_motor_list():
         pv = motor_dictionary[motor][3]
         caput(pv+'.HOMF',1)
@@ -572,25 +572,25 @@ def _SmarAct_motors_home():
     print('SamrAct motors VAL homed')
 
 def _SmarAct_enable():
-    motor_dictionary = _Kappa_motor_dictionary()
+    motor_dictionary = _kappa_motor_dictionary()
     for motor in _SmarAct_motor_list():
         spmg = motor_dictionary[motor][2]
         caput(spmg,3)  # 3=Go
 
 def _SmarAct_disable():
-    motor_dictionary = _Kappa_motor_dictionary()
+    motor_dictionary = _kappa_motor_dictionary()
     for motor in _SmarAct_motor_list():
         spmg = motor_dictionary[motor][2]
         caput(spmg,0)  # 1=Stop
 
 def _PI_motor_list():
     """
-    returns a list of the motor names for the SmarAct motors in the Kappa
+    returns a list of the motor names for the SmarAct motors in the kappa
     """
     return ['kap','kth','tth']
 
 def _PI_motors_sync():
-    motor_dictionary = _Kappa_motor_dictionary()
+    motor_dictionary = _kappa_motor_dictionary()
     for motor in _PI_motor_list():
         val_pv = motor_dictionary[motor][1]
         rbv_pv = motor_dictionary[motor][0]
@@ -609,12 +609,12 @@ def Euler_motors_sync():
     caput('29idKappa:Kappa_sync.PROC',1)
     print('Euler motors VAL/RBV synced to physical motors')
 
-def Kappa_kphi_reset_zero(val):
+def kappa_kphi_reset_zero(val):
     """
     resets the zero for the kphi motor
 
     """
-    kphi_pv = _Kappa_motor_dictionary()['kphi'][3]
+    kphi_pv = _kappa_motor_dictionary()['kphi'][3]
     caput(kphi_pv+".SET",1)    # 1 = Set
     sleep(0.5)
     caput("kphi_pv.VAL",val)
@@ -622,7 +622,7 @@ def Kappa_kphi_reset_zero(val):
     caput(kphi_pv+".SET",0)    # 0 = Use
     print("\nkphi has been reset to " +str(val))
 
-def Kappa_tth_reset_zero():
+def kappa_tth_reset_zero():
     """
     resets the zero for the tth motor
     """
@@ -667,9 +667,9 @@ def th2th_scan_sensitivity(th_table,gain_num_table,gain_unit_table,**kwargs):
     else:
         detector = kwargs['detector']
 
-    kth_offset = Kappa_kth_offset_get()
+    kth_offset = kappa_kth_offset_get()
 
-    motor_dictionary = _Kappa_motor_dictionary()
+    motor_dictionary = _kappa_motor_dictionary()
     kth_val,kth_rbv,kth_spmg,kth_pv = motor_dictionary['kth']
     tth_val,tth_rbv,tth_spmg,tth_pv = motor_dictionary['tth']
 
@@ -693,7 +693,7 @@ def th2th_scan_sensitivity(th_table,gain_num_table,gain_unit_table,**kwargs):
     iex.BL.mda.fillin_table(gain_unit_pv,"",gain_unit_table,**kwargs)
 
     print("\nDon't forget to clear extra positionners at the end of the scan if you were to abort the script using the function:")
-    print("                Clear_Scan_Positioners('Kappa',1)")
+    print("                Clear_Scan_Positioners('kappa',1)")
  
     scaler_cts(kwargs['cts'],verbose=False)
     if kwargs['execute']:
@@ -725,8 +725,8 @@ def scan_th2th(tth_start,tth_stop,tth_step,th_offset,**kwargs):
     print('th: '+str(th_start)+"/"+str(th_stop)+"/"+str(tth_step/2.0))
     
     #write to the scanRecord
-    th_val,th_rbv,th_spmg,th_pv = _Kappa_motor_dictionary['th']
-    tth_val,tth_rbv,tth_spmg,tth_pv = _Kappa_motor_dictionary['tth']
+    th_val,th_rbv,th_spmg,th_pv = _kappa_motor_dictionary['th']
+    tth_val,tth_rbv,tth_spmg,tth_pv = _kappa_motor_dictionary['tth']
 
     kwargs.update("positioner_num",2)
     iex.BL.mda.fillin(th_val,th_rbv,th_start,th_stop,th_step,**kwargs)
@@ -767,8 +767,8 @@ def th2th_table(tth_table,th0,**kwargs):
     tth_table=np.asarray(tth_table)
     th_table=tth_table/2.0+th0
 
-    th_val,th_rbv,th_spmg,th_pv = _Kappa_motor_dictionary['th']
-    tth_val,tth_rbv,tth_spmg,tth_pv = _Kappa_motor_dictionary['tth']
+    th_val,th_rbv,th_spmg,th_pv = _kappa_motor_dictionary['th']
+    tth_val,tth_rbv,tth_spmg,tth_pv = _kappa_motor_dictionary['tth']
 
     #write to the scanRecord
     kwargs.update("positioner_num",1)
@@ -794,22 +794,22 @@ def th2th_table(tth_table,th0,**kwargs):
 #############################################################################################################
 ##############################             Preset Positions        ##############################
 ##############################################################################################################
-def _KappaTransfer_StrSeq():
+def _kappaTransfer_StrSeq():
     #User= [    DESC,        x,        y,      z,        tth,       kth,       kap,    kphi]
-    User = ["Kappa Transfer",0, -2650, -650, 0, 57, 0, -88]
+    User = ["kappa Transfer",0, -2650, -650, 0, 57, 0, -88]
     n=4
-    _KappaPreset_StrSeq(n,User)
+    _kappaPreset_StrSeq(n,User)
 
 
-def _KappaGrazing_StrSeq(): #Need to determine positions and then add to the Kappa graphic
+def _kappaGrazing_StrSeq(): #Need to determine positions and then add to the kappa graphic
     #Dial= [    DESC,        x,        y,      z,        tth,       kth,       kap,    kphi]
-    User = ["Kappa Grazing",0, 0, 0, 0, 57.045, 134.76,57.045]
+    User = ["kappa Grazing",0, 0, 0, 0, 57.045, 134.76,57.045]
     n=3
-    _KappaPreset_StrSeq(n,User)
+    _kappaPreset_StrSeq(n,User)
 
-def Kappa_ResetPreset():
-    _KappaGrazing_StrSeq()
-    _KappaTransfer_StrSeq()
+def kappa_ResetPreset():
+    _kappaGrazing_StrSeq()
+    _kappaTransfer_StrSeq()
 
 
 
@@ -823,7 +823,7 @@ def Kappa_ResetPreset():
 ##############################################################################################################
 ##############################             Kappa light       ##############################
 ############################################################################################################## 
-def Kappa_light(ON_OFF):
+def kappa_light(ON_OFF):
     """
     Previously:light
     """
@@ -839,11 +839,11 @@ def Kappa_light(ON_OFF):
 ##############################################################################################################
 ########################        Scan Temp and Pressure           ##############################
 ##############################################################################################################
-def Kappa_temperature_pressure_scan(scan_dim=1):
+def kappa_temperature_pressure_scan(scan_dim=1):
     """
     starts scan to monitor temperature and pressure in the kappa chamber
 
-    Previously: Kappa_ScanTempPres
+    Previously: kappa_ScanTempPres
     """
 
     pv="29id"+iex.BL.mda.ioc+":scan"+str(scan_dim)
@@ -859,9 +859,9 @@ def Kappa_temperature_pressure_scan(scan_dim=1):
 
 
 ##############################################################################################################
-##############################             Kappa safestate        ##############################
+##############################             kappa safestate        ##############################
 ##############################################################################################################
-def Kappa_safe_state(**kwargs):
+def kappa_safe_state(**kwargs):
     """
     puts the C-branch in a safe state, 
     **kwargs
@@ -888,21 +888,21 @@ def Kappa_safe_state(**kwargs):
 
 ### uan moves tth and th simultaneously 
 def uan(tth,th):
-    """ Moves tth and th motors simultaneously in the in the Kappa chamber
+    """ Moves tth and th motors simultaneously in the in the kappa chamber
     """
-    if iex.BL.endstation == 'Kappa':
+    if iex.BL.endstation == 'kappa':
         #move tth and th
-        mvth(th,wait=False)
-        mvtth(tth,wait=False)
+        kappa_Motors.move('th',th,wait=False)
+        kappa_Motors.move('tth',tth,wait=False)
         time.sleep(0.2)     
 
         while True:
-            status = iex.BL.Motors.status()
+            status = kappa_Motors.status()
             if status == 0:
                 time.sleep(0.2)
             else:
-                tth_RBV=round(iex.BL.Motors.get('tth',verbose=False),3)
-                th_RBV=round(iex.BL.Motors.get('th',verbose=False),3)
+                tth_RBV=round(kappa_Motors.get('tth',verbose=False),3)
+                th_RBV=round(kappa_Motors.get('th',verbose=False),3)
                 print('tth='+str(tth_RBV)+' th='+str(th_RBV))
                 break
     else:
diff --git a/iexcode/instruments/Kappa_det.py b/iexcode/instruments/Kappa_det.py
index 6a392a2..5ea9e9e 100644
--- a/iexcode/instruments/Kappa_det.py
+++ b/iexcode/instruments/Kappa_det.py
@@ -14,7 +14,8 @@ class Kappa_Detector:
     class for Kappa detector
     """
  
-    def __init__(self,Kappa_Motors):
+    def __init__(self,kappa_Motors):
+        self.motors = kappa_Motors
         self.get()
 
     def get(self):
@@ -26,7 +27,7 @@ class Kappa_Detector:
         #det_name = caget('29idKappa:userStringSeq6.STR1')
         det_name = caget(det_set_pv)
         self.name = det_name
-        tth_val = Kappa_Motors.get('tth')
+        tth_val = self.motors.get('tth')
         return self.name, tth_val
 
     def set(self,det_name,move=True):
@@ -42,22 +43,22 @@ class Kappa_Detector:
             yag: yag 'fluorescence screen'
         """
         #get current value for tth
-        tth_val = Kappa_Motors.get('tth')
+        tth_val = self.motors.get('tth')
 
         #change det 
         if det_name in det_list:
             caput(det_set_pv,det_name)
             if move:
-                Kappa_Motors.move('tth',tth_val,wait=True,verbose=False)
+                self.motors.move('tth',tth_val,wait=True,verbose=False)
 
-    def tth0_set(move):
+    def tth0_set(self,move):
         """
         resetting the tth motor zero to correspond to direct beam
 
         only works with d4
         """
         current_det=caget(det_set_pv,as_string=True)
-        tth_pv = Kappa_Motors._motor_dictionary['th'][3]
+        tth_pv = self.motors._motor_dictionary['th'][3]
 
         if current_det != 'd4':
             print('tth0 can only be redefined with d4')
diff --git a/iexcode/instruments/MPA.py b/iexcode/instruments/MPA.py
index 767c9e9..6856fb6 100644
--- a/iexcode/instruments/MPA.py
+++ b/iexcode/instruments/MPA.py
@@ -1,11 +1,11 @@
 from time import sleep
-from os.path import dirname, join
+from os.path import dirname, join,exists,mkdir
 import socket
 
 from epics import caget, caput
 
 import iexcode.instruments.cfg as iex
-
+from iexcode.instruments.files_and_folders import get_next_fileNumber
 from iexcode.instruments.userCalcs import userCalcOut_clear,userStringSeq_clear
 from iexcode.instruments.scalers import Kappa_scaler
 from iexcode.instruments.AD_utilities import AD_ROI_setup
diff --git a/iexcode/instruments/VLS_PGM.py b/iexcode/instruments/VLS_PGM.py
index c4bb2d1..4a40674 100644
--- a/iexcode/instruments/VLS_PGM.py
+++ b/iexcode/instruments/VLS_PGM.py
@@ -14,7 +14,7 @@ from iexcode.instruments.utilities import print_warning_message,read_dict
 ##############################################################################################################
 ################################             mono             ##############################
 ##############################################################################################################
-def mono_grating_names():
+def _mono_grating_names():
     """
     List of grating names 
     
@@ -24,7 +24,7 @@ def mono_grating_names():
     GRT_names=GRT_names[0:2] # only use the first 3 slots
     return GRT_names
 
-def mono_mirror_names():
+def _mono_mirror_names():
     """
     List of grating names 
     
@@ -34,7 +34,7 @@ def mono_mirror_names():
     MIR_names=MIR_names[0:2] # only use the first 3 slots
     return MIR_names
 
-def mono_extensions():
+def _mono_extensions():
     """
     extension used for the mono mirror and grating locations
     """
@@ -74,24 +74,24 @@ def mono_get_all(verbose=False):
         print(" grating  : "+vals['grating']," mirror  : "+vals['mirror'])
     return vals
 
-def mono_grating_num():
+def _mono_grating_num():
     """returns the current grating num"""
     return caget('29idmonoGRT_TYPE_MON')
 
-def mono_mirror_num():
+def _mono_mirror_num():
     """returns the current mirror num"""
     return caget('29idmonoMIR_TYPE_MON')
 
-def mono_pvs(grt_num=None,mir_num=None):
+def _mono_pvs(grt_num=None,mir_num=None):
     """
     returns a dictionary with all the mono pvs
     """
     if grt_num is None:
-        grt_num = mono_grating_num()
+        grt_num = _mono_grating_num()
     if mir_num is None:
-        mir_num = mono_mirror_num()
+        mir_num = _mono_mirror_num()
 
-    ext=mono_extensions()
+    ext=_mono_extensions()
 
     d={
         'energy':"29idmono:ENERGY_MON",
@@ -125,14 +125,14 @@ def mono_get_all_extended(verbose=False):
 
     Previously: Mono_Optics
     """
-    grt_num = mono_grating_num()
-    mir_num = mono_mirror_num()
-    grt_names = mono_grating_names()
-    mir_names = mono_mirror_names()
+    grt_num = _mono_grating_num()
+    mir_num = _mono_mirror_num()
+    grt_names = _mono_grating_names()
+    mir_names = _mono_mirror_names()
 
-    ext=mono_extensions()
+    ext=_mono_extensions()
 
-    pvs = mono_pvs(grt_num=None,mir_num=None)
+    pvs = _mono_pvs(grt_num=None,mir_num=None)
     vals={
         'grt_num':grt_num,
         'mir_num':mir_num,
@@ -190,7 +190,7 @@ def mono_energy_set(hv_eV,verbose=True):
     Previously: SetMono
     """
     hv_min, hv_max = mono_energy_range()
-    pv = mono_pvs()['energy_sp']
+    pv = _mono_pvs()['energy_sp']
     if hv_min <= hv_eV <= hv_max: 
         caput(pv,hv_eV,wait=True,timeout=60)
     time.sleep(2.5)
@@ -210,19 +210,20 @@ def mono_scan_pvs():
     """
     returns the pvs to be used in scanning
     """
-    val_pv = mono_pvs()['energy_sp']
-    rbv_pv = mono_pvs()['energy']
+    val_pv = _mono_pvs()['energy_sp']
+    rbv_pv = _mono_pvs()['energy']
     return val_pv, rbv_pv
 
 def mono_status_get():
     """
     returns the status of the mirror (GRT * MIR)
         1 = ready
+        2 = moving
 
 
     Previously Mono_Status
     """
-    pvs = mono_pvs()['energy']
+    pvs = _mono_pvs()['energy']
     mir_P_status = caget(pvs['mir_P_status'])
     grt_P_status = caget(pvs['grt_P_status'])
     mir_X_status = caget(pvs['mir_P_status'])
@@ -244,13 +245,13 @@ def mono_grating_translate(grating,verbose=True):
     hv_eV = mono_energy_get()
 
     try:
-        grating_state = mono_grating_names().index(grating)
+        grating_state = _mono_grating_names().index(grating)
 
     except:
         print_warning_message(grating+' not a valid grating')
 
     if current_grating != grating:
-        pvs=mono_pvs()
+        pvs=_mono_pvs()
         caput(pvs['grt_type_sp'],grating_state,wait=True,timeout=18000)        
         caput(pvs['grt_move'],1,wait=True,timeout=18000)
         while True:
@@ -351,11 +352,11 @@ def mono_parameters_pv(grt_num=None,mir_num=None):
     returns dictionary with mono_parameter for current grating/mirror
     """
     if grt_num is None:
-        grt_num =  mono_grating_num()()
+        grt_num =  _mono_grating_num()()
     if mir_num is None:
-        mir_num = mono_mirror_num()()
+        mir_num = _mono_mirror_num()()
    
-    ext = mono_extensions()
+    ext = _mono_extensions()
 
     d={
         'mir_offset':"29idmonoMIR:P_OFFSETS."+ext[mir_num],
@@ -375,9 +376,9 @@ def mono_parameters_get():
     Previously: Mono_Parameters_Get
     """
     date=time.strftime("%Y%m%d",time.localtime())
-    mirList = mono_mirror_names()
-    grtList = mono_grating_names()
-    pvList = mono_extensions()
+    mirList = _mono_mirror_names()
+    grtList = _mono_grating_names()
+    pvList = _mono_extensions()
 
     #MIR
     txt="MonoParm[\'"+date+"\']= {\n\t"
@@ -479,10 +480,10 @@ def mono_scan_fillin(hv_start,hv_stop,hv_step,**kwargs):
 
     #Setting up the ScanRecord for Mono in Table mode
     val_pv, rbv_pv = mono_scan_pvs()
-    BL.mda.fillin(val_pv,rbv_pv,hv_start,hv_stop,hv_step,**kwargs)
+    iex.BL.mda.fillin(val_pv,rbv_pv,hv_start,hv_stop,hv_step,**kwargs)
 
     #mono needs to stay and have a longer settling time
-    BL.mda.positioner_after_scan("STAY")
+    iex.BL.mda.positioner_after_scan("STAY")
 
     
 def mono_scan_fillin_table(hv_array,**kwargs):
@@ -499,19 +500,19 @@ def mono_scan_fillin_table(hv_array,**kwargs):
 
     #Setting up the ScanRecord for Mono in Table mode
     val_pv, rbv_pv = mono_scan_pvs()
-    BL.mda.fillin.table(val_pv,rbv_pv,hv_array,**kwargs)
+    iex.BL.mda.fillin.table(val_pv,rbv_pv,hv_array,**kwargs)
 
     #mono needs to stay and have a longer settling time
-    BL.mda.positioner_settling_time(kwargs['positioner_settling_time'])
-    BL.mda.positioner_after_scan("STAY")
+    iex.BL.mda.positioner_settling_time(kwargs['positioner_settling_time'])
+    iex.BL.mda.positioner_after_scan("STAY")
 
 def mono_scan_after(**kwargs):
     """
     resets mda after scanning the mono
     """
-    after_scan_pv = BL.mda.default_after_scan_seq
+    after_scan_pv = iex.BL.mda.default_after_scan_seq
     caput(after_scan_pv+".PROC",1)
-    BL.mda.positioner_after_scan("PRIOR POS")
+    iex.BL.mda.positioner_after_scan("PRIOR POS")
 
 
 ##############################################################################################################
@@ -546,7 +547,7 @@ def mono_motor_scan_fillin(motor,start,stop,step,**kwargs):
     val_pv,rbv_pv = mono_motor_scan_pvs(motor)
     caput(val_pv+".PREC",3) # database sets .PREC==0.  We want more digits than that.
 
-    BL.mda.fillin(val_pv,rbv_pv,start,stop,step,**kwargs)
+    iex.BL.mda.fillin(val_pv,rbv_pv,start,stop,step,**kwargs)
 
 def mono_zero_order(angle):
     """
@@ -617,7 +618,7 @@ def mono_grating_offset_set(val,grt_num=None):
 
     Previously: Mono_Set_GRT0
     """
-    pvs=mono_pvs(grt_num,None)
+    pvs=_mono_pvs(grt_num,None)
     caput(pvs['grt_offset'],val)
     mono_get_all_extended(verbose=True)
 
@@ -627,7 +628,7 @@ def mono_mirror_offset_set(val,mir_num=None):
 
     Previously: Mono_Set_MIR0
     """
-    pvs=mono_pvs(None,mir_num)
+    pvs=_mono_pvs(None,mir_num)
     caput(pvs['mir_offset'],val)
     mono_get_all_extended(verbose=True)
 
@@ -669,7 +670,7 @@ def mono_grating_b2_set(val,grt_num=None):
     Previously: Mono_Set_b2
     """
     hv = mono_energy_get()
-    pvs = mono_pvs(grt_num,None)
+    pvs = _mono_pvs(grt_num,None)
     caput(pvs['grt_b2t'],val)
     time.sleep(1)
     
@@ -684,7 +685,7 @@ def mono_cff_set(val,tune_num):
     Previously: Mono_Set_cff
     """
     hv = mono_energy_get()
-    pvs = mono_pvs()
+    pvs = _mono_pvs()
 
     #get current info
     current_vals = mono_get_all_extended(verbose=False)
@@ -715,7 +716,7 @@ def mono_arm_set(distance_mm):
     Previously: Mono_Set_ExitArm
     """
     hv = mono_energy_get()
-    pvs = mono_pvs()
+    pvs = _mono_pvs()
 
     #get current info
     current_vals = mono_get_all_extended(verbose=False)
diff --git a/iexcode/instruments/cameras.py b/iexcode/instruments/cameras.py
index c41d35c..9f43d0f 100644
--- a/iexcode/instruments/cameras.py
+++ b/iexcode/instruments/cameras.py
@@ -110,10 +110,18 @@ def cam_live(cam_num):
     ADplugin = _pv_dictionary()[cam_num]+ADtype+":"
     AD_FreeRun(ADplugin)
 
-def cam_done(cam_num):
+def cam_done(cam_num,**kwargs):
     """
     stops camera acquisition (not will stop after current acquisition)
     """
     ADtype='TIFF'
     ADplugin = _pv_dictionary()[cam_num]+ADtype+":"
     AD_Done(ADplugin,**kwargs)
+
+def cam_save_setup(cam_num,**kwargs):
+    """
+    sets up the save paths using iex.BL.mda.current_user
+    """
+    ADtype='TIFF'
+    ADplugin = _pv_dictionary()[cam_num]+ADtype+":"
+    AD_SaveFileSetup(ADplugin,**kwargs)
diff --git a/iexcode/instruments/cheatsheet.txt b/iexcode/instruments/cheatsheet.txt
deleted file mode 100644
index d658910..0000000
--- a/iexcode/instruments/cheatsheet.txt
+++ /dev/null
@@ -1,142 +0,0 @@
-#ARPES: ARPES specific functions
-
-#AD_untilites: functions for common area detector operations
-
-#bakeout: functions for monitoring a bakeout
-
-#cameras: used for taking images from epics
-cam_snap => takes a single image
-cam_scan_setup => configures the scanRecord to take an image at each polarization
-cam_live => puts the camera back in live/free-run mode
-cam_done => turns off acquisition
-
-#cfg: config file which holds global variable BL and MPA
-usage => import iexcode.instruments.cfg as iex
-
-#converstions_constants: 
-h => Planck's constant (eV/s)
-c => speed of light (m/s)
-deg2rad => converts degree to radian
-rad2deg => converts radian to degrees
-eV2Lambda => converts eV to Angstroms
-Lambda2eV => converts Angstroms to eV
-
-#current_amplifiers:
-Keithley => class for Keithley current amplifiers
-ca_detector_list => list of detectors which are used in a given branch ('b for beamline)
-ca_average => turns on averaging for all Keithleys in ca_list
-ca_reset_all => resets all Keithleys in all branches
-SRS => class for SRS current amplifiers
-current2flux => calculates the flux based on the current reading in an AUX100 photodiode
-flux2current => calculates the current reading for a given flux for and AUX100 photodiode
-
-#diagnostics: bemaline diagnostics
-diagnostics_list_all => prints the name of all the diagnostics_all_in
-diagnostic => moves the specified diagnostic in/out
-diagnostics_all_out => moves all beamline diagnostics out
-diagnostics_all_in => moves all beamline diagnostics in; Note that they can shadow/block downstream diagnostics 
-mesh_W => moves W-mesh in the A-hutch in/out
-diode_c => moves diode in c-branch in/out
-diode_c_read => reads the current amplifier for the c-branch diode
-diode_d => moves diode in c-branch in/out; located just before the kappa endstation
-mesh_d => moves mesh in d-branch in/out; used for normalization
-mesh_d_read => reads the current amplifier for the d-branch mesh
-
-
-#electron_analyzer: beamline specific calls to Scienta
-EA => electron analyzer class
-EA_ioc_init => initializes the ioc after a reboot (eventually goes in AutoSave)
-folders_EA => sets the folder for the Scienta spectra saving (called by Folders_ARPES)
-SES_slit_get => gets the analyzer slit number
-SES_slit_set => sets the analyzer slit to the given value
-scanEA => takes a spectra
-scanFM => takes a Fermi map
-mvth_interp => moves to an interpolated theta value
-scanEA_hv => takes a spectra at each photon energy
-scanEA_motor => takes a spectra at each motor point 
-resolution_EA => get the analyzer contribution to the resolution
-
-#encoder: beamline absolute encoders
-encoder_name_list => lists names in encoder dictionary
-encoder_sync => syncs all the encoders associated with name
-encoders_slit2B_reset_zero => resets the center for the slit2B encoder
-
-#files_and_folders: general scripts for dealing with files and directories
-path_dserv => path to user data directory on the dserve
-check_run => returns the current run based on todays date
-make_ftp => creates the folders on the ftp server, kip
-make_user_folders => creates all the appropriate user folders
-folder_mda => creates/set the user folder for the scanRecord
-folder_SPEC
-get_last_fileNumber => gets the last file number in the directory
-
-FMB_mirrors: functions for M0,M1,M3R
-FMB_mirror_get => get the current position of all axes for a given mirror
-FMB_mirror_move => moves the specified axis ('Tx','Ty','Tz','Rx','Ry','Rz') for the given mirror
-FMB_mirror_move_all => moves all the axes to the positions specified in position_list
-FMB_mirror_tweak => relative moves
-FMB_mirror_scan => scan a mirror axis
-M0M1_Table => reads the dictionary file to get the previous mirror positions
-M0M1_SP => writes the values form M0M1_Table to the set points (still need to push move)
-
-#hxp_mirrors: Newport hexapods
-hxp_sync => syncs the motor setpoint and readback values for a given mirror
-hxp_get => gets a mirror position
-hxp_get_all => gets all the mirror positions
-
-
-#IEX_BL_config: used to access current beamline configuration, based on instance initialization not pv
-Beamline_Config => class to carry all configuration info gets stored in iexcode\instruments\cft BL
-BL_ioc => returns the scan ioc
-BL_branch => returns the branch (shutter not mirror position)
-BL_mode => returns the current mode (user/staff)
-BL_mda_prefix => return prefix for mda scanRecord
-BL_mda_filepath => returns the file path in mda scanRecord
-get_all => gets relavent pv values
-
-#IEX_VPU: undulator functions
-ID_get_all => gets ID_mode, ID_QP_ratio, ID_sp, ID_rbv
-ID_off => turns off the ID 
-ID_start => turns on the ID
-ID_restart => turns off the ID and then turns it on with the same set point
-
-#kappa_angle_calcs:
-fourc2kappa => converts between four-circle angles and kappa angles
-kappa2fourc => converts between kappa dn four-circle angles
-
-#kappa_det: defines kappa tth detector class and other functions
-Kappa_Detector => for detset etc in kappa chamber
-
-#kappa: kappa specific functions
-
-#Logfile: functions for writing logfile.txt, gets set by IEX_BL_config
-log_print => print a comment in the logfile
-log_update => updates the logfile with the current info (used if script is aborted)
-log_name_set => change name of logfile
-
-#m3r: functions for dealin with m3r
-m3r_tweak_pitch => tweaks the pitch of m3r
-m3r_table => go to the default position specified branch
-m3r_branch => returns the branch based on mirror position
-m3r_switch_branch => moves the mirror to the default position for a given branch
-m3r_centroid => returns the centroid position for m3r
-m3r_align => aligns the m3r
-
-#Motors: motor class and common name functions
-Motor => class definition get set in Beamline_Config
-mvx => moves motor x
-dmvx => relative move of x 
-scanx => scan of x motor
-dscanx => relative scan of x motor
-
-#xrays
-energy_get_all()
-energy_get()
-getE()
-energy(hv_eV)
-
-mvid()
-mvmono()
-
-switch_gratings(grt)
-polarization(ID_mode)
\ No newline at end of file
diff --git a/iexcode/instruments/conversions_constants.py b/iexcode/instruments/conversions_constants.py
index d98149c..44f8490 100644
--- a/iexcode/instruments/conversions_constants.py
+++ b/iexcode/instruments/conversions_constants.py
@@ -1,5 +1,4 @@
 import numpy as np
-from epics import caget
 
 ##############################################################################################################
 ##############################            conversions         ##############################
diff --git a/iexcode/instruments/m3r.py b/iexcode/instruments/m3r.py
index a996a86..b601fe4 100644
--- a/iexcode/instruments/m3r.py
+++ b/iexcode/instruments/m3r.py
@@ -50,19 +50,27 @@ def m3r_tweak_pitch(sign,val=0.005):
     elif sign == "-":
         m3r_tweak(axis,-val)
 
-
-def m3r_table(branch):   
+def m3r_position_dictionary():
     """
-    Defines the positions used by switch_branch() form M3R
-    WARNING: branch_pv uses: D => (Tx <= 0) and (Ry < 0) - Make sure this remains true or change it
+    dictionary for the default positions for a given branch
     """
     positions={
         "c":[10,0,0,0,0,0],
         "d":[-2.5,0,0,-13.955,-16.450,-5.15],
         "e":[-2.000,0,0,-13.960,-16.614,-7.500] 
     }
+
+
     # d => optimized for MEG @ 500 eV on 2/29/def start
     # e => 2018_3-- JM changed for RSoXS alignment max diode current
+    return positions
+    
+def m3r_table(branch):   
+    """
+    Defines the positions used by switch_branch() form M3R
+    WARNING: branch_pv uses: D => (Tx <= 0) and (Ry < 0) - Make sure this remains true or change it
+    """
+    positions = m3r_position_dictionary()
 
     try:
         position = positions[branch]
diff --git a/iexcode/instruments/resolution.py b/iexcode/instruments/resolution.py
index cd8c836..7cdbf8f 100644
--- a/iexcode/instruments/resolution.py
+++ b/iexcode/instruments/resolution.py
@@ -2,8 +2,9 @@ import numpy as np
 
 from epics import caget
 
+import iexcode.instruments.cfg as iex
 from iexcode.instruments.utilities import take_closest_value
-from iexcode.instruments.xrays import get_branch, getE, slit_get
+from iexcode.instruments.xrays import getE, slit_get
 from iexcode.instruments.VLS_PGM import mono_grating_get
 from iexcode.instruments.electron_analyzer import EA, resolution_EA, getSESslit
 from iexcode.instruments.ARPES import ARPES_extra_pvs
@@ -16,7 +17,7 @@ def resolution():
         ARPES: total resolution i.e. sqrt(kbT^2 + analyzer^2 + BL^2); default SES slit = 5.
         Kappa:  beamline contribution only
     """
-    branch = get_branch()
+    branch = iex.BL.branch
     grt = mono_grating_get()
     hv_eV = getE()
     slit_size = take_closest_value([10,20,50,100,200],round(slit_get(),0))
@@ -24,10 +25,13 @@ def resolution():
     if branch == "c":
         slit_SES = getSESslit()
         PE = int(EA.PassEnergy)
-        T = caget(ARPES_extra_pvs['TA'])
-        resolution_ARPES(grt,hv_eV,slit_size,PE,slit_SES,T,verbose=True)
+        Tsample = caget(ARPES_extra_pvs['TA'])
+        resolution_ARPES(grt,hv_eV,slit_size,PE,slit_SES,Tsample,verbose=True)
+        print("Calculate: resolution_ARPES(grt,hv_eV,slit_size,PE,slit_SES,Tsample)")
     else:
         resolution_beamline(grt,hv_eV,slit_size,verbose=True)
+        print("Calculate: resolution_beamline(grt,hv_eV,slit_size)")
+
 
 
 def resolution_calculate_beamline(grt,hv_eV,slit_size):
@@ -105,7 +109,7 @@ def resolution_ARPES(grt,hv_eV,slit_size,PE,slit_SES,T,verbose=True):
 
     return resolution
 
-def Resolution_BL_eff(grating,hv,slit_3C,PE,slit_SES,T,Ef):
+def resolution_BL_eff(grating,hv,slit_3C,PE,slit_SES,T,Ef):
     M = resolution_mono_noise(grating,hv)
     KbT = T*25/300
     BL = resolution_calculate_beamline(grating,hv,slit_3C)
@@ -118,7 +122,7 @@ def Resolution_BL_eff(grating,hv,slit_3C,PE,slit_SES,T,Ef):
     print("BL_eff: "+"%.0f" % effective, "meV")
 
 
-def Resolution_BL_eff2(grating,hv,slit_3C,PE,slit_SES,T,Ef,Dirty_Au):
+def resolution_BL_eff2(grating,hv,slit_3C,PE,slit_SES,T,Ef,Dirty_Au):
     M = resolution_mono_noise(grating,hv)
     KbT = T*25/300
     BL = resolution_calculate_beamline(grating,hv,slit_3C)
diff --git a/iexcode/instruments/scalers.py b/iexcode/instruments/scalers.py
index 9f608be..82bba65 100644
--- a/iexcode/instruments/scalers.py
+++ b/iexcode/instruments/scalers.py
@@ -1,5 +1,4 @@
 from math import floor
-
 from epics import caput,PV
 
 import iexcode.instruments.cfg as iex
@@ -8,7 +7,8 @@ def scaler_cts(time_seconds=0.1,verbose=True):
     """
     sets the scalers counting for the endstation defined in BL
     """ 
-    if iex.BL.ioc == 'Kappa':
+    'For new endstation modify here:'
+    if iex.BL.endstation_name == 'Kappa':
         Kappa_scaler(time_seconds,verbose=verbose)
     else:
         pass
diff --git a/iexcode/instruments/scanRecord.py b/iexcode/instruments/scanRecord.py
index f390693..41ecc6d 100644
--- a/iexcode/instruments/scanRecord.py
+++ b/iexcode/instruments/scanRecord.py
@@ -8,7 +8,7 @@ import iexcode.instruments.cfg as iex
 
 from iexcode.instruments.utilities import dateandtime, print_warning_message
 from iexcode.instruments.userCalcs import userStringSeq_pvs,userStringSeq_clear
-
+from iexcode.instruments.shutters import shutter_check
 
 def scan_fillin(VAL,RBV,start,stop,steps_points,**kwargs):
     """
diff --git a/iexcode/instruments/shutters.py b/iexcode/instruments/shutters.py
index 6cffb7e..8279908 100644
--- a/iexcode/instruments/shutters.py
+++ b/iexcode/instruments/shutters.py
@@ -8,6 +8,26 @@ import iexcode.instruments.cfg as iex
 from iexcode.instruments.utilities import dateandtime
 
 
+def shutter_check():
+    """
+    Checks main shutter is open, if not opens it"
+    Checks brancg shutter is open, if not opens it"
+    
+    Previously: Check_MainShutter
+    """
+    while True:
+        shutter_open = main_shutter_status()
+        if shutter_open == False:
+            print("MAIN SHUTTER CLOSED !!!" , dateandtime())
+            main_shutter_open()
+            sleep(10)
+        else:
+            print("Shutter is now open" , dateandtime())
+            break
+        shutter_open = branch_shutter_status()
+        if shutter_open == False:
+            branch_shutter_open()
+
 ##############################################################################################################
 ################################             main shutter             ##############################
 ##############################################################################################################
@@ -22,7 +42,7 @@ def main_shutter_open(verbose=True):
     if verbose:
         print("Opening Main Shutter...")
 
-def main_shutter_close():
+def main_shutter_close(verbose=True):
     """
     closes the main shutter
 
@@ -51,21 +71,6 @@ def main_shutter_status():
     return shutter_open
 
 
-def main_shutter_check_open():
-    """
-    Checks main shutter is open, if not opens it"
-    
-    Previously: Check_MainShutter
-    """
-    while True:
-        shutter_open = main_shutter_status()
-        if shutter_open == False:
-            print("MAIN SHUTTER CLOSED !!!" , dateandtime())
-            main_shutter_open()
-            sleep(10)
-        else:
-            print("Shutter is now open" , dateandtime())
-            break
 ##############################################################################################################
 ################################             branch shutters            ##############################
 ##############################################################################################################
diff --git a/iexcode/instruments/slits.py b/iexcode/instruments/slits.py
index fa7102f..dcfa558 100644
--- a/iexcode/instruments/slits.py
+++ b/iexcode/instruments/slits.py
@@ -1,16 +1,15 @@
 from numpy import inf,nan
 
 from epics import caget, caput
-from .IEX_BL_config import *
-
 
+import iexcode.instruments.cfg as iex
 from iexcode.instruments.shutters import main_shutter_close
 from iexcode.instruments.utilities import print_warning_message
 from iexcode.instruments.encoders import encoders_reset_zero
 
 slit_ioc="29idb:"
 
-def slits_dictionary():
+def _slits_dictionary():
     """
     dictionary of slit pv names for two and four blade slit assemblies
 
@@ -21,20 +20,49 @@ def slits_dictionary():
     d = {
         'slit1A' : ('Slit1H','Slit1V'),
         'slit2B' : ('Slit2H','Slit2V'),
+        'slit3C' : None,
         'slit3D' : ('Slit4V')
+        
+        }
+    return d
+
+def slit_name_list():
+    d=_slits_dictionary
+    for key in d.keys():
+        print(key)
+
+def _slits_wide_open_dictionary():
+    """
+    wide open size for the slits
+    These are not the epics limits, but the physical extent of the beam
+    """
+    d = {
+        'slit1A' : (4.5,4.5),
+        'slit2B' : (6,8),
+        'slit3C' : (300),
+        'slit3D' : (2000)
+        
         }
     return d
 
-def slits_pvs(slit_name):
+def _slits_pvs(slit_name):
     """
     returns the rbv and drive for the size,center
     (rbv_size,val_size),(rvb_center,val_center)
     """
-    slit_pv = slit_ioc + slit_name
-    size_rbv = slit_pv +'t2.D'
-    size_val = slit_pv +'center.VAL'
-    center_rbv = slit_pv +'t2.C'
-    center_val = slit_pv +'center.VAL'
+    d = _slits_dictionary()
+    if slit_name in d.keys():
+        if slit_name == 'slit3C':
+            size_rbv = '29idb:Slit3CRBV'
+            size_val = '29idb:Slit3CFit.A'
+            center_rbv = None
+            center_val = None   
+        else:
+            slit_pv = slit_ioc + slit_name
+            size_rbv = slit_pv +'t2.D'
+            size_val = slit_pv +'center.VAL'
+            center_rbv = slit_pv +'t2.C'
+            center_val = slit_pv +'center.VAL'
 
     return (size_rbv,size_val),(center_rbv,center_val)
 
@@ -42,8 +70,11 @@ def slits_synch(slit_name):
     """
     synch the motor position and the slit table for all the beamline slits
     """
-    slit_pv = slit_ioc + slit_name+'sync.PROC'
-    caput(slit_pv,1)
+    d = _slits_dictionary()
+    if slit_name in d.keys():
+        if slit_name != 'slit3C':
+            slit_pv = slit_ioc + slit_name+'sync.PROC'
+            caput(slit_pv,1)
 
 def slits_sync_all():
     """
@@ -52,62 +83,46 @@ def slits_sync_all():
 
     Previously: SyncAllSlits
     """
-    slit_list = slits_dictionary()
+    slit_list = _slits_dictionary()
     for slit_name in slit_list.keys():
         slits_synch(slit_name)
 
-def slits_print_all():
-    """
-    gets the current position of slit-1A, slit-2B, slit-3C, slit-3D
 
-    Previously Get_Slits
-    """
-    slits_sync_all()
-    slit1A_get(verbose=True)
-    slit2B_get(verbose=True)
-
-    slit3C_get(verbose=True)
-    slit3D_get(verbose=True)
-
-def slits_get_all(verbose=False):
+def slits_get_all(verbose=True):
     """
     returns a dictionary with the current slit status
     """
     vals = {}
-    vals['slit1A_size'], vals['slit1A_center'] = slit1A_get(verbose=False)
-    vals['slit2B_size'], vals['slit2B_center'] = slit2B_get(verbose=False)
-    vals['slit3C_size'] = slit3C_get(verbose=False)
-    vals['slit3D_size'],vals['slit3D_center'] = slit3D_get(verbose=False)
-
-    if verbose:
-        slits_print_all()
-    return vals
+    vals['slit1A_size'], vals['slit1A_center'] = slit1A_get(verbose=verbose)
+    vals['slit2B_size'], vals['slit2B_center'] = slit2B_get(verbose=verbose)
+    vals['slit3C_size'] = slit3C_get(verbose=verbose)
+    vals['slit3D_size'],vals['slit3D_center'] = slit3D_get(verbose=verbose)
 
 def slits_set(slit_name,size,center,verbose=True):
     """
     synchs the slit motors and the slit table and then sets the center and size
     
     slit_name is key in slits_dictionary
-    size = (H_size, V_size) 
+    size = (H_size, V_size)  #inf => all the way open
     center = (H_center, V_center)
     
     Previously: SetSlit
     """
-    d = slits_dictionary()
+    d = _slits_dictionary()
     #syncing
     slits_synch(slit_name)
 
-    for i,slit_HV in enumerate(d[slit_name]): #H and V
-        (size_rbv,size_val),(center_rbv,center_val) = slits_pvs(slit_HV)
-        caput(size_val, size[i],timeout=180)
-        caput(center_val, center[i],timeout=180)
-
-    if verbose:
-        if (d[slit_name])>1:
-            print(slit_name + " = ("+str(round(size[0],3))+"x"+str(round(size[1],3))+") @ ("+str(center[0])+","+str(center[1])+")")
-        else:
-            print(slit_name + " = ("+str(round(size[0],3))+") @ ("+str(center[0])+")")
-
+    if inf in size:
+        size = _slits_wide_open_dictionary()[slit_name]
+    if d[slit_name] != None:
+        for i,slit_HV in enumerate(d[slit_name]): #H and V
+            (size_rbv,size_val),(center_rbv,center_val) = _slits_pvs(slit_HV)   
+            if center_rbv != None:    
+                caput(center_val, center[i],timeout=180)
+            if size_rbv != None:  
+                caput(size_val, size[i],timeout=180)
+    else:
+        print_warning_message("Not a valid slit_name")
     return size,center
 
 
@@ -116,7 +131,7 @@ def slits_get(slit_name,verbose=True):
     returns the current H_size,V_size,H_center,V_center
     
     """
-    d=slits_dictionary()
+    d=_slits_dictionary()
     size = []
     center = []
 
@@ -124,9 +139,13 @@ def slits_get(slit_name,verbose=True):
     slits_synch(slit_name)
 
     for slit_HV in d[slit_name]: #H and V
-        (size_rbv,size_val),(center_rbv,center_val) = slits_pvs(slit_HV)
-        size.append(caget(size_rbv))
-        center.append(caget(center_rbv))
+        (size_rbv,size_val),(center_rbv,center_val) = _slits_pvs(slit_HV)
+        if size_rbv != None:
+            size.append(caget(size_rbv))
+        if center_rbv != None:
+            center.append(caget(center_rbv))
+        else:
+            center.append(0)
 
     if verbose:
         if (d[slit_name])>1:
@@ -166,19 +185,19 @@ def slits_scan_size(slit_name,direction,start,stop,step,**kwargs):
     kwargs.setdefault('center',slits_get(slit_name,verbose=False)[1])
     kwargs.setdefault('execute',True) 
 
-    slit_H,slit_V = slits_dictionary()[slit_name]
+    slit_H,slit_V = _slits_dictionary()[slit_name]
        
     if direction == 'H':
-        (size_rbv,size_val),(center_rbv,center_val) = slits_pvs(slit_H)
+        (size_rbv,size_val),(center_rbv,center_val) = _slits_pvs(slit_H)
     if direction == 'V':
-        (size_rbv,size_val),(center_rbv,center_val) = slits_pvs(slit_V)
+        (size_rbv,size_val),(center_rbv,center_val) = _slits_pvs(slit_V)
 
     #set slit center
     slits_set_center(slit_name,kwargs['center'])
     #scan
-    BL.mda.fillin(size_rbv,size_val,start,stop,step,**kwargs)
+    iex.BL.mda.fillin(size_rbv,size_val,start,stop,step,**kwargs)
     if kwargs['execute']:
-        BL.mda.go(**kwargs)
+        iex.BL.mda.go(**kwargs)
 
 def slits_scan_center(slit_name,direction,start,stop,step,**kwargs):
     """
@@ -190,19 +209,19 @@ def slits_scan_center(slit_name,direction,start,stop,step,**kwargs):
     kwargs.setdefault('size',slits_get(slit_name,verbose=False)[0])
     kwargs.setdefault('execute',True) 
 
-    slit_H,slit_V = slits_dictionary()[slit_name]
+    slit_H,slit_V = _slits_dictionary()[slit_name]
 
     if direction == 'H':
-        (size_rbv,size_val),(center_rbv,center_val) = slits_pvs(slit_H)
+        (size_rbv,size_val),(center_rbv,center_val) = _slits_pvs(slit_H)
     if direction == 'V':
-        (size_rbv,size_val),(center_rbv,center_val) = slits_pvs(slit_V)
+        (size_rbv,size_val),(center_rbv,center_val) = _slits_pvs(slit_V)
     
     #set slit center
     slits_set_size(slit_name,kwargs['size'])
     #scan
-    BL.mda.fillin(center_rbv,center_val,start,stop,step,**kwargs)
+    iex.BL.mda.fillin(center_rbv,center_val,start,stop,step,**kwargs)
     if kwargs['execute']:
-        BL.mda.go(**kwargs)
+        iex.BL.mda.go(**kwargs)
 
 def slit1A_scribe_marks():
     """
@@ -230,11 +249,6 @@ def slit1A_set(H_size,V_size,verbose=True,**kwargs):
     kwargs.setdefault('center',(0,0))
     slit_name = 'slit1A'
 
-    if H_size in [inf,nan,None]: 
-        H_size=4.5
-    if V_size in [inf,nan,None]: 
-        V_size=4.5
-
     size = (H_size,V_size)
     center = kwargs['center']
     slits_set(slit_name,size,center, verbose=verbose)
@@ -243,8 +257,7 @@ def slit1A_get(verbose=True):
     """
     returns the current (H_size,V_size),(H_center,V_center)
     """
-    slit_name = "slit1A"
- 
+    slit_name = 'slit1A'
     return  slits_get(slit_name,verbose=verbose)
 
 def slit2B_set(H_size,V_size,verbose=True,**kwargs):
@@ -260,26 +273,10 @@ def slit2B_set(H_size,V_size,verbose=True,**kwargs):
     kwargs.setdefault('center',(0,0))
     slit_name = "slit2B"
 
-    if H_size in [inf,nan,None]: 
-        H_size=6
-    if V_size in [inf,nan,None]: 
-        V_size=8
-
     size = (H_size,V_size)
     center = kwargs['center']
     slits_set(slit_name,size,center, verbose=verbose)
 
-def slit2B_set_small(Hsize,Vsize,coef,verbose=True,**kwargs):
-    """
-    Used to scale the aperature size by coef
-        Hsize = Hsize * coef
-        Vsize = Vsize * coef
-    """
-    Hsize = Hsize * coef
-    Vsize = Vsize * coef
-    print_warning_message("closing Slit-2B down by a factor of", coef, "!!!")
-    slit2B_set(Hsize,Vsize,verbose=True,**kwargs)
-  
 def slit2B_get(verbose=True):
     """
     returns the current (H_size,V_size),(H_center,V_center)
@@ -295,7 +292,7 @@ def slit2B_encoders_reset(Hcenter,Vcenter):
     Previously: Reset_Slit2B_Encoders
     """
     slit_name = 'slit2B'
-    slits_set(slit_name,(0,0),(Hcenter,Vcenter), verbose=verbose)
+    slits_set(slit_name,(0,0),(Hcenter,Vcenter), verbose=True)
     encoders_reset_zero(slit_name)
     slits_synch(slit_name)
 
@@ -306,23 +303,17 @@ def slit3C_set(size,verbose=True):
 
     Previously SetSlit3C
     """
-    position=round(slit_3C_fit(size),1)
-    caput("29idb:Slit3CFit.A",size,wait=True,timeout=18000)
-    
-    if verbose:
-        print("Slit-3C =",size,"um  -  ( m24 =",position,")")
+    slit_name = 'slit3C'
+    center = None
+    slits_set(slit_name,size,center, verbose=verbose)
 
 def slit3C_get(size,verbose=True):
     """
     gets slit-3C (ARPES resolution defining slit)
     returns size, position
     """
-    size, position = slit_3C_rbv()
-    
-    if verbose:
-        print("Slit-3C =",size,"um  -  ( m24 =",position,")")
-
-    return size, position
+    slit_name = "slit3C"   
+    return  slits_get(slit_name,verbose=verbose)
 
 def slit3D_set(V_size,verbose=True,**kwargs):
     """
@@ -365,24 +356,21 @@ def slit3D_encoders_reset(Vcenter):
     """
 
     slit_name = 'slit3D'
-    slits_set(slit_name,(0),(Vcenter), verbose=verbose)
+    slits_set(slit_name,(0),(Vcenter), verbose=True)
     encoders_reset_zero(slit_name)
     slits_synch(slit_name)
 
-def exit_slit(branch, size, verbose=True):
+def exit_slit(size, verbose=True):
     """
     verbose used to supress printing
 
     Previously: SetExitSlit
     """
+    branch=iex.BL.mda.branch
     if branch == "c":
         slit3C_set(size, verbose)
     elif branch == "d":
         slit3D_set(size, verbose)
-    elif branch == "e":
-        slit3D_set(size, verbose)
-
-
 
 
 
@@ -390,7 +378,6 @@ def exit_slit(branch, size, verbose=True):
 ################################             slit fits             ##############################
 ##############################################################################################################
 
-
 def aperture_fit(hv,slit_num):
     """
     used close the beamline apertures/slits to only take the center of the beam, 
@@ -398,12 +385,12 @@ def aperture_fit(hv,slit_num):
 
     Previously Aperture_Fit
     """
-    K=slit_Coef(slit_num)[1]
+    K=slit_coef(slit_num)[1]
     sizeH=K[0]+K[1]*hv+K[2]*hv*hv
     sizeV=K[3]+K[4]*hv+K[5]*hv*hv
     return [round(sizeH,3),round(sizeV,3)]
 
-def slit_Coef(slit_num):
+def slit_coef(slit_num):
     """
     3rd order polynomials coeffients for closing slit1A / slit2B to minimize heat bump effects
     slit_num = 1 / 2 for slit1A / slit2B
@@ -432,11 +419,10 @@ def slit_Coef(slit_num):
     return pv,K
 
 
-def slit_3C_fit(size):
+def slit_3C_fit_calc_position(size):
     """
     used to convert slit size to motor position for slit 3C - flexure stage
-
-    empirically determine offline with a camera
+    empirically determine offline with a camera, coeffients used by epics
 
     Previously: Slit3C_Fit
     """
@@ -450,13 +436,13 @@ def slit_3C_fit(size):
     motor=K0+K1*size+K2*size**2+K3*size**3+K4*size**4+K5*size**5+K6*size**6
     return motor
 
-def slit_3C_rbv():
+def slit_3C_fit_calc_size(position):
     """
-    used to convert slit motor position to size
+    used to convert slit size to motor position for slit 3C - flexure stage
+    empirically determine offline with a camera, coeffients used by epics
     
     Previously: Slit3C_RBV
     """
-    position=caget("29idb:m24.RBV")
     K0=299.66
     K1=16.404
     K2=1.5572
@@ -465,5 +451,6 @@ def slit_3C_rbv():
     K5=0.00014501
     K6=1.2617e-06
     size=round(K0+K1*position+K2*position**2+K3*position**3+K4*position**4+K5*position**5+K6*position**6,0)
-    return size, position
+    return size
+
 
diff --git a/iexcode/instruments/staff.py b/iexcode/instruments/staff.py
index e7c1fbb..a31ba22 100644
--- a/iexcode/instruments/staff.py
+++ b/iexcode/instruments/staff.py
@@ -1,6 +1,9 @@
 from os import listdir,mkdir,chmod
 from os.path import join, isfile, exists
 
+from iexcode.instruments.ARPES import folders_ARPES
+from iexcode.instruments.kappa import folders_kappa
+
 def folders_startup(run):
     """
     Creates the run directories for the following:
@@ -22,8 +25,8 @@ def folders_startup(run):
         if not (exists(path)):
             mkdir(path)
 
-    #folders_ARPES('Staff',create_only=True)
-    #folders_Kappa('Staff',create_only=True)
+    folders_ARPES('Staff',create_only=True)
+    folders_kappa('Staff',create_only=True)
 
     txt="\n\n\nupdate the rsync portion the 29id@nerdy crontab\n"
     txt+="*/1 * * * * /usr/bin/rsync -av --exclude=core /net/s29data/export/data_29idd/"+run+" kip:/net/kip/sftp/pub/29iddftp/files >  /home/beams22/29ID/cronfiles/cptoftp-currrun-d.log 2>&1"
diff --git a/iexcode/instruments/storage_ring.py b/iexcode/instruments/storage_ring.py
index a2269b8..de3e7fb 100644
--- a/iexcode/instruments/storage_ring.py
+++ b/iexcode/instruments/storage_ring.py
@@ -9,14 +9,14 @@ from time import sleep
 
 from iexcode.instruments.utilities import dateandtime
 
-def wait_for_beam():
+def wait_for_beam(ring_current=80):
     """
     Monitors the storage ring current and breaks when the ring current is above 60 mA
     Checks the status every 30 seconds
     """
     while True:
         SR=caget("S:SRcurrentAI.VAL")
-        if (SR<80):
+        if (SR<ring_current):
             sleep(30)
         else:
             print("Beam is back -"+dateandtime())
diff --git a/iexcode/instruments/utilities.py b/iexcode/instruments/utilities.py
index 2a1fdcd..7b04586 100644
--- a/iexcode/instruments/utilities.py
+++ b/iexcode/instruments/utilities.py
@@ -9,7 +9,6 @@ import sys
 import ast
 import os
 import numpy as np
-from numpy import inf
 
 from epics import caget, caput
 
diff --git a/iexcode/instruments/xrays.py b/iexcode/instruments/xrays.py
index 7efd024..67ed2f8 100644
--- a/iexcode/instruments/xrays.py
+++ b/iexcode/instruments/xrays.py
@@ -8,18 +8,18 @@ from time import sleep
 from epics import caget,caput
 
 import iexcode.instruments.cfg as iex
-
-from iexcode.instruments.IEX_VPU import *
-from iexcode.instruments.VLS_PGM import *
-from iexcode.instruments.slits import *
-from iexcode.instruments.shutters import *
-from iexcode.instruments.valves import *
-from iexcode.instruments.diagnostics import *
-from iexcode.instruments.m3r import m3r_align
 from iexcode.instruments.cameras import _enable_endstation_cameras
-from iexcode.instruments.utilities import print_warning_message,make_table
 from iexcode.instruments.current_amplifiers import ca_average, ca_detector_list
+from iexcode.instruments.diagnostics import *
+from iexcode.instruments.FMB_mirrors import FMB_mirror_get
+from iexcode.instruments.IEX_VPU import *
 from iexcode.instruments.Logfile import log_update
+from iexcode.instruments.m3r import m3r_align,m3r_branch,m3r_switch_branch,m3r_position_dictionary
+from iexcode.instruments.shutters import *
+from iexcode.instruments.slits import *
+from iexcode.instruments.utilities import print_warning_message,make_table
+from iexcode.instruments.valves import *
+from iexcode.instruments.VLS_PGM import *
 
 mpa = iex.mpa
 
@@ -219,7 +219,7 @@ def energy_get():
     """
     return the mono energy readback
     """
-    hv = getE()
+    hv = mono_energy_get()
     return hv
 
 def energy(hv_eV,slit_coeff=1,m3r=True,verbose=True):
@@ -348,7 +348,7 @@ def getE():
     """ 
     Returns current mono set point.
     """
-    return mono_energy_get()
+    return energy_get()
 
 def grating(grating):
     """
@@ -411,7 +411,7 @@ def scanmono(start,stop,step,average_pnts=1,**kwargs):
 
 
 
-def scanXAS(start_stop_step_lists,ID_eV=None, **kwargs):
+def scanXAS(start_stop_step_lists,ID_eV=None,ID_tracking=False, **kwargs):
     """
     scans the beamline energy:
         ID_eV = None        => the ID stays at the current value (default) 
@@ -465,7 +465,7 @@ def scanXAS(start_stop_step_lists,ID_eV=None, **kwargs):
 
     #Scanning
     if kwargs['execute']:
-        mono_energy_set(hv_array[0])
+        mono_energy_set(mono_array[0])
         iex.BL.mda.go(scan_dim)
     
         #Setting everything back
@@ -546,10 +546,10 @@ def switch_branch(branch, force=False, shutter=True,scan_reset=True,enable_cams=
     Previously: Switch_Branch
     """
     branch = branch.lower()
-    if branch in ["c","d","e"]:
-
     # Check current branch:
-        if get_branch() == branch and not force:
+    d = m3r_position_dictionary()
+    if branch in d.keys():
+        if m3r_branch() == branch and not force:
             m3r_position = FMB_mirror_get(3,verbose=False)
             if np.sum(np.array(m3r_position)):
                 print("\nMirror homed...")
@@ -602,11 +602,7 @@ def slit(size):
         ARPES = 0 < x < 300  um
         Kappa  = 0 < x < 1000 um
     """
-    branch = iex.BL.branch
-    if branch == "c":
-        slit3C_set(size, quiet=False)
-    elif branch == "d":
-        slit3D_set(size, quiet=False)
+    exit_slit(size)
 
 
 def slit_get(verbose=True):
diff --git a/iexcode/launch_all.py b/iexcode/launch_all.py
index 768f822..8c8d3a9 100644
--- a/iexcode/launch_all.py
+++ b/iexcode/launch_all.py
@@ -8,3 +8,6 @@ from iexcode.instruments.diagnostics import diagnostics_list_all, diagnostic
 from iexcode.instruments.diagnostics import diagnostics_all_out, diagnostics_all_in, mesh_W
 from iexcode.instruments.IEX_BL_config import get_all
 from iexcode.instruments.Motors import *
+from iexcode.instruments.scalers import *
+from iexcode.instruments.scanRecord import *
+from iexcode.instruments.utilities import *
\ No newline at end of file
diff --git a/iexcode/launch_staff.py b/iexcode/launch_staff.py
index 902b663..83489cb 100644
--- a/iexcode/launch_staff.py
+++ b/iexcode/launch_staff.py
@@ -5,6 +5,11 @@ from iexcode.instruments.files_and_folders import *
 from iexcode.instruments.hxp_mirrors import *
 from iexcode.instruments.IEX_BL_config import *
 from iexcode.instruments.m3r import *
+from iexcode.instruments.slits import *
+from iexcode.instruments.staff import *
+from iexcode.instruments.userCalcs import *
+from iexcode.instruments.valves import *
+from iexcode.instruments.VLS_PGM import *
 
 
 
diff --git a/iexcode/launch_xrays.py b/iexcode/launch_xrays.py
index fc12149..5d1e98b 100644
--- a/iexcode/launch_xrays.py
+++ b/iexcode/launch_xrays.py
@@ -1,3 +1,7 @@
 from iexcode.instruments.IEX_VPU import ID_get_all,ID_off,ID_start,ID_restart
 from iexcode.instruments.m3r import m3r_centroid,m3r_align,m3r_tweak_pitch 
 from iexcode.instruments.xrays import * 
+from iexcode.instruments.slits import exit_slit
+from iexcode.instruments.storage_ring import wait_for_beam
+from iexcode.instruments.valves import branch_valve_open, branch_valve_close
+from iexcode.instruments.xrays import *
\ No newline at end of file
-- 
GitLab