diff --git a/build/lib/iexcode/instruments/AD_utilities.py b/build/lib/iexcode/instruments/AD_utilities.py index f8d43d23aed84bf5a1ee86d46cefdbb81f5d1ffa..15dd0a09b5a21539352d7827c64cb70c5359e4b7 100644 --- a/build/lib/iexcode/instruments/AD_utilities.py +++ b/build/lib/iexcode/instruments/AD_utilities.py @@ -13,7 +13,7 @@ from os.path import join, isfile, exists, dirname from time import sleep from epics import caget, caput -from iexcode.instruments.IEX_endstations import * +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 90f825f9fa07a93d36c82263dbf7404f0ea79efd..a2337c0b13b2a5f7dab34c46b4e977b5949c31b9 100644 --- a/build/lib/iexcode/instruments/ARPES.py +++ b/build/lib/iexcode/instruments/ARPES.py @@ -3,7 +3,7 @@ from time import sleep from epics import caget,caput,PV -from iexcode.instruments.IEX_endstations import * +from iexcode.instruments.IEX_endstations import Endstation from iexcode.instruments.staff import staff_detector_dictionary from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda @@ -12,11 +12,12 @@ from iexcode.instruments.logfile import logfile_name_set,logfile_header from iexcode.instruments.conversions_constants import * from iexcode.instruments.utilities import * + from iexcode.instruments.userCalcs import userStringSeq_clear, userStringSeq_pvs +from iexcode.instruments.scanRecord import ScanRecord +from iexcode.instruments.xrays import xrays_detector_dictionary,xrays_reset,xrays_get_all -from iexcode.instruments.scanRecord import * -from iexcode.instruments.Motors import * -from iexcode.instruments.xrays import * +from iexcode.instruments.Motors import Motors from iexcode.instruments.current_amplifiers import * from iexcode.instruments.gate_valves import valve_close, branch_valves from iexcode.instruments.shutters import branch_shutter_close @@ -47,7 +48,8 @@ def ARPES_init(set_folders=True,reset=True,**kwargs): #endstation global BL - BL=Endstation('ARPES',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],mda_scanRecord) + BL=Endstation('ARPES',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],mda_scanRecord, + ARPES_log_header,ARPES_log_entries,ARPES_motor_dictionary) #EA try: diff --git a/build/lib/iexcode/instruments/FMB_mirrors.py b/build/lib/iexcode/instruments/FMB_mirrors.py index 888d9b9425b99a75ac9d39dcac6447fafe0680f7..083b9e69e3a6cb39a8a2cca14b7a7d363f458827 100644 --- a/build/lib/iexcode/instruments/FMB_mirrors.py +++ b/build/lib/iexcode/instruments/FMB_mirrors.py @@ -4,7 +4,6 @@ from epics import caget, caput from iexcode.instruments.IEX_endstations import * from iexcode.instruments.utilities import read_dict, print_warning_message -from iexcode.instruments.m3r import m3r_branch M0M1_fpath="/home/beams22/29IDUSER/Documents/User_Macros/Macros_29id/IEX_Dictionaries/Dict_IDCal.txt" @@ -57,9 +56,6 @@ def FMB_mirror_get(mirror_num,verbose=True): message =+ "%.3f"+"/" % rbv if verbose: print(message) - if mirror_num == 3: - mirror_branch = m3r_branch() - print(" => In "+mirror_branch+" branch") return vals def FMB_mirror_move(mirror_num,axis,val,verbose=True): diff --git a/build/lib/iexcode/instruments/IEX_endstations.py b/build/lib/iexcode/instruments/IEX_endstations.py index 94ee6e1eb9ce4b609d49ca490ac53f24acb5cf32..6bff704cb6f1fa23ec62f65de48f217b27117852 100644 --- a/build/lib/iexcode/instruments/IEX_endstations.py +++ b/build/lib/iexcode/instruments/IEX_endstations.py @@ -26,7 +26,7 @@ class Endstation: """ - def __init__(self,endstation_name,scan_ioc,xrays,BL_mode,mda_scanRecord): + def __init__(self,endstation_name,scan_ioc,xrays,BL_mode,mda_scanRecord,log_header,log_entries,Motors): """ intializes the several beamline variables @@ -40,13 +40,16 @@ class Endstation: BL.prefix => 'ARPES_','Kappa_' BL.ioc => previously: BL_ioc() BL.mda_filepath + BL.log_header => dictionary with header list + BL.log_entries => method to get pvs to be written to log file + BL.Motors => motor calls """ global BL endstations_list = ['ARPES','Kappa'] BL_mode_list = ['user','staff'] - if self.endstation_name in endstations_list: + if endstation_name in endstations_list: self.endstation=endstation_name else: print('Not a valid Endstation choice') @@ -74,6 +77,9 @@ class Endstation: self.xrays = xrays self.ioc = scan_ioc self.mda = mda_scanRecord + self.log_header = log_header + self.log_entries = log_entries + self.Motors = Motors def set_logfile_path(): @@ -107,25 +113,3 @@ def BL_mda_filepath(): returns the mda file prefix """ return BL.filepath - -def scalar_cts(self,integration_time=0.1,verbose=True,**kwargs): - """ - Sets the integration time for the scalers - kwargs: - mcp = True/False to sum mpa - Previously: cts, Kappa counts - """ - - if BL.endstation == 'ARPES': - pass - elif BL.endstation == 'Kappa': - Kappa_scalar_pv = "29idMZ0:scaler1.TP" - mpa_Proc1_pv = "29iddMPA:Proc1:" - - caput(Kappa_scalar_pv,integration_time) - - if kwargs["mpa"]: - caput(mpa_Proc1_pv+'NumFilter',floor(time)) - - if verbose: - print("Integration time set to:", str(time)) \ No newline at end of file diff --git a/build/lib/iexcode/instruments/Kappa.py b/build/lib/iexcode/instruments/Kappa.py index 18c98109e657face5c89a1a35b50e2ae272c9966..c64636c239688b6fa69e8863d1e9d55225e1ff95 100644 --- a/build/lib/iexcode/instruments/Kappa.py +++ b/build/lib/iexcode/instruments/Kappa.py @@ -13,17 +13,20 @@ from iexcode.instruments.logfile import logfile_name_set,logfile_header from iexcode.instruments.conversions_constants import * from iexcode.instruments.utilities import * -from iexcode.instruments.userCalcs import userStringSeq_clear, userStringSeq_pvs -from iexcode.instruments.scanRecord import * -from iexcode.instruments.Motors import * -from iexcode.instruments.xrays import * -from iexcode.instruments.current_amplifiers import * +from iexcode.instruments.userCalcs import userStringSeq_clear, userStringSeq_pvs, userCalcOut_clear +from iexcode.instruments.scanRecord import ScanRecord +#from iexcode.instruments.xrays import xrays_reset,xrays_get_all + +from iexcode.instruments.Motors import Motors +from iexcode.instruments.current_amplifiers import SRS, ca_reset_all, Keithley_pv from iexcode.instruments.gate_valves import valve_close, branch_valves from iexcode.instruments.shutters import branch_shutter_close from iexcode.instruments.slits import slit3D_get -from iexcode.instruments.Kappa_det import * +from iexcode.instruments.Kappa_det import Kappa_Detector +from iexcode.instruments.scalers import scaler_cts +from iexcode.instruments.MPA import MPA from iexcode.instruments.spec_stuff import folders_spec @@ -53,15 +56,17 @@ def Kappa_init(set_folders=False,reset=False,**kwargs): #endstation global BL - BL=Endstation('Kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],mda_scanRecord) + BL=Endstation('Kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],mda_scanRecord,Kappa_log_header,Kappa_log_entries) #global detectors - global tey, d3, d4, mesh, Kappa_scaler_pv + global tey, d3, d4, mesh, Kappa_scaler_pv, mpa tey = SRS("29idMZ0:scaler1.S2", '29idd:A1') d3 = SRS("29idMZ0:scaler1.S3", '29idd:A2') d4 = SRS("29idMZ0:scaler1.S4", '29idd:A3') mesh = SRS("29idMZ0:scaler1.S14", '29idd:A4') Kappa_scaler_pv = '29idMZ0:scaler1.CNT' + tth_pv = Kappa_motor_dictionary('tth')[3] + mpa = MPA(tth_pv) global tthdet tthdet = Kappa_Detector() @@ -133,7 +138,7 @@ def Kappa_detector_dictionary(**kwargs): 38:"29idMZ0:scaler1_calc1.D", 39:"29idMZ0:scaler1_calc1.E", } - mpa={ + mpa_dets={ 30:"29iddMPA:det1:TotalRate_RBV", 41:"29iddMPA:Stats1:Total_RBV", 42:"29iddMPA:Stats2:Total_RBV", @@ -158,7 +163,7 @@ def Kappa_detector_dictionary(**kwargs): #hkl are listed just a place holders, they are filled in by thier scanning functions det_dict.update(sample_temp) det_dict.update(scalers) - det_dict.update(mpa) + det_dict.update(mpa_dets) det_dict.update(motors) if kwargs['add_vortex']: det_dict.update(vortex) @@ -278,7 +283,7 @@ def Kappa_reset(): #resetting mono and anyother beamline stuff if BL.xrays: - xrays_reset() + JLM="xrays_reset()" #reseting the Kappa Lakeshore @@ -291,7 +296,7 @@ def Kappa_reminder_list(ioc): """ resets scanRecord, current amplifiers, mono limits and synchs motors """ - mda.reset() + BL.mda.reset() if BL.xray: ca_reset_all() @@ -320,8 +325,8 @@ def Kappa_get_all(verbose=True): #beamline info if BL.xray: - beamline_info = xrays_get_all() - vals.update(beamline_info) + JLM="beamline_info = xrays_get_all()" + #vals.update(beamline_info) mesh.get() vals.update({'mesh':mesh.current}) @@ -364,7 +369,7 @@ def Kappa_log_entries(): tey_current = tey.current mesh_current = mesh.current det_name = tthdet.name - mpa_HV = mpa_HV_get() + mpa_HV = mpa.HV_get() m3r_centroid = vals['kphi'] entry_list = ["x","y","z","tth","kth","kap","kphi","TA","TB","TEY","mesh","det_name","mpa_HV","m3r_centroid"] @@ -648,26 +653,26 @@ def Kappa_th2th_scan_sensitivity(th_table,gain_num_table,gain_unit_table,detecto tth_table = 2*th_table kwargs.update("positioner_num",1) - mda.fillin_table(kth_val,kth_rbv,kth_table,**kwargs) + BL.mda.fillin_table(kth_val,kth_rbv,kth_table,**kwargs) kwargs.update("positioner_num",2) - mda.fillin_table(tth_val,tth_rbv,tth_table,**kwargs) + BL.mda.fillin_table(tth_val,tth_rbv,tth_table,**kwargs) kwargs.update("positioner_num",3) - mda.fillin_table(gain_num_pv,"",gain_num_table,**kwargs) + BL.mda.fillin_table(gain_num_pv,"",gain_num_table,**kwargs) kwargs.update("positioner_num",4) - mda.fillin_table(gain_unit_pv,"",gain_unit_table,**kwargs) + 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']: - mda.go(**kwargs) + BL.mda.go(**kwargs) #clean up after scan - mda.table_reset_after(**kwargs) + BL.mda.table_reset_after(**kwargs) scaler_cts(verbose=False) def Kappa_scan_th2th(tth_start,tth_stop,tth_step,th_offset,**kwargs): @@ -830,7 +835,7 @@ def KappaPreset_StrSeq(n,User): scanIOC="Kappa" motorIOC="29idKappa:" motor = ["m2","m3","m4","m9","m8","m7","m1"] - strSeq_pv = userStringSeq_clear(mda,n) + strSeq_pv = userStringSeq_clear(BL.mda,n) if User[0] == "Kappa Grazing": phi0= 0 if User[0] == "Kappa Transfer": phi0= 57 @@ -856,7 +861,7 @@ def KappaPreset_StrSeq(n,User): def Bragg_Angle_CalcOut(d,eV,l): n=7 - userCalcOut_pv = userCalcOut_clear(mda,n) + userCalcOut_pv = userCalcOut_clear(BL.mda,n) h=4.135667516e-15 c=299792458 @@ -906,9 +911,9 @@ def Kappa_safe_state(**kwargs): kwargs.setdefault("shutter_close",True) kwargs.setdefault("valve_close",True) - if kwargs["EA_off"]: + if kwargs["mpa_off"]: try: - mpa_HV_off() + mpa.HV_off() except: print('MPA is not running') diff --git a/build/lib/iexcode/instruments/Kappa_Euler.py b/build/lib/iexcode/instruments/Kappa_Euler.py index 42dfe2f1bac9ec223a1c6a78a4d20ab9f32720bf..ea025902dca59755f2a9ad60df51847449ad48f4 100644 --- a/build/lib/iexcode/instruments/Kappa_Euler.py +++ b/build/lib/iexcode/instruments/Kappa_Euler.py @@ -2,7 +2,7 @@ import numpy as np from epics import caget, caput from iexcode.instruments.userCalcs import userCalcOut_clear -from iexcode.instruments.IEX_endstations import mda +from iexcode.instruments.IEX_endstations import * from iexcode.instruments.userCalcs import userCalcOut_clear #### Obsolete? diff --git a/build/lib/iexcode/instruments/Kappa_det.py b/build/lib/iexcode/instruments/Kappa_det.py index 9a1a19071153d757e6dd4897cf40339b8fd4a73f..c00102003a67795f719a521a8255f94ef567ca85 100644 --- a/build/lib/iexcode/instruments/Kappa_det.py +++ b/build/lib/iexcode/instruments/Kappa_det.py @@ -1,7 +1,7 @@ from time import sleep from epics import caget, caput -from iexcode.instruments.IEX_endstations import Motors +from iexcode.instruments.Kappa import Kappa_Motors ############################################################################################################## @@ -27,7 +27,7 @@ class Kappa_Detector: #det_name = caget('29idKappa:userStringSeq6.STR1') det_name = caget(det_set_pv) self.name = det_name - tth_val = Motors.get('tth') + tth_val = Kappa_Motors.get('tth') return self.name, tth_val def set(self,det_name,move=True): @@ -43,13 +43,13 @@ class Kappa_Detector: yag: yag 'fluorescence screen' """ #get current value for tth - tth_val = Motors.get('tth') + tth_val = Kappa_Motors.get('tth') #change det if det_name in det_list: caput(det_set_pv,det_name) if move: - Motors.move('tth',tth_val,wait=True,verbose=False) + Kappa_Motors.move('tth',tth_val,wait=True,verbose=False) def tth0_set(move): """ @@ -58,7 +58,7 @@ class Kappa_Detector: only works with d4 """ current_det=caget(det_set_pv,as_string=True) - tth_pv = Motors._motor_dictionary['th'][3] + tth_pv = Kappa_Motors._motor_dictionary['th'][3] if current_det != 'd4': print('tth0 can only be redefined with d4') diff --git a/build/lib/iexcode/instruments/Motors.py b/build/lib/iexcode/instruments/Motors.py index 119b51bb725c0a065f3f6eb245b342d17eb3dad4..8b8f7adda9a34b73e43e1d71b4ea68c42002714f 100644 --- a/build/lib/iexcode/instruments/Motors.py +++ b/build/lib/iexcode/instruments/Motors.py @@ -3,7 +3,8 @@ from math import floor from epics import caget, caput -from iexcode.instruments.IEX_endstations import * +from iexcode.instruments.IEX_endstations import BL +from iexcode.instruments.scalers import scaler_cts class Motors: @@ -220,7 +221,7 @@ class Motors: outer_loop_list[2]=round(current_value1+outer_loop_list[2],3) outer_loop_list[3]=round(current_value1+outer_loop_list[3],3) - scalar_cts(kwargs['cts'],verbose=True,**kwargs) + scaler_cts(kwargs['cts'],verbose=True,**kwargs) BL.mda.fillin_2D(inner_loop_list,outer_loop_list, outer_scan_dim=kwargs['outer_scan_dim'],**kwargs) diff --git a/build/lib/iexcode/instruments/beamline.py b/build/lib/iexcode/instruments/beamline.py index 6817162fdad3533041139170c96a0fa810e51958..2071446d285365d1ff71eff8c3476f82af8d677b 100644 --- a/build/lib/iexcode/instruments/beamline.py +++ b/build/lib/iexcode/instruments/beamline.py @@ -53,25 +53,13 @@ def last_mda(): ############################################################################################################## - -def print_beeper(scanDIM=1): - """ - Prints pv to copy/paste into the beeper - - Previously: Print_Beeper - """ - branch=BL.branch - if branch == "c": - print("29idcEA:det1:Acquire") - pv=BL.ioc()+":scan"+str(scanDIM)+".FAZE" - print(pv) - print("ID29:BusyRecord") - - -def branch_cams_enable(branch=BL.branch): +def endstation_cams_enable(): """ + should live in cameras """ - cam_dict={'c':[0,1,2],'c':[3,4,6]} # index of cam_list + endstation=BL.endstation + + cam_dict={'ARPES':[0,1,2],'Kappa':[3,4,6]} # index of cam_list pvcam1=PV("29id_ps1:cam1:Acquire") pvcam2=PV("29id_ps2:cam1:Acquire") pvcam3=PV("29id_ps3:cam1:Acquire") @@ -85,7 +73,7 @@ def branch_cams_enable(branch=BL.branch): if pvcam.connected: pvcam.put(0) except: pass - for i in cam_dict[branch]: # turn ON relevant cam + for i in cam_dict[endstation]: # turn ON relevant cam try: if cam_list[i].connected: cam_list[i].put(1) else: print(cam_list[i].pvname+' not connected') diff --git a/build/lib/iexcode/instruments/electron_analyzer.py b/build/lib/iexcode/instruments/electron_analyzer.py index 8cfbb778c92dd9ce36f68ab6a062d44c5b9814af..119d7586295ed0fb92d964439e10c8b06693ebf3 100644 --- a/build/lib/iexcode/instruments/electron_analyzer.py +++ b/build/lib/iexcode/instruments/electron_analyzer.py @@ -22,14 +22,12 @@ 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.ARPES import ARPES_motor_dictionary, ARPES_motor_scan, ARPES_mvsample,ARPES_scan_2D +from iexcode.instruments.ARPES import ARPES_Motors from iexcode.instruments.Scienta import * -def __main__(): - global EA - EA = Scienta() - -mda = BL.mda +global EA +EA = Scienta() + ########################################################################### def EA_ioc_init(**kwargs): @@ -260,8 +258,8 @@ def _scanEAPrefix(ptype,**kwargs): print(ptype) if ptype == "mda": - fpath = mda.filepath[0:-3]+EA.dtype - nextMDA = mda.fileNum + fpath = BL.mda.filepath[0:-3]+EA.dtype + nextMDA = BL.mda.fileNum prefix = "MDAscan"+str.zfill(str(nextMDA),kwargs["nzeros"]) else: prefix = ptype @@ -304,7 +302,7 @@ def scanEA_reset(**kwargs): kwargs.setdefault("scan_dim",1) _scanEATrigger([],"after",**kwargs) - mda.positioners_clear(kwargs["scan_dim"]) + BL.mda.positioners_clear(kwargs["scan_dim"]) def scanEA(EAlist,**kwargs): """ @@ -348,7 +346,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])) - mda.fillin_table(pvCalcOut1+'.PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP1,1) + BL.mda.fillin_table(pvCalcOut1+'.PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP1,1) EAlist[1]=arrayP1[0] if kwargs['debug']: print('\npvCalcOut1: ',pvCalcOut1) @@ -357,7 +355,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])) - mda.fillin_table(pvCalcOut1+'PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP1,1) + 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 @@ -367,8 +365,8 @@ def scanEA(EAlist,**kwargs): EAlist[2]=caget(pvCalcOut2+'.VAL') arrayP1=list(np.full(sweeps, EAlist[1])) arrayP2=list(np.full(sweeps, EAlist[2])) - mda.fillin_table(pvCalcOut1+'.PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP1,1) - mda.fillin_table(pvCalcOut2+'.PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP2,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) if kwargs['debug']: print("\npvCalcOut1",pvCalcOut1) print("\npvCalcOut2",pvCalcOut2) @@ -388,10 +386,10 @@ def scanEA(EAlist,**kwargs): if kwargs['debug']: print("Clearing scan positioners and filling in sweeps") #Fill in Sweeps scan - mda.positioners_clear(**kwargs) + BL.mda.positioners_clear(**kwargs) VAL="" RBV="" - mda.fillin(VAL,RBV,1,sweeps,1,**kwargs) + BL.mda.fillin(VAL,RBV,1,sweeps,1,**kwargs) if kwargs['debug']: scanPV="29id"+kwargs["scanIOC"]+":scan"+str(kwargs["scan_dim"]) print("scanPV: "+scanPV) @@ -414,11 +412,11 @@ def scanEA(EAlist,**kwargs): time.sleep(10) EA.put(EAlist[1]-.05,EAlist[-3],LensMode="Angular") time.sleep(2) - mda.go(**kwargs) + BL.mda.go(**kwargs) #After scan EA_log_update() scanEA_reset(**kwargs) - mda.table_reset_after(**kwargs) + BL.mda.table_reset_after(**kwargs) else: return EAparms @@ -445,10 +443,10 @@ def scanFM(RoughPositions,thList,EAlist,**kwargs): if kwargs['debug']: print(x,y,z,th,chi,phi) - mda.fillin_table(ARPES_motor_dictionary("th")[1],ARPES_motor_dictionary("th")[0],th,positioner_num=1) - mda.fillin_table(ARPES_motor_dictionary("x")[1],ARPES_motor_dictionary("x")[0],x,positioner_num=2) - mda.fillin_table(ARPES_motor_dictionary("y")[1],ARPES_motor_dictionary("y")[0],y,positioner_num=3) - mda.fillin_table(ARPES_motor_dictionary("z")[1],ARPES_motor_dictionary("z")[0],z,positioner_num=4) + BL.mda.fillin_table(ARPES_Motors._motor_dictionary("th")[1],ARPES_Motors._motor_dictionary("th")[0],th,positioner_num=1) + BL.mda.fillin_table(ARPES_Motors._motor_dictionary("x")[1],ARPES_Motors._motor_dictionary("x")[0],x,positioner_num=2) + BL.mda.fillin_table(ARPES_Motors._motor_dictionary("y")[1],ARPES_Motors._motor_dictionary("y")[0],y,positioner_num=3) + BL.mda.fillin_table(ARPES_Motors._motor_dictionary("z")[1],ARPES_Motors._motor_dictionary("z")[0],z,positioner_num=4) #setting up EA EAkwargs={ @@ -461,7 +459,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) - mda.go(**kwargs) + BL.mda.go(**kwargs) EA_log_update() scanEA_reset(**kwargs) @@ -520,7 +518,7 @@ def mvth_interp(RoughPositions, thVal,**kwargs): x,y,z,th,chi,phi=interpRoughPositions(RoughPositions,thVal,thVal-.1,1,**kwargs) Pos=[x[0],y[0],z[0],th[0],chi[0],phi[0]] #print("Pos = ",Pos) - ARPES_mvsample(Pos) + ARPES_Motors.mvsample(Pos) def scanEA_hv(hv_start_stop_step_lists,EAlist=[],**kwargs): """ @@ -574,10 +572,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) - mda.go(**kwargs) + BL.mda.go(**kwargs) #After scan scanEA_reset(**kwargs) - mda.table_reset_after(**kwargs) + 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) @@ -617,7 +615,7 @@ def scanEA_motor(EAlist, motor,start,stop,step,mode='absolute',**kwargs): scan_dim=2 #hard coded kwargs.update({'scan_dim':scan_dim}) - ARPES_motor_scan(motor,start,stop,step,**kwargs) + ARPES_Motors.scan(motor,start,stop,step,**kwargs) if kwargs['debug']: print("ScanGo scan_dim = ",scan_dim) @@ -664,7 +662,7 @@ def scanEA_Mesh(EAlist,y_start_stop_step,z_start_stop_step,**kwargs): outer_scan_dim=3 #hard coded inner_loop_list = y_start_stop_step.insert(0,"y") outer_loop_list = z_start_stop_step.insert(0,"z") - ARPES_scan_2D(inner_loop_list,outer_loop_list,outer_scan_dim,**kwargs) + ARPES_Motors.scan_2D(inner_loop_list,outer_loop_list,outer_scan_dim,**kwargs) if kwargs['debug']: print("ScanGo scan_dim = ",outer_scan_dim) @@ -672,7 +670,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) - mda.go(scan_dim=outer_scan_dim) + BL.mda.go(scan_dim=outer_scan_dim) EA_log_update() #After scan diff --git a/build/lib/iexcode/instruments/logfile.py b/build/lib/iexcode/instruments/logfile.py index dec2ce2547f2096f5ebeda2597e496a1723b44d4..cde224d887f9755152f7aefd9450a53fb81f19ac 100644 --- a/build/lib/iexcode/instruments/logfile.py +++ b/build/lib/iexcode/instruments/logfile.py @@ -3,8 +3,6 @@ from os.path import join,isfile from epics import caget, caput from iexcode.instruments.IEX_endstations import * from iexcode.instruments.utilities import today -from iexcode.instruments.ARPES import ARPES_log_entries -from iexcode.instruments.Kappa import Kappa_log_entries ############################################################################################################## @@ -20,10 +18,8 @@ def log_update(): """ updates the log file with the last scan info """ - if BL.endstation_name == 'ARPES': - entry_list,pv_list, format_list = ARPES_log_entries() - elif BL.endstation_name == 'Kappa': - entry_list,pv_list, format_list = Kappa_log_entries() + + entry_list,pv_list, format_list = BL.log_entries() logfile_update(BL.endstation_name,BL.ioc,entry_list,pv_list,format_list) diff --git a/build/lib/iexcode/instruments/mpa.py b/build/lib/iexcode/instruments/mpa.py index 6408b462eb1ab840d591207d7a6d0ec37d3794d7..a9477f032666e5bb721717f16a876a85a1b7fd76 100644 --- a/build/lib/iexcode/instruments/mpa.py +++ b/build/lib/iexcode/instruments/mpa.py @@ -4,10 +4,10 @@ import socket from epics import caget, caput from iexcode.instruments.userCalcs import userCalcOut_clear,userStringSeq_clear -from iexcode.instruments.Kappa import Kappa_motor_dictionary,Kappa_cts, mda +from iexcode.instruments.scalers import Kappa_scaler from iexcode.instruments.AD_utilities import AD_ROI_setup -from iexcode.instruments.scalers import scaler_cts -from iexcode.instruments.scanRecord import * +from iexcode.instruments.scanRecord import ScanRecord +from iexcode.instruments.IEX_endstations import BL """ @@ -19,399 +19,409 @@ To do, get busy record in the mpa ioc, get user calcs in the mpa ioc ############################## PVs ############################## ############################################################################################################## mpa_pv = "29iddMPA:" -mpaDet_pv = mpa_pv + "det1:" mpa_busy = "29idcScienta:mybusy2" -userCalc_pv = "29idTest" +userCalc_ioc = "29idTest:" DAC_pv = '29iddau1:dau1:011:DAC' -max_HV = 2990 -ratio = 500 -tth_dLLM=13.73 -tth_dHLM=23.73 - - -def mpa_reset_pv(): - """ - returns the pv used for resetting the mpa - "writing a 1 resets" - """ - return mpa_pv+'C1O' - -def mpa_on_off_pv(): - """ - returns the pv used for turning on/off the mpa - on => caput 1 - off => caput0 - """ - return mpa_pv+'C0O' - -def mpa_HV_pvs(): - """ - returns the pvs for the userCalcout which hold the pvs for the mpa high voltage - """ - val_pv = "29idKappa:userCalcOut9.A" - rbv_pv ="29idKappa:userCalcOut10.OVAL" - return val_pv, rbv_pv - -############################################################################################################## -############################## HV Control ############################## -############################################################################################################## - -def mpa_HV_set(volt,verbose=True): - """ - sets the high voltage for the mpa - - Previously: MPA_HV_Set - """ - val_pv, rbv_pv = mpa_HV_pvs() - volt=min(volt,2990) - - caput(val_pv,volt,wait=True,timeout=18000) - sleep(1) - HV_rbv=caget(rbv_pv) - - if verbose: - print("HV = "+str(HV_rbv)+" V") - - -def mpa_HV_get(): +HV_val_pv = "29idKappa:userCalcOut9.A" +HV_rbv_pv = "29idKappa:userCalcOut10.OVAL" +class MPA: """ - sets the high voltage for the mpa + class for the MPA detector """ - val_pv, rbv_pv = mpa_HV_pvs() - return caget(rbv_pv) + def __init__(self,tth_pv, max_HV = 2990,ratio = 500,tth_dLLM=13.73,tth_dHLM=23.73): + self.pv = mpa_pv + self._reset_pv = mpa_pv+'C1O' + self._det_pv = mpa_pv + "det1:" + self._busy = mpa_busy + self._DAC_pv = DAC_pv + self.max_HV = max_HV + self.ratio = ratio + self.tth_dLLM = tth_dLLM + self.tth_dHLM = tth_dHLM -def mpa_HV_on(): - """ - turns the mpa high voltage on - - Previously: MPA_HV_ON - """ - n_on=1 - tth_pv = Kappa_motor_dictionary('tth')[3] - tth_dial = caget(tth_pv+'.DRBV') - if 13.73<= tth_dial <=23.73: - print('MPA OFF: detector in direct beam (-5 < tth for mcp < 5); move away before turning HV ON.') - else: - caput(mpa_reset_pv,1,wait=True,timeout=18000) - caput(mpa_reset_pv,0,wait=True,timeout=18000) - caput(mpa_on_off_pv,n_on,wait=True,timeout=18000) - print("MPA - HV On") - -def mpa_HV_off(): - """ - turns the mpa high voltage off - - Previously: MPA_HV_OFF - """ - n_off=0 - caput(mpa_on_off_pv,wait=True,timeout=18000) - print("MPA - HV Off") + self._tth_pv = tth_pv + self._reset_pv = mpa_pv+'C1O' #"writing a 1 resets" + self._off_on_pv = mpa_pv+'C0O' #off/on = 0/1 + pass -def mpa_HV_reset(): - """ - resets the mpa high voltage - - Previously: MPA_HV_Reset - """ - caput(mpa_reset_pv,1) - print("MPA - Reset") - -def mpa_HV_scan(start=2400,stop=2990,step=10,**kwargs): - """ - Previously: MPA_HV_scan - """ - kwargs.setdefault('positioner_settling_time',1) - Kappa_cts(1) - val_pv, rbv_pv = mpa_HV_pvs() - mda.fillin(val_pv, rbv_pv,start,stop,step,**kwargs) - mda.go(**kwargs) - -############################################################################################################## -############################## MCP Scripts ############################## -############################################################################################################## -def mpa_ROI_setup(ROI_num=1,xcenter=535,ycenter=539,xsize=50,ysize=50,binX=1,binY=1): - """ - usage: - center of MCP, roiNum = 1 => MPA_ROI_SetUp(1,535,539,50,50) - to set up all use: mpa_ROI_setup_all(xcenter,ycenter) - """ - AD_ROI_setup('29iddMPA',ROI_num,xcenter,ycenter,xsize,ysize,binX,binY) - ROI_pv = mpa_pv+"ROI"+str(ROI_num)+':' - mpa_ROI_stats(ROI_num) + def HV_pvs(self): + """ + returns the pvs for the userCalcout which hold the pvs for the mpa high voltage + """ + val_pv = HV_val_pv + rbv_pv =HV_rbv_pv + return val_pv, rbv_pv + + ############################################################################################################## + ############################## HV Control ############################## + ############################################################################################################## + + def HV_set(self,volt,verbose=True): + """ + sets the high voltage for the mpa + + Previously: MPA_HV_Set + """ + val_pv, rbv_pv = self.HV_pvs() + volt=min(volt,2990) + + caput(val_pv,volt,wait=True,timeout=18000) + sleep(1) + HV_rbv=caget(rbv_pv) + + if verbose: + print("HV = "+str(HV_rbv)+" V") + + + def HV_get(self): + """ + sets the high voltage for the mpa + """ + val_pv, rbv_pv = self.HV_pvs() + + return caget(rbv_pv) + + + def HV_on(self): + """ + turns the mpa high voltage on + + Previously: MPA_HV_ON + """ + try: + n_on=1 + tth_dial = caget(self._tth_pv+'.DRBV') + + if self.tth_dLLM <= tth_dial <= self.tth_dHLM: + print('MPA OFF: detector in direct beam (-5 < tth for mcp < 5); move away before turning HV ON.') + else: + caput(self._reset_pv,1,wait=True,timeout=18000) + caput(self._reset_pv,0,wait=True,timeout=18000) + caput(self._off_on_pv,n_on,wait=True,timeout=18000) + print("MPA - HV On") + except: + print('mpa not running') + + def HV_off(self): + """ + turns the mpa high voltage off + + Previously: MPA_HV_OFF + """ + try: + n_off=0 + caput(self._off_on_pv,n_off,wait=True,timeout=18000) + print("MPA - HV Off") + except: + print('MPA not running') + + + def HV_reset(self): + """ + resets the mpa high voltage + + Previously: MPA_HV_Reset + """ + caput(self._reset_pv,1) + print("MPA - Reset") -def mpa_ROI_setup_all(xcenter=535,ycenter=539): - """ - setup up ROI - 1 => size = 50 x 50 - 2 => size = 100 x 100 - 3 => size = 150 x 150 - 4 => size = 200 x 200 - - """ - mpa_ROI_setup(1,xcenter,ycenter,xsize=50,ysize=50) - mpa_ROI_setup(2,xcenter,ycenter,xsize=100,ysize=100) - mpa_ROI_setup(3,xcenter,ycenter,xsize=150,ysize=150) - mpa_ROI_setup(4,xcenter,ycenter,xsize=200,ysize=200) + def HV_scan(self,start=2400,stop=2990,step=10,**kwargs): + """ + + Previously: MPA_HV_scan + """ + 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) + + ############################################################################################################## + ############################## MCP Scripts ############################## + ############################################################################################################## + def ROI_setup(self,ROI_num=1,xcenter=535,ycenter=539,xsize=50,ysize=50,binX=1,binY=1): + """ + usage: + center of MCP, roiNum = 1 => MPA_ROI_SetUp(1,535,539,50,50) + to set up all use: mpa_ROI_setup_all(xcenter,ycenter) + """ + AD_ROI_setup('29iddMPA',ROI_num,xcenter,ycenter,xsize,ysize,binX,binY) + self._ROI_stats(ROI_num) -def mpa_ROI_stats(ROI_num): - """ - sequence to enable stats for mpa ROI - """ - ROI_pv=mpa_pv+"ROI"+str(ROI_num)+':' - stats_pv=mpa_pv+"Stats"+str(ROI_num)+':' - caput(stats_pv+'NDArrayPort','ROI'+str(ROI_num)) - caput(stats_pv+'EnableCallbacks','Enable') - caput(stats_pv+'ArrayCallbacks','Enable') - caput(stats_pv+'ComputeStatistics','Yes') - caput(stats_pv+'ComputeCentroid','Yes') - caput(stats_pv+'ComputeProfiles','Yes') - -def _mpa_trigger_calcOut(**kwargs): - """ - writes strSeq and calcOut for MPA this should go into the IOC - - **kwargs: - ADplugin = 'TIFF1:' (default) - """ - - kwargs.setdefault("ADplugin","TIFF1:") - kwargs.setdefault("save_image",False) - - ADplugin = mpa_pv + kwargs["ADplugin"] - Proc1 = mpa_pv + "Proc1:" - - #All this should moved into the MPA IOC - Calcs_mda = ScanRecord("29idTest:") - - desc = "MPA busy" - n=9 - busy_CalcOut = userCalcOut_clear(Calcs_mda,n) - caput(busy_CalcOut+".DESC",desc) - caput(busy_CalcOut+".INPA",mpa_busy+" CP") - caput(busy_CalcOut+".OOPT",'Transition to non-zero') - caput(busy_CalcOut+".OUT",start_strSeq+".PROC PP") - - desc = "MPA start" - n=1 - start_strSeq = userStringSeq_clear(Calcs_mda,n) - caput(start_strSeq+".DESC",desc) - caput(start_strSeq+".LNK1", Proc1+"ResetFilter PP") - caput(start_strSeq+".STR1","Yes") - - desc = "MPA wait" - n=10 - wait_CalcOut = userCalcOut_clear(Calcs_mda,n) - caput(wait_CalcOut+".DESC",desc) - caput(wait_CalcOut+".INPA",Proc1+"NumFilter_RBV") - caput(wait_CalcOut+".INPB",Proc1+"NumFiltered_RBV") - caput(wait_CalcOut+".OOPT",'Transition to non-zero') - caput(wait_CalcOut+".OUT",done_strSeq+".PROC PP") - - desc = "MPA writeDone" - n=1 - done_strSeq = userStringSeq_clear(Calcs_mda,n) - caput(done_strSeq+".DESC","MPA writeDone") - caput(done_strSeq+".LNK1", ADplugin+"WriteFile PP") - caput(done_strSeq+".STR1","Write") - caput(done_strSeq+".LNK1", mpa_busy+" PP") - caput(done_strSeq+".STR1","Done") - + def ROI_setup_all(self,xcenter=535,ycenter=539): + """ + setup up ROI + 1 => size = 50 x 50 + 2 => size = 100 x 100 + 3 => size = 150 x 150 + 4 => size = 200 x 200 + + """ + self._ROI_setup(1,xcenter,ycenter,xsize=50,ysize=50) + self._ROI_setup(2,xcenter,ycenter,xsize=100,ysize=100) + self._ROI_setup(3,xcenter,ycenter,xsize=150,ysize=150) + self._ROI_setup(4,xcenter,ycenter,xsize=200,ysize=200) - -def _mpa_trigger_callback(trigger,saveImg=False,**kwargs): - """ - used for triggering the MPA in the scanRecord, reset Proc1 and waits for finish - trigger: adds/removes trigger to mda (True/False) + def ROI_stats(self,ROI_num): + """ + sequence to enable stats for mpa ROI + """ + ROI_pv=self.pv+"ROI"+str(ROI_num)+':' + stats_pv=self.pv+"Stats"+str(ROI_num)+':' + caput(stats_pv+'NDArrayPort','ROI'+str(ROI_num)) + caput(stats_pv+'EnableCallbacks','Enable') + caput(stats_pv+'ArrayCallbacks','Enable') + caput(stats_pv+'ComputeStatistics','Yes') + caput(stats_pv+'ComputeCentroid','Yes') + caput(stats_pv+'ComputeProfiles','Yes') + + def _trigger_calcOut(self,**kwargs): + """ + writes strSeq and calcOut for MPA this should go into the IOC + + **kwargs: + ADplugin = 'TIFF1:' (default) + """ + + kwargs.setdefault("ADplugin","TIFF1:") + kwargs.setdefault("save_image",False) + + ADplugin = self.pv + kwargs["ADplugin"] + Proc1 = self.pv + "Proc1:" + + #All this should moved into the MPA IOC + Calcs_mda = ScanRecord(userCalc_ioc) - **kwargs: - save_image = False used for appropriate trigger of ROIs - = True also saves an image based on ADplugin type - ADplugin = 'TIFF1:' (default + desc = "MPA busy" + n=9 + busy_CalcOut = userCalcOut_clear(Calcs_mda,n) + caput(busy_CalcOut+".DESC",desc) + caput(busy_CalcOut+".INPA",mpa_busy+" CP") + caput(busy_CalcOut+".OOPT",'Transition to non-zero') + caput(busy_CalcOut+".OUT",start_strSeq+".PROC PP") + + desc = "MPA start" + n=1 + start_strSeq = userStringSeq_clear(Calcs_mda,n) + caput(start_strSeq+".DESC",desc) + caput(start_strSeq+".LNK1", Proc1+"ResetFilter PP") + caput(start_strSeq+".STR1","Yes") + + desc = "MPA wait" + n=10 + wait_CalcOut = userCalcOut_clear(Calcs_mda,n) + caput(wait_CalcOut+".DESC",desc) + caput(wait_CalcOut+".INPA",Proc1+"NumFilter_RBV") + caput(wait_CalcOut+".INPB",Proc1+"NumFiltered_RBV") + caput(wait_CalcOut+".OOPT",'Transition to non-zero') + caput(wait_CalcOut+".OUT",done_strSeq+".PROC PP") + + desc = "MPA writeDone" + n=1 + done_strSeq = userStringSeq_clear(Calcs_mda,n) + caput(done_strSeq+".DESC","MPA writeDone") + caput(done_strSeq+".LNK1", ADplugin+"WriteFile PP") + caput(done_strSeq+".STR1","Write") + caput(done_strSeq+".LNK1", mpa_busy+" PP") + caput(done_strSeq+".STR1","Done") + - by default ADplugin = 29iddMPA:TIFF1: - can use 29iddMPA:HDF1: - """ - - kwargs.setdefault("ADplugin","TIFF1:") - kwargs.setdefault("save_image",False) - - ADplugin = mpa_pv + kwargs['ADplugin'] - _mpa_trigger_calcOut(**kwargs) - - if trigger==True: - caput(ADplugin+"AutoResetFilter","Yes") - if saveImg: - caput(ADplugin+"AutoSave", "No") - caput(ADplugin+"EnableCallbacks", "Enable") + def self_trigger_callback(self,trigger,saveImg=False,**kwargs): + """ + used for triggering the MPA in the scanRecord, reset Proc1 and waits for finish - if trigger==False: - caput(ADplugin+"AutoResetFilter","No") - if saveImg: - caput(ADplugin+"EnableCallbacks", "Disable") - caput(ADplugin+"AutoSave", "Yes") - - return mpa_busy - -def _mpa_prefix(**kwargs): - """ - """ - kwargs.setdefault("debug",False) - - fpath=join(dirname(dirname(mda.filepath)),"mpa",'') - nextMDA = mda.fileNum - prefix="mda"+str.zfill(str(nextMDA),4)+"_mpa" - return prefix - -def mpa_trigger(trigger, **kwargs): - """ - Sets up / Cleans up the ScanRecord to trigger the MPA - - trigger: adds/removes trigger to mda (True/False) - + trigger: adds/removes trigger to mda (True/False) + + **kwargs: + save_image = False used for appropriate trigger of ROIs + = True also saves an image based on ADplugin type + ADplugin = 'TIFF1:' (default - **kwargs: - save_image = False used for appropriate trigger of ROIs - = True also saves an image based on ADplugin type - detTrigNum = 2 (default) - scan_dim = 1 (default) - ADplugin = "TIFF1" / "HDF1" - - Previously: MPA_Trigger - """ - kwargs.setdefault("detTrigNum",2) - kwargs.setdefault("save_image",False) - kwargs.setdefault('scan_dim',1) - kwargs.setdefault("ADplugin","TIFF1:") - - mpa_busy = _mpa_trigger_callback(trigger, **kwargs) - - #adding the MPA to the scanRecord trigger - if trigger == True: - _mpa_prefix(**kwargs) - mda.triggers_set(kwargs['scan_dim'],{2:mpa_busy}) - - if trigger == False: - mda.triggers_set(kwargs['scan_dim'],{2:''}) + by default ADplugin = 29iddMPA:TIFF1: + can use 29iddMPA:HDF1: + """ + + kwargs.setdefault("ADplugin","TIFF1:") + kwargs.setdefault("save_image",False) + + ADplugin = self.pv + kwargs['ADplugin'] + + self._trigger_calcOut(**kwargs) + + if trigger==True: + caput(ADplugin+"AutoResetFilter","Yes") + if saveImg: + caput(ADplugin+"AutoSave", "No") + caput(ADplugin+"EnableCallbacks", "Enable") + + if trigger==False: + caput(ADplugin+"AutoResetFilter","No") + if saveImg: + caput(ADplugin+"EnableCallbacks", "Disable") + caput(ADplugin+"AutoSave", "Yes") + + return mpa_busy + + def _mpa_prefix(self,**kwargs): + """ + """ + kwargs.setdefault("debug",False) + + fpath=join(dirname(dirname(BL.mda.filepath)),"mpa",'') + nextMDA = BL.mda.fileNum + prefix="mda"+str.zfill(str(nextMDA),4)+"_mpa" + return prefix + + def _trigger(self,trigger, **kwargs): + """ + Sets up / Cleans up the ScanRecord to trigger the MPA + + trigger: adds/removes trigger to mda (True/False) + + + **kwargs: + save_image = False used for appropriate trigger of ROIs + = True also saves an image based on ADplugin type + detTrigNum = 2 (default) + scan_dim = 1 (default) + ADplugin = "TIFF1" / "HDF1" + + Previously: MPA_Trigger + """ + kwargs.setdefault("detTrigNum",2) + kwargs.setdefault("save_image",False) + kwargs.setdefault('scan_dim',1) + kwargs.setdefault("ADplugin","TIFF1:") + + mpa_busy = self._mpa_trigger_callback(trigger, **kwargs) + + #adding the MPA to the scanRecord trigger + if trigger == True: + self._mpa_prefix(**kwargs) + BL.mda.triggers_set(kwargs['scan_dim'],{2:mpa_busy}) + + if trigger == False: + BL.mda.triggers_set(kwargs['scan_dim'],{2:''}) -def mpa_save_strSeq(**kwargs): - """ - **kwargs: - ADplugin: "TIFF1:" - """ - kwargs.setdefault("ADplugin","TIFF1:") - - ADplugin = mpa_pv + kwargs["ADplugin"] - - desc = "MCP datamode" - n=2 - strSeq_pv = userStringSeq_clear(mda,n) - caput(strSeq_pv+".DESC",desc) - caput(strSeq_pv+".LNK1",mpaDet_pv+"Acquire CA NMS") - caput(strSeq_pv+".STR1","Done") - caput(strSeq_pv+".WAIT1","Wait") - caput(strSeq_pv+".LNK2",mpaDet_pv+"RunTimeEnable PP NMS") - caput(strSeq_pv+".STR2","1") - caput(strSeq_pv+".WAIT2","Wait") - caput(strSeq_pv+".LNK3",ADplugin+"EnableCallbacks PP NMS") - caput(strSeq_pv+".STR3","1") - -def mpa_freerun_strSeq(): - """ - """ - desc = "MCP freerun" - n=1 - strSeq_pv = userStringSeq_clear(mda,n) - caput(strSeq_pv+".DESC",desc) - caput(strSeq_pv+".LNK1",mpaDet_pv+"Acquire PP NMS") - caput(strSeq_pv+".WAIT1","Wait") - caput(strSeq_pv+".STR1","Done") - caput(strSeq_pv+".LNK2","29iddMPA:TIFF1:EnableCallbacks PP NMS") - caput(strSeq_pv+".STR2","0") - caput(strSeq_pv+".WAIT2","Wait") - caput(strSeq_pv+".LNK3",mpaDet_pv+"RunTimeEnable PP NMS") - caput(strSeq_pv+".STR3","0") - caput(strSeq_pv+".WAIT3","Wait") - caput(strSeq_pv+".LNK4",mpaDet_pv+"Acquire PP NMS") - caput(strSeq_pv+".STR4","Acquire") - - -def mpa_HV_sp_calcOut(): - """ - """ - - desc = "MPA HV SP" - n=9 - calcOut_pv = userCalcOut_clear(mda,n) - - caput(calcOut_pv+".DESC",desc) - caput(calcOut_pv+".A",0) - caput(calcOut_pv+".B",ratio) - caput(calcOut_pv+".C",max_HV) - caput(calcOut_pv+".CALC$","A") - caput(calcOut_pv+".OCAL$","MIN(A/B,C/B)") - caput(calcOut_pv+".OOPT",1) # On Change - caput(calcOut_pv+".DOPT",1) # Use 0CALC - caput(calcOut_pv+".IVOA",0) # Continue Normally - caput(calcOut_pv+".OUT",DAC_pv+" PP NMS") - -def mpa_HV_rbv_calcOut(): - """ - """ - desc = "MPA HV RBV" - n=10 - calcOut_pv = userCalcOut_clear(mda,n) - - caput(calcOut_pv+".DESC",desc) - caput(calcOut_pv+".INPA",DAC_pv+' CP NMS') - caput(calcOut_pv+".B",ratio) - caput(calcOut_pv+".CALC$","A*B") - -def mpa_interlock_mpa(): - """ - """ - desc = "MPA Interlock mpa" - n=7 - calcOut_pv = userCalcOut_clear(mda,n) - - caput(calcOut_pv+".DESC",desc) - tth_pv = Kappa_motor_dictionary('tth')[3] - caput(calcOut_pv+".INPA",tth_pv+".DRBV CP NMS") - caput(calcOut_pv+".B",1) - caput(calcOut_pv+".CALC$","ABS((("+str(tth_dLLM)+"<A && A<"+str(tth_dHLM)+") && (B>0))-1)") - caput(calcOut_pv+".OCAL$",'A') - caput(calcOut_pv+".OOPT",2) # When zero - caput(calcOut_pv+".DOPT",0) # Use CALC - caput(calcOut_pv+".IVOA",0) # Continue Normally - caput(calcOut_pv+".OUT",mpa_on_off_pv()+"PP NMS") + def _save_strSeq(self,**kwargs): + """ + **kwargs: + ADplugin: "TIFF1:" + """ + kwargs.setdefault("ADplugin","TIFF1:") + + ADplugin = self.pv + kwargs["ADplugin"] + + desc = "MCP datamode" + n=2 + strSeq_pv = userStringSeq_clear(BL.mda,n) + caput(strSeq_pv+".DESC",desc) + caput(strSeq_pv+".LNK1",self._det_pv+"Acquire CA NMS") + caput(strSeq_pv+".STR1","Done") + caput(strSeq_pv+".WAIT1","Wait") + caput(strSeq_pv+".LNK2",self._det_pv+"RunTimeEnable PP NMS") + caput(strSeq_pv+".STR2","1") + caput(strSeq_pv+".WAIT2","Wait") + caput(strSeq_pv+".LNK3",ADplugin+"EnableCallbacks PP NMS") + caput(strSeq_pv+".STR3","1") + + def _freerun_strSeq(self): + """ + """ + desc = "MCP freerun" + n=1 + strSeq_pv = userStringSeq_clear(BL.mda,n) + caput(strSeq_pv+".DESC",desc) + caput(strSeq_pv+".LNK1",self._det_pv+"Acquire PP NMS") + caput(strSeq_pv+".WAIT1","Wait") + caput(strSeq_pv+".STR1","Done") + caput(strSeq_pv+".LNK2","29iddMPA:TIFF1:EnableCallbacks PP NMS") + caput(strSeq_pv+".STR2","0") + caput(strSeq_pv+".WAIT2","Wait") + caput(strSeq_pv+".LNK3",self._det_pv+"RunTimeEnable PP NMS") + caput(strSeq_pv+".STR3","0") + caput(strSeq_pv+".WAIT3","Wait") + caput(strSeq_pv+".LNK4",self._det_pv+"Acquire PP NMS") + caput(strSeq_pv+".STR4","Acquire") + + + def _HV_sp_calcOut(self): + """ + """ + + desc = "MPA HV SP" + n=9 + calcOut_pv = userCalcOut_clear(BL.mda,n) + + caput(calcOut_pv+".DESC",desc) + caput(calcOut_pv+".A",0) + caput(calcOut_pv+".B",self.ratio) + caput(calcOut_pv+".C",self.max_HV) + caput(calcOut_pv+".CALC$","A") + caput(calcOut_pv+".OCAL$","MIN(A/B,C/B)") + caput(calcOut_pv+".OOPT",1) # On Change + caput(calcOut_pv+".DOPT",1) # Use 0CALC + caput(calcOut_pv+".IVOA",0) # Continue Normally + caput(calcOut_pv+".OUT",self._DAC_pv+" PP NMS") + + def _HV_rbv_calcOut(self): + """ + """ + desc = "MPA HV RBV" + n=10 + calcOut_pv = userCalcOut_clear(BL.mda,n) + + caput(calcOut_pv+".DESC",desc) + caput(calcOut_pv+".INPA",DAC_pv+' CP NMS') + caput(calcOut_pv+".B",self.ratio) + caput(calcOut_pv+".CALC$","A*B") + + def _interlock_mpa(self): + """ + """ + desc = "MPA Interlock mpa" + n=7 + calcOut_pv = userCalcOut_clear(BL.mda,n) + + caput(calcOut_pv+".DESC",desc) + tth_pv = self._tth_pv + caput(calcOut_pv+".INPA",tth_pv+".DRBV CP NMS") + caput(calcOut_pv+".B",1) + caput(calcOut_pv+".CALC$","ABS((("+str(self.tth_dLLM)+"<A && A<"+str(self.tth_dHLM)+") && (B>0))-1)") + caput(calcOut_pv+".OCAL$",'A') + caput(calcOut_pv+".OOPT",2) # When zero + caput(calcOut_pv+".DOPT",0) # Use CALC + caput(calcOut_pv+".IVOA",0) # Continue Normally + caput(calcOut_pv+".OUT",self._off_on_pv()+"PP NMS") -def mpa_interlock_DAC(): - """ - """ - desc = "MPA Interlock DAC" - n=8 - calcOut_pv = userCalcOut_clear(mda,n) - - caput(calcOut_pv+".DESC",desc) - tth_pv = Kappa_motor_dictionary('tth')[3] - caput(calcOut_pv+".INPA",tth_pv+".DRBV CP NMS") - caput(calcOut_pv+".B",1) - caput(calcOut_pv+".CALC$","ABS((("+str(tth_dLLM)+"<A && A<"+str(tth_dHLM)+") && (B>0))-1)") - caput(calcOut_pv+".OCAL$",'A') - caput(calcOut_pv+".OOPT",2) # When zero - caput(calcOut_pv+".DOPT",0) # Use CALC - caput(calcOut_pv+".IVOA",0) # Continue Normally - caput(calcOut_pv+".OUT",DAC_pv+"_Se PP NMS") + def _interlock_DAC(self): + """ + """ + desc = "MPA Interlock DAC" + n=8 + calcOut_pv = userCalcOut_clear(BL.mda,n) + + caput(calcOut_pv+".DESC",desc) + tth_pv = self._tth_pv + caput(calcOut_pv+".INPA",tth_pv+".DRBV CP NMS") + caput(calcOut_pv+".B",1) + caput(calcOut_pv+".CALC$","ABS((("+str(self.tth_dLLM)+"<A && A<"+str(self.tth_dHLM)+") && (B>0))-1)") + caput(calcOut_pv+".OCAL$",'A') + caput(calcOut_pv+".OOPT",2) # When zero + caput(calcOut_pv+".DOPT",0) # Use CALC + caput(calcOut_pv+".IVOA",0) # Continue Normally + caput(calcOut_pv+".OUT",self._DAC_pv+"_Se PP NMS") def reset_mpa_HV(): """ diff --git a/build/lib/iexcode/instruments/resolution.py b/build/lib/iexcode/instruments/resolution.py index a34f8919c7df6eca028e3216ec5b13e3d5973da2..cd8c8367cf08540c76971236c93793493377778d 100644 --- a/build/lib/iexcode/instruments/resolution.py +++ b/build/lib/iexcode/instruments/resolution.py @@ -1,9 +1,35 @@ import numpy as np -from iexcode.instruments.electron_analyzer import resolution_EA +from epics import caget + +from iexcode.instruments.utilities import take_closest_value +from iexcode.instruments.xrays import get_branch, getE, slit_get +from iexcode.instruments.VLS_PGM import mono_grating_get +from iexcode.instruments.electron_analyzer import EA, resolution_EA, getSESslit +from iexcode.instruments.ARPES import ARPES_extra_pvs ############################################################################################################# ############################## Resolution ############################## ############################################################################################################# +def resolution(): + """ + Calculate the theoretical resolution for the current beamline settings: + ARPES: total resolution i.e. sqrt(kbT^2 + analyzer^2 + BL^2); default SES slit = 5. + Kappa: beamline contribution only + """ + branch = get_branch() + grt = mono_grating_get() + hv_eV = getE() + slit_size = take_closest_value([10,20,50,100,200],round(slit_get(),0)) + + if branch == "c": + slit_SES = getSESslit() + PE = int(EA.PassEnergy) + T = caget(ARPES_extra_pvs['TA']) + resolution_ARPES(grt,hv_eV,slit_size,PE,slit_SES,T,verbose=True) + else: + resolution_beamline(grt,hv_eV,slit_size,verbose=True) + + def resolution_calculate_beamline(grt,hv_eV,slit_size): """ diff --git a/build/lib/iexcode/instruments/staff.py b/build/lib/iexcode/instruments/staff.py index b9d6eef6b0732753a2c5c190dd1903e2f2d2652c..ba5648b20ddbb97055a2626f03afbdec84e006b3 100644 --- a/build/lib/iexcode/instruments/staff.py +++ b/build/lib/iexcode/instruments/staff.py @@ -1,10 +1,6 @@ from os import listdir,mkdir,chmod from os.path import join, isfile, exists -#from .ARPES import folders_ARPES -#from .Kappa import folders_Kappa - - def folders_startup(run): """ Creates the run directories for the following: diff --git a/build/lib/iexcode/instruments/xrays.py b/build/lib/iexcode/instruments/xrays.py index aa029404a075cb0b00ddbf7f9878598afc57032b..b4a4c1883e8164297706e38a2faefeafd0047e07 100644 --- a/build/lib/iexcode/instruments/xrays.py +++ b/build/lib/iexcode/instruments/xrays.py @@ -8,7 +8,6 @@ from time import sleep from epics import caget,caput from iexcode.instruments.IEX_endstations import BL -from iexcode.instruments.resolution import * from iexcode.instruments.IEX_VPU import * from iexcode.instruments.VLS_PGM import * from iexcode.instruments.slits import * @@ -18,13 +17,12 @@ from iexcode.instruments.diagnostics import * from iexcode.instruments.m3r import * from iexcode.instruments.logfile import * from iexcode.instruments.utilities import print_warning_message,make_table, take_closest_value -from iexcode.instruments.mpa import * from iexcode.instruments.current_amplifiers import ca_average -from iexcode.instruments.beamline import branch_cams_enable +from iexcode.instruments.beamline import endstation_cams_enable + +from iexcode.instruments.MPA import mpa_HV_on,mpa_HV_off + -from iexcode.instruments.ARPES import ARPES_mprint,ARPES_extra_pvs -from iexcode.instruments.Kappa import Kappa_mprint -from iexcode.instruments.electron_analyzer import getSESslit, EA ############################################################################################################## ############################## resets and detector lists ############################## ############################################################################################################## @@ -104,10 +102,9 @@ 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({'ARPES':ARPES_mprint()}) - print("ARPES = ",ARPES_mprint()) - vals.update({'Kappa':Kappa_mprint()}) - print("Kappa = ",Kappa_mprint()) + vals.update({BL.endstation:BL.Motors.mprint()}) + print(BL.endstation+" = ",BL.Motors.mprint()) + print("===========================================================") return vals @@ -143,12 +140,12 @@ def xrays_log_entries(**kwargs): #endstation info if BL.endstation_name == 'ARPES': - endstation_entry, endstation_pv, endstation_format = ARPES_log_entries(**kwargs) + endstation_entry, endstation_pv, endstation_format = 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 = Kappa_log_entries(**kwargs) + endstation_entry, endstation_pv, endstation_format = BL.log_entries(**kwargs) entry_list.append(endstation_entry[:-7]) pv_list.append(endstation_pv[:-7]) format_list.append(endstation_format[:-7]) @@ -167,7 +164,7 @@ def xrays_log_entries(**kwargs): #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 = Kappa_log_entries(**kwargs) + endstation_entry, endstation_pv, endstation_format = BL.log_entries(**kwargs) entry_list.append(endstation_entry[-7:]) pv_list.append(endstation_pv[-7:]) format_list.append(endstation_format[-7:]) @@ -289,7 +286,7 @@ def scan_ID(ID_sp_start,ID_sp_stop,ID_sp_step,**kwargs): scan the ID set point """ val_pv,rbv_pv = ID_scan_pvs() - mda.fillin(val_pv,rbv_pv,ID_sp_start,ID_sp_stop,ID_sp_step,**kwargs) + BL.mda.fillin(val_pv,rbv_pv,ID_sp_start,ID_sp_stop,ID_sp_step,**kwargs) def mvmono(val): @@ -357,12 +354,12 @@ def scanhv(start,stop,step,average_pnts=1,**kwargs): """ ca_average(average_pnts) - mono_scan_fillin(mda,start,stop,step,**kwargs) + mono_scan_fillin(BL.mda,start,stop,step,**kwargs) mono_energy_set(start) - mda.go(**kwargs) + BL.mda.go(**kwargs) - mono_scan_after(mda) + mono_scan_after(BL.mda) def scanE(start,stop,step,ID_offset=0,mesh='stay',average_pnts=1,scan_dim=1,**kwargs): @@ -447,8 +444,8 @@ def scanXAS(ID_eV,start_stop_step_lists,**kwargs): #Setting everything back mono_energy_set(ID_eV) - mono_scan_after(mda,scan_dim) - mda.table_reset_after(scan_dim) + mono_scan_after(BL.mda,scan_dim) + BL.mda.table_reset_after(scan_dim) if BL.branch == "d": if kwargs["mcp"]: @@ -487,10 +484,10 @@ def scanXAS_BL(start_stop_step_lists,**kwargs): mono_array,ID_array = BL_energy_tables(start_stop_step_lists) kwargs.update('positioner_num',1) - mono_scan_fillin_table(mda,scan_dim,mono_array,**kwargs) + mono_scan_fillin_table(BL.mda,scan_dim,mono_array,**kwargs) kwargs.update('positioner_num',2) - ID_scan_fillin_table(mda,scan_dim,ID_array,**kwargs) + ID_scan_fillin_table(BL.mda,scan_dim,ID_array,**kwargs) #Averaging and Normalization ca_average(kwargs['average_pnts']) @@ -512,8 +509,8 @@ def scanXAS_BL(start_stop_step_lists,**kwargs): #Setting everything back mono_energy_set(mono_array[0]) - mono_scan_after(mda,scan_dim) - mda.table_reset_after(scan_dim) + mono_scan_after(BL.mda,scan_dim) + BL.mda.table_reset_after(scan_dim) if BL.branch == "d": if kwargs["mcp"]: @@ -626,7 +623,7 @@ def switch_branch(branch, force=False, shutter=True,scan_reset=True,enable_cams= BL.mda.reset() if enable_cams: - branch_cams_enable(branch) + endstation_cams_enable(branch) else: print_warning_message(branch+' is not a valid branch selection') @@ -677,24 +674,7 @@ def slit_get(verbose=True): print(message) return slit_size,slit_center -def resolution(): - """ - Calculate the theoretical resolution for the current beamline settings: - ARPES: total resolution i.e. sqrt(kbT^2 + analyzer^2 + BL^2); default SES slit = 5. - Kappa: beamline contribution only - """ - branch = get_branch() - grt = mono_grating_get() - hv_eV = getE() - slit_size = take_closest_value([10,20,50,100,200],round(slit_get(),0)) - if branch == "c": - slit_SES = getSESslit() - PE = int(EA.PassEnergy) - T = caget(ARPES_extra_pvs['TA']) - resolution_ARPES(grt,hv_eV,slit_size,PE,slit_SES,T,verbose=True) - else: - resolution_beamline(grt,hv_eV,slit_size,verbose=True) diff --git a/iexcode.egg-info/SOURCES.txt b/iexcode.egg-info/SOURCES.txt index e22a33a508fd45a06267a30d008faaffa8c624a0..4b38e09f7e8b8e374fd86d99b4ed8654170a0561 100644 --- a/iexcode.egg-info/SOURCES.txt +++ b/iexcode.egg-info/SOURCES.txt @@ -15,6 +15,7 @@ iexcode/instruments/Kappa.py iexcode/instruments/Kappa_Euler.py iexcode/instruments/Kappa_det.py iexcode/instruments/Lakeshore_335.py +iexcode/instruments/MPA.py iexcode/instruments/Motors.py iexcode/instruments/Scienta.py iexcode/instruments/VLS_PGM.py @@ -38,7 +39,6 @@ iexcode/instruments/resolution.py iexcode/instruments/s29_temp_cntl.py iexcode/instruments/scalers.py iexcode/instruments/scanRecord.py -iexcode/instruments/scratch.py iexcode/instruments/shutters.py iexcode/instruments/slits.py iexcode/instruments/spec_stuff.py diff --git a/iexcode/instruments/AD_utilities.py b/iexcode/instruments/AD_utilities.py index f8d43d23aed84bf5a1ee86d46cefdbb81f5d1ffa..15dd0a09b5a21539352d7827c64cb70c5359e4b7 100644 --- a/iexcode/instruments/AD_utilities.py +++ b/iexcode/instruments/AD_utilities.py @@ -13,7 +13,7 @@ from os.path import join, isfile, exists, dirname from time import sleep from epics import caget, caput -from iexcode.instruments.IEX_endstations import * +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 90f825f9fa07a93d36c82263dbf7404f0ea79efd..a2337c0b13b2a5f7dab34c46b4e977b5949c31b9 100644 --- a/iexcode/instruments/ARPES.py +++ b/iexcode/instruments/ARPES.py @@ -3,7 +3,7 @@ from time import sleep from epics import caget,caput,PV -from iexcode.instruments.IEX_endstations import * +from iexcode.instruments.IEX_endstations import Endstation from iexcode.instruments.staff import staff_detector_dictionary from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda @@ -12,11 +12,12 @@ from iexcode.instruments.logfile import logfile_name_set,logfile_header from iexcode.instruments.conversions_constants import * from iexcode.instruments.utilities import * + from iexcode.instruments.userCalcs import userStringSeq_clear, userStringSeq_pvs +from iexcode.instruments.scanRecord import ScanRecord +from iexcode.instruments.xrays import xrays_detector_dictionary,xrays_reset,xrays_get_all -from iexcode.instruments.scanRecord import * -from iexcode.instruments.Motors import * -from iexcode.instruments.xrays import * +from iexcode.instruments.Motors import Motors from iexcode.instruments.current_amplifiers import * from iexcode.instruments.gate_valves import valve_close, branch_valves from iexcode.instruments.shutters import branch_shutter_close @@ -47,7 +48,8 @@ def ARPES_init(set_folders=True,reset=True,**kwargs): #endstation global BL - BL=Endstation('ARPES',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],mda_scanRecord) + BL=Endstation('ARPES',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],mda_scanRecord, + ARPES_log_header,ARPES_log_entries,ARPES_motor_dictionary) #EA try: diff --git a/iexcode/instruments/FMB_mirrors.py b/iexcode/instruments/FMB_mirrors.py index 888d9b9425b99a75ac9d39dcac6447fafe0680f7..083b9e69e3a6cb39a8a2cca14b7a7d363f458827 100644 --- a/iexcode/instruments/FMB_mirrors.py +++ b/iexcode/instruments/FMB_mirrors.py @@ -4,7 +4,6 @@ from epics import caget, caput from iexcode.instruments.IEX_endstations import * from iexcode.instruments.utilities import read_dict, print_warning_message -from iexcode.instruments.m3r import m3r_branch M0M1_fpath="/home/beams22/29IDUSER/Documents/User_Macros/Macros_29id/IEX_Dictionaries/Dict_IDCal.txt" @@ -57,9 +56,6 @@ def FMB_mirror_get(mirror_num,verbose=True): message =+ "%.3f"+"/" % rbv if verbose: print(message) - if mirror_num == 3: - mirror_branch = m3r_branch() - print(" => In "+mirror_branch+" branch") return vals def FMB_mirror_move(mirror_num,axis,val,verbose=True): diff --git a/iexcode/instruments/IEX_endstations.py b/iexcode/instruments/IEX_endstations.py index 94ee6e1eb9ce4b609d49ca490ac53f24acb5cf32..6bff704cb6f1fa23ec62f65de48f217b27117852 100644 --- a/iexcode/instruments/IEX_endstations.py +++ b/iexcode/instruments/IEX_endstations.py @@ -26,7 +26,7 @@ class Endstation: """ - def __init__(self,endstation_name,scan_ioc,xrays,BL_mode,mda_scanRecord): + def __init__(self,endstation_name,scan_ioc,xrays,BL_mode,mda_scanRecord,log_header,log_entries,Motors): """ intializes the several beamline variables @@ -40,13 +40,16 @@ class Endstation: BL.prefix => 'ARPES_','Kappa_' BL.ioc => previously: BL_ioc() BL.mda_filepath + BL.log_header => dictionary with header list + BL.log_entries => method to get pvs to be written to log file + BL.Motors => motor calls """ global BL endstations_list = ['ARPES','Kappa'] BL_mode_list = ['user','staff'] - if self.endstation_name in endstations_list: + if endstation_name in endstations_list: self.endstation=endstation_name else: print('Not a valid Endstation choice') @@ -74,6 +77,9 @@ class Endstation: self.xrays = xrays self.ioc = scan_ioc self.mda = mda_scanRecord + self.log_header = log_header + self.log_entries = log_entries + self.Motors = Motors def set_logfile_path(): @@ -107,25 +113,3 @@ def BL_mda_filepath(): returns the mda file prefix """ return BL.filepath - -def scalar_cts(self,integration_time=0.1,verbose=True,**kwargs): - """ - Sets the integration time for the scalers - kwargs: - mcp = True/False to sum mpa - Previously: cts, Kappa counts - """ - - if BL.endstation == 'ARPES': - pass - elif BL.endstation == 'Kappa': - Kappa_scalar_pv = "29idMZ0:scaler1.TP" - mpa_Proc1_pv = "29iddMPA:Proc1:" - - caput(Kappa_scalar_pv,integration_time) - - if kwargs["mpa"]: - caput(mpa_Proc1_pv+'NumFilter',floor(time)) - - if verbose: - print("Integration time set to:", str(time)) \ No newline at end of file diff --git a/iexcode/instruments/Kappa.py b/iexcode/instruments/Kappa.py index 18c98109e657face5c89a1a35b50e2ae272c9966..c64636c239688b6fa69e8863d1e9d55225e1ff95 100644 --- a/iexcode/instruments/Kappa.py +++ b/iexcode/instruments/Kappa.py @@ -13,17 +13,20 @@ from iexcode.instruments.logfile import logfile_name_set,logfile_header from iexcode.instruments.conversions_constants import * from iexcode.instruments.utilities import * -from iexcode.instruments.userCalcs import userStringSeq_clear, userStringSeq_pvs -from iexcode.instruments.scanRecord import * -from iexcode.instruments.Motors import * -from iexcode.instruments.xrays import * -from iexcode.instruments.current_amplifiers import * +from iexcode.instruments.userCalcs import userStringSeq_clear, userStringSeq_pvs, userCalcOut_clear +from iexcode.instruments.scanRecord import ScanRecord +#from iexcode.instruments.xrays import xrays_reset,xrays_get_all + +from iexcode.instruments.Motors import Motors +from iexcode.instruments.current_amplifiers import SRS, ca_reset_all, Keithley_pv from iexcode.instruments.gate_valves import valve_close, branch_valves from iexcode.instruments.shutters import branch_shutter_close from iexcode.instruments.slits import slit3D_get -from iexcode.instruments.Kappa_det import * +from iexcode.instruments.Kappa_det import Kappa_Detector +from iexcode.instruments.scalers import scaler_cts +from iexcode.instruments.MPA import MPA from iexcode.instruments.spec_stuff import folders_spec @@ -53,15 +56,17 @@ def Kappa_init(set_folders=False,reset=False,**kwargs): #endstation global BL - BL=Endstation('Kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],mda_scanRecord) + BL=Endstation('Kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],mda_scanRecord,Kappa_log_header,Kappa_log_entries) #global detectors - global tey, d3, d4, mesh, Kappa_scaler_pv + global tey, d3, d4, mesh, Kappa_scaler_pv, mpa tey = SRS("29idMZ0:scaler1.S2", '29idd:A1') d3 = SRS("29idMZ0:scaler1.S3", '29idd:A2') d4 = SRS("29idMZ0:scaler1.S4", '29idd:A3') mesh = SRS("29idMZ0:scaler1.S14", '29idd:A4') Kappa_scaler_pv = '29idMZ0:scaler1.CNT' + tth_pv = Kappa_motor_dictionary('tth')[3] + mpa = MPA(tth_pv) global tthdet tthdet = Kappa_Detector() @@ -133,7 +138,7 @@ def Kappa_detector_dictionary(**kwargs): 38:"29idMZ0:scaler1_calc1.D", 39:"29idMZ0:scaler1_calc1.E", } - mpa={ + mpa_dets={ 30:"29iddMPA:det1:TotalRate_RBV", 41:"29iddMPA:Stats1:Total_RBV", 42:"29iddMPA:Stats2:Total_RBV", @@ -158,7 +163,7 @@ def Kappa_detector_dictionary(**kwargs): #hkl are listed just a place holders, they are filled in by thier scanning functions det_dict.update(sample_temp) det_dict.update(scalers) - det_dict.update(mpa) + det_dict.update(mpa_dets) det_dict.update(motors) if kwargs['add_vortex']: det_dict.update(vortex) @@ -278,7 +283,7 @@ def Kappa_reset(): #resetting mono and anyother beamline stuff if BL.xrays: - xrays_reset() + JLM="xrays_reset()" #reseting the Kappa Lakeshore @@ -291,7 +296,7 @@ def Kappa_reminder_list(ioc): """ resets scanRecord, current amplifiers, mono limits and synchs motors """ - mda.reset() + BL.mda.reset() if BL.xray: ca_reset_all() @@ -320,8 +325,8 @@ def Kappa_get_all(verbose=True): #beamline info if BL.xray: - beamline_info = xrays_get_all() - vals.update(beamline_info) + JLM="beamline_info = xrays_get_all()" + #vals.update(beamline_info) mesh.get() vals.update({'mesh':mesh.current}) @@ -364,7 +369,7 @@ def Kappa_log_entries(): tey_current = tey.current mesh_current = mesh.current det_name = tthdet.name - mpa_HV = mpa_HV_get() + mpa_HV = mpa.HV_get() m3r_centroid = vals['kphi'] entry_list = ["x","y","z","tth","kth","kap","kphi","TA","TB","TEY","mesh","det_name","mpa_HV","m3r_centroid"] @@ -648,26 +653,26 @@ def Kappa_th2th_scan_sensitivity(th_table,gain_num_table,gain_unit_table,detecto tth_table = 2*th_table kwargs.update("positioner_num",1) - mda.fillin_table(kth_val,kth_rbv,kth_table,**kwargs) + BL.mda.fillin_table(kth_val,kth_rbv,kth_table,**kwargs) kwargs.update("positioner_num",2) - mda.fillin_table(tth_val,tth_rbv,tth_table,**kwargs) + BL.mda.fillin_table(tth_val,tth_rbv,tth_table,**kwargs) kwargs.update("positioner_num",3) - mda.fillin_table(gain_num_pv,"",gain_num_table,**kwargs) + BL.mda.fillin_table(gain_num_pv,"",gain_num_table,**kwargs) kwargs.update("positioner_num",4) - mda.fillin_table(gain_unit_pv,"",gain_unit_table,**kwargs) + 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']: - mda.go(**kwargs) + BL.mda.go(**kwargs) #clean up after scan - mda.table_reset_after(**kwargs) + BL.mda.table_reset_after(**kwargs) scaler_cts(verbose=False) def Kappa_scan_th2th(tth_start,tth_stop,tth_step,th_offset,**kwargs): @@ -830,7 +835,7 @@ def KappaPreset_StrSeq(n,User): scanIOC="Kappa" motorIOC="29idKappa:" motor = ["m2","m3","m4","m9","m8","m7","m1"] - strSeq_pv = userStringSeq_clear(mda,n) + strSeq_pv = userStringSeq_clear(BL.mda,n) if User[0] == "Kappa Grazing": phi0= 0 if User[0] == "Kappa Transfer": phi0= 57 @@ -856,7 +861,7 @@ def KappaPreset_StrSeq(n,User): def Bragg_Angle_CalcOut(d,eV,l): n=7 - userCalcOut_pv = userCalcOut_clear(mda,n) + userCalcOut_pv = userCalcOut_clear(BL.mda,n) h=4.135667516e-15 c=299792458 @@ -906,9 +911,9 @@ def Kappa_safe_state(**kwargs): kwargs.setdefault("shutter_close",True) kwargs.setdefault("valve_close",True) - if kwargs["EA_off"]: + if kwargs["mpa_off"]: try: - mpa_HV_off() + mpa.HV_off() except: print('MPA is not running') diff --git a/iexcode/instruments/Kappa_Euler.py b/iexcode/instruments/Kappa_Euler.py index 42dfe2f1bac9ec223a1c6a78a4d20ab9f32720bf..ea025902dca59755f2a9ad60df51847449ad48f4 100644 --- a/iexcode/instruments/Kappa_Euler.py +++ b/iexcode/instruments/Kappa_Euler.py @@ -2,7 +2,7 @@ import numpy as np from epics import caget, caput from iexcode.instruments.userCalcs import userCalcOut_clear -from iexcode.instruments.IEX_endstations import mda +from iexcode.instruments.IEX_endstations import * from iexcode.instruments.userCalcs import userCalcOut_clear #### Obsolete? diff --git a/iexcode/instruments/Kappa_det.py b/iexcode/instruments/Kappa_det.py index 9a1a19071153d757e6dd4897cf40339b8fd4a73f..c00102003a67795f719a521a8255f94ef567ca85 100644 --- a/iexcode/instruments/Kappa_det.py +++ b/iexcode/instruments/Kappa_det.py @@ -1,7 +1,7 @@ from time import sleep from epics import caget, caput -from iexcode.instruments.IEX_endstations import Motors +from iexcode.instruments.Kappa import Kappa_Motors ############################################################################################################## @@ -27,7 +27,7 @@ class Kappa_Detector: #det_name = caget('29idKappa:userStringSeq6.STR1') det_name = caget(det_set_pv) self.name = det_name - tth_val = Motors.get('tth') + tth_val = Kappa_Motors.get('tth') return self.name, tth_val def set(self,det_name,move=True): @@ -43,13 +43,13 @@ class Kappa_Detector: yag: yag 'fluorescence screen' """ #get current value for tth - tth_val = Motors.get('tth') + tth_val = Kappa_Motors.get('tth') #change det if det_name in det_list: caput(det_set_pv,det_name) if move: - Motors.move('tth',tth_val,wait=True,verbose=False) + Kappa_Motors.move('tth',tth_val,wait=True,verbose=False) def tth0_set(move): """ @@ -58,7 +58,7 @@ class Kappa_Detector: only works with d4 """ current_det=caget(det_set_pv,as_string=True) - tth_pv = Motors._motor_dictionary['th'][3] + tth_pv = Kappa_Motors._motor_dictionary['th'][3] if current_det != 'd4': print('tth0 can only be redefined with d4') diff --git a/iexcode/instruments/Motors.py b/iexcode/instruments/Motors.py index 119b51bb725c0a065f3f6eb245b342d17eb3dad4..8b8f7adda9a34b73e43e1d71b4ea68c42002714f 100644 --- a/iexcode/instruments/Motors.py +++ b/iexcode/instruments/Motors.py @@ -3,7 +3,8 @@ from math import floor from epics import caget, caput -from iexcode.instruments.IEX_endstations import * +from iexcode.instruments.IEX_endstations import BL +from iexcode.instruments.scalers import scaler_cts class Motors: @@ -220,7 +221,7 @@ class Motors: outer_loop_list[2]=round(current_value1+outer_loop_list[2],3) outer_loop_list[3]=round(current_value1+outer_loop_list[3],3) - scalar_cts(kwargs['cts'],verbose=True,**kwargs) + scaler_cts(kwargs['cts'],verbose=True,**kwargs) BL.mda.fillin_2D(inner_loop_list,outer_loop_list, outer_scan_dim=kwargs['outer_scan_dim'],**kwargs) diff --git a/iexcode/instruments/__pycache__/AD_utilities.cpython-37.pyc b/iexcode/instruments/__pycache__/AD_utilities.cpython-37.pyc index 763286c8ddcdce49fed5d93a0cf42c0560f773e6..1a6e8475e8f93358fb1fe83baa8349354c91d9ae 100644 Binary files a/iexcode/instruments/__pycache__/AD_utilities.cpython-37.pyc and b/iexcode/instruments/__pycache__/AD_utilities.cpython-37.pyc differ diff --git a/iexcode/instruments/__pycache__/ARPES.cpython-37.pyc b/iexcode/instruments/__pycache__/ARPES.cpython-37.pyc index 062ed0acd605454bc28bed0f3204edf64921a4eb..638823899b8a5742d22cc711aa7fbd24ab3aa5c6 100644 Binary files a/iexcode/instruments/__pycache__/ARPES.cpython-37.pyc and b/iexcode/instruments/__pycache__/ARPES.cpython-37.pyc differ diff --git a/iexcode/instruments/__pycache__/FMB_mirrors.cpython-37.pyc b/iexcode/instruments/__pycache__/FMB_mirrors.cpython-37.pyc index cc28ad732f71f5749fe7379b7c1c41463fa49469..57c1211c32d375f886d98398dd6a047fcccc963b 100644 Binary files a/iexcode/instruments/__pycache__/FMB_mirrors.cpython-37.pyc and b/iexcode/instruments/__pycache__/FMB_mirrors.cpython-37.pyc differ diff --git a/iexcode/instruments/__pycache__/IEX_endstations.cpython-37.pyc b/iexcode/instruments/__pycache__/IEX_endstations.cpython-37.pyc index b4ef735bafb06232202d431f08609321d27de902..8e65b8fe990c1e2b9197a6c897ee4d0453c48d44 100644 Binary files a/iexcode/instruments/__pycache__/IEX_endstations.cpython-37.pyc and b/iexcode/instruments/__pycache__/IEX_endstations.cpython-37.pyc differ diff --git a/iexcode/instruments/__pycache__/Kappa.cpython-37.pyc b/iexcode/instruments/__pycache__/Kappa.cpython-37.pyc index b280eebee6bb33b0a5a9ee70a1958a91420d40e9..736a0ae36869c21290ea6c99ada18730aef76083 100644 Binary files a/iexcode/instruments/__pycache__/Kappa.cpython-37.pyc and b/iexcode/instruments/__pycache__/Kappa.cpython-37.pyc differ diff --git a/iexcode/instruments/__pycache__/Kappa_Euler.cpython-37.pyc b/iexcode/instruments/__pycache__/Kappa_Euler.cpython-37.pyc index d7e5066528a6d569653c3be9a202fe97ce5d86f4..e36da7b8c710469157f0613f122dab8b950e3934 100644 Binary files a/iexcode/instruments/__pycache__/Kappa_Euler.cpython-37.pyc and b/iexcode/instruments/__pycache__/Kappa_Euler.cpython-37.pyc differ diff --git a/iexcode/instruments/__pycache__/Kappa_det.cpython-37.pyc b/iexcode/instruments/__pycache__/Kappa_det.cpython-37.pyc index 64a16ee6fa9eb6ab0e825aeb9dc61f7afccee3c6..b79f19388690f3f26c6f29f4833f23d50c264c21 100644 Binary files a/iexcode/instruments/__pycache__/Kappa_det.cpython-37.pyc and b/iexcode/instruments/__pycache__/Kappa_det.cpython-37.pyc differ diff --git a/iexcode/instruments/__pycache__/Motors.cpython-37.pyc b/iexcode/instruments/__pycache__/Motors.cpython-37.pyc index c3ada008630f4d6119799aa0b66f9b538493f799..65303762f5649d738bebae3d0b95eefade32aa4c 100644 Binary files a/iexcode/instruments/__pycache__/Motors.cpython-37.pyc and b/iexcode/instruments/__pycache__/Motors.cpython-37.pyc differ diff --git a/iexcode/instruments/__pycache__/beamline.cpython-37.pyc b/iexcode/instruments/__pycache__/beamline.cpython-37.pyc index bb16662015007d4b73929f7a716b9331a54537d8..084b895e5db96a6afb98a4b3acb29e2dbfa44245 100644 Binary files a/iexcode/instruments/__pycache__/beamline.cpython-37.pyc and b/iexcode/instruments/__pycache__/beamline.cpython-37.pyc differ diff --git a/iexcode/instruments/__pycache__/electron_analyzer.cpython-37.pyc b/iexcode/instruments/__pycache__/electron_analyzer.cpython-37.pyc index 91ff70dc60fd8a66b8eb2c045939a252083917e3..3ebdc4fd88753351e22ad01cdee9eb50dd7c3314 100644 Binary files a/iexcode/instruments/__pycache__/electron_analyzer.cpython-37.pyc and b/iexcode/instruments/__pycache__/electron_analyzer.cpython-37.pyc differ diff --git a/iexcode/instruments/__pycache__/logfile.cpython-37.pyc b/iexcode/instruments/__pycache__/logfile.cpython-37.pyc index b49542070a25057382ecc6276ee31b7fe9f44a17..68a3b11783f01b7a8f197290c663bd7183375a04 100644 Binary files a/iexcode/instruments/__pycache__/logfile.cpython-37.pyc and b/iexcode/instruments/__pycache__/logfile.cpython-37.pyc differ diff --git a/iexcode/instruments/__pycache__/mpa.cpython-37.pyc b/iexcode/instruments/__pycache__/mpa.cpython-37.pyc index 706901ac024918e144fc9eece5186afcac389293..d08115e60825b3719c2b6d5775a66c30eaf8a333 100644 Binary files a/iexcode/instruments/__pycache__/mpa.cpython-37.pyc and b/iexcode/instruments/__pycache__/mpa.cpython-37.pyc differ diff --git a/iexcode/instruments/__pycache__/resolution.cpython-37.pyc b/iexcode/instruments/__pycache__/resolution.cpython-37.pyc index ff69f443a3bdb693d5a4a10a67e75ff819044f0a..e396add37e1deb4258a5e6078e6261a4e7fb4c97 100644 Binary files a/iexcode/instruments/__pycache__/resolution.cpython-37.pyc and b/iexcode/instruments/__pycache__/resolution.cpython-37.pyc differ diff --git a/iexcode/instruments/__pycache__/staff.cpython-37.pyc b/iexcode/instruments/__pycache__/staff.cpython-37.pyc index c323fc27e5c18ca6a135a8417e28121eee33a507..df7f088dba4cb799008ae549f7e7b4d2d635dcd8 100644 Binary files a/iexcode/instruments/__pycache__/staff.cpython-37.pyc and b/iexcode/instruments/__pycache__/staff.cpython-37.pyc differ diff --git a/iexcode/instruments/__pycache__/xrays.cpython-37.pyc b/iexcode/instruments/__pycache__/xrays.cpython-37.pyc index 6d7ea418488f9414d9abefdb6532e7066cd55956..914a5f624aecb4e6115c86b8777ed70d57dd766e 100644 Binary files a/iexcode/instruments/__pycache__/xrays.cpython-37.pyc and b/iexcode/instruments/__pycache__/xrays.cpython-37.pyc differ diff --git a/iexcode/instruments/beamline.py b/iexcode/instruments/beamline.py index 6817162fdad3533041139170c96a0fa810e51958..2071446d285365d1ff71eff8c3476f82af8d677b 100644 --- a/iexcode/instruments/beamline.py +++ b/iexcode/instruments/beamline.py @@ -53,25 +53,13 @@ def last_mda(): ############################################################################################################## - -def print_beeper(scanDIM=1): - """ - Prints pv to copy/paste into the beeper - - Previously: Print_Beeper - """ - branch=BL.branch - if branch == "c": - print("29idcEA:det1:Acquire") - pv=BL.ioc()+":scan"+str(scanDIM)+".FAZE" - print(pv) - print("ID29:BusyRecord") - - -def branch_cams_enable(branch=BL.branch): +def endstation_cams_enable(): """ + should live in cameras """ - cam_dict={'c':[0,1,2],'c':[3,4,6]} # index of cam_list + endstation=BL.endstation + + cam_dict={'ARPES':[0,1,2],'Kappa':[3,4,6]} # index of cam_list pvcam1=PV("29id_ps1:cam1:Acquire") pvcam2=PV("29id_ps2:cam1:Acquire") pvcam3=PV("29id_ps3:cam1:Acquire") @@ -85,7 +73,7 @@ def branch_cams_enable(branch=BL.branch): if pvcam.connected: pvcam.put(0) except: pass - for i in cam_dict[branch]: # turn ON relevant cam + for i in cam_dict[endstation]: # turn ON relevant cam try: if cam_list[i].connected: cam_list[i].put(1) else: print(cam_list[i].pvname+' not connected') diff --git a/iexcode/instruments/electron_analyzer.py b/iexcode/instruments/electron_analyzer.py index 8cfbb778c92dd9ce36f68ab6a062d44c5b9814af..119d7586295ed0fb92d964439e10c8b06693ebf3 100644 --- a/iexcode/instruments/electron_analyzer.py +++ b/iexcode/instruments/electron_analyzer.py @@ -22,14 +22,12 @@ 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.ARPES import ARPES_motor_dictionary, ARPES_motor_scan, ARPES_mvsample,ARPES_scan_2D +from iexcode.instruments.ARPES import ARPES_Motors from iexcode.instruments.Scienta import * -def __main__(): - global EA - EA = Scienta() - -mda = BL.mda +global EA +EA = Scienta() + ########################################################################### def EA_ioc_init(**kwargs): @@ -260,8 +258,8 @@ def _scanEAPrefix(ptype,**kwargs): print(ptype) if ptype == "mda": - fpath = mda.filepath[0:-3]+EA.dtype - nextMDA = mda.fileNum + fpath = BL.mda.filepath[0:-3]+EA.dtype + nextMDA = BL.mda.fileNum prefix = "MDAscan"+str.zfill(str(nextMDA),kwargs["nzeros"]) else: prefix = ptype @@ -304,7 +302,7 @@ def scanEA_reset(**kwargs): kwargs.setdefault("scan_dim",1) _scanEATrigger([],"after",**kwargs) - mda.positioners_clear(kwargs["scan_dim"]) + BL.mda.positioners_clear(kwargs["scan_dim"]) def scanEA(EAlist,**kwargs): """ @@ -348,7 +346,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])) - mda.fillin_table(pvCalcOut1+'.PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP1,1) + BL.mda.fillin_table(pvCalcOut1+'.PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP1,1) EAlist[1]=arrayP1[0] if kwargs['debug']: print('\npvCalcOut1: ',pvCalcOut1) @@ -357,7 +355,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])) - mda.fillin_table(pvCalcOut1+'PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP1,1) + 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 @@ -367,8 +365,8 @@ def scanEA(EAlist,**kwargs): EAlist[2]=caget(pvCalcOut2+'.VAL') arrayP1=list(np.full(sweeps, EAlist[1])) arrayP2=list(np.full(sweeps, EAlist[2])) - mda.fillin_table(pvCalcOut1+'.PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP1,1) - mda.fillin_table(pvCalcOut2+'.PROC',"",kwargs["scanIOC"],kwargs["scan_dim"],arrayP2,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) if kwargs['debug']: print("\npvCalcOut1",pvCalcOut1) print("\npvCalcOut2",pvCalcOut2) @@ -388,10 +386,10 @@ def scanEA(EAlist,**kwargs): if kwargs['debug']: print("Clearing scan positioners and filling in sweeps") #Fill in Sweeps scan - mda.positioners_clear(**kwargs) + BL.mda.positioners_clear(**kwargs) VAL="" RBV="" - mda.fillin(VAL,RBV,1,sweeps,1,**kwargs) + BL.mda.fillin(VAL,RBV,1,sweeps,1,**kwargs) if kwargs['debug']: scanPV="29id"+kwargs["scanIOC"]+":scan"+str(kwargs["scan_dim"]) print("scanPV: "+scanPV) @@ -414,11 +412,11 @@ def scanEA(EAlist,**kwargs): time.sleep(10) EA.put(EAlist[1]-.05,EAlist[-3],LensMode="Angular") time.sleep(2) - mda.go(**kwargs) + BL.mda.go(**kwargs) #After scan EA_log_update() scanEA_reset(**kwargs) - mda.table_reset_after(**kwargs) + BL.mda.table_reset_after(**kwargs) else: return EAparms @@ -445,10 +443,10 @@ def scanFM(RoughPositions,thList,EAlist,**kwargs): if kwargs['debug']: print(x,y,z,th,chi,phi) - mda.fillin_table(ARPES_motor_dictionary("th")[1],ARPES_motor_dictionary("th")[0],th,positioner_num=1) - mda.fillin_table(ARPES_motor_dictionary("x")[1],ARPES_motor_dictionary("x")[0],x,positioner_num=2) - mda.fillin_table(ARPES_motor_dictionary("y")[1],ARPES_motor_dictionary("y")[0],y,positioner_num=3) - mda.fillin_table(ARPES_motor_dictionary("z")[1],ARPES_motor_dictionary("z")[0],z,positioner_num=4) + BL.mda.fillin_table(ARPES_Motors._motor_dictionary("th")[1],ARPES_Motors._motor_dictionary("th")[0],th,positioner_num=1) + BL.mda.fillin_table(ARPES_Motors._motor_dictionary("x")[1],ARPES_Motors._motor_dictionary("x")[0],x,positioner_num=2) + BL.mda.fillin_table(ARPES_Motors._motor_dictionary("y")[1],ARPES_Motors._motor_dictionary("y")[0],y,positioner_num=3) + BL.mda.fillin_table(ARPES_Motors._motor_dictionary("z")[1],ARPES_Motors._motor_dictionary("z")[0],z,positioner_num=4) #setting up EA EAkwargs={ @@ -461,7 +459,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) - mda.go(**kwargs) + BL.mda.go(**kwargs) EA_log_update() scanEA_reset(**kwargs) @@ -520,7 +518,7 @@ def mvth_interp(RoughPositions, thVal,**kwargs): x,y,z,th,chi,phi=interpRoughPositions(RoughPositions,thVal,thVal-.1,1,**kwargs) Pos=[x[0],y[0],z[0],th[0],chi[0],phi[0]] #print("Pos = ",Pos) - ARPES_mvsample(Pos) + ARPES_Motors.mvsample(Pos) def scanEA_hv(hv_start_stop_step_lists,EAlist=[],**kwargs): """ @@ -574,10 +572,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) - mda.go(**kwargs) + BL.mda.go(**kwargs) #After scan scanEA_reset(**kwargs) - mda.table_reset_after(**kwargs) + 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) @@ -617,7 +615,7 @@ def scanEA_motor(EAlist, motor,start,stop,step,mode='absolute',**kwargs): scan_dim=2 #hard coded kwargs.update({'scan_dim':scan_dim}) - ARPES_motor_scan(motor,start,stop,step,**kwargs) + ARPES_Motors.scan(motor,start,stop,step,**kwargs) if kwargs['debug']: print("ScanGo scan_dim = ",scan_dim) @@ -664,7 +662,7 @@ def scanEA_Mesh(EAlist,y_start_stop_step,z_start_stop_step,**kwargs): outer_scan_dim=3 #hard coded inner_loop_list = y_start_stop_step.insert(0,"y") outer_loop_list = z_start_stop_step.insert(0,"z") - ARPES_scan_2D(inner_loop_list,outer_loop_list,outer_scan_dim,**kwargs) + ARPES_Motors.scan_2D(inner_loop_list,outer_loop_list,outer_scan_dim,**kwargs) if kwargs['debug']: print("ScanGo scan_dim = ",outer_scan_dim) @@ -672,7 +670,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) - mda.go(scan_dim=outer_scan_dim) + BL.mda.go(scan_dim=outer_scan_dim) EA_log_update() #After scan diff --git a/iexcode/instruments/logfile.py b/iexcode/instruments/logfile.py index dec2ce2547f2096f5ebeda2597e496a1723b44d4..cde224d887f9755152f7aefd9450a53fb81f19ac 100644 --- a/iexcode/instruments/logfile.py +++ b/iexcode/instruments/logfile.py @@ -3,8 +3,6 @@ from os.path import join,isfile from epics import caget, caput from iexcode.instruments.IEX_endstations import * from iexcode.instruments.utilities import today -from iexcode.instruments.ARPES import ARPES_log_entries -from iexcode.instruments.Kappa import Kappa_log_entries ############################################################################################################## @@ -20,10 +18,8 @@ def log_update(): """ updates the log file with the last scan info """ - if BL.endstation_name == 'ARPES': - entry_list,pv_list, format_list = ARPES_log_entries() - elif BL.endstation_name == 'Kappa': - entry_list,pv_list, format_list = Kappa_log_entries() + + entry_list,pv_list, format_list = BL.log_entries() logfile_update(BL.endstation_name,BL.ioc,entry_list,pv_list,format_list) diff --git a/iexcode/instruments/mpa.py b/iexcode/instruments/mpa.py index 6408b462eb1ab840d591207d7a6d0ec37d3794d7..a9477f032666e5bb721717f16a876a85a1b7fd76 100644 --- a/iexcode/instruments/mpa.py +++ b/iexcode/instruments/mpa.py @@ -4,10 +4,10 @@ import socket from epics import caget, caput from iexcode.instruments.userCalcs import userCalcOut_clear,userStringSeq_clear -from iexcode.instruments.Kappa import Kappa_motor_dictionary,Kappa_cts, mda +from iexcode.instruments.scalers import Kappa_scaler from iexcode.instruments.AD_utilities import AD_ROI_setup -from iexcode.instruments.scalers import scaler_cts -from iexcode.instruments.scanRecord import * +from iexcode.instruments.scanRecord import ScanRecord +from iexcode.instruments.IEX_endstations import BL """ @@ -19,399 +19,409 @@ To do, get busy record in the mpa ioc, get user calcs in the mpa ioc ############################## PVs ############################## ############################################################################################################## mpa_pv = "29iddMPA:" -mpaDet_pv = mpa_pv + "det1:" mpa_busy = "29idcScienta:mybusy2" -userCalc_pv = "29idTest" +userCalc_ioc = "29idTest:" DAC_pv = '29iddau1:dau1:011:DAC' -max_HV = 2990 -ratio = 500 -tth_dLLM=13.73 -tth_dHLM=23.73 - - -def mpa_reset_pv(): - """ - returns the pv used for resetting the mpa - "writing a 1 resets" - """ - return mpa_pv+'C1O' - -def mpa_on_off_pv(): - """ - returns the pv used for turning on/off the mpa - on => caput 1 - off => caput0 - """ - return mpa_pv+'C0O' - -def mpa_HV_pvs(): - """ - returns the pvs for the userCalcout which hold the pvs for the mpa high voltage - """ - val_pv = "29idKappa:userCalcOut9.A" - rbv_pv ="29idKappa:userCalcOut10.OVAL" - return val_pv, rbv_pv - -############################################################################################################## -############################## HV Control ############################## -############################################################################################################## - -def mpa_HV_set(volt,verbose=True): - """ - sets the high voltage for the mpa - - Previously: MPA_HV_Set - """ - val_pv, rbv_pv = mpa_HV_pvs() - volt=min(volt,2990) - - caput(val_pv,volt,wait=True,timeout=18000) - sleep(1) - HV_rbv=caget(rbv_pv) - - if verbose: - print("HV = "+str(HV_rbv)+" V") - - -def mpa_HV_get(): +HV_val_pv = "29idKappa:userCalcOut9.A" +HV_rbv_pv = "29idKappa:userCalcOut10.OVAL" +class MPA: """ - sets the high voltage for the mpa + class for the MPA detector """ - val_pv, rbv_pv = mpa_HV_pvs() - return caget(rbv_pv) + def __init__(self,tth_pv, max_HV = 2990,ratio = 500,tth_dLLM=13.73,tth_dHLM=23.73): + self.pv = mpa_pv + self._reset_pv = mpa_pv+'C1O' + self._det_pv = mpa_pv + "det1:" + self._busy = mpa_busy + self._DAC_pv = DAC_pv + self.max_HV = max_HV + self.ratio = ratio + self.tth_dLLM = tth_dLLM + self.tth_dHLM = tth_dHLM -def mpa_HV_on(): - """ - turns the mpa high voltage on - - Previously: MPA_HV_ON - """ - n_on=1 - tth_pv = Kappa_motor_dictionary('tth')[3] - tth_dial = caget(tth_pv+'.DRBV') - if 13.73<= tth_dial <=23.73: - print('MPA OFF: detector in direct beam (-5 < tth for mcp < 5); move away before turning HV ON.') - else: - caput(mpa_reset_pv,1,wait=True,timeout=18000) - caput(mpa_reset_pv,0,wait=True,timeout=18000) - caput(mpa_on_off_pv,n_on,wait=True,timeout=18000) - print("MPA - HV On") - -def mpa_HV_off(): - """ - turns the mpa high voltage off - - Previously: MPA_HV_OFF - """ - n_off=0 - caput(mpa_on_off_pv,wait=True,timeout=18000) - print("MPA - HV Off") + self._tth_pv = tth_pv + self._reset_pv = mpa_pv+'C1O' #"writing a 1 resets" + self._off_on_pv = mpa_pv+'C0O' #off/on = 0/1 + pass -def mpa_HV_reset(): - """ - resets the mpa high voltage - - Previously: MPA_HV_Reset - """ - caput(mpa_reset_pv,1) - print("MPA - Reset") - -def mpa_HV_scan(start=2400,stop=2990,step=10,**kwargs): - """ - Previously: MPA_HV_scan - """ - kwargs.setdefault('positioner_settling_time',1) - Kappa_cts(1) - val_pv, rbv_pv = mpa_HV_pvs() - mda.fillin(val_pv, rbv_pv,start,stop,step,**kwargs) - mda.go(**kwargs) - -############################################################################################################## -############################## MCP Scripts ############################## -############################################################################################################## -def mpa_ROI_setup(ROI_num=1,xcenter=535,ycenter=539,xsize=50,ysize=50,binX=1,binY=1): - """ - usage: - center of MCP, roiNum = 1 => MPA_ROI_SetUp(1,535,539,50,50) - to set up all use: mpa_ROI_setup_all(xcenter,ycenter) - """ - AD_ROI_setup('29iddMPA',ROI_num,xcenter,ycenter,xsize,ysize,binX,binY) - ROI_pv = mpa_pv+"ROI"+str(ROI_num)+':' - mpa_ROI_stats(ROI_num) + def HV_pvs(self): + """ + returns the pvs for the userCalcout which hold the pvs for the mpa high voltage + """ + val_pv = HV_val_pv + rbv_pv =HV_rbv_pv + return val_pv, rbv_pv + + ############################################################################################################## + ############################## HV Control ############################## + ############################################################################################################## + + def HV_set(self,volt,verbose=True): + """ + sets the high voltage for the mpa + + Previously: MPA_HV_Set + """ + val_pv, rbv_pv = self.HV_pvs() + volt=min(volt,2990) + + caput(val_pv,volt,wait=True,timeout=18000) + sleep(1) + HV_rbv=caget(rbv_pv) + + if verbose: + print("HV = "+str(HV_rbv)+" V") + + + def HV_get(self): + """ + sets the high voltage for the mpa + """ + val_pv, rbv_pv = self.HV_pvs() + + return caget(rbv_pv) + + + def HV_on(self): + """ + turns the mpa high voltage on + + Previously: MPA_HV_ON + """ + try: + n_on=1 + tth_dial = caget(self._tth_pv+'.DRBV') + + if self.tth_dLLM <= tth_dial <= self.tth_dHLM: + print('MPA OFF: detector in direct beam (-5 < tth for mcp < 5); move away before turning HV ON.') + else: + caput(self._reset_pv,1,wait=True,timeout=18000) + caput(self._reset_pv,0,wait=True,timeout=18000) + caput(self._off_on_pv,n_on,wait=True,timeout=18000) + print("MPA - HV On") + except: + print('mpa not running') + + def HV_off(self): + """ + turns the mpa high voltage off + + Previously: MPA_HV_OFF + """ + try: + n_off=0 + caput(self._off_on_pv,n_off,wait=True,timeout=18000) + print("MPA - HV Off") + except: + print('MPA not running') + + + def HV_reset(self): + """ + resets the mpa high voltage + + Previously: MPA_HV_Reset + """ + caput(self._reset_pv,1) + print("MPA - Reset") -def mpa_ROI_setup_all(xcenter=535,ycenter=539): - """ - setup up ROI - 1 => size = 50 x 50 - 2 => size = 100 x 100 - 3 => size = 150 x 150 - 4 => size = 200 x 200 - - """ - mpa_ROI_setup(1,xcenter,ycenter,xsize=50,ysize=50) - mpa_ROI_setup(2,xcenter,ycenter,xsize=100,ysize=100) - mpa_ROI_setup(3,xcenter,ycenter,xsize=150,ysize=150) - mpa_ROI_setup(4,xcenter,ycenter,xsize=200,ysize=200) + def HV_scan(self,start=2400,stop=2990,step=10,**kwargs): + """ + + Previously: MPA_HV_scan + """ + 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) + + ############################################################################################################## + ############################## MCP Scripts ############################## + ############################################################################################################## + def ROI_setup(self,ROI_num=1,xcenter=535,ycenter=539,xsize=50,ysize=50,binX=1,binY=1): + """ + usage: + center of MCP, roiNum = 1 => MPA_ROI_SetUp(1,535,539,50,50) + to set up all use: mpa_ROI_setup_all(xcenter,ycenter) + """ + AD_ROI_setup('29iddMPA',ROI_num,xcenter,ycenter,xsize,ysize,binX,binY) + self._ROI_stats(ROI_num) -def mpa_ROI_stats(ROI_num): - """ - sequence to enable stats for mpa ROI - """ - ROI_pv=mpa_pv+"ROI"+str(ROI_num)+':' - stats_pv=mpa_pv+"Stats"+str(ROI_num)+':' - caput(stats_pv+'NDArrayPort','ROI'+str(ROI_num)) - caput(stats_pv+'EnableCallbacks','Enable') - caput(stats_pv+'ArrayCallbacks','Enable') - caput(stats_pv+'ComputeStatistics','Yes') - caput(stats_pv+'ComputeCentroid','Yes') - caput(stats_pv+'ComputeProfiles','Yes') - -def _mpa_trigger_calcOut(**kwargs): - """ - writes strSeq and calcOut for MPA this should go into the IOC - - **kwargs: - ADplugin = 'TIFF1:' (default) - """ - - kwargs.setdefault("ADplugin","TIFF1:") - kwargs.setdefault("save_image",False) - - ADplugin = mpa_pv + kwargs["ADplugin"] - Proc1 = mpa_pv + "Proc1:" - - #All this should moved into the MPA IOC - Calcs_mda = ScanRecord("29idTest:") - - desc = "MPA busy" - n=9 - busy_CalcOut = userCalcOut_clear(Calcs_mda,n) - caput(busy_CalcOut+".DESC",desc) - caput(busy_CalcOut+".INPA",mpa_busy+" CP") - caput(busy_CalcOut+".OOPT",'Transition to non-zero') - caput(busy_CalcOut+".OUT",start_strSeq+".PROC PP") - - desc = "MPA start" - n=1 - start_strSeq = userStringSeq_clear(Calcs_mda,n) - caput(start_strSeq+".DESC",desc) - caput(start_strSeq+".LNK1", Proc1+"ResetFilter PP") - caput(start_strSeq+".STR1","Yes") - - desc = "MPA wait" - n=10 - wait_CalcOut = userCalcOut_clear(Calcs_mda,n) - caput(wait_CalcOut+".DESC",desc) - caput(wait_CalcOut+".INPA",Proc1+"NumFilter_RBV") - caput(wait_CalcOut+".INPB",Proc1+"NumFiltered_RBV") - caput(wait_CalcOut+".OOPT",'Transition to non-zero') - caput(wait_CalcOut+".OUT",done_strSeq+".PROC PP") - - desc = "MPA writeDone" - n=1 - done_strSeq = userStringSeq_clear(Calcs_mda,n) - caput(done_strSeq+".DESC","MPA writeDone") - caput(done_strSeq+".LNK1", ADplugin+"WriteFile PP") - caput(done_strSeq+".STR1","Write") - caput(done_strSeq+".LNK1", mpa_busy+" PP") - caput(done_strSeq+".STR1","Done") - + def ROI_setup_all(self,xcenter=535,ycenter=539): + """ + setup up ROI + 1 => size = 50 x 50 + 2 => size = 100 x 100 + 3 => size = 150 x 150 + 4 => size = 200 x 200 + + """ + self._ROI_setup(1,xcenter,ycenter,xsize=50,ysize=50) + self._ROI_setup(2,xcenter,ycenter,xsize=100,ysize=100) + self._ROI_setup(3,xcenter,ycenter,xsize=150,ysize=150) + self._ROI_setup(4,xcenter,ycenter,xsize=200,ysize=200) - -def _mpa_trigger_callback(trigger,saveImg=False,**kwargs): - """ - used for triggering the MPA in the scanRecord, reset Proc1 and waits for finish - trigger: adds/removes trigger to mda (True/False) + def ROI_stats(self,ROI_num): + """ + sequence to enable stats for mpa ROI + """ + ROI_pv=self.pv+"ROI"+str(ROI_num)+':' + stats_pv=self.pv+"Stats"+str(ROI_num)+':' + caput(stats_pv+'NDArrayPort','ROI'+str(ROI_num)) + caput(stats_pv+'EnableCallbacks','Enable') + caput(stats_pv+'ArrayCallbacks','Enable') + caput(stats_pv+'ComputeStatistics','Yes') + caput(stats_pv+'ComputeCentroid','Yes') + caput(stats_pv+'ComputeProfiles','Yes') + + def _trigger_calcOut(self,**kwargs): + """ + writes strSeq and calcOut for MPA this should go into the IOC + + **kwargs: + ADplugin = 'TIFF1:' (default) + """ + + kwargs.setdefault("ADplugin","TIFF1:") + kwargs.setdefault("save_image",False) + + ADplugin = self.pv + kwargs["ADplugin"] + Proc1 = self.pv + "Proc1:" + + #All this should moved into the MPA IOC + Calcs_mda = ScanRecord(userCalc_ioc) - **kwargs: - save_image = False used for appropriate trigger of ROIs - = True also saves an image based on ADplugin type - ADplugin = 'TIFF1:' (default + desc = "MPA busy" + n=9 + busy_CalcOut = userCalcOut_clear(Calcs_mda,n) + caput(busy_CalcOut+".DESC",desc) + caput(busy_CalcOut+".INPA",mpa_busy+" CP") + caput(busy_CalcOut+".OOPT",'Transition to non-zero') + caput(busy_CalcOut+".OUT",start_strSeq+".PROC PP") + + desc = "MPA start" + n=1 + start_strSeq = userStringSeq_clear(Calcs_mda,n) + caput(start_strSeq+".DESC",desc) + caput(start_strSeq+".LNK1", Proc1+"ResetFilter PP") + caput(start_strSeq+".STR1","Yes") + + desc = "MPA wait" + n=10 + wait_CalcOut = userCalcOut_clear(Calcs_mda,n) + caput(wait_CalcOut+".DESC",desc) + caput(wait_CalcOut+".INPA",Proc1+"NumFilter_RBV") + caput(wait_CalcOut+".INPB",Proc1+"NumFiltered_RBV") + caput(wait_CalcOut+".OOPT",'Transition to non-zero') + caput(wait_CalcOut+".OUT",done_strSeq+".PROC PP") + + desc = "MPA writeDone" + n=1 + done_strSeq = userStringSeq_clear(Calcs_mda,n) + caput(done_strSeq+".DESC","MPA writeDone") + caput(done_strSeq+".LNK1", ADplugin+"WriteFile PP") + caput(done_strSeq+".STR1","Write") + caput(done_strSeq+".LNK1", mpa_busy+" PP") + caput(done_strSeq+".STR1","Done") + - by default ADplugin = 29iddMPA:TIFF1: - can use 29iddMPA:HDF1: - """ - - kwargs.setdefault("ADplugin","TIFF1:") - kwargs.setdefault("save_image",False) - - ADplugin = mpa_pv + kwargs['ADplugin'] - _mpa_trigger_calcOut(**kwargs) - - if trigger==True: - caput(ADplugin+"AutoResetFilter","Yes") - if saveImg: - caput(ADplugin+"AutoSave", "No") - caput(ADplugin+"EnableCallbacks", "Enable") + def self_trigger_callback(self,trigger,saveImg=False,**kwargs): + """ + used for triggering the MPA in the scanRecord, reset Proc1 and waits for finish - if trigger==False: - caput(ADplugin+"AutoResetFilter","No") - if saveImg: - caput(ADplugin+"EnableCallbacks", "Disable") - caput(ADplugin+"AutoSave", "Yes") - - return mpa_busy - -def _mpa_prefix(**kwargs): - """ - """ - kwargs.setdefault("debug",False) - - fpath=join(dirname(dirname(mda.filepath)),"mpa",'') - nextMDA = mda.fileNum - prefix="mda"+str.zfill(str(nextMDA),4)+"_mpa" - return prefix - -def mpa_trigger(trigger, **kwargs): - """ - Sets up / Cleans up the ScanRecord to trigger the MPA - - trigger: adds/removes trigger to mda (True/False) - + trigger: adds/removes trigger to mda (True/False) + + **kwargs: + save_image = False used for appropriate trigger of ROIs + = True also saves an image based on ADplugin type + ADplugin = 'TIFF1:' (default - **kwargs: - save_image = False used for appropriate trigger of ROIs - = True also saves an image based on ADplugin type - detTrigNum = 2 (default) - scan_dim = 1 (default) - ADplugin = "TIFF1" / "HDF1" - - Previously: MPA_Trigger - """ - kwargs.setdefault("detTrigNum",2) - kwargs.setdefault("save_image",False) - kwargs.setdefault('scan_dim',1) - kwargs.setdefault("ADplugin","TIFF1:") - - mpa_busy = _mpa_trigger_callback(trigger, **kwargs) - - #adding the MPA to the scanRecord trigger - if trigger == True: - _mpa_prefix(**kwargs) - mda.triggers_set(kwargs['scan_dim'],{2:mpa_busy}) - - if trigger == False: - mda.triggers_set(kwargs['scan_dim'],{2:''}) + by default ADplugin = 29iddMPA:TIFF1: + can use 29iddMPA:HDF1: + """ + + kwargs.setdefault("ADplugin","TIFF1:") + kwargs.setdefault("save_image",False) + + ADplugin = self.pv + kwargs['ADplugin'] + + self._trigger_calcOut(**kwargs) + + if trigger==True: + caput(ADplugin+"AutoResetFilter","Yes") + if saveImg: + caput(ADplugin+"AutoSave", "No") + caput(ADplugin+"EnableCallbacks", "Enable") + + if trigger==False: + caput(ADplugin+"AutoResetFilter","No") + if saveImg: + caput(ADplugin+"EnableCallbacks", "Disable") + caput(ADplugin+"AutoSave", "Yes") + + return mpa_busy + + def _mpa_prefix(self,**kwargs): + """ + """ + kwargs.setdefault("debug",False) + + fpath=join(dirname(dirname(BL.mda.filepath)),"mpa",'') + nextMDA = BL.mda.fileNum + prefix="mda"+str.zfill(str(nextMDA),4)+"_mpa" + return prefix + + def _trigger(self,trigger, **kwargs): + """ + Sets up / Cleans up the ScanRecord to trigger the MPA + + trigger: adds/removes trigger to mda (True/False) + + + **kwargs: + save_image = False used for appropriate trigger of ROIs + = True also saves an image based on ADplugin type + detTrigNum = 2 (default) + scan_dim = 1 (default) + ADplugin = "TIFF1" / "HDF1" + + Previously: MPA_Trigger + """ + kwargs.setdefault("detTrigNum",2) + kwargs.setdefault("save_image",False) + kwargs.setdefault('scan_dim',1) + kwargs.setdefault("ADplugin","TIFF1:") + + mpa_busy = self._mpa_trigger_callback(trigger, **kwargs) + + #adding the MPA to the scanRecord trigger + if trigger == True: + self._mpa_prefix(**kwargs) + BL.mda.triggers_set(kwargs['scan_dim'],{2:mpa_busy}) + + if trigger == False: + BL.mda.triggers_set(kwargs['scan_dim'],{2:''}) -def mpa_save_strSeq(**kwargs): - """ - **kwargs: - ADplugin: "TIFF1:" - """ - kwargs.setdefault("ADplugin","TIFF1:") - - ADplugin = mpa_pv + kwargs["ADplugin"] - - desc = "MCP datamode" - n=2 - strSeq_pv = userStringSeq_clear(mda,n) - caput(strSeq_pv+".DESC",desc) - caput(strSeq_pv+".LNK1",mpaDet_pv+"Acquire CA NMS") - caput(strSeq_pv+".STR1","Done") - caput(strSeq_pv+".WAIT1","Wait") - caput(strSeq_pv+".LNK2",mpaDet_pv+"RunTimeEnable PP NMS") - caput(strSeq_pv+".STR2","1") - caput(strSeq_pv+".WAIT2","Wait") - caput(strSeq_pv+".LNK3",ADplugin+"EnableCallbacks PP NMS") - caput(strSeq_pv+".STR3","1") - -def mpa_freerun_strSeq(): - """ - """ - desc = "MCP freerun" - n=1 - strSeq_pv = userStringSeq_clear(mda,n) - caput(strSeq_pv+".DESC",desc) - caput(strSeq_pv+".LNK1",mpaDet_pv+"Acquire PP NMS") - caput(strSeq_pv+".WAIT1","Wait") - caput(strSeq_pv+".STR1","Done") - caput(strSeq_pv+".LNK2","29iddMPA:TIFF1:EnableCallbacks PP NMS") - caput(strSeq_pv+".STR2","0") - caput(strSeq_pv+".WAIT2","Wait") - caput(strSeq_pv+".LNK3",mpaDet_pv+"RunTimeEnable PP NMS") - caput(strSeq_pv+".STR3","0") - caput(strSeq_pv+".WAIT3","Wait") - caput(strSeq_pv+".LNK4",mpaDet_pv+"Acquire PP NMS") - caput(strSeq_pv+".STR4","Acquire") - - -def mpa_HV_sp_calcOut(): - """ - """ - - desc = "MPA HV SP" - n=9 - calcOut_pv = userCalcOut_clear(mda,n) - - caput(calcOut_pv+".DESC",desc) - caput(calcOut_pv+".A",0) - caput(calcOut_pv+".B",ratio) - caput(calcOut_pv+".C",max_HV) - caput(calcOut_pv+".CALC$","A") - caput(calcOut_pv+".OCAL$","MIN(A/B,C/B)") - caput(calcOut_pv+".OOPT",1) # On Change - caput(calcOut_pv+".DOPT",1) # Use 0CALC - caput(calcOut_pv+".IVOA",0) # Continue Normally - caput(calcOut_pv+".OUT",DAC_pv+" PP NMS") - -def mpa_HV_rbv_calcOut(): - """ - """ - desc = "MPA HV RBV" - n=10 - calcOut_pv = userCalcOut_clear(mda,n) - - caput(calcOut_pv+".DESC",desc) - caput(calcOut_pv+".INPA",DAC_pv+' CP NMS') - caput(calcOut_pv+".B",ratio) - caput(calcOut_pv+".CALC$","A*B") - -def mpa_interlock_mpa(): - """ - """ - desc = "MPA Interlock mpa" - n=7 - calcOut_pv = userCalcOut_clear(mda,n) - - caput(calcOut_pv+".DESC",desc) - tth_pv = Kappa_motor_dictionary('tth')[3] - caput(calcOut_pv+".INPA",tth_pv+".DRBV CP NMS") - caput(calcOut_pv+".B",1) - caput(calcOut_pv+".CALC$","ABS((("+str(tth_dLLM)+"<A && A<"+str(tth_dHLM)+") && (B>0))-1)") - caput(calcOut_pv+".OCAL$",'A') - caput(calcOut_pv+".OOPT",2) # When zero - caput(calcOut_pv+".DOPT",0) # Use CALC - caput(calcOut_pv+".IVOA",0) # Continue Normally - caput(calcOut_pv+".OUT",mpa_on_off_pv()+"PP NMS") + def _save_strSeq(self,**kwargs): + """ + **kwargs: + ADplugin: "TIFF1:" + """ + kwargs.setdefault("ADplugin","TIFF1:") + + ADplugin = self.pv + kwargs["ADplugin"] + + desc = "MCP datamode" + n=2 + strSeq_pv = userStringSeq_clear(BL.mda,n) + caput(strSeq_pv+".DESC",desc) + caput(strSeq_pv+".LNK1",self._det_pv+"Acquire CA NMS") + caput(strSeq_pv+".STR1","Done") + caput(strSeq_pv+".WAIT1","Wait") + caput(strSeq_pv+".LNK2",self._det_pv+"RunTimeEnable PP NMS") + caput(strSeq_pv+".STR2","1") + caput(strSeq_pv+".WAIT2","Wait") + caput(strSeq_pv+".LNK3",ADplugin+"EnableCallbacks PP NMS") + caput(strSeq_pv+".STR3","1") + + def _freerun_strSeq(self): + """ + """ + desc = "MCP freerun" + n=1 + strSeq_pv = userStringSeq_clear(BL.mda,n) + caput(strSeq_pv+".DESC",desc) + caput(strSeq_pv+".LNK1",self._det_pv+"Acquire PP NMS") + caput(strSeq_pv+".WAIT1","Wait") + caput(strSeq_pv+".STR1","Done") + caput(strSeq_pv+".LNK2","29iddMPA:TIFF1:EnableCallbacks PP NMS") + caput(strSeq_pv+".STR2","0") + caput(strSeq_pv+".WAIT2","Wait") + caput(strSeq_pv+".LNK3",self._det_pv+"RunTimeEnable PP NMS") + caput(strSeq_pv+".STR3","0") + caput(strSeq_pv+".WAIT3","Wait") + caput(strSeq_pv+".LNK4",self._det_pv+"Acquire PP NMS") + caput(strSeq_pv+".STR4","Acquire") + + + def _HV_sp_calcOut(self): + """ + """ + + desc = "MPA HV SP" + n=9 + calcOut_pv = userCalcOut_clear(BL.mda,n) + + caput(calcOut_pv+".DESC",desc) + caput(calcOut_pv+".A",0) + caput(calcOut_pv+".B",self.ratio) + caput(calcOut_pv+".C",self.max_HV) + caput(calcOut_pv+".CALC$","A") + caput(calcOut_pv+".OCAL$","MIN(A/B,C/B)") + caput(calcOut_pv+".OOPT",1) # On Change + caput(calcOut_pv+".DOPT",1) # Use 0CALC + caput(calcOut_pv+".IVOA",0) # Continue Normally + caput(calcOut_pv+".OUT",self._DAC_pv+" PP NMS") + + def _HV_rbv_calcOut(self): + """ + """ + desc = "MPA HV RBV" + n=10 + calcOut_pv = userCalcOut_clear(BL.mda,n) + + caput(calcOut_pv+".DESC",desc) + caput(calcOut_pv+".INPA",DAC_pv+' CP NMS') + caput(calcOut_pv+".B",self.ratio) + caput(calcOut_pv+".CALC$","A*B") + + def _interlock_mpa(self): + """ + """ + desc = "MPA Interlock mpa" + n=7 + calcOut_pv = userCalcOut_clear(BL.mda,n) + + caput(calcOut_pv+".DESC",desc) + tth_pv = self._tth_pv + caput(calcOut_pv+".INPA",tth_pv+".DRBV CP NMS") + caput(calcOut_pv+".B",1) + caput(calcOut_pv+".CALC$","ABS((("+str(self.tth_dLLM)+"<A && A<"+str(self.tth_dHLM)+") && (B>0))-1)") + caput(calcOut_pv+".OCAL$",'A') + caput(calcOut_pv+".OOPT",2) # When zero + caput(calcOut_pv+".DOPT",0) # Use CALC + caput(calcOut_pv+".IVOA",0) # Continue Normally + caput(calcOut_pv+".OUT",self._off_on_pv()+"PP NMS") -def mpa_interlock_DAC(): - """ - """ - desc = "MPA Interlock DAC" - n=8 - calcOut_pv = userCalcOut_clear(mda,n) - - caput(calcOut_pv+".DESC",desc) - tth_pv = Kappa_motor_dictionary('tth')[3] - caput(calcOut_pv+".INPA",tth_pv+".DRBV CP NMS") - caput(calcOut_pv+".B",1) - caput(calcOut_pv+".CALC$","ABS((("+str(tth_dLLM)+"<A && A<"+str(tth_dHLM)+") && (B>0))-1)") - caput(calcOut_pv+".OCAL$",'A') - caput(calcOut_pv+".OOPT",2) # When zero - caput(calcOut_pv+".DOPT",0) # Use CALC - caput(calcOut_pv+".IVOA",0) # Continue Normally - caput(calcOut_pv+".OUT",DAC_pv+"_Se PP NMS") + def _interlock_DAC(self): + """ + """ + desc = "MPA Interlock DAC" + n=8 + calcOut_pv = userCalcOut_clear(BL.mda,n) + + caput(calcOut_pv+".DESC",desc) + tth_pv = self._tth_pv + caput(calcOut_pv+".INPA",tth_pv+".DRBV CP NMS") + caput(calcOut_pv+".B",1) + caput(calcOut_pv+".CALC$","ABS((("+str(self.tth_dLLM)+"<A && A<"+str(self.tth_dHLM)+") && (B>0))-1)") + caput(calcOut_pv+".OCAL$",'A') + caput(calcOut_pv+".OOPT",2) # When zero + caput(calcOut_pv+".DOPT",0) # Use CALC + caput(calcOut_pv+".IVOA",0) # Continue Normally + caput(calcOut_pv+".OUT",self._DAC_pv+"_Se PP NMS") def reset_mpa_HV(): """ diff --git a/iexcode/instruments/resolution.py b/iexcode/instruments/resolution.py index a34f8919c7df6eca028e3216ec5b13e3d5973da2..cd8c8367cf08540c76971236c93793493377778d 100644 --- a/iexcode/instruments/resolution.py +++ b/iexcode/instruments/resolution.py @@ -1,9 +1,35 @@ import numpy as np -from iexcode.instruments.electron_analyzer import resolution_EA +from epics import caget + +from iexcode.instruments.utilities import take_closest_value +from iexcode.instruments.xrays import get_branch, getE, slit_get +from iexcode.instruments.VLS_PGM import mono_grating_get +from iexcode.instruments.electron_analyzer import EA, resolution_EA, getSESslit +from iexcode.instruments.ARPES import ARPES_extra_pvs ############################################################################################################# ############################## Resolution ############################## ############################################################################################################# +def resolution(): + """ + Calculate the theoretical resolution for the current beamline settings: + ARPES: total resolution i.e. sqrt(kbT^2 + analyzer^2 + BL^2); default SES slit = 5. + Kappa: beamline contribution only + """ + branch = get_branch() + grt = mono_grating_get() + hv_eV = getE() + slit_size = take_closest_value([10,20,50,100,200],round(slit_get(),0)) + + if branch == "c": + slit_SES = getSESslit() + PE = int(EA.PassEnergy) + T = caget(ARPES_extra_pvs['TA']) + resolution_ARPES(grt,hv_eV,slit_size,PE,slit_SES,T,verbose=True) + else: + resolution_beamline(grt,hv_eV,slit_size,verbose=True) + + def resolution_calculate_beamline(grt,hv_eV,slit_size): """ diff --git a/iexcode/instruments/scratch.py b/iexcode/instruments/scratch.py deleted file mode 100644 index ded5e799532a9f085e7e81f233ff0d2a7e4267a8..0000000000000000000000000000000000000000 --- a/iexcode/instruments/scratch.py +++ /dev/null @@ -1,44 +0,0 @@ -############################################################################################################## -############################## setting folder from ARPES ############################## -############################################################################################################## -def folders_ARPES(user_name,**kwargs): - """ - Create and sets (if create_only=False) all the folders the current run and ARPES user - Sets the FileName for logging to be "UserName/YYYYMMDD_log.txt using logname_Set()" - - **kwargs: - set_folders = True (default); set the mda and EA scanRecords - = False; only makes the folders (was create_only) - run: run cycle e.g. 2022_1 (default => check_run() ) - ftp = True / False (default); print what needs to be added to the ftps crontab and create additional ftp folders - mda_ioc: will overwrite the default ioc for mda scans - debug - - """ - kwargs.setdefault('set_folders',True) - kwargs.setdefault('run',check_run()) - kwargs.setdefault('ftp',False) - kwargs.setdefault('debug',False) - - run = kwargs['run'] - - if kwargs['debug']: - print("run,folder,user_name,ioc,ftp: ",run,BL.folder,user_name,BL.ioc,kwargs['ftp']) - - # Create User Folder: - make_user_folders(run,BL.folder,user_name,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,ARPES_log_header()) - - - #Set up Scienta folders: - try: - userPath = "/net/s29data/export/data_29id"+BL.folder+"/"+run+"/"+user_name+"/" - folders_EA(userPath,filePrefix="EA") - except: - print_warning_message("EA ioc is not running, cannot set folder") \ No newline at end of file diff --git a/iexcode/instruments/staff.py b/iexcode/instruments/staff.py index b9d6eef6b0732753a2c5c190dd1903e2f2d2652c..ba5648b20ddbb97055a2626f03afbdec84e006b3 100644 --- a/iexcode/instruments/staff.py +++ b/iexcode/instruments/staff.py @@ -1,10 +1,6 @@ from os import listdir,mkdir,chmod from os.path import join, isfile, exists -#from .ARPES import folders_ARPES -#from .Kappa import folders_Kappa - - def folders_startup(run): """ Creates the run directories for the following: diff --git a/iexcode/instruments/xrays.py b/iexcode/instruments/xrays.py index aa029404a075cb0b00ddbf7f9878598afc57032b..b4a4c1883e8164297706e38a2faefeafd0047e07 100644 --- a/iexcode/instruments/xrays.py +++ b/iexcode/instruments/xrays.py @@ -8,7 +8,6 @@ from time import sleep from epics import caget,caput from iexcode.instruments.IEX_endstations import BL -from iexcode.instruments.resolution import * from iexcode.instruments.IEX_VPU import * from iexcode.instruments.VLS_PGM import * from iexcode.instruments.slits import * @@ -18,13 +17,12 @@ from iexcode.instruments.diagnostics import * from iexcode.instruments.m3r import * from iexcode.instruments.logfile import * from iexcode.instruments.utilities import print_warning_message,make_table, take_closest_value -from iexcode.instruments.mpa import * from iexcode.instruments.current_amplifiers import ca_average -from iexcode.instruments.beamline import branch_cams_enable +from iexcode.instruments.beamline import endstation_cams_enable + +from iexcode.instruments.MPA import mpa_HV_on,mpa_HV_off + -from iexcode.instruments.ARPES import ARPES_mprint,ARPES_extra_pvs -from iexcode.instruments.Kappa import Kappa_mprint -from iexcode.instruments.electron_analyzer import getSESslit, EA ############################################################################################################## ############################## resets and detector lists ############################## ############################################################################################################## @@ -104,10 +102,9 @@ 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({'ARPES':ARPES_mprint()}) - print("ARPES = ",ARPES_mprint()) - vals.update({'Kappa':Kappa_mprint()}) - print("Kappa = ",Kappa_mprint()) + vals.update({BL.endstation:BL.Motors.mprint()}) + print(BL.endstation+" = ",BL.Motors.mprint()) + print("===========================================================") return vals @@ -143,12 +140,12 @@ def xrays_log_entries(**kwargs): #endstation info if BL.endstation_name == 'ARPES': - endstation_entry, endstation_pv, endstation_format = ARPES_log_entries(**kwargs) + endstation_entry, endstation_pv, endstation_format = 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 = Kappa_log_entries(**kwargs) + endstation_entry, endstation_pv, endstation_format = BL.log_entries(**kwargs) entry_list.append(endstation_entry[:-7]) pv_list.append(endstation_pv[:-7]) format_list.append(endstation_format[:-7]) @@ -167,7 +164,7 @@ def xrays_log_entries(**kwargs): #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 = Kappa_log_entries(**kwargs) + endstation_entry, endstation_pv, endstation_format = BL.log_entries(**kwargs) entry_list.append(endstation_entry[-7:]) pv_list.append(endstation_pv[-7:]) format_list.append(endstation_format[-7:]) @@ -289,7 +286,7 @@ def scan_ID(ID_sp_start,ID_sp_stop,ID_sp_step,**kwargs): scan the ID set point """ val_pv,rbv_pv = ID_scan_pvs() - mda.fillin(val_pv,rbv_pv,ID_sp_start,ID_sp_stop,ID_sp_step,**kwargs) + BL.mda.fillin(val_pv,rbv_pv,ID_sp_start,ID_sp_stop,ID_sp_step,**kwargs) def mvmono(val): @@ -357,12 +354,12 @@ def scanhv(start,stop,step,average_pnts=1,**kwargs): """ ca_average(average_pnts) - mono_scan_fillin(mda,start,stop,step,**kwargs) + mono_scan_fillin(BL.mda,start,stop,step,**kwargs) mono_energy_set(start) - mda.go(**kwargs) + BL.mda.go(**kwargs) - mono_scan_after(mda) + mono_scan_after(BL.mda) def scanE(start,stop,step,ID_offset=0,mesh='stay',average_pnts=1,scan_dim=1,**kwargs): @@ -447,8 +444,8 @@ def scanXAS(ID_eV,start_stop_step_lists,**kwargs): #Setting everything back mono_energy_set(ID_eV) - mono_scan_after(mda,scan_dim) - mda.table_reset_after(scan_dim) + mono_scan_after(BL.mda,scan_dim) + BL.mda.table_reset_after(scan_dim) if BL.branch == "d": if kwargs["mcp"]: @@ -487,10 +484,10 @@ def scanXAS_BL(start_stop_step_lists,**kwargs): mono_array,ID_array = BL_energy_tables(start_stop_step_lists) kwargs.update('positioner_num',1) - mono_scan_fillin_table(mda,scan_dim,mono_array,**kwargs) + mono_scan_fillin_table(BL.mda,scan_dim,mono_array,**kwargs) kwargs.update('positioner_num',2) - ID_scan_fillin_table(mda,scan_dim,ID_array,**kwargs) + ID_scan_fillin_table(BL.mda,scan_dim,ID_array,**kwargs) #Averaging and Normalization ca_average(kwargs['average_pnts']) @@ -512,8 +509,8 @@ def scanXAS_BL(start_stop_step_lists,**kwargs): #Setting everything back mono_energy_set(mono_array[0]) - mono_scan_after(mda,scan_dim) - mda.table_reset_after(scan_dim) + mono_scan_after(BL.mda,scan_dim) + BL.mda.table_reset_after(scan_dim) if BL.branch == "d": if kwargs["mcp"]: @@ -626,7 +623,7 @@ def switch_branch(branch, force=False, shutter=True,scan_reset=True,enable_cams= BL.mda.reset() if enable_cams: - branch_cams_enable(branch) + endstation_cams_enable(branch) else: print_warning_message(branch+' is not a valid branch selection') @@ -677,24 +674,7 @@ def slit_get(verbose=True): print(message) return slit_size,slit_center -def resolution(): - """ - Calculate the theoretical resolution for the current beamline settings: - ARPES: total resolution i.e. sqrt(kbT^2 + analyzer^2 + BL^2); default SES slit = 5. - Kappa: beamline contribution only - """ - branch = get_branch() - grt = mono_grating_get() - hv_eV = getE() - slit_size = take_closest_value([10,20,50,100,200],round(slit_get(),0)) - if branch == "c": - slit_SES = getSESslit() - PE = int(EA.PassEnergy) - T = caget(ARPES_extra_pvs['TA']) - resolution_ARPES(grt,hv_eV,slit_size,PE,slit_SES,T,verbose=True) - else: - resolution_beamline(grt,hv_eV,slit_size,verbose=True)