From 901a435c6ed1aa76a3daaf7ade6583486858d495 Mon Sep 17 00:00:00 2001 From: "FR@29iduser" <rodolakis@anl.gov> Date: Fri, 30 Sep 2022 14:26:18 -0500 Subject: [PATCH] fixed log_entries --- build/lib/iexcode/instruments/ARPES.py | 13 +++-- build/lib/iexcode/instruments/Motors.py | 50 +++++++++++-------- .../iexcode/instruments/electron_analyzer.py | 1 + build/lib/iexcode/instruments/resolution.py | 4 +- build/lib/iexcode/instruments/scanRecord.py | 2 +- iexcode.egg-info/SOURCES.txt | 5 -- iexcode/instruments/ARPES.py | 11 +++- iexcode/instruments/Logfile.py | 17 ++++--- iexcode/instruments/Motors.py | 50 +++++++++++-------- iexcode/instruments/Octupole.py | 8 ++- iexcode/instruments/scanRecord.py | 2 +- 11 files changed, 100 insertions(+), 63 deletions(-) diff --git a/build/lib/iexcode/instruments/ARPES.py b/build/lib/iexcode/instruments/ARPES.py index cd06154..eb59983 100644 --- a/build/lib/iexcode/instruments/ARPES.py +++ b/build/lib/iexcode/instruments/ARPES.py @@ -43,6 +43,10 @@ def ARPES_init(*userName,**kwargs): reset: to reset the detectors in the IOC, sets the logfile name, etc (default => False) xrays: sets global variable and detectors for x-ray (default => True) mode: used sets the detectors 'user ' / 'staff' (default => 'user' ) + + usage: + tey,ca15 = ARPES_init('user_name') + tey,ca15 = ARPES_init(mode='staff') """ kwargs.setdefault('scan_ioc',default_ioc) kwargs.setdefault('xrays',True) @@ -64,7 +68,7 @@ def ARPES_init(*userName,**kwargs): #setting folders if kwargs['set_folders']: if iex.BL.mode == 'staff': - user_name = 'staff' + user_name = 'Staff' else: if len(userName)==0: user_name = input('user name: ') @@ -217,7 +221,10 @@ def folders_ARPES(user_name,**kwargs): #Set up Scienta folders: if EA.connected: userPath = path_dserv(iex.BL.folder,run,user_name) - folders_EA(userPath,filePrefix="EA") + try: + folders_EA(userPath,filePrefix="EA") + except: + print("EA folder not set; need to be 29id to create folder on the dserv") else: print_warning_message("EA ioc is not running, h5 folder not set") @@ -725,5 +732,5 @@ def ARPES_sample_map2D(step_y=0.5,step_z=0.5): Previously: Map_ARPES_Sample """ print("Scan_ARPES_2Dmotor(\"y\",0,4,"+str(step_y)+",\"z\",12,16,"+str(step_z)+")") - ARPES_Motors.scan2D(["y",0,4,step_y],["z",12,16,step_z]) + ARPES_Motors.scan_2D(["y",0,4,step_y],["z",12,16,step_z]) diff --git a/build/lib/iexcode/instruments/Motors.py b/build/lib/iexcode/instruments/Motors.py index b59469b..0e216a2 100644 --- a/build/lib/iexcode/instruments/Motors.py +++ b/build/lib/iexcode/instruments/Motors.py @@ -268,9 +268,10 @@ def scanx(start,stop,step,**kwargs): """ scans the x motor in the endstation""" iex.BL.motors.scan("x",start,stop,step,**kwargs) -def dscanx(start,stop,step): +def dscanx(start,stop,step,**kwargs): """relative scans of the x motor in the endstation """ - iex.BL.motors.scan("x",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("x",start,stop,step,**kwargs) ### y ### def mvy(val,**kwargs): @@ -285,9 +286,10 @@ def scany(start,stop,step,**kwargs): """ scans the y motor in the endstation""" iex.BL.motors.scan("y",start,stop,step,**kwargs) -def dscany(start,stop,step): +def dscany(start,stop,step,**kwargs): """relative scans of the y motor in the endstation """ - iex.BL.motors.scan("y",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("y",start,stop,step,**kwargs) ### z ### def mvz(val,**kwargs): @@ -302,9 +304,10 @@ def scanz(start,stop,step,**kwargs): """ scans the z motor in the endstation""" iex.BL.motors.scan("z",start,stop,step,**kwargs) -def dscanz(start,stop,step): +def dscanz(start,stop,step,**kwargs): """relative scans of the z motor in the endstation """ - iex.BL.motors.scan("z",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("z",start,stop,step,**kwargs) ### kth ### def mvkth(val,**kwargs): @@ -319,9 +322,10 @@ def scankth(start,stop,step,**kwargs): """ scans the kth motor in the endstation""" iex.BL.motors.scan("kth",start,stop,step,**kwargs) -def dscankth(start,stop,step): +def dscankth(start,stop,step,**kwargs): """relative scans of the kth motor in the endstation """ - iex.BL.motors.scan("kth",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("kth",start,stop,step,**kwargs) ### kphi ### def mvkphi(val,**kwargs): @@ -336,9 +340,10 @@ def scankphi(start,stop,step,**kwargs): """ scans the kphi motor in the endstation""" iex.BL.motors.scan("kphi",start,stop,step,**kwargs) -def dscankphi(start,stop,step): +def dscankphi(start,stop,step,**kwargs): """relative scans of the kphi motor in the endstation """ - iex.BL.motors.scan("kphi",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("kphi",start,stop,step,**kwargs) ### kap ### def mvkap(val,**kwargs): @@ -353,9 +358,10 @@ def scankap(start,stop,step,**kwargs): """ scans the kap motor in the endstation""" iex.BL.motors.scan("kap",start,stop,step,**kwargs) -def dscankap(start,stop,step): +def dscankap(start,stop,step,**kwargs): """relative scans of the kap motor in the endstation """ - iex.BL.motors.scan("kap",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("kap",start,stop,step,**kwargs) ### tth ### def mvtth(val,**kwargs): @@ -370,9 +376,10 @@ def scantth(start,stop,step,**kwargs): """ scans the tth motor in the endstation""" iex.BL.motors.scan("tth",start,stop,step,**kwargs) -def dscantth(start,stop,step): +def dscantth(start,stop,step,**kwargs): """relative scans of the tth motor in the endstation """ - iex.BL.motors.scan("tth",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("tth",start,stop,step,**kwargs) ### th ### def mvth(val,**kwargs): @@ -387,9 +394,10 @@ def scanth(start,stop,step,**kwargs): """ scans the th motor in the endstation""" iex.BL.motors.scan("th",start,stop,step,**kwargs) -def dscanth(start,stop,step): +def dscanth(start,stop,step,**kwargs): """relative scans of the th motor in the endstation """ - iex.BL.motors.scan("th",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("th",start,stop,step,**kwargs) ### chi ### def mvchi(val,**kwargs): @@ -404,9 +412,10 @@ def scanchi(start,stop,step,**kwargs): """ scans the chi motor in the endstation""" iex.BL.motors.scan("chi",start,stop,step,**kwargs) -def dscanchi(start,stop,step): +def dscanchi(start,stop,step,**kwargs): """relative scans of the chi motor in the endstation """ - iex.BL.motors.scan("chi",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("chi",start,stop,step,**kwargs) ### phi ### def mvphi(val,**kwargs): @@ -421,9 +430,10 @@ def scanphi(start,stop,step,**kwargs): """ scans the phi motor in the endstation""" iex.BL.motors.scan("phi",start,stop,step,**kwargs) -def dscanphi(start,stop,step): +def dscanphi(start,stop,step,**kwargs): """relative scans of the phi motor in the endstation """ - iex.BL.motors.scan("phi",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("phi",start,stop,step,**kwargs) def scan_motors_2D(inner_loop_list,outer_loop_list,**kwargs): diff --git a/build/lib/iexcode/instruments/electron_analyzer.py b/build/lib/iexcode/instruments/electron_analyzer.py index 782174e..d7c92a1 100644 --- a/build/lib/iexcode/instruments/electron_analyzer.py +++ b/build/lib/iexcode/instruments/electron_analyzer.py @@ -801,3 +801,4 @@ def SES_slit_set(val): def SES_slit_get(): SES=caget("29idc:m8.RBV") return SES + diff --git a/build/lib/iexcode/instruments/resolution.py b/build/lib/iexcode/instruments/resolution.py index 7cdbf8f..c6f5a73 100644 --- a/build/lib/iexcode/instruments/resolution.py +++ b/build/lib/iexcode/instruments/resolution.py @@ -6,7 +6,7 @@ import iexcode.instruments.cfg as iex from iexcode.instruments.utilities import take_closest_value 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.electron_analyzer import EA, resolution_EA, SES_slit_get from iexcode.instruments.ARPES import ARPES_extra_pvs ############################################################################################################# ############################## Resolution ############################## @@ -23,7 +23,7 @@ def resolution(): slit_size = take_closest_value([10,20,50,100,200],round(slit_get(),0)) if branch == "c": - slit_SES = getSESslit() + slit_SES = SES_slit_get() PE = int(EA.PassEnergy) Tsample = caget(ARPES_extra_pvs['TA']) resolution_ARPES(grt,hv_eV,slit_size,PE,slit_SES,Tsample,verbose=True) diff --git a/build/lib/iexcode/instruments/scanRecord.py b/build/lib/iexcode/instruments/scanRecord.py index bbf6676..25acc9f 100644 --- a/build/lib/iexcode/instruments/scanRecord.py +++ b/build/lib/iexcode/instruments/scanRecord.py @@ -788,7 +788,7 @@ class ScanRecord: scan_pv = self.ioc+"scan"+str(scan_dim) caput(scan_pv+".EXSC",1,wait=True,timeout=900000) #pushes scan button if self.log != None: - log_update() # writes the log file + log_update(**kwargs) # writes the log file print(filename+str(fileNum)+" finished at ", dateandtime()) print('\n') diff --git a/iexcode.egg-info/SOURCES.txt b/iexcode.egg-info/SOURCES.txt index 5f295bd..01565ed 100644 --- a/iexcode.egg-info/SOURCES.txt +++ b/iexcode.egg-info/SOURCES.txt @@ -1,11 +1,6 @@ README.md setup.py iexcode/__init__.py -iexcode/launch_ARPES.py -iexcode/launch_Kappa.py -iexcode/launch_all.py -iexcode/launch_staff.py -iexcode/launch_xrays.py iexcode.egg-info/PKG-INFO iexcode.egg-info/SOURCES.txt iexcode.egg-info/dependency_links.txt diff --git a/iexcode/instruments/ARPES.py b/iexcode/instruments/ARPES.py index 0d586f0..eb59983 100644 --- a/iexcode/instruments/ARPES.py +++ b/iexcode/instruments/ARPES.py @@ -43,6 +43,10 @@ def ARPES_init(*userName,**kwargs): reset: to reset the detectors in the IOC, sets the logfile name, etc (default => False) xrays: sets global variable and detectors for x-ray (default => True) mode: used sets the detectors 'user ' / 'staff' (default => 'user' ) + + usage: + tey,ca15 = ARPES_init('user_name') + tey,ca15 = ARPES_init(mode='staff') """ kwargs.setdefault('scan_ioc',default_ioc) kwargs.setdefault('xrays',True) @@ -64,7 +68,7 @@ def ARPES_init(*userName,**kwargs): #setting folders if kwargs['set_folders']: if iex.BL.mode == 'staff': - user_name = 'staff' + user_name = 'Staff' else: if len(userName)==0: user_name = input('user name: ') @@ -217,7 +221,10 @@ def folders_ARPES(user_name,**kwargs): #Set up Scienta folders: if EA.connected: userPath = path_dserv(iex.BL.folder,run,user_name) - folders_EA(userPath,filePrefix="EA") + try: + folders_EA(userPath,filePrefix="EA") + except: + print("EA folder not set; need to be 29id to create folder on the dserv") else: print_warning_message("EA ioc is not running, h5 folder not set") diff --git a/iexcode/instruments/Logfile.py b/iexcode/instruments/Logfile.py index d49f283..c7ae335 100644 --- a/iexcode/instruments/Logfile.py +++ b/iexcode/instruments/Logfile.py @@ -21,13 +21,13 @@ def log_print(comment=''): except: print('No logfile written') -def log_update(d=None): +def log_update(d=None,**kwargs): """ updates the log file with the last scan info d = dictionary of {header:[data,format]} """ #try: - iex.BL.mda.log.update(d) + iex.BL.mda.log.update(d,**kwargs) #except: # print('No logfile written') @@ -152,10 +152,12 @@ class Logfile: print("Logprint failed") - def log_entries(self,endstation_dictionary=None,comment=''): + def log_entries(self,endstation_dictionary=None,**kwargs): """ gets the meta data to write in the log file """ + kwargs.setdefault('comment','') + if endstation_dictionary is None: endstation_dictionary = self.log_dictionary() @@ -169,7 +171,7 @@ class Logfile: time_comments={ 'time': (time.strftime("%D-%H:%M:%S"),"s"), - 'comment':(comment,"s") + 'comment':(kwargs['comment'],"s") } d = scan_log d.update(endstation_dictionary) @@ -183,6 +185,7 @@ class Logfile: header_list.append(key) data_list.append(val[0]) format_list.append(val[1]) + print(data_list) return header_list,data_list,format_list def _intit_log(self,header_list): @@ -221,14 +224,14 @@ class Logfile: self.write_header(head_list) with open(self.filepath, "a+") as f: - for i in range(len(format_list)): + for i in range(len(format_list)-1): pv_format = "{0:"+format_list[i]+"}," f.write(pv_format.format(data_list[i])) last_entry=len(format_list)-1 pv_format="{0:"+format_list[last_entry]+"}\n" f.write(pv_format.format(data_list[last_entry])) - def update(self,d=None,comment=''): + def update(self,d=None,**kwargs): """ To be used for scanlog and scanEA functions. Update SaveFile_Header version number when changing the structure of the file (indexing). @@ -238,7 +241,7 @@ class Logfile: if d == None: d = iex.BL.mda.log.log_dictionary() - header_list,data_list,format_list = self.log_entries(d) + header_list,data_list,format_list = self.log_entries(d,**kwargs) if not isfile(self.filepath): self._intit_log(header_list) diff --git a/iexcode/instruments/Motors.py b/iexcode/instruments/Motors.py index b59469b..0e216a2 100644 --- a/iexcode/instruments/Motors.py +++ b/iexcode/instruments/Motors.py @@ -268,9 +268,10 @@ def scanx(start,stop,step,**kwargs): """ scans the x motor in the endstation""" iex.BL.motors.scan("x",start,stop,step,**kwargs) -def dscanx(start,stop,step): +def dscanx(start,stop,step,**kwargs): """relative scans of the x motor in the endstation """ - iex.BL.motors.scan("x",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("x",start,stop,step,**kwargs) ### y ### def mvy(val,**kwargs): @@ -285,9 +286,10 @@ def scany(start,stop,step,**kwargs): """ scans the y motor in the endstation""" iex.BL.motors.scan("y",start,stop,step,**kwargs) -def dscany(start,stop,step): +def dscany(start,stop,step,**kwargs): """relative scans of the y motor in the endstation """ - iex.BL.motors.scan("y",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("y",start,stop,step,**kwargs) ### z ### def mvz(val,**kwargs): @@ -302,9 +304,10 @@ def scanz(start,stop,step,**kwargs): """ scans the z motor in the endstation""" iex.BL.motors.scan("z",start,stop,step,**kwargs) -def dscanz(start,stop,step): +def dscanz(start,stop,step,**kwargs): """relative scans of the z motor in the endstation """ - iex.BL.motors.scan("z",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("z",start,stop,step,**kwargs) ### kth ### def mvkth(val,**kwargs): @@ -319,9 +322,10 @@ def scankth(start,stop,step,**kwargs): """ scans the kth motor in the endstation""" iex.BL.motors.scan("kth",start,stop,step,**kwargs) -def dscankth(start,stop,step): +def dscankth(start,stop,step,**kwargs): """relative scans of the kth motor in the endstation """ - iex.BL.motors.scan("kth",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("kth",start,stop,step,**kwargs) ### kphi ### def mvkphi(val,**kwargs): @@ -336,9 +340,10 @@ def scankphi(start,stop,step,**kwargs): """ scans the kphi motor in the endstation""" iex.BL.motors.scan("kphi",start,stop,step,**kwargs) -def dscankphi(start,stop,step): +def dscankphi(start,stop,step,**kwargs): """relative scans of the kphi motor in the endstation """ - iex.BL.motors.scan("kphi",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("kphi",start,stop,step,**kwargs) ### kap ### def mvkap(val,**kwargs): @@ -353,9 +358,10 @@ def scankap(start,stop,step,**kwargs): """ scans the kap motor in the endstation""" iex.BL.motors.scan("kap",start,stop,step,**kwargs) -def dscankap(start,stop,step): +def dscankap(start,stop,step,**kwargs): """relative scans of the kap motor in the endstation """ - iex.BL.motors.scan("kap",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("kap",start,stop,step,**kwargs) ### tth ### def mvtth(val,**kwargs): @@ -370,9 +376,10 @@ def scantth(start,stop,step,**kwargs): """ scans the tth motor in the endstation""" iex.BL.motors.scan("tth",start,stop,step,**kwargs) -def dscantth(start,stop,step): +def dscantth(start,stop,step,**kwargs): """relative scans of the tth motor in the endstation """ - iex.BL.motors.scan("tth",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("tth",start,stop,step,**kwargs) ### th ### def mvth(val,**kwargs): @@ -387,9 +394,10 @@ def scanth(start,stop,step,**kwargs): """ scans the th motor in the endstation""" iex.BL.motors.scan("th",start,stop,step,**kwargs) -def dscanth(start,stop,step): +def dscanth(start,stop,step,**kwargs): """relative scans of the th motor in the endstation """ - iex.BL.motors.scan("th",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("th",start,stop,step,**kwargs) ### chi ### def mvchi(val,**kwargs): @@ -404,9 +412,10 @@ def scanchi(start,stop,step,**kwargs): """ scans the chi motor in the endstation""" iex.BL.motors.scan("chi",start,stop,step,**kwargs) -def dscanchi(start,stop,step): +def dscanchi(start,stop,step,**kwargs): """relative scans of the chi motor in the endstation """ - iex.BL.motors.scan("chi",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("chi",start,stop,step,**kwargs) ### phi ### def mvphi(val,**kwargs): @@ -421,9 +430,10 @@ def scanphi(start,stop,step,**kwargs): """ scans the phi motor in the endstation""" iex.BL.motors.scan("phi",start,stop,step,**kwargs) -def dscanphi(start,stop,step): +def dscanphi(start,stop,step,**kwargs): """relative scans of the phi motor in the endstation """ - iex.BL.motors.scan("phi",start,stop,step,relative=True) + kwargs.update({'relative':True}) + iex.BL.motors.scan("phi",start,stop,step,**kwargs) def scan_motors_2D(inner_loop_list,outer_loop_list,**kwargs): diff --git a/iexcode/instruments/Octupole.py b/iexcode/instruments/Octupole.py index 148eb83..0025b61 100644 --- a/iexcode/instruments/Octupole.py +++ b/iexcode/instruments/Octupole.py @@ -47,7 +47,11 @@ def Octupole_init(*userName,**kwargs): reset: to reset the detectors in the IOC, etc (default => True) xrays: sets global variable and detectors for x-ray (default => True) mode: used sets the detectors 'user ' / 'staff' (default => 'user' ) - """ + + usage: + tey,tfy,pd,mesh,diag,kbh,kbv = Octupole_init('user_name') + tey,tfy,pd,mesh,diag,kbh,kbv = Octupole_init(mode='staff') + """ kwargs.setdefault('scan_ioc',default_ioc) kwargs.setdefault('xrays',True) kwargs.setdefault('mode','user') @@ -66,7 +70,7 @@ def Octupole_init(*userName,**kwargs): #setting folders if kwargs['set_folders']: if iex.BL.mode == 'staff': - user_name = 'staff' + user_name = 'Staff' else: if len(userName)==0: user_name = input('user name: ') diff --git a/iexcode/instruments/scanRecord.py b/iexcode/instruments/scanRecord.py index bbf6676..25acc9f 100644 --- a/iexcode/instruments/scanRecord.py +++ b/iexcode/instruments/scanRecord.py @@ -788,7 +788,7 @@ class ScanRecord: scan_pv = self.ioc+"scan"+str(scan_dim) caput(scan_pv+".EXSC",1,wait=True,timeout=900000) #pushes scan button if self.log != None: - log_update() # writes the log file + log_update(**kwargs) # writes the log file print(filename+str(fileNum)+" finished at ", dateandtime()) print('\n') -- GitLab