diff --git a/iexcode/instruments/ARPES.py b/iexcode/instruments/ARPES.py index b62398ad0ca98baec4589c2fb7c43d81cfb45eb9..0beb42f625811f81f5f8a4be65b82a95bb0b3fee 100644 --- a/iexcode/instruments/ARPES.py +++ b/iexcode/instruments/ARPES.py @@ -11,7 +11,7 @@ from iexcode.instruments.IEX_cameras import _enable_endstation_cameras from iexcode.instruments.scanRecord import * from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda,path_dserv_user -from iexcode.instruments.Logfile import log_init, log_name_set +from iexcode.instruments.Logfile import log_init from iexcode.instruments.staff import staff_detector_dictionary from iexcode.instruments.xrays import xrays_detector_dictionary, _xrays_reset, xrays_get_all, xrays_log_dictionary diff --git a/iexcode/instruments/IEX_VPU.py b/iexcode/instruments/IEX_VPU.py index 408ce168ca954f47f22b53970d5871fe1eab261b..489b9ddd254c4b98a245d07f3e938786cfc53cdb 100644 --- a/iexcode/instruments/IEX_VPU.py +++ b/iexcode/instruments/IEX_VPU.py @@ -174,12 +174,13 @@ def ID_mode_set(ID_mode): writes the desired mode to the correct ID pv """ ID_mode = ID_mode.upper() - if ID_mode in ID_mode_list(): - ID_state = ID_mode_list().index(ID_mode) - caput(ID_pvs()['mode_val'],ID_state,wait=True,timeout=18000) - sleep(1) - else: - print_warning_message('ID_mode not in '+str(ID_mode_list())) + if ID_mode_get(verbose=False) != ID_mode: + if ID_mode in ID_mode_list(): + ID_state = ID_mode_list().index(ID_mode) + caput(ID_pvs()['mode_val'],ID_state,wait=True,timeout=18000) + sleep(1) + else: + print_warning_message('ID_mode not in '+str(ID_mode_list())) def ID_ready(verbose=False): @@ -245,7 +246,7 @@ def ID_start(ID_mode='RCP',QP_ratio=None, verbose=True): QP ratio if specified """ #turns on if ID is off - if ID_power_status =='Off': + if ID_power_status() =='Off': pv_sp = ID_pvs()['energy_sp'] caput(pv_sp,3.8) ID_on() @@ -254,7 +255,7 @@ def ID_start(ID_mode='RCP',QP_ratio=None, verbose=True): ID_QP_mode_set(QP_ratio,verbose) #set ID mode if ID_ready(): - ID_mode_set(ID_mode, verbose) + ID_mode_set(ID_mode) #opens the main shutter if ID_ready(): shutter_check(verbose) @@ -332,12 +333,13 @@ def ID_get_sp_eV(verbose=False): return ID_SP def _ID_write_SP_proc(keV): - # pressing ramp button doesn't work - # ramp_delay=5 - # caput(ID_pvs()['energy_sp'],keV,wait=True,timeout=18000) - # sleep(ramp_delay) - # caput(ID_pvs()['start_ramp'],1,wait=True,timeout=18000) - caput(ID_pvs()['scan_val'],keV,wait=True,timeout=18000) + if ID_power_status() == 'Off': + ID_start() + + caput(ID_pvs()['energy_sp'],keV,wait=True,timeout=18000) + caput(ID_pvs()['start_ramp'],1,wait=True,timeout=18000 ) + + #caput(ID_pvs()['scan_val'],keV,wait=True,timeout=18000) #caput(ID_pvs()['energy_sp'],keV,wait=True,timeout=18000) # just for bookkeeping sleep(1) @@ -452,14 +454,14 @@ def ID_QP_mode_set(QP_ratio=None,verbose=True): Previously: Switch_IDQP """ - #checking if above the minimum allowed value - QP_min = 70 - if QP_ratio < QP_min: - message_string="QP ratio is too small, setting it to minimum allowed value ("+str(QP_min)+")" - print_warning_message(message_string) - QP_ratio=min(100,max(70,QP_ratio)) - if QP_ratio != None: + #checking if above the minimum allowed value + QP_min = 70 + if QP_ratio < QP_min: + message_string="QP ratio is too small, setting it to minimum allowed value ("+str(QP_min)+")" + print_warning_message(message_string) + QP_ratio=min(100,max(70,QP_ratio)) + #checking to see if already in specified QP ratio_RBV, ratio_calc = ID_QP_ratio_get() #not the same ratio diff --git a/iexcode/instruments/Kappa.py b/iexcode/instruments/Kappa.py index 330809a7692ddd97cd0c37f7051289957f155d35..c3943cda0c9731051a27c24ffd1ec0805d4b0111 100644 --- a/iexcode/instruments/Kappa.py +++ b/iexcode/instruments/Kappa.py @@ -13,14 +13,14 @@ from iexcode.instruments.scanRecord import * from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda,path_dserv_user from iexcode.instruments.Logfile import log_init,log_name_set from iexcode.instruments.staff import staff_detector_dictionary -from iexcode.instruments.xrays import xrays_detector_dictionary, _xrays_reset, xrays_get_all +from iexcode.instruments.xrays import xrays_detector_dictionary, _xrays_reset, xrays_get_all, xrays_log_dictionary from iexcode.instruments.conversions_constants import * from iexcode.instruments.utilities import * from iexcode.instruments.userCalcs import * from iexcode.instruments.Motors import Motors -from iexcode.instruments.Keithley_current_amplifiers import * +from iexcode.instruments.Keithley_current_amplifiers import Keithley, _Keithley_pv, ca_reset_all, _ca_live_sequence from iexcode.instruments.SRS_current_amplifiers import * from iexcode.instruments.valves import branch_valve_close diff --git a/iexcode/instruments/Octupole.py b/iexcode/instruments/Octupole.py index 539ab95753d700a19e1215412a61b7a2ea61a20a..d92c6e3f92bcd0f006d79b7d1334b493b7335f61 100644 --- a/iexcode/instruments/Octupole.py +++ b/iexcode/instruments/Octupole.py @@ -10,9 +10,9 @@ from iexcode.instruments.IEX_cameras import _enable_endstation_cameras from iexcode.instruments.scanRecord import * from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda,path_dserv_user -from iexcode.instruments.Logfile import log_init,log_name_set +from iexcode.instruments.Logfile import log_init from iexcode.instruments.staff import staff_detector_dictionary -from iexcode.instruments.xrays import xrays_detector_dictionary, _xrays_reset, xrays_get_all +from iexcode.instruments.xrays import xrays_detector_dictionary, _xrays_reset, xrays_get_all, xrays_log_dictionary from iexcode.instruments.conversions_constants import * from iexcode.instruments.utilities import * diff --git a/iexcode/instruments/scanRecord.py b/iexcode/instruments/scanRecord.py index 19190300798c7af89266b9947c1b8a697cc9b74c..3c28c0a5f02b6bd9d53232b8afaf5697d4bbe84f 100644 --- a/iexcode/instruments/scanRecord.py +++ b/iexcode/instruments/scanRecord.py @@ -1086,7 +1086,7 @@ class ScanRecord: self.fillin(outer_loop_list[0],outer_loop_list[1],outer_loop_list[2],outer_loop_list[3],outer_loop_list[4],**kwargs) if execute: - kwargs.update('scan_dim'=kwargs['outer_scan_dim']) + kwargs.update({'scan_dim':kwargs['outer_scan_dim']}) self.go(**kwargs) diff --git a/iexcode/instruments/shutters.py b/iexcode/instruments/shutters.py index 0ff07dfb5b28a3986b166e2c8b8c15c1931ddd44..306adb2ead92372f929a01169dbee22888c1f5fc 100644 --- a/iexcode/instruments/shutters.py +++ b/iexcode/instruments/shutters.py @@ -41,6 +41,7 @@ def main_shutter_open(verbose=True): Previously: Open_MainShutter """ caput("PC:29ID:FES_OPEN_REQUEST.VAL",1, wait=True,timeout=180000) + sleep(10) if verbose: print("Opening Main Shutter...") diff --git a/iexcode/instruments/xrays.py b/iexcode/instruments/xrays.py index 556e17e685228511cb1db9636b53b28c4c3ef9ef..3ebc2a94a7563e34d12f2c2deeae9a6f54546f48 100644 --- a/iexcode/instruments/xrays.py +++ b/iexcode/instruments/xrays.py @@ -346,10 +346,10 @@ def grating(grating_name): Previously: Switch_Grating """ current_grt = mono_grating_get() - if grating != current_grt: + if grating.upper() != current_grt: shutter_open = main_shutter_status() main_shutter_close() - print("Switching grating, please wait...") + print("\nSwitching grating, please wait...") mono_grating_set(grating_name,verbose=False) apertures_set() @@ -507,13 +507,8 @@ def switch_branch(branch, force=False, shutter=True,enable_cams=True): 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...") - print("...Try again using: Switch_Branch(which, forced=True)") - else: - print("\nWell, looks like the beam is already in this branch...") - print("...if you want to force the mirror motion, use the argument: forced=True") + print("\nWell, looks like the beam is already in this branch...") + print("...if you want to force the mirror motion, use the argument: forced=True") else: # Close both shutters: print("\n") diff --git a/iexcode/macros/start_of_the_week.py b/iexcode/macros/start_of_the_week.py index 977b2fe3790a3a98db6364788ba9a3ad0ca6b995..3f8b6d8e4ea7b735a28b2ce5709277e1c0403735 100644 --- a/iexcode/macros/start_of_the_week.py +++ b/iexcode/macros/start_of_the_week.py @@ -1,5 +1,6 @@ import datetime from re import A +from time import sleep import matplotlib.pyplot as plt import iexcode.instruments.cfg as iex @@ -7,7 +8,7 @@ from iexcode.instruments.ARPES import ARPES_init from iexcode.instruments.Kappa import kappa_init from iexcode.instruments.scanRecord import * -from iexcode.instruments.diagnostics import _diagnostics_dict, diagnostics_all_out, diagnostics_all_in,diode_c,diode_d +from iexcode.instruments.diagnostics import diagnostics_all_out, diagnostics_all_in,diode_c,diode_d from iexcode.instruments.SRS_current_amplifiers import * from iexcode.instruments.xrays import * from iexcode.instruments.VLS_PGM import * @@ -171,6 +172,7 @@ def sotw_setup(grt,branch,wait,**kwargs): ### checking branch shutter: branch_shutter_open() + sleep(15) main_shutter_open() if main_shutter_status() == False: @@ -367,8 +369,11 @@ def StartOfTheWeek(grt,branch,wait=False,**kwargs): if kwargs['repeat']: #check to see if init is defined BL_init=sotw_BLinit(branch) - if BLconfig_branch() != branch: - BL_init('staff',reset=True,set_folders=False,xrays=True) + try: + if BLconfig_branch() != branch: + BL_init('staff',reset=True,set_folders=False,xrays=True) + except: + BL_init('staff',reset=True,set_folders=False,xrays=True) else: sotw_setup(grt,branch,wait,**kwargs) @@ -403,7 +408,8 @@ def StartOfTheWeek(grt,branch,wait=False,**kwargs): else: foo=input('Is detector D'+str(kwargs['detDiode'])+' in direct beam (y or n)? >') print("\n\n================== Mono/slit scans:") - sotw_slit_vs_mono(grt,slit_name,detDiode,**kwargs) + for slit_name in ['slit1A','slit2B']: + sotw_slit_vs_mono(grt,slit_name,detDiode,**kwargs) ###### Check flux: