diff --git a/build/lib/iexcode/instruments/AD_utilities.py b/build/lib/iexcode/instruments/AD_utilities.py index 15dd0a09b5a21539352d7827c64cb70c5359e4b7..cfe1930890eddd5dc2bde59f1782aea8caa3d855 100644 --- a/build/lib/iexcode/instruments/AD_utilities.py +++ b/build/lib/iexcode/instruments/AD_utilities.py @@ -13,7 +13,6 @@ from os.path import join, isfile, exists, dirname from time import sleep from epics import caget, caput -from iexcode.instruments.IEX_endstations import BL from iexcode.instruments.files_and_folders import get_next_fileNumber diff --git a/build/lib/iexcode/instruments/ARPES.py b/build/lib/iexcode/instruments/ARPES.py index 9189eca4a951e3dd6a144a047c26970c2982b926..63ace10ceedadd91f68bdcba2ec6f88b2cd6c56b 100644 --- a/build/lib/iexcode/instruments/ARPES.py +++ b/build/lib/iexcode/instruments/ARPES.py @@ -3,12 +3,15 @@ from time import sleep from epics import caget,caput,PV +import iexcode.instruments.cfg as iex from iexcode.instruments.IEX_endstations import Endstation +#import iexcode.instruments.IEX_endstations as iex + from iexcode.instruments.staff import staff_detector_dictionary from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda from iexcode.instruments.staff import staff_detector_dictionary -from iexcode.instruments.logfile import Logfile +from iexcode.instruments.Logfile import Logfile from iexcode.instruments.conversions_constants import * from iexcode.instruments.utilities import * @@ -26,7 +29,6 @@ from iexcode.instruments.slits import slit3C_get from iexcode.instruments.Lakeshore_335 import Lakeshore_reset from iexcode.instruments.electron_analyzer import EA_init_Motors,folders_EA,EA -global BL global tey,ca15 global ARPES_Motors @@ -54,13 +56,13 @@ def ARPES_init(*userName,**kwargs): ARPES_Motors = Motors('ARPES',ARPES_motor_dictionary(),physical_motors,psuedo_motors) #endstation - global BL - BL=Endstation('ARPES',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],ARPES_Motors) + #global BL + iex.BL = Endstation('ARPES',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],ARPES_Motors) #setting folders if kwargs['set_folders']: - if BL.mode == 'staff': + if iex.BL.mode == 'staff': user_name = 'staff' else: if len(userName)==0: @@ -71,7 +73,7 @@ def ARPES_init(*userName,**kwargs): folders_ARPES(user_name,**kwargs) #update for default scanRecord advanced parameters - BL.mda.log('ARPES',user_name,ARPES_log_header(),ARPES_log_entries) + iex.BL.mda.log('ARPES',user_name,ARPES_log_header(),ARPES_log_entries) #EA if EA.connected: @@ -178,28 +180,28 @@ def folders_ARPES(user_name,**kwargs): kwargs.setdefault('ftp',False) kwargs.setdefault('debug',False) - global BL + #global BL run = kwargs['run'] if kwargs['debug']: - print("run,folder,user_name,ioc,ftp: ",run,BL.folder,user_name,kwargs['scan_ioc'],kwargs['ftp']) + print("run,folder,user_name,ioc,ftp: ",run,iex.BL.folder,user_name,kwargs['scan_ioc'],kwargs['ftp']) # Create User Folder: - make_user_folders(run,BL.folder,user_name,BL.endstation,ftp=kwargs['ftp']) + make_user_folders(run,iex.BL.folder,user_name,iex.BL.endstation,ftp=kwargs['ftp']) sleep(5) if kwargs["set_folders"]: # Set up MDA folder: - folder_mda(run,BL.folder,user_name,BL.prefix,BL.ioc) + folder_mda(run,iex.BL.folder,user_name,iex.BL.prefix,iex.BL.ioc) sleep(5) - logfile_name_set(BL.endstation) + logfile_name_set(iex.BL.endstation) sleep(2) - logfile_header(BL.endstation,BL.ioc,ARPES_log_header()) + logfile_header(iex.BL.endstation,iex.BL.ioc,ARPES_log_header()) #Set up Scienta folders: if EA.connected: - userPath = "/net/s29data/export/data_29id"+BL.folder+"/"+run+"/"+user_name+"/" + userPath = "/net/s29data/export/data_29id"+iex.BL.folder+"/"+run+"/"+user_name+"/" folders_EA(userPath,filePrefix="EA") else: print_warning_message("EA ioc is not running, h5 folder not set") @@ -208,27 +210,27 @@ def ARPES_reset(**kwargs): """ resets scanRecord, current amplifiers, mono limits and lakeshore """ - global BL + #global BL #resetting the scanRecord - if BL.mode=='staff': - BL.mda.detector_dictionary = staff_detector_dictionary() + if iex.BL.mode=='staff': + iex.BL.mda.detector_dictionary = staff_detector_dictionary() else: - BL.mda.detector_dictionary = ARPES_detector_dictionary() + iex.BL.mda.detector_dictionary = ARPES_detector_dictionary() - BL.mda.trigger_dictionary = ARPES_trigger_dictionary(**kwargs) - BL.mda.scan_before_sequence = ARPES_scan_before_sequence(**kwargs) - BL.mda.scan_after_sequence = ARPES_scan_after_sequence(**kwargs) + iex.BL.mda.trigger_dictionary = ARPES_trigger_dictionary(**kwargs) + iex.BL.mda.scan_before_sequence = ARPES_scan_before_sequence(**kwargs) + iex.BL.mda.scan_after_sequence = ARPES_scan_after_sequence(**kwargs) - BL.mda.reset_all() + iex.BL.mda.reset_all() #resetting the current amplifiers - if BL.xrays: + if iex.BL.xrays: ca_reset_all() else: tey.reset() #resetting mono and anyother beamline stuff - if BL.xrays: + if iex.BL.xrays: xrays_reset() #reseting the ARPES Lakeshore @@ -262,7 +264,7 @@ def ARPES_get_all(verbose=True): vals.update('exit_slit',slit3C_get()) #beamline info - if BL.xray: + if iex.BL.xray: beamline_info = xrays_get_all() vals.update(beamline_info) @@ -323,9 +325,9 @@ def ARPES_scan_before_sequence(**kwargs): kwargs.setdefault('seq_num',9) seq_num=kwargs['seq_num'] - global BL + #global BL - scan_ioc = BL.ioc + scan_ioc = iex.BL.ioc before_scan_pv,before_scan_proc = userStringSeq_pvs(scan_ioc,seq_num) @@ -346,9 +348,9 @@ def ARPES_ca_live_sequence(**kwargs): """ """ kwargs.setdefault('seq_num',7) - global BL + #global BL - ca_live_sequence_proc = ca_live_sequence(BL.ioc,kwargs['seq_num'],ARPES_detector_list()) + ca_live_sequence_proc = ca_live_sequence(iex.BL.ioc,kwargs['seq_num'],ARPES_detector_list()) return ca_live_sequence_proc def ARPES_scan_after_sequence(**kwargs): @@ -368,8 +370,8 @@ def ARPES_scan_after_sequence(**kwargs): seq_num = kwargs['seq_num'] scan_dim = kwargs['scan_dim'] - global BL - scan_ioc = BL.ioc + #global BL + scan_ioc = iex.BL.ioc after_scan_pv,after_scan_proc = userStringSeq_pvs(scan_ioc, seq_num) @@ -382,7 +384,7 @@ def ARPES_scan_after_sequence(**kwargs): caput(after_scan_pv+".LNK1",ca_live_sequence_proc+" PP NMS") caput(after_scan_pv+".DO1",1) - scan_pv = BL.ioc+"scan"+str(scan_dim) + scan_pv = iex.BL.ioc+"scan"+str(scan_dim) ## Put scan record back in absolute mode caput(after_scan_pv+".LNK2",scan_pv+".P1AR") caput(after_scan_pv+".STR2","ABSOLUTE") @@ -409,8 +411,8 @@ def ARPES_detector_triggers_sequence(**kwargs): # do we need to add 29idb:ca5 kwargs.setdefault('seq_num',8) seq_num=kwargs['seq_num'] - global BL - scan_ioc = BL.ioc + #global BL + scan_ioc = iex.BL.ioc detector_triggers_pv,detector_triggers_proc = userStringSeq_pvs(scan_ioc, seq_num) #clear the userStringSeq diff --git a/build/lib/iexcode/instruments/IEX_endstations.py b/build/lib/iexcode/instruments/IEX_endstations.py index 172f2128985784f3829e022812525971ee874656..2013e71d57874f6960d786b4a7a7c29bf8a140f2 100644 --- a/build/lib/iexcode/instruments/IEX_endstations.py +++ b/build/lib/iexcode/instruments/IEX_endstations.py @@ -6,6 +6,7 @@ from tkinter.messagebox import NO from epics import caput from iexcode.instruments.scanRecord import ScanRecord +import iexcode.instruments.cfg as iex """ Endstation class is used to contain information about ioc, branch, mode @@ -15,8 +16,6 @@ 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. """ -global BL -BL = None class Endstation: """ @@ -118,22 +117,22 @@ def BL_ioc(): """ returns the branch from the Endstation instance """ - return BL.ioc + return iex.BL.ioc def BL_mode(): """ returns the beamline mode, User / Staff / No_Xray """ - return BL.ioc + return iex.BL.ioc def BL_mda_prefix(): """ returns the mda file prefix """ - return BL.prefix + return iex.BL.prefix def BL_mda_filepath(): """ returns the mda file prefix """ - return BL.filepath + return iex.BL.filepath diff --git a/build/lib/iexcode/instruments/Kappa.py b/build/lib/iexcode/instruments/Kappa.py index 25ead0a32447dcfc11b6c2ac930aab7ce4a84e3b..eab7ca30dbc64badfaffd5630f753d3b442d1f6c 100644 --- a/build/lib/iexcode/instruments/Kappa.py +++ b/build/lib/iexcode/instruments/Kappa.py @@ -4,12 +4,14 @@ from math import floor from epics import caget, caput,PV -from iexcode.instruments.IEX_endstations import BL +#from iexcode.instruments.IEX_endstations import * +import iexcode.instruments.IEX_endstations as iex + from iexcode.instruments.staff import staff_detector_dictionary from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda from iexcode.instruments.staff import staff_detector_dictionary -from iexcode.instruments.logfile import logfile_name_set,logfile_header +from iexcode.instruments.Logfile import logfile_name_set,logfile_header from iexcode.instruments.conversions_constants import * from iexcode.instruments.utilities import * @@ -74,7 +76,7 @@ def Kappa_init(set_folders=False,reset=False,**kwargs): #setting folders if 'set_folders': - if BL.mode == 'staff': + if iex.BL.mode == 'staff': user_name = 'staff' else: user_name = input('user name: ') @@ -247,24 +249,24 @@ def folders_Kappa(user_name,**kwargs): run = kwargs['run'] if kwargs['debug']: - print("run,folder,user_name,ioc,ftp: ",run,BL.folder,user_name,BL.ioc,kwargs['ftp']) + print("run,folder,user_name,ioc,ftp: ",run,iex.BL.folder,user_name,iex.BL.ioc,kwargs['ftp']) # Create User Folder: - make_user_folders(run,BL.folder,user_name,BL.endstation,ftp=kwargs['ftp']) + make_user_folders(run,iex.BL.folder,user_name,iex.BL.endstation,ftp=kwargs['ftp']) sleep(5) if kwargs["set_folders"]: # Set up MDA folder: - folder_mda(run,BL.folder,user_name,BL.prefix,BL.ioc) - logfile_name_set(BL.endstation) - logfile_header(BL.endstation,BL.ioc,Kappa_log_header()) + 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()) # Set up SPEC folder: - folders_spec(run,BL.folder,user_name) + folders_spec(run,iex.BL.folder,user_name) # Set up MPA folder: - #Folder_MPA(run,BL.folder,user_name) + #Folder_MPA(run,iex.BL.folder,user_name) #resetting if 'reset': @@ -275,14 +277,14 @@ def Kappa_reset(): resets scanRecord, current amplifiers, mono limits and lakeshore """ #resetting the scanRecord - BL.mda.reset() + iex.BL.mda.reset() #resetting the current amplifiers - if BL.xray: + if iex.BL.xray: ca_reset_all() #resetting mono and anyother beamline stuff - if BL.xrays: + if iex.BL.xrays: xrays_reset() #reseting the Kappa Lakeshore @@ -296,8 +298,8 @@ def Kappa_reminder_list(ioc): """ resets scanRecord, current amplifiers, mono limits and synchs motors """ - BL.mda.reset() - if BL.xray: + iex.BL.mda.reset() + if iex.BL.xray: ca_reset_all() @@ -324,7 +326,7 @@ def Kappa_get_all(verbose=True): vals.update(key,caget(extra_pvs[key])) #beamline info - if BL.xray: + if iex.BL.xray: beamline_info = xrays_get_all() #vals.update(beamline_info) @@ -426,11 +428,11 @@ def Kappa_scan_after_sequence(scan_ioc,scan_dim,**kwargs): if 'scan_ioc' in kwargs: scan_ioc = kwargs['scan_ioc'] try: - BL.ioc = kwargs['scan_ioc'] + iex.BL.ioc = kwargs['scan_ioc'] except: error = 'undefined' else: - scan_ioc = BL.ioc + scan_ioc = iex.BL.ioc after_scan_pv,after_scan_proc = userStringSeq_pvs(scan_ioc, seq_num) @@ -438,7 +440,7 @@ def Kappa_scan_after_sequence(scan_ioc,scan_dim,**kwargs): userStringSeq_clear(scan_ioc,seq_num) caput(after_scan_pv+".DESC","After Scan") - scan_pv = BL.ioc+"scan"+str(scan_dim) + scan_pv = iex.BL.ioc+"scan"+str(scan_dim) ## Put scan record back in absolute mode caput(after_scan_pv+".LNK2",scan_pv+".P1AR") caput(after_scan_pv+".STR2","ABSOLUTE") @@ -464,7 +466,7 @@ def Kappa_detector_triggers_sequence(scan_ioc,scan_dim,**kwargs): # do we nee kwargs.setdefault(seq_num,8) seq_num=kwargs['seq_num'] - detector_triggers_pv,detector_triggers_proc = userStringSeq_pvs(BL.ioc, seq_num) + detector_triggers_pv,detector_triggers_proc = userStringSeq_pvs(iex.BL.ioc, seq_num) #clear the userStringSeq userStringSeq_clear(scan_ioc,seq_num=kwargs['seq_num']) @@ -668,26 +670,26 @@ def Kappa_th2th_scan_sensitivity(th_table,gain_num_table,gain_unit_table,**kwarg tth_table = 2*th_table kwargs.update("positioner_num",1) - BL.mda.fillin_table(kth_val,kth_rbv,kth_table,**kwargs) + iex.BL.mda.fillin_table(kth_val,kth_rbv,kth_table,**kwargs) kwargs.update("positioner_num",2) - BL.mda.fillin_table(tth_val,tth_rbv,tth_table,**kwargs) + iex.BL.mda.fillin_table(tth_val,tth_rbv,tth_table,**kwargs) kwargs.update("positioner_num",3) - BL.mda.fillin_table(gain_num_pv,"",gain_num_table,**kwargs) + iex.BL.mda.fillin_table(gain_num_pv,"",gain_num_table,**kwargs) kwargs.update("positioner_num",4) - BL.mda.fillin_table(gain_unit_pv,"",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)") scaler_cts(kwargs['cts'],verbose=False) if kwargs['execute']: - BL.mda.go(**kwargs) + iex.BL.mda.go(**kwargs) #clean up after scan - BL.mda.table_reset_after(**kwargs) + iex.BL.mda.table_reset_after(**kwargs) scaler_cts(verbose=False) def Kappa_scan_th2th(tth_start,tth_stop,tth_step,th_offset,**kwargs): @@ -716,14 +718,14 @@ def Kappa_scan_th2th(tth_start,tth_stop,tth_step,th_offset,**kwargs): tth_val,tth_rbv,tth_spmg,tth_pv = Kappa_motor_dictionary['tth'] kwargs.update("positioner_num",2) - BL.mda.fillin(th_val,th_rbv,th_start,th_stop,th_step,**kwargs) + iex.BL.mda.fillin(th_val,th_rbv,th_start,th_stop,th_step,**kwargs) kwargs.update("positioner_num",1) - BL.mda.fillin(tth_val,tth_rbv,tth_start,tth_stop,tth_step,**kwargs) + iex.BL.mda.fillin(tth_val,tth_rbv,tth_start,tth_stop,tth_step,**kwargs) scaler_cts(kwargs['cts'],verbose=False) if kwargs['execute']: - BL.mda.go(**kwargs) + iex.BL.mda.go(**kwargs) #clean up after scan scaler_cts(verbose=False) @@ -759,21 +761,21 @@ def scan_th2th_table(tth_table,th0,**kwargs): #write to the scanRecord kwargs.update("positioner_num",1) - BL.mda.fillin_table(tth_val,tth_rbv,tth_table,**kwargs) + iex.BL.mda.fillin_table(tth_val,tth_rbv,tth_table,**kwargs) kwargs.update("positioner_num",2) - BL.mda.fillin_table(th_val,th_rbv,th_table,**kwargs) - BL.mda.positioner_after_scan(after="STAY") + iex.BL.mda.fillin_table(th_val,th_rbv,th_table,**kwargs) + iex.BL.mda.positioner_after_scan(after="STAY") scaler_cts(kwargs['cts'],verbose=False,**kwargs) if kwargs['execute']: - BL.mda.go(**kwargs) + iex.BL.mda.go(**kwargs) #clean up after scan - BL.mda.table_reset_after() + iex.BL.mda.table_reset_after() scaler_cts(verbose=False) - BL.mda.positioner_after_scan(after="PRIOR POS",**kwargs) + iex.BL.mda.positioner_after_scan(after="PRIOR POS",**kwargs) @@ -831,10 +833,10 @@ def Kappa_detector_triggers_strSeq(**kwargs): # do we need to add 29idb:ca5 ? kwargs.setdefault(seq_num,8) seq_num=kwargs['seq_num'] - detector_triggers_pv,detector_triggers_proc = userStringSeq_pvs(BL.ioc, seq_num) + detector_triggers_pv,detector_triggers_proc = userStringSeq_pvs(iex.BL.ioc, seq_num) #clear the userStringSeq - userStringSeq_clear(BL.ioc,seq_num=kwargs['seq_num']) + userStringSeq_clear(iex.BL.ioc,seq_num=kwargs['seq_num']) caput(detector_triggers_pv+".DESC","Kappa_Trigger1") #no triggers see ARPES_detector_triggers_sequence for example @@ -850,7 +852,7 @@ def KappaPreset_StrSeq(n,User): scanIOC="Kappa" motorIOC="29idKappa:" motor = ["m2","m3","m4","m9","m8","m7","m1"] - strSeq_pv = userStringSeq_clear(BL.mda,n) + strSeq_pv = userStringSeq_clear(iex.BL.mda,n) if User[0] == "Kappa Grazing": phi0= 0 if User[0] == "Kappa Transfer": phi0= 57 @@ -876,7 +878,7 @@ def KappaPreset_StrSeq(n,User): def Bragg_Angle_CalcOut(d,eV,l): n=7 - userCalcOut_pv = userCalcOut_clear(BL.mda,n) + userCalcOut_pv = userCalcOut_clear(iex.BL.mda,n) h=4.135667516e-15 c=299792458 @@ -899,7 +901,7 @@ def Kappa_temperature_pressure_scan(scan_dim=1): Previously: Kappa_ScanTempPres """ - pv="29id"+BL.mda.ioc+":scan"+str(scan_dim) + pv="29id"+iex.BL.mda.ioc+":scan"+str(scan_dim) #Clear all scan pvs caput(pv+".CMND",6) #Set detectors @@ -907,7 +909,7 @@ def Kappa_temperature_pressure_scan(scan_dim=1): caput(pv+".D02PV","29idd:tc1:getVal_B.VAL") caput(pv+".D03PV","29idb:VS11D.VAL") #time scan - BL.mda.time_go() + iex.BL.mda.time_go() diff --git a/build/lib/iexcode/instruments/Motors.py b/build/lib/iexcode/instruments/Motors.py index eb66288053995a59f3fcd2e5c67cc3c8f1d66831..2882fd9e5d883cb637d3b41d0c0d40ab19dd3861 100644 --- a/build/lib/iexcode/instruments/Motors.py +++ b/build/lib/iexcode/instruments/Motors.py @@ -3,10 +3,14 @@ from math import floor from epics import caget, caput -from iexcode.instruments.IEX_endstations import BL +#from iexcode.instruments.IEX_endstations import * +#import iexcode.instruments.IEX_endstations as iex +import iexcode.instruments.cfg as iex + from iexcode.instruments.scalers import scaler_cts + class Motors: """ short hand to move motors in endstation @@ -139,7 +143,7 @@ class Motors: if verbose: print("Sample now @ "+sample_name) - def scan(self,name,start,stop,step, **kwargs): + def scan(self,name,start,stop,step,**kwargs): """ scans a motor @@ -157,13 +161,16 @@ class Motors: kwargs.setdefault('relative',False) kwargs.setdefault('scan_dim',1) kwargs.setdefault('execute',True) + + from iexcode.instruments.IEX_endstations import BL + #for kappa only kwargs.setdefault('cts',0.1) kwargs.setdefault('mpa',False) - rbv_pv,val_pv,sgm_pv,pv =self._motor_dictionary()[name] + rbv_pv,val_pv,sgm_pv,pv =self._motor_dictionary[name] - if kwargs['mode'] == "relative": + if kwargs['relative']: current_value = caget(rbv_pv) abs_start = round(current_value + start,3) abs_stop = round(current_value + stop,3) @@ -173,11 +180,11 @@ class Motors: abs_start = start abs_stop = stop - self._scalar_cts(kwargs['cts'],verbose=True,**kwargs) - BL.mda.fillin(val_pv,rbv_pv,abs_start,abs_stop,step,**kwargs) + scaler_cts(kwargs['cts'],verbose=True) + iex.BL.mda.fillin(val_pv,rbv_pv,abs_start,abs_stop,step,**kwargs) if kwargs['execute']: - BL.mda.go(**kwargs) + iex.BL.mda.go(**kwargs) def scan_2D(self,inner_loop_list,outer_loop_list,**kwargs): @@ -207,11 +214,13 @@ class Motors: kwargs.setdefault('cts',0.1) kwargs.setdefault('mpa',False) - rbv_pv,val_pv,sgm_pv,pv = self._motor_dictionary()[inner_loop_list[0]] + from iexcode.instruments.IEX_endstations import BL + + rbv_pv,val_pv,sgm_pv,pv = self._motor_dictionary[inner_loop_list[0]] inner_loop_list.insert(0,rbv_pv) inner_loop_list.insert(0,val_pv) - rbv_pv,val_pv,sgm_pv,pv = self._motor_dictionary()[outer_loop_list[0]] + rbv_pv,val_pv,sgm_pv,pv = self._motor_dictionary[outer_loop_list[0]] outer_loop_list.insert(0,rbv_pv) outer_loop_list.insert(0,val_pv) @@ -225,11 +234,11 @@ class Motors: outer_loop_list[3]=round(current_value1+outer_loop_list[3],3) scaler_cts(kwargs['cts'],verbose=True,**kwargs) - BL.mda.fillin_2D(inner_loop_list,outer_loop_list, + iex.BL.mda.fillin_2D(inner_loop_list,outer_loop_list, outer_scan_dim=kwargs['outer_scan_dim'],**kwargs) if kwargs['execute']: - BL.mda.go(**kwargs) + iex.BL.mda.go(**kwargs) diff --git a/build/lib/iexcode/instruments/Scienta.py b/build/lib/iexcode/instruments/Scienta.py index be0869dfcdbd9316a34d3c595a5ee18869d86fd2..315ad0d73ec4aa1e0b149751b49bb7f64e2d198e 100644 --- a/build/lib/iexcode/instruments/Scienta.py +++ b/build/lib/iexcode/instruments/Scienta.py @@ -3,8 +3,6 @@ import numpy as np from epics import caget,caput, PV - - #----------------------------------------------- #--- Beamline dependent PVs and definitions --- #----------------------------------------------- diff --git a/build/lib/iexcode/instruments/beamline.py b/build/lib/iexcode/instruments/beamline.py index 441aaafe27832a1317db20ec5c849d872b0c026c..79819388f1de8fff7529aba494860b3abf01ddda 100644 --- a/build/lib/iexcode/instruments/beamline.py +++ b/build/lib/iexcode/instruments/beamline.py @@ -4,12 +4,14 @@ short name for functions used with or without x-rays """ -from iexcode.instruments.IEX_endstations import BL import numpy as np from time import sleep from epics import PV +#from iexcode.instruments.IEX_endstations import * +#import iexcode.instruments.IEX_endstations as iex +import iexcode.instruments.cfg as iex ############################################################################################################## ############################## logging ############################## @@ -18,9 +20,9 @@ def log_print(comment=''): """ prints a comment to the logfile """ - global BL + #global BL try: - BL.mda.log.print(comment='') + iex.BL.mda.log.print(comment='') except: print('No logfile written') @@ -28,17 +30,17 @@ def log_update(): """ updates the log file with the last scan info """ - global BL + #global BL try: - entry_list,pv_list, format_list = BL.log.entries_function() - BL.mda.log.update(entry_list,pv_list,format_list) + entry_list,pv_list, format_list = iex.BLlog.entries_function() + iex.BL.mda.log.update(entry_list,pv_list,format_list) except: print('No logfile written') def log_name_set(file_name): - global BL + #global BL try: - BL.mda.log.name_set(filename=file_name) + iex.BL.mda.log.name_set(filename=file_name) except: print('No logfile name change') @@ -52,13 +54,13 @@ def scan_fillin(VAL,RBV,start,stop,steps_points,**kwargs): """ fills in the scan record for the curretn beamline ioc """ - BL.mda.fillin(VAL,RBV,start,stop,steps_points,**kwargs) + iex.BL.mda.fillin(VAL,RBV,start,stop,steps_points,**kwargs) def scan_fillin_table(VAL,RBV,my_table,**kwargs): """ fills in the scan record for the curretn beamline ioc """ - BL.mda.fillin_table(VAL,RBV,my_table,**kwargs) + iex.BL.mda.fillin_table(VAL,RBV,my_table,**kwargs) def scan_go(**kwargs): """ @@ -69,7 +71,7 @@ def scan_go(**kwargs): X-ray = True (default), does shutter checks = False no shutter checks """ - BL.mda.go(verbose=True,**kwargs) + iex.BL.mda.go(verbose=True,**kwargs) def last_mda(): @@ -77,7 +79,7 @@ def last_mda(): returns the last mda file number in the ioc defined by BL_ioc Previously: LastMDA """ - filenum = BL.mda.lastFileNum() + filenum = iex.BL.mda.lastFileNum() return filenum @@ -91,7 +93,7 @@ def endstation_cams_enable(): """ should live in cameras """ - endstation=BL.endstation + endstation=iex.BLendstation cam_dict={'ARPES':[0,1,2],'Kappa':[3,4,6]} # index of cam_list pvcam1=PV("29id_ps1:cam1:Acquire") diff --git a/build/lib/iexcode/instruments/current_amplifiers.py b/build/lib/iexcode/instruments/current_amplifiers.py index d021d10b11b39be96de5beca7990d925d5a1fa00..88268a27cc8c0a7f7ff27565234289265a682a1a 100644 --- a/build/lib/iexcode/instruments/current_amplifiers.py +++ b/build/lib/iexcode/instruments/current_amplifiers.py @@ -97,7 +97,7 @@ class Keithley: pv = self._pv caput(pv+"reset.PROC",1) - sleep(5) + sleep(.1) caput(pv+"digitalFilterSet","Off") caput(pv+"medianFilterSet","Off") caput(pv+"zeroCheckSet",0) diff --git a/build/lib/iexcode/instruments/diagnostics.py b/build/lib/iexcode/instruments/diagnostics.py index 50814ae88854f644fb99cd2b62123794f6428fac..0127d98e6c9939e0ac311ea549fd99226f09f0ba 100644 --- a/build/lib/iexcode/instruments/diagnostics.py +++ b/build/lib/iexcode/instruments/diagnostics.py @@ -1,7 +1,7 @@ from numpy import nan from epics import caput, caget -from iexcode.instruments.IEX_endstations import * +#from iexcode.instruments.IEX_endstations import * ############################################################################################################## ################################ default positions ############################## diff --git a/build/lib/iexcode/instruments/electron_analyzer.py b/build/lib/iexcode/instruments/electron_analyzer.py index 3c208d0aba3a14068fcfbb5cf379fa8a567a438b..28aaec7386f40d3b97024e1bcdd826378b9acb18 100644 --- a/build/lib/iexcode/instruments/electron_analyzer.py +++ b/build/lib/iexcode/instruments/electron_analyzer.py @@ -21,7 +21,7 @@ from iexcode.instruments.xrays import energy, scanXAS_BL, BL_energy_tables from iexcode.instruments.shutters import branch_shutter_close from iexcode.instruments.VLS_PGM import mono_energy_get from iexcode.instruments.files_and_folders import get_next_fileNumber -from iexcode.instruments.logfile import * +from iexcode.instruments.Logfile import * from iexcode.instruments.Scienta import * global EA diff --git a/build/lib/iexcode/instruments/scalers.py b/build/lib/iexcode/instruments/scalers.py index 89be3dbabd0b813aa88d6e5088354e5aa049ee33..1ae03b59c447099af97828a7720a63a985163afa 100644 --- a/build/lib/iexcode/instruments/scalers.py +++ b/build/lib/iexcode/instruments/scalers.py @@ -1,16 +1,17 @@ from math import floor from epics import caput,PV - -from iexcode.instruments.IEX_endstations import BL +#import iexcode.instruments.IEX_endstations as iex +import iexcode.instruments.cfg as iex def scaler_cts(time_seconds=0.1,verbose=True): """ sets the scalers counting for the endstation defined in BL - """ - if BL.ioc == 'Kappa': + """ + if iex.BL.ioc == 'Kappa': Kappa_scaler(time_seconds,verbose=verbose) - + else: + pass def Kappa_scaler(time_seconds=0.1,verbose=True): """ diff --git a/build/lib/iexcode/instruments/scanRecord.py b/build/lib/iexcode/instruments/scanRecord.py index 816c10f6fc92a39d626356d2bd47fc4327f641cd..3d4e9d9eadbcef617a41b33d70e3a7e32b0565cb 100644 --- a/build/lib/iexcode/instruments/scanRecord.py +++ b/build/lib/iexcode/instruments/scanRecord.py @@ -315,13 +315,11 @@ class ScanRecord: Previously: Reset_ScanAll """ - if hasattr(self, 'detector_dictionary'): - kwargs.setdefault('detector_dictionary',self.detector_dictionary) - if hasattr(self, 'trigger_dictionary'): - kwargs.setdefault('trigger_dictionary',self.trigger_dictionary) - if hasattr(self, 'before_scan_pv'): + kwargs.setdefault('detector_dictionary',self.detector_dictionary) + kwargs.setdefault('trigger_dictionary',self.trigger_dictionary) + if self.before_scan_pv != None: kwargs.setdefault('before_scan_pv',self.before_scan_pv) - if hasattr(self, 'after_scan_pv'): + if self.after_scan_pv != None: kwargs.setdefault('after_scan_pv',self.after_scan_pv) #clearing all diff --git a/build/lib/iexcode/instruments/xrays.py b/build/lib/iexcode/instruments/xrays.py index 23b2ddc3a367032cd8114354ccd50a6b766ffd1b..62bf9d9533a8688f786a2cd45cabf472ca1b0d3b 100644 --- a/build/lib/iexcode/instruments/xrays.py +++ b/build/lib/iexcode/instruments/xrays.py @@ -6,7 +6,9 @@ import numpy as np from time import sleep from epics import caget,caput -from iexcode.instruments.IEX_endstations import BL +#from iexcode.instruments.IEX_endstations import * +#import iexcode.instruments.IEX_endstations as iex +import iexcode.instruments.cfg as iex from iexcode.instruments.IEX_VPU import * from iexcode.instruments.VLS_PGM import * @@ -15,7 +17,7 @@ from iexcode.instruments.shutters import * from iexcode.instruments.gate_valves import * from iexcode.instruments.diagnostics import * from iexcode.instruments.m3r import * -from iexcode.instruments.logfile import * +#from iexcode.instruments.Logfile import * from iexcode.instruments.utilities import print_warning_message,make_table, take_closest_value from iexcode.instruments.current_amplifiers import ca_average from iexcode.instruments.beamline import endstation_cams_enable @@ -92,6 +94,7 @@ def xrays_get_all(verbose=False): returns a dictionary """ + #global BL vals={} print("\n===========================================================") vals.update(ID_get_all(verbose=True)) @@ -102,8 +105,8 @@ def xrays_get_all(verbose=False): vals.update(FMB_mirror_get(1,verbose=True)) vals.update(FMB_mirror_get(3,verbose=True)) print("-----------------------------------------------------------") - vals.update({BL.endstation:BL.Motors.mprint()}) - print(BL.endstation+" = ",BL.Motors.mprint()) + vals.update({iex.BL.endstation:iex.BL.Motors.mprint()}) + print(iex.BL.endstation+" = ",iex.BL.Motors.mprint()) print("===========================================================") return vals @@ -121,11 +124,12 @@ def xrays_log_entries(**kwargs): """ #default parameters kwargs.setdefault('comment','') + #global BL - ioc = BL.ioc + ioc = iex.BL.ioc #scan Num - scan = BL.mda.prefix(ioc)+str(BL.mda.fileNum(ioc)) + scan = iex.BL.mda.prefix(ioc)+str(iex.BL.mda.fileNum(ioc)) entry_list=["scan"] pv_list=[scan] format_list=["s" ] @@ -139,32 +143,32 @@ def xrays_log_entries(**kwargs): format_list.append("s",".3f",".3f",".3f") #endstation info - if BL.endstation_name == 'ARPES': - endstation_entry, endstation_pv, endstation_format = BL.log_entries(**kwargs) + if iex.BL.endstation_name == 'ARPES': + endstation_entry, endstation_pv, endstation_format = iex.BL.log_entries(**kwargs) entry_list.append(endstation_entry) pv_list.append(endstation_pv) format_list.append(endstation_format) - elif BL.endstation_name == 'Kappa': - endstation_entry, endstation_pv, endstation_format = BL.log_entries(**kwargs) + elif iex.BL.endstation_name == 'Kappa': + endstation_entry, endstation_pv, endstation_format = iex.BL.log_entries(**kwargs) entry_list.append(endstation_entry[:-7]) pv_list.append(endstation_pv[:-7]) format_list.append(endstation_format[:-7]) #beamline info - ID_mode = ID_mode_get(verbose=False) if BL.xrays else "no_xrays" - ID_QP_ratio = ID_QP_ratio_get (verbose=False) if BL.xrays else "no_xrays" - ID_sp = round(ID_SP_get_eV()) if BL.xrays else 0 - ID_rbv = round(ID_rbv_get_eV,4) if BL.xrays else 0 - hv = mono_energy_get() if BL.xrays else 0 - grt = mono_grating_get() if BL.xrays else 0 - slit_size = slit_get()[0] if BL.xrays else 0 + ID_mode = ID_mode_get(verbose=False) if iex.BL.xrays else "no_xrays" + ID_QP_ratio = ID_QP_ratio_get (verbose=False) if iex.BL.xrays else "no_xrays" + ID_sp = round(ID_SP_get_eV()) if iex.BL.xrays else 0 + ID_rbv = round(ID_rbv_get_eV,4) if iex.BL.xrays else 0 + hv = mono_energy_get() if iex.BL.xrays else 0 + grt = mono_grating_get() if iex.BL.xrays else 0 + slit_size = slit_get()[0] if iex.BL.xrays else 0 entry_list.append("hv","exit_slit","GRT", "ID_SP", "ID_RBV", "ID_Mode", "ID_QP") pv_list.append(hv,slit_size,grt, ID_sp, ID_rbv,ID_mode, ID_QP_ratio) format_list.append(".2f",".0f","s",".1f",".1f","s", ".0f") #endstation info 2: Fanny can I change to order to get rid of this complication? - if BL.endstation_name == 'Kappa': - endstation_entry, endstation_pv, endstation_format = BL.log_entries(**kwargs) + if iex.BL.endstation_name == 'Kappa': + endstation_entry, endstation_pv, endstation_format = iex.BL.log_entries(**kwargs) entry_list.append(endstation_entry[-7:]) pv_list.append(endstation_pv[-7:]) format_list.append(endstation_format[-7:]) @@ -177,7 +181,7 @@ def xrays_log_entries(**kwargs): format_list.append("s","s") try: - logfile_update(BL.endstation,BL.ioc,entry_list,pv_list,format_list) + logfile_update(iex.BL.endstation,iex.BL.ioc,entry_list,pv_list,format_list) except: print("scanlog did not write to file, check for errors.") @@ -226,7 +230,8 @@ def energy(hv_eV,slit_coeff=1,m3r=True,verbose=True): m3r => if True optimizes the mirror for the d-branch only Previously: Set_BL, energy """ - if BL.xrays: + #global BL + if iex.BL.xrays: if hv_eV != energy_range_check(hv_eV): message_string = 'request photon energy '+str(hv_eV)+' not with the allowed range' message_string = '\n closest allowed energy is '+str(energy_range_check(hv_eV)) @@ -238,7 +243,7 @@ def energy(hv_eV,slit_coeff=1,m3r=True,verbose=True): slits_set_BL(c_2B=slit_coeff,c_1A=1,verbose=verbose) if m3r == True: - if BL.branch() == 'd': + if iex.BL.branch() == 'd': print('\nalign_m3r()') try: m3r_align() @@ -248,7 +253,7 @@ def energy(hv_eV,slit_coeff=1,m3r=True,verbose=True): except: print('Unable to align; check camera settings.') else: - message_string = 'BL.xrays = False, energy is not set' + message_string = 'iex.BL.xrays = False, energy is not set' print_warning_message(message_string) def energy_range_min_max(): @@ -285,8 +290,9 @@ def scan_ID(ID_sp_start,ID_sp_stop,ID_sp_step,**kwargs): """ scan the ID set point """ + #global BL val_pv,rbv_pv = ID_scan_pvs() - BL.mda.fillin(val_pv,rbv_pv,ID_sp_start,ID_sp_stop,ID_sp_step,**kwargs) + iex.BL.mda.fillin(val_pv,rbv_pv,ID_sp_start,ID_sp_stop,ID_sp_step,**kwargs) def mvmono(val): @@ -352,14 +358,15 @@ def scanhv(start,stop,step,average_pnts=1,**kwargs): scans the mono at the current ID value """ + #global BL ca_average(average_pnts) - mono_scan_fillin(BL.mda,start,stop,step,**kwargs) + mono_scan_fillin(iex.BL.mda,start,stop,step,**kwargs) mono_energy_set(start) - BL.mda.go(**kwargs) + iex.BL.mda.go(**kwargs) - mono_scan_after(BL.mda) + mono_scan_after(iex.BL.mda) def scanE(start,stop,step,ID_offset=0,mesh='stay',average_pnts=1,scan_dim=1,**kwargs): @@ -378,7 +385,8 @@ def scanE(start,stop,step,ID_offset=0,mesh='stay',average_pnts=1,scan_dim=1,**kw scan_dim positioner_settling_time = 0.2 """ - mda = BL.mda + #global BL + mda = iex.BL.mda ca_average(average_pnts) if ID_offset != None: @@ -389,7 +397,7 @@ def scanE(start,stop,step,ID_offset=0,mesh='stay',average_pnts=1,scan_dim=1,**kw mono_scan_fillin(mda,scan_dim,start,stop,step,**kwargs) mono_energy_set(start) - BL.mda.go(scan_dim) + iex.BL.mda.go(scan_dim) mono_scan_after(mda,scan_dim) @@ -419,22 +427,23 @@ def scanXAS(ID_eV,start_stop_step_lists,**kwargs): kwargs.setdefault("mcp",True) kwargs.setdefault('execute',True) + #global BL scan_dim=kwargs['scan_dim'] #Setting up the ScanRecord for Mono in Table mode hv_array = make_table(start_stop_step_lists) - mono_scan_fillin_table(BL.mda,scan_dim,hv_array,**kwargs) + mono_scan_fillin_table(iex.BL.mda,scan_dim,hv_array,**kwargs) #Averaging and Normalization ca_average(kwargs['average_pnts']) - if BL.branch=="d": + if iex.BL.branch=="d": meshD("In") #Setting the beamline energy energy(ID_eV,m3r=kwargs["m3r"]) #mpa - if BL.branch == "d" and kwargs["mcp"]: + if iex.BL.branch == "d" and kwargs["mcp"]: mpa_HV_on() #Scanning @@ -478,6 +487,7 @@ def scanXAS_BL(start_stop_step_lists,**kwargs): kwargs.setdefault("mcp",True) kwargs.setdefault('execute',True) + #global BL scan_dim=kwargs['scan_dim'] #Setting up the ScanRecord for Mono and ID in Table mode @@ -647,6 +657,7 @@ def slit(size): ARPES = 0 < x < 300 um Kappa = 0 < x < 1000 um """ + global BL branch = BL.branch if branch == "c": slit3C_set(size, quiet=False) @@ -661,6 +672,7 @@ def slit_get(verbose=True): ARPES = 0 < x < 300 um Kappa = 0 < x < 1000 um """ + global BL branch = BL.branch if branch == "c": slit_size = slit3C_get(verbose=False) diff --git a/build/lib/iexcode/macros/__init__.py b/build/lib/iexcode/macros/__init__.py index d2a66a14d237e6ff8467fe93e859aa4c9aeac418..8ccf3df1571798ce4fa3a305fa3ac5ca11eff3e5 100644 --- a/build/lib/iexcode/macros/__init__.py +++ b/build/lib/iexcode/macros/__init__.py @@ -6,7 +6,7 @@ from iexcode.instruments.conversions_constants import * from iexcode.instruments.encoders import * from iexcode.instruments.files_and_folders import * from iexcode.instruments.IEX_endstations import * -from iexcode.instruments.logfile import * +from iexcode.instruments.Logfile import * from iexcode.instruments.Motors import * from iexcode.instruments.remote_controlers import * from iexcode.instruments.s29_temp_cntl import * diff --git a/build/lib/iexcode/macros/commissioning.py b/build/lib/iexcode/macros/commissioning.py index 675889f949a341e87f8a5b9886768e49fef05040..80046bc6ef6fccf8a4e58cac90f929a4d383f154 100644 --- a/build/lib/iexcode/macros/commissioning.py +++ b/build/lib/iexcode/macros/commissioning.py @@ -17,7 +17,7 @@ from ..instruments.IEX_VPU import ID_switch_mode from ..instruments.diagnostics import diagnostics_all_out, diagnostics_all_in,diodeC,diodeD from ..instruments.current_amplifiers import current2flux from ..instruments.slits import set_exit_slit -from ..instruments.logfile import * +from ..instruments.Logfile import * from ..instruments.cameras import * from ..instruments.ARPES import * diff --git a/iexcode.egg-info/SOURCES.txt b/iexcode.egg-info/SOURCES.txt index b6dad633e0401d6be05e2fba3b297ffda084b0b8..969f22a9df1510682b7f91c3e8c509fee622a6a1 100644 --- a/iexcode.egg-info/SOURCES.txt +++ b/iexcode.egg-info/SOURCES.txt @@ -19,6 +19,7 @@ iexcode/instruments/Kappa.py iexcode/instruments/Kappa_Euler.py iexcode/instruments/Kappa_det.py iexcode/instruments/Lakeshore_335.py +iexcode/instruments/Logfile.py iexcode/instruments/MPA.py iexcode/instruments/Motors.py iexcode/instruments/Scienta.py @@ -27,6 +28,7 @@ iexcode/instruments/__init__.py iexcode/instruments/bakeout.py iexcode/instruments/beamline.py iexcode/instruments/cameras.py +iexcode/instruments/cfg.py iexcode/instruments/conversions_constants.py iexcode/instruments/current_amplifiers.py iexcode/instruments/diagnostics.py @@ -35,7 +37,6 @@ iexcode/instruments/encoders.py iexcode/instruments/files_and_folders.py iexcode/instruments/gate_valves.py iexcode/instruments/hxp_mirrors.py -iexcode/instruments/logfile.py iexcode/instruments/m3r.py iexcode/instruments/remote_controlers.py iexcode/instruments/resolution.py diff --git a/iexcode/instruments/AD_utilities.py b/iexcode/instruments/AD_utilities.py index 15dd0a09b5a21539352d7827c64cb70c5359e4b7..cfe1930890eddd5dc2bde59f1782aea8caa3d855 100644 --- a/iexcode/instruments/AD_utilities.py +++ b/iexcode/instruments/AD_utilities.py @@ -13,7 +13,6 @@ from os.path import join, isfile, exists, dirname from time import sleep from epics import caget, caput -from iexcode.instruments.IEX_endstations import BL from iexcode.instruments.files_and_folders import get_next_fileNumber diff --git a/iexcode/instruments/ARPES.py b/iexcode/instruments/ARPES.py index 9189eca4a951e3dd6a144a047c26970c2982b926..63ace10ceedadd91f68bdcba2ec6f88b2cd6c56b 100644 --- a/iexcode/instruments/ARPES.py +++ b/iexcode/instruments/ARPES.py @@ -3,12 +3,15 @@ from time import sleep from epics import caget,caput,PV +import iexcode.instruments.cfg as iex from iexcode.instruments.IEX_endstations import Endstation +#import iexcode.instruments.IEX_endstations as iex + from iexcode.instruments.staff import staff_detector_dictionary from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda from iexcode.instruments.staff import staff_detector_dictionary -from iexcode.instruments.logfile import Logfile +from iexcode.instruments.Logfile import Logfile from iexcode.instruments.conversions_constants import * from iexcode.instruments.utilities import * @@ -26,7 +29,6 @@ from iexcode.instruments.slits import slit3C_get from iexcode.instruments.Lakeshore_335 import Lakeshore_reset from iexcode.instruments.electron_analyzer import EA_init_Motors,folders_EA,EA -global BL global tey,ca15 global ARPES_Motors @@ -54,13 +56,13 @@ def ARPES_init(*userName,**kwargs): ARPES_Motors = Motors('ARPES',ARPES_motor_dictionary(),physical_motors,psuedo_motors) #endstation - global BL - BL=Endstation('ARPES',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],ARPES_Motors) + #global BL + iex.BL = Endstation('ARPES',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],ARPES_Motors) #setting folders if kwargs['set_folders']: - if BL.mode == 'staff': + if iex.BL.mode == 'staff': user_name = 'staff' else: if len(userName)==0: @@ -71,7 +73,7 @@ def ARPES_init(*userName,**kwargs): folders_ARPES(user_name,**kwargs) #update for default scanRecord advanced parameters - BL.mda.log('ARPES',user_name,ARPES_log_header(),ARPES_log_entries) + iex.BL.mda.log('ARPES',user_name,ARPES_log_header(),ARPES_log_entries) #EA if EA.connected: @@ -178,28 +180,28 @@ def folders_ARPES(user_name,**kwargs): kwargs.setdefault('ftp',False) kwargs.setdefault('debug',False) - global BL + #global BL run = kwargs['run'] if kwargs['debug']: - print("run,folder,user_name,ioc,ftp: ",run,BL.folder,user_name,kwargs['scan_ioc'],kwargs['ftp']) + print("run,folder,user_name,ioc,ftp: ",run,iex.BL.folder,user_name,kwargs['scan_ioc'],kwargs['ftp']) # Create User Folder: - make_user_folders(run,BL.folder,user_name,BL.endstation,ftp=kwargs['ftp']) + make_user_folders(run,iex.BL.folder,user_name,iex.BL.endstation,ftp=kwargs['ftp']) sleep(5) if kwargs["set_folders"]: # Set up MDA folder: - folder_mda(run,BL.folder,user_name,BL.prefix,BL.ioc) + folder_mda(run,iex.BL.folder,user_name,iex.BL.prefix,iex.BL.ioc) sleep(5) - logfile_name_set(BL.endstation) + logfile_name_set(iex.BL.endstation) sleep(2) - logfile_header(BL.endstation,BL.ioc,ARPES_log_header()) + logfile_header(iex.BL.endstation,iex.BL.ioc,ARPES_log_header()) #Set up Scienta folders: if EA.connected: - userPath = "/net/s29data/export/data_29id"+BL.folder+"/"+run+"/"+user_name+"/" + userPath = "/net/s29data/export/data_29id"+iex.BL.folder+"/"+run+"/"+user_name+"/" folders_EA(userPath,filePrefix="EA") else: print_warning_message("EA ioc is not running, h5 folder not set") @@ -208,27 +210,27 @@ def ARPES_reset(**kwargs): """ resets scanRecord, current amplifiers, mono limits and lakeshore """ - global BL + #global BL #resetting the scanRecord - if BL.mode=='staff': - BL.mda.detector_dictionary = staff_detector_dictionary() + if iex.BL.mode=='staff': + iex.BL.mda.detector_dictionary = staff_detector_dictionary() else: - BL.mda.detector_dictionary = ARPES_detector_dictionary() + iex.BL.mda.detector_dictionary = ARPES_detector_dictionary() - BL.mda.trigger_dictionary = ARPES_trigger_dictionary(**kwargs) - BL.mda.scan_before_sequence = ARPES_scan_before_sequence(**kwargs) - BL.mda.scan_after_sequence = ARPES_scan_after_sequence(**kwargs) + iex.BL.mda.trigger_dictionary = ARPES_trigger_dictionary(**kwargs) + iex.BL.mda.scan_before_sequence = ARPES_scan_before_sequence(**kwargs) + iex.BL.mda.scan_after_sequence = ARPES_scan_after_sequence(**kwargs) - BL.mda.reset_all() + iex.BL.mda.reset_all() #resetting the current amplifiers - if BL.xrays: + if iex.BL.xrays: ca_reset_all() else: tey.reset() #resetting mono and anyother beamline stuff - if BL.xrays: + if iex.BL.xrays: xrays_reset() #reseting the ARPES Lakeshore @@ -262,7 +264,7 @@ def ARPES_get_all(verbose=True): vals.update('exit_slit',slit3C_get()) #beamline info - if BL.xray: + if iex.BL.xray: beamline_info = xrays_get_all() vals.update(beamline_info) @@ -323,9 +325,9 @@ def ARPES_scan_before_sequence(**kwargs): kwargs.setdefault('seq_num',9) seq_num=kwargs['seq_num'] - global BL + #global BL - scan_ioc = BL.ioc + scan_ioc = iex.BL.ioc before_scan_pv,before_scan_proc = userStringSeq_pvs(scan_ioc,seq_num) @@ -346,9 +348,9 @@ def ARPES_ca_live_sequence(**kwargs): """ """ kwargs.setdefault('seq_num',7) - global BL + #global BL - ca_live_sequence_proc = ca_live_sequence(BL.ioc,kwargs['seq_num'],ARPES_detector_list()) + ca_live_sequence_proc = ca_live_sequence(iex.BL.ioc,kwargs['seq_num'],ARPES_detector_list()) return ca_live_sequence_proc def ARPES_scan_after_sequence(**kwargs): @@ -368,8 +370,8 @@ def ARPES_scan_after_sequence(**kwargs): seq_num = kwargs['seq_num'] scan_dim = kwargs['scan_dim'] - global BL - scan_ioc = BL.ioc + #global BL + scan_ioc = iex.BL.ioc after_scan_pv,after_scan_proc = userStringSeq_pvs(scan_ioc, seq_num) @@ -382,7 +384,7 @@ def ARPES_scan_after_sequence(**kwargs): caput(after_scan_pv+".LNK1",ca_live_sequence_proc+" PP NMS") caput(after_scan_pv+".DO1",1) - scan_pv = BL.ioc+"scan"+str(scan_dim) + scan_pv = iex.BL.ioc+"scan"+str(scan_dim) ## Put scan record back in absolute mode caput(after_scan_pv+".LNK2",scan_pv+".P1AR") caput(after_scan_pv+".STR2","ABSOLUTE") @@ -409,8 +411,8 @@ def ARPES_detector_triggers_sequence(**kwargs): # do we need to add 29idb:ca5 kwargs.setdefault('seq_num',8) seq_num=kwargs['seq_num'] - global BL - scan_ioc = BL.ioc + #global BL + scan_ioc = iex.BL.ioc detector_triggers_pv,detector_triggers_proc = userStringSeq_pvs(scan_ioc, seq_num) #clear the userStringSeq diff --git a/iexcode/instruments/IEX_endstations.py b/iexcode/instruments/IEX_endstations.py index 172f2128985784f3829e022812525971ee874656..2013e71d57874f6960d786b4a7a7c29bf8a140f2 100644 --- a/iexcode/instruments/IEX_endstations.py +++ b/iexcode/instruments/IEX_endstations.py @@ -6,6 +6,7 @@ from tkinter.messagebox import NO from epics import caput from iexcode.instruments.scanRecord import ScanRecord +import iexcode.instruments.cfg as iex """ Endstation class is used to contain information about ioc, branch, mode @@ -15,8 +16,6 @@ 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. """ -global BL -BL = None class Endstation: """ @@ -118,22 +117,22 @@ def BL_ioc(): """ returns the branch from the Endstation instance """ - return BL.ioc + return iex.BL.ioc def BL_mode(): """ returns the beamline mode, User / Staff / No_Xray """ - return BL.ioc + return iex.BL.ioc def BL_mda_prefix(): """ returns the mda file prefix """ - return BL.prefix + return iex.BL.prefix def BL_mda_filepath(): """ returns the mda file prefix """ - return BL.filepath + return iex.BL.filepath diff --git a/iexcode/instruments/Kappa.py b/iexcode/instruments/Kappa.py index 25ead0a32447dcfc11b6c2ac930aab7ce4a84e3b..eab7ca30dbc64badfaffd5630f753d3b442d1f6c 100644 --- a/iexcode/instruments/Kappa.py +++ b/iexcode/instruments/Kappa.py @@ -4,12 +4,14 @@ from math import floor from epics import caget, caput,PV -from iexcode.instruments.IEX_endstations import BL +#from iexcode.instruments.IEX_endstations import * +import iexcode.instruments.IEX_endstations as iex + from iexcode.instruments.staff import staff_detector_dictionary from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda from iexcode.instruments.staff import staff_detector_dictionary -from iexcode.instruments.logfile import logfile_name_set,logfile_header +from iexcode.instruments.Logfile import logfile_name_set,logfile_header from iexcode.instruments.conversions_constants import * from iexcode.instruments.utilities import * @@ -74,7 +76,7 @@ def Kappa_init(set_folders=False,reset=False,**kwargs): #setting folders if 'set_folders': - if BL.mode == 'staff': + if iex.BL.mode == 'staff': user_name = 'staff' else: user_name = input('user name: ') @@ -247,24 +249,24 @@ def folders_Kappa(user_name,**kwargs): run = kwargs['run'] if kwargs['debug']: - print("run,folder,user_name,ioc,ftp: ",run,BL.folder,user_name,BL.ioc,kwargs['ftp']) + print("run,folder,user_name,ioc,ftp: ",run,iex.BL.folder,user_name,iex.BL.ioc,kwargs['ftp']) # Create User Folder: - make_user_folders(run,BL.folder,user_name,BL.endstation,ftp=kwargs['ftp']) + make_user_folders(run,iex.BL.folder,user_name,iex.BL.endstation,ftp=kwargs['ftp']) sleep(5) if kwargs["set_folders"]: # Set up MDA folder: - folder_mda(run,BL.folder,user_name,BL.prefix,BL.ioc) - logfile_name_set(BL.endstation) - logfile_header(BL.endstation,BL.ioc,Kappa_log_header()) + 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()) # Set up SPEC folder: - folders_spec(run,BL.folder,user_name) + folders_spec(run,iex.BL.folder,user_name) # Set up MPA folder: - #Folder_MPA(run,BL.folder,user_name) + #Folder_MPA(run,iex.BL.folder,user_name) #resetting if 'reset': @@ -275,14 +277,14 @@ def Kappa_reset(): resets scanRecord, current amplifiers, mono limits and lakeshore """ #resetting the scanRecord - BL.mda.reset() + iex.BL.mda.reset() #resetting the current amplifiers - if BL.xray: + if iex.BL.xray: ca_reset_all() #resetting mono and anyother beamline stuff - if BL.xrays: + if iex.BL.xrays: xrays_reset() #reseting the Kappa Lakeshore @@ -296,8 +298,8 @@ def Kappa_reminder_list(ioc): """ resets scanRecord, current amplifiers, mono limits and synchs motors """ - BL.mda.reset() - if BL.xray: + iex.BL.mda.reset() + if iex.BL.xray: ca_reset_all() @@ -324,7 +326,7 @@ def Kappa_get_all(verbose=True): vals.update(key,caget(extra_pvs[key])) #beamline info - if BL.xray: + if iex.BL.xray: beamline_info = xrays_get_all() #vals.update(beamline_info) @@ -426,11 +428,11 @@ def Kappa_scan_after_sequence(scan_ioc,scan_dim,**kwargs): if 'scan_ioc' in kwargs: scan_ioc = kwargs['scan_ioc'] try: - BL.ioc = kwargs['scan_ioc'] + iex.BL.ioc = kwargs['scan_ioc'] except: error = 'undefined' else: - scan_ioc = BL.ioc + scan_ioc = iex.BL.ioc after_scan_pv,after_scan_proc = userStringSeq_pvs(scan_ioc, seq_num) @@ -438,7 +440,7 @@ def Kappa_scan_after_sequence(scan_ioc,scan_dim,**kwargs): userStringSeq_clear(scan_ioc,seq_num) caput(after_scan_pv+".DESC","After Scan") - scan_pv = BL.ioc+"scan"+str(scan_dim) + scan_pv = iex.BL.ioc+"scan"+str(scan_dim) ## Put scan record back in absolute mode caput(after_scan_pv+".LNK2",scan_pv+".P1AR") caput(after_scan_pv+".STR2","ABSOLUTE") @@ -464,7 +466,7 @@ def Kappa_detector_triggers_sequence(scan_ioc,scan_dim,**kwargs): # do we nee kwargs.setdefault(seq_num,8) seq_num=kwargs['seq_num'] - detector_triggers_pv,detector_triggers_proc = userStringSeq_pvs(BL.ioc, seq_num) + detector_triggers_pv,detector_triggers_proc = userStringSeq_pvs(iex.BL.ioc, seq_num) #clear the userStringSeq userStringSeq_clear(scan_ioc,seq_num=kwargs['seq_num']) @@ -668,26 +670,26 @@ def Kappa_th2th_scan_sensitivity(th_table,gain_num_table,gain_unit_table,**kwarg tth_table = 2*th_table kwargs.update("positioner_num",1) - BL.mda.fillin_table(kth_val,kth_rbv,kth_table,**kwargs) + iex.BL.mda.fillin_table(kth_val,kth_rbv,kth_table,**kwargs) kwargs.update("positioner_num",2) - BL.mda.fillin_table(tth_val,tth_rbv,tth_table,**kwargs) + iex.BL.mda.fillin_table(tth_val,tth_rbv,tth_table,**kwargs) kwargs.update("positioner_num",3) - BL.mda.fillin_table(gain_num_pv,"",gain_num_table,**kwargs) + iex.BL.mda.fillin_table(gain_num_pv,"",gain_num_table,**kwargs) kwargs.update("positioner_num",4) - BL.mda.fillin_table(gain_unit_pv,"",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)") scaler_cts(kwargs['cts'],verbose=False) if kwargs['execute']: - BL.mda.go(**kwargs) + iex.BL.mda.go(**kwargs) #clean up after scan - BL.mda.table_reset_after(**kwargs) + iex.BL.mda.table_reset_after(**kwargs) scaler_cts(verbose=False) def Kappa_scan_th2th(tth_start,tth_stop,tth_step,th_offset,**kwargs): @@ -716,14 +718,14 @@ def Kappa_scan_th2th(tth_start,tth_stop,tth_step,th_offset,**kwargs): tth_val,tth_rbv,tth_spmg,tth_pv = Kappa_motor_dictionary['tth'] kwargs.update("positioner_num",2) - BL.mda.fillin(th_val,th_rbv,th_start,th_stop,th_step,**kwargs) + iex.BL.mda.fillin(th_val,th_rbv,th_start,th_stop,th_step,**kwargs) kwargs.update("positioner_num",1) - BL.mda.fillin(tth_val,tth_rbv,tth_start,tth_stop,tth_step,**kwargs) + iex.BL.mda.fillin(tth_val,tth_rbv,tth_start,tth_stop,tth_step,**kwargs) scaler_cts(kwargs['cts'],verbose=False) if kwargs['execute']: - BL.mda.go(**kwargs) + iex.BL.mda.go(**kwargs) #clean up after scan scaler_cts(verbose=False) @@ -759,21 +761,21 @@ def scan_th2th_table(tth_table,th0,**kwargs): #write to the scanRecord kwargs.update("positioner_num",1) - BL.mda.fillin_table(tth_val,tth_rbv,tth_table,**kwargs) + iex.BL.mda.fillin_table(tth_val,tth_rbv,tth_table,**kwargs) kwargs.update("positioner_num",2) - BL.mda.fillin_table(th_val,th_rbv,th_table,**kwargs) - BL.mda.positioner_after_scan(after="STAY") + iex.BL.mda.fillin_table(th_val,th_rbv,th_table,**kwargs) + iex.BL.mda.positioner_after_scan(after="STAY") scaler_cts(kwargs['cts'],verbose=False,**kwargs) if kwargs['execute']: - BL.mda.go(**kwargs) + iex.BL.mda.go(**kwargs) #clean up after scan - BL.mda.table_reset_after() + iex.BL.mda.table_reset_after() scaler_cts(verbose=False) - BL.mda.positioner_after_scan(after="PRIOR POS",**kwargs) + iex.BL.mda.positioner_after_scan(after="PRIOR POS",**kwargs) @@ -831,10 +833,10 @@ def Kappa_detector_triggers_strSeq(**kwargs): # do we need to add 29idb:ca5 ? kwargs.setdefault(seq_num,8) seq_num=kwargs['seq_num'] - detector_triggers_pv,detector_triggers_proc = userStringSeq_pvs(BL.ioc, seq_num) + detector_triggers_pv,detector_triggers_proc = userStringSeq_pvs(iex.BL.ioc, seq_num) #clear the userStringSeq - userStringSeq_clear(BL.ioc,seq_num=kwargs['seq_num']) + userStringSeq_clear(iex.BL.ioc,seq_num=kwargs['seq_num']) caput(detector_triggers_pv+".DESC","Kappa_Trigger1") #no triggers see ARPES_detector_triggers_sequence for example @@ -850,7 +852,7 @@ def KappaPreset_StrSeq(n,User): scanIOC="Kappa" motorIOC="29idKappa:" motor = ["m2","m3","m4","m9","m8","m7","m1"] - strSeq_pv = userStringSeq_clear(BL.mda,n) + strSeq_pv = userStringSeq_clear(iex.BL.mda,n) if User[0] == "Kappa Grazing": phi0= 0 if User[0] == "Kappa Transfer": phi0= 57 @@ -876,7 +878,7 @@ def KappaPreset_StrSeq(n,User): def Bragg_Angle_CalcOut(d,eV,l): n=7 - userCalcOut_pv = userCalcOut_clear(BL.mda,n) + userCalcOut_pv = userCalcOut_clear(iex.BL.mda,n) h=4.135667516e-15 c=299792458 @@ -899,7 +901,7 @@ def Kappa_temperature_pressure_scan(scan_dim=1): Previously: Kappa_ScanTempPres """ - pv="29id"+BL.mda.ioc+":scan"+str(scan_dim) + pv="29id"+iex.BL.mda.ioc+":scan"+str(scan_dim) #Clear all scan pvs caput(pv+".CMND",6) #Set detectors @@ -907,7 +909,7 @@ def Kappa_temperature_pressure_scan(scan_dim=1): caput(pv+".D02PV","29idd:tc1:getVal_B.VAL") caput(pv+".D03PV","29idb:VS11D.VAL") #time scan - BL.mda.time_go() + iex.BL.mda.time_go() diff --git a/iexcode/instruments/logfile.py b/iexcode/instruments/Logfile.py similarity index 100% rename from iexcode/instruments/logfile.py rename to iexcode/instruments/Logfile.py diff --git a/iexcode/instruments/MPA.py b/iexcode/instruments/MPA.py index a9477f032666e5bb721717f16a876a85a1b7fd76..f3c6eb38ce8eb011ccb259957e00dd32004a694b 100644 --- a/iexcode/instruments/MPA.py +++ b/iexcode/instruments/MPA.py @@ -7,8 +7,11 @@ 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 from iexcode.instruments.scanRecord import ScanRecord -from iexcode.instruments.IEX_endstations import BL +#from iexcode.instruments.IEX_endstations import * +#import iexcode.instruments.IEX_endstations as iex +import iexcode.instruments.cfg as iex +#global BL """ To do, get busy record in the mpa ioc, get user calcs in the mpa ioc @@ -139,8 +142,8 @@ class MPA: kwargs.setdefault('positioner_settling_time',1) Kappa_scaler(1) val_pv, rbv_pv = self._HV_pvs() - BL.mda.fillin(val_pv, rbv_pv,start,stop,step,**kwargs) - BL.mda.go(**kwargs) + iex.BL.mda.fillin(val_pv, rbv_pv,start,stop,step,**kwargs) + iex.BL.mda.go(**kwargs) ############################################################################################################## ############################## MCP Scripts ############################## @@ -275,8 +278,8 @@ class MPA: """ kwargs.setdefault("debug",False) - fpath=join(dirname(dirname(BL.mda.filepath)),"mpa",'') - nextMDA = BL.mda.fileNum + fpath=join(dirname(dirname(iex.BL.mda.filepath)),"mpa",'') + nextMDA = iex.BL.mda.fileNum prefix="mda"+str.zfill(str(nextMDA),4)+"_mpa" return prefix @@ -306,10 +309,10 @@ class MPA: #adding the MPA to the scanRecord trigger if trigger == True: self._mpa_prefix(**kwargs) - BL.mda.triggers_set(kwargs['scan_dim'],{2:mpa_busy}) + iex.BL.mda.triggers_set(kwargs['scan_dim'],{2:mpa_busy}) if trigger == False: - BL.mda.triggers_set(kwargs['scan_dim'],{2:''}) + iex.BL.mda.triggers_set(kwargs['scan_dim'],{2:''}) @@ -324,7 +327,7 @@ class MPA: desc = "MCP datamode" n=2 - strSeq_pv = userStringSeq_clear(BL.mda,n) + strSeq_pv = userStringSeq_clear(iex.BL.mda,n) caput(strSeq_pv+".DESC",desc) caput(strSeq_pv+".LNK1",self._det_pv+"Acquire CA NMS") caput(strSeq_pv+".STR1","Done") @@ -340,7 +343,7 @@ class MPA: """ desc = "MCP freerun" n=1 - strSeq_pv = userStringSeq_clear(BL.mda,n) + strSeq_pv = userStringSeq_clear(iex.BL.mda,n) caput(strSeq_pv+".DESC",desc) caput(strSeq_pv+".LNK1",self._det_pv+"Acquire PP NMS") caput(strSeq_pv+".WAIT1","Wait") @@ -361,7 +364,7 @@ class MPA: desc = "MPA HV SP" n=9 - calcOut_pv = userCalcOut_clear(BL.mda,n) + calcOut_pv = userCalcOut_clear(iex.BL.mda,n) caput(calcOut_pv+".DESC",desc) caput(calcOut_pv+".A",0) @@ -379,7 +382,7 @@ class MPA: """ desc = "MPA HV RBV" n=10 - calcOut_pv = userCalcOut_clear(BL.mda,n) + calcOut_pv = userCalcOut_clear(iex.BL.mda,n) caput(calcOut_pv+".DESC",desc) caput(calcOut_pv+".INPA",DAC_pv+' CP NMS') @@ -391,7 +394,7 @@ class MPA: """ desc = "MPA Interlock mpa" n=7 - calcOut_pv = userCalcOut_clear(BL.mda,n) + calcOut_pv = userCalcOut_clear(iex.BL.mda,n) caput(calcOut_pv+".DESC",desc) tth_pv = self._tth_pv @@ -410,7 +413,7 @@ class MPA: """ desc = "MPA Interlock DAC" n=8 - calcOut_pv = userCalcOut_clear(BL.mda,n) + calcOut_pv = userCalcOut_clear(iex.BL.mda,n) caput(calcOut_pv+".DESC",desc) tth_pv = self._tth_pv diff --git a/iexcode/instruments/Motors.py b/iexcode/instruments/Motors.py index eb66288053995a59f3fcd2e5c67cc3c8f1d66831..2882fd9e5d883cb637d3b41d0c0d40ab19dd3861 100644 --- a/iexcode/instruments/Motors.py +++ b/iexcode/instruments/Motors.py @@ -3,10 +3,14 @@ from math import floor from epics import caget, caput -from iexcode.instruments.IEX_endstations import BL +#from iexcode.instruments.IEX_endstations import * +#import iexcode.instruments.IEX_endstations as iex +import iexcode.instruments.cfg as iex + from iexcode.instruments.scalers import scaler_cts + class Motors: """ short hand to move motors in endstation @@ -139,7 +143,7 @@ class Motors: if verbose: print("Sample now @ "+sample_name) - def scan(self,name,start,stop,step, **kwargs): + def scan(self,name,start,stop,step,**kwargs): """ scans a motor @@ -157,13 +161,16 @@ class Motors: kwargs.setdefault('relative',False) kwargs.setdefault('scan_dim',1) kwargs.setdefault('execute',True) + + from iexcode.instruments.IEX_endstations import BL + #for kappa only kwargs.setdefault('cts',0.1) kwargs.setdefault('mpa',False) - rbv_pv,val_pv,sgm_pv,pv =self._motor_dictionary()[name] + rbv_pv,val_pv,sgm_pv,pv =self._motor_dictionary[name] - if kwargs['mode'] == "relative": + if kwargs['relative']: current_value = caget(rbv_pv) abs_start = round(current_value + start,3) abs_stop = round(current_value + stop,3) @@ -173,11 +180,11 @@ class Motors: abs_start = start abs_stop = stop - self._scalar_cts(kwargs['cts'],verbose=True,**kwargs) - BL.mda.fillin(val_pv,rbv_pv,abs_start,abs_stop,step,**kwargs) + scaler_cts(kwargs['cts'],verbose=True) + iex.BL.mda.fillin(val_pv,rbv_pv,abs_start,abs_stop,step,**kwargs) if kwargs['execute']: - BL.mda.go(**kwargs) + iex.BL.mda.go(**kwargs) def scan_2D(self,inner_loop_list,outer_loop_list,**kwargs): @@ -207,11 +214,13 @@ class Motors: kwargs.setdefault('cts',0.1) kwargs.setdefault('mpa',False) - rbv_pv,val_pv,sgm_pv,pv = self._motor_dictionary()[inner_loop_list[0]] + from iexcode.instruments.IEX_endstations import BL + + rbv_pv,val_pv,sgm_pv,pv = self._motor_dictionary[inner_loop_list[0]] inner_loop_list.insert(0,rbv_pv) inner_loop_list.insert(0,val_pv) - rbv_pv,val_pv,sgm_pv,pv = self._motor_dictionary()[outer_loop_list[0]] + rbv_pv,val_pv,sgm_pv,pv = self._motor_dictionary[outer_loop_list[0]] outer_loop_list.insert(0,rbv_pv) outer_loop_list.insert(0,val_pv) @@ -225,11 +234,11 @@ class Motors: outer_loop_list[3]=round(current_value1+outer_loop_list[3],3) scaler_cts(kwargs['cts'],verbose=True,**kwargs) - BL.mda.fillin_2D(inner_loop_list,outer_loop_list, + iex.BL.mda.fillin_2D(inner_loop_list,outer_loop_list, outer_scan_dim=kwargs['outer_scan_dim'],**kwargs) if kwargs['execute']: - BL.mda.go(**kwargs) + iex.BL.mda.go(**kwargs) diff --git a/iexcode/instruments/Scienta.py b/iexcode/instruments/Scienta.py index be0869dfcdbd9316a34d3c595a5ee18869d86fd2..315ad0d73ec4aa1e0b149751b49bb7f64e2d198e 100644 --- a/iexcode/instruments/Scienta.py +++ b/iexcode/instruments/Scienta.py @@ -3,8 +3,6 @@ import numpy as np from epics import caget,caput, PV - - #----------------------------------------------- #--- Beamline dependent PVs and definitions --- #----------------------------------------------- diff --git a/iexcode/instruments/beamline.py b/iexcode/instruments/beamline.py index 441aaafe27832a1317db20ec5c849d872b0c026c..79819388f1de8fff7529aba494860b3abf01ddda 100644 --- a/iexcode/instruments/beamline.py +++ b/iexcode/instruments/beamline.py @@ -4,12 +4,14 @@ short name for functions used with or without x-rays """ -from iexcode.instruments.IEX_endstations import BL import numpy as np from time import sleep from epics import PV +#from iexcode.instruments.IEX_endstations import * +#import iexcode.instruments.IEX_endstations as iex +import iexcode.instruments.cfg as iex ############################################################################################################## ############################## logging ############################## @@ -18,9 +20,9 @@ def log_print(comment=''): """ prints a comment to the logfile """ - global BL + #global BL try: - BL.mda.log.print(comment='') + iex.BL.mda.log.print(comment='') except: print('No logfile written') @@ -28,17 +30,17 @@ def log_update(): """ updates the log file with the last scan info """ - global BL + #global BL try: - entry_list,pv_list, format_list = BL.log.entries_function() - BL.mda.log.update(entry_list,pv_list,format_list) + entry_list,pv_list, format_list = iex.BLlog.entries_function() + iex.BL.mda.log.update(entry_list,pv_list,format_list) except: print('No logfile written') def log_name_set(file_name): - global BL + #global BL try: - BL.mda.log.name_set(filename=file_name) + iex.BL.mda.log.name_set(filename=file_name) except: print('No logfile name change') @@ -52,13 +54,13 @@ def scan_fillin(VAL,RBV,start,stop,steps_points,**kwargs): """ fills in the scan record for the curretn beamline ioc """ - BL.mda.fillin(VAL,RBV,start,stop,steps_points,**kwargs) + iex.BL.mda.fillin(VAL,RBV,start,stop,steps_points,**kwargs) def scan_fillin_table(VAL,RBV,my_table,**kwargs): """ fills in the scan record for the curretn beamline ioc """ - BL.mda.fillin_table(VAL,RBV,my_table,**kwargs) + iex.BL.mda.fillin_table(VAL,RBV,my_table,**kwargs) def scan_go(**kwargs): """ @@ -69,7 +71,7 @@ def scan_go(**kwargs): X-ray = True (default), does shutter checks = False no shutter checks """ - BL.mda.go(verbose=True,**kwargs) + iex.BL.mda.go(verbose=True,**kwargs) def last_mda(): @@ -77,7 +79,7 @@ def last_mda(): returns the last mda file number in the ioc defined by BL_ioc Previously: LastMDA """ - filenum = BL.mda.lastFileNum() + filenum = iex.BL.mda.lastFileNum() return filenum @@ -91,7 +93,7 @@ def endstation_cams_enable(): """ should live in cameras """ - endstation=BL.endstation + endstation=iex.BLendstation cam_dict={'ARPES':[0,1,2],'Kappa':[3,4,6]} # index of cam_list pvcam1=PV("29id_ps1:cam1:Acquire") diff --git a/iexcode/instruments/cfg.py b/iexcode/instruments/cfg.py new file mode 100644 index 0000000000000000000000000000000000000000..ddd518fdb09b95ec37188dad0c2ab700e96897da --- /dev/null +++ b/iexcode/instruments/cfg.py @@ -0,0 +1,2 @@ +BL=None + diff --git a/iexcode/instruments/current_amplifiers.py b/iexcode/instruments/current_amplifiers.py index d021d10b11b39be96de5beca7990d925d5a1fa00..88268a27cc8c0a7f7ff27565234289265a682a1a 100644 --- a/iexcode/instruments/current_amplifiers.py +++ b/iexcode/instruments/current_amplifiers.py @@ -97,7 +97,7 @@ class Keithley: pv = self._pv caput(pv+"reset.PROC",1) - sleep(5) + sleep(.1) caput(pv+"digitalFilterSet","Off") caput(pv+"medianFilterSet","Off") caput(pv+"zeroCheckSet",0) diff --git a/iexcode/instruments/diagnostics.py b/iexcode/instruments/diagnostics.py index 50814ae88854f644fb99cd2b62123794f6428fac..0127d98e6c9939e0ac311ea549fd99226f09f0ba 100644 --- a/iexcode/instruments/diagnostics.py +++ b/iexcode/instruments/diagnostics.py @@ -1,7 +1,7 @@ from numpy import nan from epics import caput, caget -from iexcode.instruments.IEX_endstations import * +#from iexcode.instruments.IEX_endstations import * ############################################################################################################## ################################ default positions ############################## diff --git a/iexcode/instruments/electron_analyzer.py b/iexcode/instruments/electron_analyzer.py index 3c208d0aba3a14068fcfbb5cf379fa8a567a438b..28aaec7386f40d3b97024e1bcdd826378b9acb18 100644 --- a/iexcode/instruments/electron_analyzer.py +++ b/iexcode/instruments/electron_analyzer.py @@ -21,7 +21,7 @@ from iexcode.instruments.xrays import energy, scanXAS_BL, BL_energy_tables from iexcode.instruments.shutters import branch_shutter_close from iexcode.instruments.VLS_PGM import mono_energy_get from iexcode.instruments.files_and_folders import get_next_fileNumber -from iexcode.instruments.logfile import * +from iexcode.instruments.Logfile import * from iexcode.instruments.Scienta import * global EA diff --git a/iexcode/instruments/scalers.py b/iexcode/instruments/scalers.py index 89be3dbabd0b813aa88d6e5088354e5aa049ee33..1ae03b59c447099af97828a7720a63a985163afa 100644 --- a/iexcode/instruments/scalers.py +++ b/iexcode/instruments/scalers.py @@ -1,16 +1,17 @@ from math import floor from epics import caput,PV - -from iexcode.instruments.IEX_endstations import BL +#import iexcode.instruments.IEX_endstations as iex +import iexcode.instruments.cfg as iex def scaler_cts(time_seconds=0.1,verbose=True): """ sets the scalers counting for the endstation defined in BL - """ - if BL.ioc == 'Kappa': + """ + if iex.BL.ioc == 'Kappa': Kappa_scaler(time_seconds,verbose=verbose) - + else: + pass def Kappa_scaler(time_seconds=0.1,verbose=True): """ diff --git a/iexcode/instruments/scanRecord.py b/iexcode/instruments/scanRecord.py index 816c10f6fc92a39d626356d2bd47fc4327f641cd..3d4e9d9eadbcef617a41b33d70e3a7e32b0565cb 100644 --- a/iexcode/instruments/scanRecord.py +++ b/iexcode/instruments/scanRecord.py @@ -315,13 +315,11 @@ class ScanRecord: Previously: Reset_ScanAll """ - if hasattr(self, 'detector_dictionary'): - kwargs.setdefault('detector_dictionary',self.detector_dictionary) - if hasattr(self, 'trigger_dictionary'): - kwargs.setdefault('trigger_dictionary',self.trigger_dictionary) - if hasattr(self, 'before_scan_pv'): + kwargs.setdefault('detector_dictionary',self.detector_dictionary) + kwargs.setdefault('trigger_dictionary',self.trigger_dictionary) + if self.before_scan_pv != None: kwargs.setdefault('before_scan_pv',self.before_scan_pv) - if hasattr(self, 'after_scan_pv'): + if self.after_scan_pv != None: kwargs.setdefault('after_scan_pv',self.after_scan_pv) #clearing all diff --git a/iexcode/instruments/xrays.py b/iexcode/instruments/xrays.py index 23b2ddc3a367032cd8114354ccd50a6b766ffd1b..62bf9d9533a8688f786a2cd45cabf472ca1b0d3b 100644 --- a/iexcode/instruments/xrays.py +++ b/iexcode/instruments/xrays.py @@ -6,7 +6,9 @@ import numpy as np from time import sleep from epics import caget,caput -from iexcode.instruments.IEX_endstations import BL +#from iexcode.instruments.IEX_endstations import * +#import iexcode.instruments.IEX_endstations as iex +import iexcode.instruments.cfg as iex from iexcode.instruments.IEX_VPU import * from iexcode.instruments.VLS_PGM import * @@ -15,7 +17,7 @@ from iexcode.instruments.shutters import * from iexcode.instruments.gate_valves import * from iexcode.instruments.diagnostics import * from iexcode.instruments.m3r import * -from iexcode.instruments.logfile import * +#from iexcode.instruments.Logfile import * from iexcode.instruments.utilities import print_warning_message,make_table, take_closest_value from iexcode.instruments.current_amplifiers import ca_average from iexcode.instruments.beamline import endstation_cams_enable @@ -92,6 +94,7 @@ def xrays_get_all(verbose=False): returns a dictionary """ + #global BL vals={} print("\n===========================================================") vals.update(ID_get_all(verbose=True)) @@ -102,8 +105,8 @@ def xrays_get_all(verbose=False): vals.update(FMB_mirror_get(1,verbose=True)) vals.update(FMB_mirror_get(3,verbose=True)) print("-----------------------------------------------------------") - vals.update({BL.endstation:BL.Motors.mprint()}) - print(BL.endstation+" = ",BL.Motors.mprint()) + vals.update({iex.BL.endstation:iex.BL.Motors.mprint()}) + print(iex.BL.endstation+" = ",iex.BL.Motors.mprint()) print("===========================================================") return vals @@ -121,11 +124,12 @@ def xrays_log_entries(**kwargs): """ #default parameters kwargs.setdefault('comment','') + #global BL - ioc = BL.ioc + ioc = iex.BL.ioc #scan Num - scan = BL.mda.prefix(ioc)+str(BL.mda.fileNum(ioc)) + scan = iex.BL.mda.prefix(ioc)+str(iex.BL.mda.fileNum(ioc)) entry_list=["scan"] pv_list=[scan] format_list=["s" ] @@ -139,32 +143,32 @@ def xrays_log_entries(**kwargs): format_list.append("s",".3f",".3f",".3f") #endstation info - if BL.endstation_name == 'ARPES': - endstation_entry, endstation_pv, endstation_format = BL.log_entries(**kwargs) + if iex.BL.endstation_name == 'ARPES': + endstation_entry, endstation_pv, endstation_format = iex.BL.log_entries(**kwargs) entry_list.append(endstation_entry) pv_list.append(endstation_pv) format_list.append(endstation_format) - elif BL.endstation_name == 'Kappa': - endstation_entry, endstation_pv, endstation_format = BL.log_entries(**kwargs) + elif iex.BL.endstation_name == 'Kappa': + endstation_entry, endstation_pv, endstation_format = iex.BL.log_entries(**kwargs) entry_list.append(endstation_entry[:-7]) pv_list.append(endstation_pv[:-7]) format_list.append(endstation_format[:-7]) #beamline info - ID_mode = ID_mode_get(verbose=False) if BL.xrays else "no_xrays" - ID_QP_ratio = ID_QP_ratio_get (verbose=False) if BL.xrays else "no_xrays" - ID_sp = round(ID_SP_get_eV()) if BL.xrays else 0 - ID_rbv = round(ID_rbv_get_eV,4) if BL.xrays else 0 - hv = mono_energy_get() if BL.xrays else 0 - grt = mono_grating_get() if BL.xrays else 0 - slit_size = slit_get()[0] if BL.xrays else 0 + ID_mode = ID_mode_get(verbose=False) if iex.BL.xrays else "no_xrays" + ID_QP_ratio = ID_QP_ratio_get (verbose=False) if iex.BL.xrays else "no_xrays" + ID_sp = round(ID_SP_get_eV()) if iex.BL.xrays else 0 + ID_rbv = round(ID_rbv_get_eV,4) if iex.BL.xrays else 0 + hv = mono_energy_get() if iex.BL.xrays else 0 + grt = mono_grating_get() if iex.BL.xrays else 0 + slit_size = slit_get()[0] if iex.BL.xrays else 0 entry_list.append("hv","exit_slit","GRT", "ID_SP", "ID_RBV", "ID_Mode", "ID_QP") pv_list.append(hv,slit_size,grt, ID_sp, ID_rbv,ID_mode, ID_QP_ratio) format_list.append(".2f",".0f","s",".1f",".1f","s", ".0f") #endstation info 2: Fanny can I change to order to get rid of this complication? - if BL.endstation_name == 'Kappa': - endstation_entry, endstation_pv, endstation_format = BL.log_entries(**kwargs) + if iex.BL.endstation_name == 'Kappa': + endstation_entry, endstation_pv, endstation_format = iex.BL.log_entries(**kwargs) entry_list.append(endstation_entry[-7:]) pv_list.append(endstation_pv[-7:]) format_list.append(endstation_format[-7:]) @@ -177,7 +181,7 @@ def xrays_log_entries(**kwargs): format_list.append("s","s") try: - logfile_update(BL.endstation,BL.ioc,entry_list,pv_list,format_list) + logfile_update(iex.BL.endstation,iex.BL.ioc,entry_list,pv_list,format_list) except: print("scanlog did not write to file, check for errors.") @@ -226,7 +230,8 @@ def energy(hv_eV,slit_coeff=1,m3r=True,verbose=True): m3r => if True optimizes the mirror for the d-branch only Previously: Set_BL, energy """ - if BL.xrays: + #global BL + if iex.BL.xrays: if hv_eV != energy_range_check(hv_eV): message_string = 'request photon energy '+str(hv_eV)+' not with the allowed range' message_string = '\n closest allowed energy is '+str(energy_range_check(hv_eV)) @@ -238,7 +243,7 @@ def energy(hv_eV,slit_coeff=1,m3r=True,verbose=True): slits_set_BL(c_2B=slit_coeff,c_1A=1,verbose=verbose) if m3r == True: - if BL.branch() == 'd': + if iex.BL.branch() == 'd': print('\nalign_m3r()') try: m3r_align() @@ -248,7 +253,7 @@ def energy(hv_eV,slit_coeff=1,m3r=True,verbose=True): except: print('Unable to align; check camera settings.') else: - message_string = 'BL.xrays = False, energy is not set' + message_string = 'iex.BL.xrays = False, energy is not set' print_warning_message(message_string) def energy_range_min_max(): @@ -285,8 +290,9 @@ def scan_ID(ID_sp_start,ID_sp_stop,ID_sp_step,**kwargs): """ scan the ID set point """ + #global BL val_pv,rbv_pv = ID_scan_pvs() - BL.mda.fillin(val_pv,rbv_pv,ID_sp_start,ID_sp_stop,ID_sp_step,**kwargs) + iex.BL.mda.fillin(val_pv,rbv_pv,ID_sp_start,ID_sp_stop,ID_sp_step,**kwargs) def mvmono(val): @@ -352,14 +358,15 @@ def scanhv(start,stop,step,average_pnts=1,**kwargs): scans the mono at the current ID value """ + #global BL ca_average(average_pnts) - mono_scan_fillin(BL.mda,start,stop,step,**kwargs) + mono_scan_fillin(iex.BL.mda,start,stop,step,**kwargs) mono_energy_set(start) - BL.mda.go(**kwargs) + iex.BL.mda.go(**kwargs) - mono_scan_after(BL.mda) + mono_scan_after(iex.BL.mda) def scanE(start,stop,step,ID_offset=0,mesh='stay',average_pnts=1,scan_dim=1,**kwargs): @@ -378,7 +385,8 @@ def scanE(start,stop,step,ID_offset=0,mesh='stay',average_pnts=1,scan_dim=1,**kw scan_dim positioner_settling_time = 0.2 """ - mda = BL.mda + #global BL + mda = iex.BL.mda ca_average(average_pnts) if ID_offset != None: @@ -389,7 +397,7 @@ def scanE(start,stop,step,ID_offset=0,mesh='stay',average_pnts=1,scan_dim=1,**kw mono_scan_fillin(mda,scan_dim,start,stop,step,**kwargs) mono_energy_set(start) - BL.mda.go(scan_dim) + iex.BL.mda.go(scan_dim) mono_scan_after(mda,scan_dim) @@ -419,22 +427,23 @@ def scanXAS(ID_eV,start_stop_step_lists,**kwargs): kwargs.setdefault("mcp",True) kwargs.setdefault('execute',True) + #global BL scan_dim=kwargs['scan_dim'] #Setting up the ScanRecord for Mono in Table mode hv_array = make_table(start_stop_step_lists) - mono_scan_fillin_table(BL.mda,scan_dim,hv_array,**kwargs) + mono_scan_fillin_table(iex.BL.mda,scan_dim,hv_array,**kwargs) #Averaging and Normalization ca_average(kwargs['average_pnts']) - if BL.branch=="d": + if iex.BL.branch=="d": meshD("In") #Setting the beamline energy energy(ID_eV,m3r=kwargs["m3r"]) #mpa - if BL.branch == "d" and kwargs["mcp"]: + if iex.BL.branch == "d" and kwargs["mcp"]: mpa_HV_on() #Scanning @@ -478,6 +487,7 @@ def scanXAS_BL(start_stop_step_lists,**kwargs): kwargs.setdefault("mcp",True) kwargs.setdefault('execute',True) + #global BL scan_dim=kwargs['scan_dim'] #Setting up the ScanRecord for Mono and ID in Table mode @@ -647,6 +657,7 @@ def slit(size): ARPES = 0 < x < 300 um Kappa = 0 < x < 1000 um """ + global BL branch = BL.branch if branch == "c": slit3C_set(size, quiet=False) @@ -661,6 +672,7 @@ def slit_get(verbose=True): ARPES = 0 < x < 300 um Kappa = 0 < x < 1000 um """ + global BL branch = BL.branch if branch == "c": slit_size = slit3C_get(verbose=False) diff --git a/iexcode/macros/__init__.py b/iexcode/macros/__init__.py index d2a66a14d237e6ff8467fe93e859aa4c9aeac418..8ccf3df1571798ce4fa3a305fa3ac5ca11eff3e5 100644 --- a/iexcode/macros/__init__.py +++ b/iexcode/macros/__init__.py @@ -6,7 +6,7 @@ from iexcode.instruments.conversions_constants import * from iexcode.instruments.encoders import * from iexcode.instruments.files_and_folders import * from iexcode.instruments.IEX_endstations import * -from iexcode.instruments.logfile import * +from iexcode.instruments.Logfile import * from iexcode.instruments.Motors import * from iexcode.instruments.remote_controlers import * from iexcode.instruments.s29_temp_cntl import * diff --git a/iexcode/macros/commissioning.py b/iexcode/macros/commissioning.py index 675889f949a341e87f8a5b9886768e49fef05040..80046bc6ef6fccf8a4e58cac90f929a4d383f154 100644 --- a/iexcode/macros/commissioning.py +++ b/iexcode/macros/commissioning.py @@ -17,7 +17,7 @@ from ..instruments.IEX_VPU import ID_switch_mode from ..instruments.diagnostics import diagnostics_all_out, diagnostics_all_in,diodeC,diodeD from ..instruments.current_amplifiers import current2flux from ..instruments.slits import set_exit_slit -from ..instruments.logfile import * +from ..instruments.Logfile import * from ..instruments.cameras import * from ..instruments.ARPES import *