diff --git a/build/lib/iexcode/instruments/ARPES.py b/build/lib/iexcode/instruments/ARPES.py index 5237aa116e883b803111df6a0f6a03f7fe076567..d54b041e71f20ee4c1c350ad318a8843f15adc14 100644 --- a/build/lib/iexcode/instruments/ARPES.py +++ b/build/lib/iexcode/instruments/ARPES.py @@ -211,7 +211,7 @@ def ARPES_reset(**kwargs): """ #writing default parameters to iex.BL.mda if iex.BL.mode=='staff': - iex.BL.mda.detector_dictionary = staff_detector_dictionary(kwargs['xrays']) + iex.BL.mda.detector_dictionary = staff_detector_dictionary() else: iex.BL.mda.detector_dictionary = ARPES_detector_dictionary(kwargs['xrays']) iex.BL.mda.trigger_dictionary = ARPES_trigger_dictionary(**kwargs) diff --git a/iexcode/instruments/ARPES.py b/iexcode/instruments/ARPES.py index 01feb7834e796e6cd8df0729f3611beed9109fab..0fca9d76a0988b65cf8f54c0545c511b2417460c 100644 --- a/iexcode/instruments/ARPES.py +++ b/iexcode/instruments/ARPES.py @@ -108,7 +108,7 @@ def _ARPES_detector_list(): ca_list=[["c",1],["b",15],["b",4],["b",13]] return ca_list -def _ARPES_detector_dictionary(xrays=True): +def _ARPES_detector_dictionary(): """ returns a dictionary of the default detectors for the scan record @@ -127,8 +127,9 @@ def _ARPES_detector_dictionary(xrays=True): det_dict.update({17:EA._statsPlugin+"Total_RBV"}) #add detectors related to beamline - if xrays: + if iex.BL.xrays: det_dict.update(_xrays_detector_dictionary()) + return det_dict def _ARPES_motor_dictionary(): @@ -208,18 +209,18 @@ def folders_ARPES(user_name,**kwargs): else: print_warning_message("EA ioc is not running, h5 folder not set") -def ARPES_reset(**kwargs): +def ARPES_reset(): """ resets scanRecord, current amplifiers, mono limits and lakeshore """ #writing default parameters to iex.BL.mda if iex.BL.mode=='staff': - iex.BL.mda.detector_dictionary = staff_detector_dictionary(kwargs['xrays']) + iex.BL.mda.detector_dictionary = staff_detector_dictionary() else: - iex.BL.mda.detector_dictionary = _ARPES_detector_dictionary(kwargs['xrays']) - 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) + iex.BL.mda.detector_dictionary = _ARPES_detector_dictionary() + iex.BL.mda.trigger_dictionary = _ARPES_trigger_dictionary() + iex.BL.mda.scan_before_sequence = _ARPES_scan_before_sequence() + iex.BL.mda.scan_after_sequence = _ARPES_scan_after_sequence() #resetting the scanRecord print("resetting the scanRecord - "+iex.BL.ioc) diff --git a/iexcode/instruments/Kappa.py b/iexcode/instruments/Kappa.py index ba236cc780fefda4d831fa98d23185e165b7c0d2..b329f6d8a508b18e25064ed3e240b50eeff224c8 100644 --- a/iexcode/instruments/Kappa.py +++ b/iexcode/instruments/Kappa.py @@ -58,7 +58,7 @@ def Kappa_init(*userName,**kwargs): Kappa_Motors = Motors('Kappa',_Kappa_motor_dictionary(),physical_motors,psuedo_motors) #endstation - iex.BL = Endstation('Kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],ARPES_Motors) + iex.BL = Endstation('Kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],Kappa_Motors) #setting folders if kwargs['set_folders']: @@ -175,6 +175,10 @@ def _Kappa_detector_dictionary(**kwargs): if kwargs['add_vortex']: det_dict.update(vortex) + #add detectors related to beamline + if iex.BL.xrays: + det_dict.update(_xrays_detector_dictionary()) + return det_dict @@ -283,12 +287,12 @@ def Kappa_reset(): """ #writing default parameters to iex.BL.mda if iex.BL.mode=='staff': - iex.BL.mda.detector_dictionary = staff_detector_dictionary(kwargs['xrays']) + iex.BL.mda.detector_dictionary = staff_detector_dictionary() else: - iex.BL.mda.detector_dictionary = _Kappa_detector_dictionary(kwargs['xrays']) - iex.BL.mda.trigger_dictionary = _Kappa_trigger_dictionary(**kwargs) - iex.BL.mda.scan_before_sequence = _Kappa_scan_before_sequence(**kwargs) - iex.BL.mda.scan_after_sequence = _Kappa_scan_after_sequence(**kwargs) + iex.BL.mda.detector_dictionary = _Kappa_detector_dictionary() + iex.BL.mda.trigger_dictionary = _Kappa_trigger_dictionary() + iex.BL.mda.scan_before_sequence = _Kappa_scan_before_sequence() + iex.BL.mda.scan_after_sequence = _Kappa_scan_after_sequence() #resetting the scanRecord print("resetting the scanRecord - "+iex.BL.ioc) diff --git a/iexcode/instruments/Motors.py b/iexcode/instruments/Motors.py index 43229d940e8f8c3c82bed02518f30e39aa3767a9..a5caf6bb3f5bb9f0ff49a020c5f89630536b45fe 100644 --- a/iexcode/instruments/Motors.py +++ b/iexcode/instruments/Motors.py @@ -427,12 +427,12 @@ def uan(tth,th): #move tth and th mvth(th,wait=False) mvtth(tth,wait=False) - sleep(0.2) + time.sleep(0.2) while True: status = iex.BL.Motors.status() if status == 0: - sleep(0.2) + time.sleep(0.2) else: tth_RBV=round(iex.BL.Motors.get('tth',verbose=False),3) th_RBV=round(iex.BL.Motors.get('th',verbose=False),3) diff --git a/iexcode/instruments/cheatsheet.txt b/iexcode/instruments/cheatsheet.txt new file mode 100644 index 0000000000000000000000000000000000000000..222259ef87bce23f5f407c433a2f37df52105c57 --- /dev/null +++ b/iexcode/instruments/cheatsheet.txt @@ -0,0 +1,42 @@ +# beamline +from re import L +from iexcode.instruments.conversions_constants import Lambda2eV, deg2rad, eV2Lambda, rad2deg +from iexcode.instruments.diagnostics import diodeC_read, meshD, meshD_read +from iexcode.instruments.xrays import energy_get, energy_get_all, mvid, switch_gratings + + +get_all() + +# cameras import +cam_snap(cam_num) + +#converstions_constants +deg2rad(angle_deg) +rad2deg(angle_rad) +eV2Lambda(eV) +Lambda2eV(Angstrom) + +#diagnostics +diodeC(In_Out) +diodeC_read() + +meshD(In_Out) +meshD_read() + +#electron_analyzer +EA.get() +EA.put(KE,PE) +scanEA(EAlist) +scanEA_hv() + +#xrays +energy_get_all() +energy_get() +getE() +energy(hv_eV) + +mvid() +mvmono() + +switch_gratings(grt) +polarization(ID_mode) \ No newline at end of file diff --git a/iexcode/instruments/conversions_constants.py b/iexcode/instruments/conversions_constants.py index 68cae3f1b8dc5238d21cddf6b9d115796d6414bd..9bbdd2741d8f2b2cb9e8cb585611fdd380b49835 100644 --- a/iexcode/instruments/conversions_constants.py +++ b/iexcode/instruments/conversions_constants.py @@ -96,15 +96,13 @@ def KtoE(k_theta,k_kappa,k_phi,k_arm=50): e_chi = 2.0 * np.asin( np.sin(k_kappa*conv/2.0) * np.sin(k_ang) ) e_phi = k_phi*conv - delta #print round(e_theta,1),round(e_phi,1),round(e_chi,1) - def rounder(val): # convert from rad to deg - conv = np.pi/180.0 - roundVal=round(1000.0*val/conv)/1000.0 - return roundVal theta = rounder(e_theta)+(57.045-kth_offset) chi = rounder(e_chi) # convert from rad to deg phi = rounder(e_phi) #print round(delta,1) return (theta,chi,phi) - - +def rounder(val): # convert from rad to deg + conv = np.pi/180.0 + roundVal=round(1000.0*val/conv)/1000.0 + return roundVal \ No newline at end of file diff --git a/iexcode/instruments/diagnostics.py b/iexcode/instruments/diagnostics.py index 0127d98e6c9939e0ac311ea549fd99226f09f0ba..84148ad35be7519b9f5dbf36503f4fe2f4c3d459 100644 --- a/iexcode/instruments/diagnostics.py +++ b/iexcode/instruments/diagnostics.py @@ -1,7 +1,8 @@ from numpy import nan from epics import caput, caget -#from iexcode.instruments.IEX_endstations import * + +import iexcode.instruments.cfg as iex ############################################################################################################## ################################ default positions ############################## @@ -70,7 +71,7 @@ def diagnostics_all_out(diode_stay_in=False): #which motor is Diode of interest if diode_stay_in: - branch = BL.branch + branch = iex.BL.branch if branch == 'c': diode_motor=diag["motor"]["gas-cell"] @@ -82,7 +83,7 @@ def diagnostics_all_out(diode_stay_in=False): #Taking out the diagnostic for motor in list(diag["Out"].keys()): if motor is diode_motor: - text=' except Diode-'+BL.branch + text=' except Diode-'+iex.BL.branch #putting Diode In if not already in -JM position=diag["In"][motor] caput("29idb:m"+str(motor)+".VAL",position,wait=True,timeout=18000) diff --git a/iexcode/instruments/electron_analyzer.py b/iexcode/instruments/electron_analyzer.py index 28aaec7386f40d3b97024e1bcdd826378b9acb18..e80d937c8e4dc24ec889f25957653623fa153ae7 100644 --- a/iexcode/instruments/electron_analyzer.py +++ b/iexcode/instruments/electron_analyzer.py @@ -170,14 +170,14 @@ def EA_log_update(): entry_list.append(key) pv_list.append(spectra_info[key][0]) format_list.append(spectra_info[key][1]) - logfile_update("ARPES",BL.ioc,entry_list,pv_list,format_list) + logfile_update("ARPES",iex.BL.ioc,entry_list,pv_list,format_list) except: print("EAlog did not write to file, check for errors.") def log_headerEA():##JM - need to update so that we get the keys from log_EA s="\nscan x y z th chi phi T scan_mode E1 E2 step i f PE lens_mode SES slit # ID_mode hv exit_slit GRT TEY1 TEY2 time\n" kwargs={'comment': s} - logfile_print("ARPES",BL.ioc,comment='') + logfile_print("ARPES",iex.BL.ioc,comment='') def EAsweptTime_estimate(EAlist,overhead=[60,.22]): """ @@ -226,7 +226,7 @@ def _scanEATrigger(EAlist,before_after,**kwargs): kwargs.setdefault("prefix","EA")# if not None then over rides the auto kwargs.setdefault("debug",False) - scanPV=BL.ioc+"scan"+str(kwargs["scan_dim"]) + scanPV=iex.BL.ioc+"scan"+str(kwargs["scan_dim"]) triggerPV=scanPV+".T"+str(kwargs["detTrig"])+"PV" if kwargs["debug"]: @@ -266,8 +266,8 @@ def _scanEAPrefix(ptype,**kwargs): print(ptype) if ptype == "mda": - fpath = BL.mda.filepath[0:-3]+EA.dtype - nextMDA = BL.mda.fileNum + fpath = iex.BL.mda.filepath[0:-3]+EA.dtype + nextMDA = iex.BL.mda.fileNum prefix = "MDAscan"+str.zfill(str(nextMDA),kwargs["nzeros"]) else: prefix = ptype @@ -310,7 +310,7 @@ def scanEA_reset(**kwargs): kwargs.setdefault("scan_dim",1) _scanEATrigger([],"after",**kwargs) - BL.mda.positioners_clear(kwargs["scan_dim"]) + iex.BL.mda.positioners_clear(kwargs["scan_dim"]) def scanEA(EAlist,**kwargs): """ @@ -331,7 +331,7 @@ def scanEA(EAlist,**kwargs): """ - kwargs.setdefault('scanIOC',BL.ioc()) + kwargs.setdefault('scanIOC',iex.BL.ioc()) kwargs.setdefault('scan_dim',1) kwargs.setdefault('execute',True) kwargs.setdefault("debug",False) @@ -354,7 +354,7 @@ def scanEA(EAlist,**kwargs): pvCalcOut1=_BE2KE_setupCalc(EAlist[1],"BE_center",10,"29idcScienta:HV:fixedEnergy.VAL") EAlist[1]=caget(pvCalcOut1+'.VAL') arrayP1=list(np.full(sweeps, EAlist[1])) - BL.mda.fillin_table(pvCalcOut1+'.PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP1,1) + iex.BL.mda.fillin_table(pvCalcOut1+'.PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP1,1) EAlist[1]=arrayP1[0] if kwargs['debug']: print('\npvCalcOut1: ',pvCalcOut1) @@ -363,7 +363,7 @@ def scanEA(EAlist,**kwargs): pvCalcOut1=_BE2KE_setupCalc(EAlist[1],"BE_center",10,"29idcScienta:HV:babySweepCenter.VAL") EAlist[1]=caget(pvCalcOut1+'.VAL') arrayP1=list(np.full(sweeps, EAlist[1])) - BL.mda.fillin_table(pvCalcOut1+'PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP1,1) + iex.BL.mda.fillin_table(pvCalcOut1+'PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP1,1) print('\npvCalcOut1: ',pvCalcOut1) print('Pos1 table:',arrayP1) elif len(EAlist)==7: #Sweep @@ -373,8 +373,8 @@ def scanEA(EAlist,**kwargs): EAlist[2]=caget(pvCalcOut2+'.VAL') arrayP1=list(np.full(sweeps, EAlist[1])) arrayP2=list(np.full(sweeps, EAlist[2])) - BL.mda.fillin_table(pvCalcOut1+'.PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP1,1) - BL.mda.fillin_table(pvCalcOut2+'.PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP2,2) + iex.BL.mda.fillin_table(pvCalcOut1+'.PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP1,1) + iex.BL.mda.fillin_table(pvCalcOut2+'.PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP2,2) if kwargs['debug']: print("\npvCalcOut1",pvCalcOut1) print("\npvCalcOut2",pvCalcOut2) @@ -394,10 +394,10 @@ def scanEA(EAlist,**kwargs): if kwargs['debug']: print("Clearing scan positioners and filling in sweeps") #Fill in Sweeps scan - BL.mda.positioners_clear(**kwargs) + iex.BL.mda.positioners_clear(**kwargs) VAL="" RBV="" - BL.mda.fillin(VAL,RBV,1,sweeps,1,**kwargs) + iex.BL.mda.fillin(VAL,RBV,1,sweeps,1,**kwargs) if kwargs['debug']: scanPV="29id"+kwargs["scanIOC"]+":scan"+str(kwargs["scan_dim"]) print("scanPV: "+scanPV) @@ -420,11 +420,11 @@ def scanEA(EAlist,**kwargs): time.sleep(10) EA.put(EAlist[1]-.05,EAlist[-3],LensMode="Angular") time.sleep(2) - BL.mda.go(**kwargs) + iex.BL.mda.go(**kwargs) #After scan EA_log_update() scanEA_reset(**kwargs) - BL.mda.table_reset_after(**kwargs) + iex.BL.mda.table_reset_after(**kwargs) else: return EAparms @@ -451,10 +451,10 @@ def scanFM(RoughPositions,thList,EAlist,**kwargs): if kwargs['debug']: print(x,y,z,th,chi,phi) - BL.mda.fillin_table(EA.Motors._motor_dictionary("th")[1],EA.Motors._motor_dictionary("th")[0],th,positioner_num=1) - BL.mda.fillin_table(EA.Motors._motor_dictionary("x")[1],EA.Motors._motor_dictionary("x")[0],x,positioner_num=2) - BL.mda.fillin_table(EA.Motors._motor_dictionary("y")[1],EA.Motors._motor_dictionary("y")[0],y,positioner_num=3) - BL.mda.fillin_table(EA.Motors._motor_dictionary("z")[1],EA.Motors._motor_dictionary("z")[0],z,positioner_num=4) + iex.BL.mda.fillin_table(EA.Motors._motor_dictionary("th")[1],EA.Motors._motor_dictionary("th")[0],th,positioner_num=1) + iex.BL.mda.fillin_table(EA.Motors._motor_dictionary("x")[1],EA.Motors._motor_dictionary("x")[0],x,positioner_num=2) + iex.BL.mda.fillin_table(EA.Motors._motor_dictionary("y")[1],EA.Motors._motor_dictionary("y")[0],y,positioner_num=3) + iex.BL.mda.fillin_table(EA.Motors._motor_dictionary("z")[1],EA.Motors._motor_dictionary("z")[0],z,positioner_num=4) #setting up EA EAkwargs={ @@ -467,7 +467,7 @@ def scanFM(RoughPositions,thList,EAlist,**kwargs): if kwargs["execute"]==True: print(EAparms) EA.put(EAparms['KineticEnergy'],EAparms['PassEnergy'],LensMode="Angular",Frames=EAparms['Frames'],**kwargs) - BL.mda.go(**kwargs) + iex.BL.mda.go(**kwargs) EA_log_update() scanEA_reset(**kwargs) @@ -580,10 +580,10 @@ def scanEA_hv(hv_start_stop_step_lists,EAlist=[],**kwargs): energy(mono_array[0]) #Scanning EA.put(mono_array[0]-EAlist[1],EAparms['PassEnergy'],LensMode="Angular",Frames=EAparms['Frames'],**kwargs) - BL.mda.go(**kwargs) + iex.BL.mda.go(**kwargs) #After scan scanEA_reset(**kwargs) - BL.mda.table_reset_after(**kwargs) + iex.BL.mda.table_reset_after(**kwargs) def scanEA_y(EAlist, start,stop,step,mode='absolute',**kwargs): scanEA_motor(EAlist,'y',start,stop,step,mode=mode,**kwargs) @@ -631,7 +631,7 @@ def scanEA_motor(EAlist, motor,start,stop,step,mode='absolute',**kwargs): if kwargs["execute"]==True: #Scanning EA.put(EAlist[1],EAparms['PassEnergy'],LensMode="Angular",Frames=EAparms['Frames'],**kwargs) - BL.mda.go(kwargs["scanIOC"],scan_dim) + iex.BL.mda.go(kwargs["scanIOC"],scan_dim) EA_log_update() #After scan scanEA_reset(**kwargs) @@ -678,7 +678,7 @@ def scanEA_Mesh(EAlist,y_start_stop_step,z_start_stop_step,**kwargs): if kwargs['execute']: #Scanning EA.put(EAlist[1],EAparms['PassEnergy'],LensMode="Angular",Frames=EAparms['Frames'],**kwargs) - BL.mda.go(scan_dim=outer_scan_dim) + iex.BL.mda.go(scan_dim=outer_scan_dim) EA_log_update() #After scan diff --git a/iexcode/instruments/staff.py b/iexcode/instruments/staff.py index ba5648b20ddbb97055a2626f03afbdec84e006b3..e7c1fbb0ce991326c18f00b58944145a80fbe75f 100644 --- a/iexcode/instruments/staff.py +++ b/iexcode/instruments/staff.py @@ -36,7 +36,7 @@ def folders_startup(run): ############################################################################################################## -def staff_detector_dictionary(xrays=True): +def staff_detector_dictionary(): """ returns a dictionary of the default detectors