diff --git a/build/lib/iexcode/init_Kapp.py b/build/lib/iexcode/init_Kapp.py index 0ef1a887c02017f3a40fce88c37dcae46a6d0fb1..d0b32195c0745aa89403f7fcf0f0c09141342f8d 100644 --- a/build/lib/iexcode/init_Kapp.py +++ b/build/lib/iexcode/init_Kapp.py @@ -1,6 +1,6 @@ -from iexcode.instruments.Kappa import * -from iexcode.instruments.Kappa_det import * +from iexcode.instruments.kappa import * +from iexcode.instruments.kappa_det import * from iexcode.instruments.Kappa_Euler import * from iexcode.instruments.current_amplifiers import * diff --git a/build/lib/iexcode/instruments/AD_utilites.py b/build/lib/iexcode/instruments/AD_utilites.py index f8d43d23aed84bf5a1ee86d46cefdbb81f5d1ffa..9828834bfa96f6d2cc63625a048394df22e343f8 100644 --- a/build/lib/iexcode/instruments/AD_utilites.py +++ b/build/lib/iexcode/instruments/AD_utilites.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_BL_config import * 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 90001dd85fb09d9ac5e0ac1d9f2fc297f894b099..81517b4342da01fdff2c0ab7720bd2bcf545541b 100644 --- a/build/lib/iexcode/instruments/ARPES.py +++ b/build/lib/iexcode/instruments/ARPES.py @@ -4,7 +4,7 @@ from time import sleep from epics import caget,caput,PV import iexcode.instruments.cfg as iex -from iexcode.instruments.IEX_endstations import Endstation +from iexcode.instruments.IEX_BL_config import Beamline_Config from iexcode.instruments.cameras import _enable_endstation_cameras from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda @@ -25,7 +25,7 @@ from iexcode.instruments.shutters import branch_shutter_close from iexcode.instruments.slits import slit3C_get #endstation specific from iexcode.instruments.Lakeshore_335 import Lakeshore_reset -from iexcode.instruments.electron_analyzer import EA_init_Motors,folders_EA,EA +from iexcode.instruments.electron_analyzer import _EA_init_Motors,folders_EA,EA default_ioc = '29idARPES:' ############################################################################# @@ -55,7 +55,7 @@ def ARPES_init(*userName,**kwargs): ARPES_Motors = Motors('ARPES',_ARPES_motor_dictionary(),physical_motors,psuedo_motors) #endstation - iex.BL = Endstation('ARPES',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],ARPES_Motors) + iex.BL = Beamline_Config('ARPES',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],ARPES_Motors) iex.BL.safe_state = ARPES_safe_state iex.BL.endstation_get = ARPES_get_all @@ -77,7 +77,7 @@ def ARPES_init(*userName,**kwargs): #EA if EA.connected: EA.get() - EA_init_Motors(ARPES_Motors) + _EA_init_Motors(ARPES_Motors) else: print("NOTE: Scienta IOC is not running") @@ -346,7 +346,7 @@ def _ARPES_scan_before_sequence(**kwargs): #sequence put CAs in passive ca_list = _ARPES_detector_list() for (i,ca) in enumerate(ca_list): - ca_pv = Keithley_pv(ca[0], ca[1])+':read.SCAN PP NMS' + ca_pv = _Keithley_pv(ca[0], ca[1])+':read.SCAN PP NMS' caput(before_scan_pv+".LNK" +str(i+1),ca_pv) caput(before_scan_pv+".STR" +str(i+1),"Passive") @@ -357,7 +357,7 @@ def _ARPES_ca_live_sequence(**kwargs): """ kwargs.setdefault('seq_num',7) - ca_live_sequence_proc = ca_live_sequence(iex.BL.ioc,kwargs['seq_num'],_ARPES_detector_list()) + ca_live_sequence_proc = _ca_live_sequence(iex.BL.ioc,kwargs['seq_num'],_ARPES_detector_list()) return ca_live_sequence_proc def _ARPES_scan_after_sequence(**kwargs): @@ -427,7 +427,7 @@ def _ARPES_detector_triggers_sequence(**kwargs): # do we need to add 29idb:ca ca_list = _ARPES_detector_list() last = len(ca_list) for i,ca in enumerate(ca_list): - ca_pv = Keithley_pv(ca[0], ca[1])+':read.PROC CA NMS' + ca_pv = _Keithley_pv(ca[0], ca[1])+':read.PROC CA NMS' caput(detector_triggers_pv+".LNK" +str(i+1),ca_pv) caput(detector_triggers_pv+".WAIT"+str(i+1),"After"+str(last)) diff --git a/build/lib/iexcode/instruments/FMB_mirrors.py b/build/lib/iexcode/instruments/FMB_mirrors.py index 083b9e69e3a6cb39a8a2cca14b7a7d363f458827..d389584e9fa5f77bf7c8ba7ed5239158fc0d0cdf 100644 --- a/build/lib/iexcode/instruments/FMB_mirrors.py +++ b/build/lib/iexcode/instruments/FMB_mirrors.py @@ -2,7 +2,7 @@ from time import sleep from epics import caget, caput -from iexcode.instruments.IEX_endstations import * +from iexcode.instruments.IEX_BL_config import * from iexcode.instruments.utilities import read_dict, print_warning_message M0M1_fpath="/home/beams22/29IDUSER/Documents/User_Macros/Macros_29id/IEX_Dictionaries/Dict_IDCal.txt" diff --git a/build/lib/iexcode/instruments/Kappa.py b/build/lib/iexcode/instruments/Kappa.py index edd6198526d0c51d10ab84a0a6a2ab114971a209..2d6bb236e0f89d802a455763df59348d6ea9a0c2 100644 --- a/build/lib/iexcode/instruments/Kappa.py +++ b/build/lib/iexcode/instruments/Kappa.py @@ -5,7 +5,7 @@ from math import floor from epics import caget, caput,PV import iexcode.instruments.cfg as iex -from iexcode.instruments.IEX_endstations import Endstation +from iexcode.instruments.IEX_BL_config import Beamline_Config from iexcode.instruments.cameras import _enable_endstation_cameras from iexcode.instruments.staff import staff_detector_dictionary @@ -18,14 +18,14 @@ from iexcode.instruments.utilities import * from iexcode.instruments.userCalcs import userStringSeq_clear, userStringSeq_pvs, userCalcOut_clear from iexcode.instruments.Motors import Motors -from iexcode.instruments.current_amplifiers import SRS, ca_reset_all, Keithley_pv +from iexcode.instruments.current_amplifiers import SRS, ca_reset_all, _Keithley_pv from iexcode.instruments.valves import branch_valve_close from iexcode.instruments.shutters import branch_shutter_close #branch specific from iexcode.instruments.slits import slit3D_get #endstation specific -from iexcode.instruments.Kappa_det import Kappa_Detector +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 @@ -58,7 +58,7 @@ def Kappa_init(*userName,**kwargs): Kappa_Motors = Motors('Kappa',_Kappa_motor_dictionary(),physical_motors,psuedo_motors) #endstation - iex.BL = Endstation('Kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],Kappa_Motors) + iex.BL = Beamline_Config('Kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['BL_mode'],Kappa_Motors) #setting folders if kwargs['set_folders']: @@ -494,7 +494,7 @@ def _Kappa_detector_triggers_sequence(scan_ioc,scan_dim,**kwargs): # do we ne ca_list = _Kappa_detector_list() last = len(ca_list) for i,ca in enumerate(ca_list): - ca_pv = Keithley_pv(ca[0], ca[1])+':read.PROC CA NMS' + ca_pv = _Keithley_pv(ca[0], ca[1])+':read.PROC CA NMS' caput(detector_triggers_pv+".LNK" +str(i+2),ca_pv) caput(detector_triggers_pv+".WAIT"+str(i+2),"After"+str(last)) diff --git a/build/lib/iexcode/instruments/Kappa_Euler.py b/build/lib/iexcode/instruments/Kappa_Euler.py index ea025902dca59755f2a9ad60df51847449ad48f4..20d6047e8ba685bb504e3b5aa26981029a7cdeda 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 * +from iexcode.instruments.IEX_BL_config import * from iexcode.instruments.userCalcs import userCalcOut_clear #### Obsolete? diff --git a/build/lib/iexcode/instruments/Lakeshore_335.py b/build/lib/iexcode/instruments/Lakeshore_335.py index 5acc6b95dd8ba5c3da389836f2b159966a62fd99..3c2784d571404a2ce8f1cb692b6ca77291bac749 100644 --- a/build/lib/iexcode/instruments/Lakeshore_335.py +++ b/build/lib/iexcode/instruments/Lakeshore_335.py @@ -7,7 +7,7 @@ import numpy as np from epics import caget, caput -from iexcode.instruments.IEX_endstations import * +from iexcode.instruments.IEX_BL_config import * from iexcode.instruments.utilities import read_dict def Lakeshore_reset(pv,d): diff --git a/build/lib/iexcode/instruments/Motors.py b/build/lib/iexcode/instruments/Motors.py index 43229d940e8f8c3c82bed02518f30e39aa3767a9..3db6923f1ff73c1209de69c47cae9798572171b3 100644 --- a/build/lib/iexcode/instruments/Motors.py +++ b/build/lib/iexcode/instruments/Motors.py @@ -217,7 +217,7 @@ class Motors: kwargs.setdefault('cts',0.1) kwargs.setdefault('mpa',False) - from iexcode.instruments.IEX_endstations import BL + from iexcode.instruments.IEX_BL_config import BL rbv_pv,val_pv,sgm_pv,pv = self._motor_dictionary[inner_loop_list[0]] inner_loop_list.insert(0,rbv_pv) diff --git a/build/lib/iexcode/instruments/VLS_PGM.py b/build/lib/iexcode/instruments/VLS_PGM.py index 8f7bfdc225a080961c962b0d084059f2b535f179..c4bb2d114bdf9eb2eb0fbd30d7c4038ad2d0f055 100644 --- a/build/lib/iexcode/instruments/VLS_PGM.py +++ b/build/lib/iexcode/instruments/VLS_PGM.py @@ -7,7 +7,7 @@ import numpy as np from epics import caget,caput -from iexcode.instruments.IEX_endstations import * +from iexcode.instruments.IEX_BL_config import * from iexcode.instruments.utilities import print_warning_message,read_dict diff --git a/build/lib/iexcode/instruments/electron_analyzer.py b/build/lib/iexcode/instruments/electron_analyzer.py index 28aaec7386f40d3b97024e1bcdd826378b9acb18..557b1a1301eb647fe50048f9e00a980a1ac27c28 100644 --- a/build/lib/iexcode/instruments/electron_analyzer.py +++ b/build/lib/iexcode/instruments/electron_analyzer.py @@ -13,7 +13,7 @@ import numpy as np from scipy.interpolate import interp1d from epics import caput,caget -from iexcode.instruments.IEX_endstations import * +from iexcode.instruments.IEX_BL_config import * from iexcode.instruments.scanRecord import * from iexcode.instruments.conversions_constants import * diff --git a/build/lib/iexcode/instruments/mpa.py b/build/lib/iexcode/instruments/mpa.py index a9477f032666e5bb721717f16a876a85a1b7fd76..034396dbd695f609f0e5910e19ff35cec8afb499 100644 --- a/build/lib/iexcode/instruments/mpa.py +++ b/build/lib/iexcode/instruments/mpa.py @@ -7,7 +7,7 @@ from iexcode.instruments.userCalcs import userCalcOut_clear,userStringSeq_clear from iexcode.instruments.scalers import Kappa_scaler from iexcode.instruments.AD_utilities import AD_ROI_setup from iexcode.instruments.scanRecord import ScanRecord -from iexcode.instruments.IEX_endstations import BL +from iexcode.instruments.IEX_BL_config import BL """ diff --git a/build/lib/iexcode/instruments/slits.py b/build/lib/iexcode/instruments/slits.py index 1b323e3ead9d82e35929bd013f277f8cfc7b3bd3..e843bac8ca53de7f353422325a9a23ba63c8e625 100644 --- a/build/lib/iexcode/instruments/slits.py +++ b/build/lib/iexcode/instruments/slits.py @@ -7,7 +7,7 @@ from .IEX_endstations import * from iexcode.instruments.shutters import main_shutter_close from iexcode.instruments.utilities import print_warning_message, read_dict from iexcode.instruments.VLS_PGM import mono_get_all -from iexcode.instruments.encoders import encoders_reset +from iexcode.instruments.encoders import encoders_reset_zero slit_ioc="29idb:" @@ -295,7 +295,7 @@ def slit2B_encoders_reset(Hcenter,Vcenter): Previously: Reset_Slit2B_Encoders """ - encoders_reset('slit2B',Hcenter,Vcenter) + encoders_reset_zero('slit2B',Hcenter,Vcenter) slits_synch('slit2B') @@ -362,7 +362,7 @@ def slit3D_encoders_reset(Hcenter,Vcenter): Previously: Reset_Slit2B_Encoders """ - encoders_reset('slit3D',Hcenter,Vcenter) + encoders_reset_zero('slit3D',Hcenter,Vcenter) slits_synch('slit3D') def exit_slit(branch, size, verbose=True): diff --git a/build/lib/iexcode/instruments/xrays.py b/build/lib/iexcode/instruments/xrays.py index 64822c0b2e424e77a4ae80133c193fa6a27fc4e1..382804e00eae33559e7791917d8e01579ff68e6f 100644 --- a/build/lib/iexcode/instruments/xrays.py +++ b/build/lib/iexcode/instruments/xrays.py @@ -443,7 +443,7 @@ def scanXAS(ID_eV,start_stop_step_lists,**kwargs): #Averaging and Normalization ca_average(kwargs['average_pnts']) if iex.BL.branch=="d": - meshD("In") + mesh_d("In") #Setting the beamline energy energy(ID_eV,m3r=kwargs["m3r"]) @@ -507,7 +507,7 @@ def scanXAS_BL(start_stop_step_lists,**kwargs): #Averaging and Normalization ca_average(kwargs['average_pnts']) if BL.branch=="d": - meshD("In") + mesh_d("In") #Setting the beamline energy apertures_set(mono_array[0],m3r=kwargs["m3r"]) diff --git a/build/lib/iexcode/macros/__init__.py b/build/lib/iexcode/macros/__init__.py index 8ccf3df1571798ce4fa3a305fa3ac5ca11eff3e5..22fb71cbe6c4dbf4d150e410132792ad6b62713f 100644 --- a/build/lib/iexcode/macros/__init__.py +++ b/build/lib/iexcode/macros/__init__.py @@ -5,7 +5,7 @@ from iexcode.instruments.cameras import * from iexcode.instruments.conversions_constants import * from iexcode.instruments.encoders import * from iexcode.instruments.files_and_folders import * -from iexcode.instruments.IEX_endstations import * +from iexcode.instruments.IEX_BL_config import * from iexcode.instruments.Logfile import * from iexcode.instruments.Motors import * from iexcode.instruments.remote_controlers import * diff --git a/build/lib/iexcode/macros/commissioning.py b/build/lib/iexcode/macros/commissioning.py index 80046bc6ef6fccf8a4e58cac90f929a4d383f154..60f7b983b224def32c6e68d20b36751d0ee18ed6 100644 --- a/build/lib/iexcode/macros/commissioning.py +++ b/build/lib/iexcode/macros/commissioning.py @@ -275,7 +275,7 @@ def mono_MIR_GRT_find_offset(grating,slit_list,**kwargs): slit2B_set(2,0.5,0,0) #set zero order, scan grating pitch - for ang in RangeUp(1.5,5,0.5): + for ang in range_up(1.5,5,0.5): print("\r") mono_zero_order(ang) print("Mirror pitch: "+str(ang)+"\r") @@ -339,7 +339,7 @@ def scan_energy_along_grating(hv,peakBE=84,pts=11,r=0.75,i=1,**kwargs): print("\n--------------- Starting core level vs Slit-2B(V) map ---------------") #Take XPS for each Slit-2V position - for V_center in RangeUp(Vstart,-Vstart,Vstep): + for V_center in range_up(Vstart,-Vstart,Vstep): caput(center_val,V_center,wait=True,timeout=18000) kwargs.update({'comment': "2-V center ="+str(V_center)[0:6]}) EAlist=["BE",peakBE,PE,17*60*i,1] @@ -363,7 +363,7 @@ def scan_mono_energy_drift(start,stop,step,peakBE=84,EF=None,**kwargs): ''' kwargs.setdefault('c','3') - for hv in RangeUp(start,stop,step): + for hv in range_up(start,stop,step): energy(hv) c=int(kwargs['c']) exit_slit_vs_hv(hv,c) @@ -792,7 +792,7 @@ def ID_calibration_scan(ID_start,ID_stop,ID_step,bandwidth=10,QP=None,Harm=1,sca log_print(comment="====== Starting Mono Scan vs ID ======") - for ID_energy in RangeUp(ID_start,ID_stop,ID_step): + for ID_energy in range_up(ID_start,ID_stop,ID_step): print("\n------------------ ID-SP @ "+str(ID_energy)+" ------------------") mono_energy_set(ID_energy) ID_SP_set(ID_energy) diff --git a/build/lib/iexcode/macros/start_of_the_week.py b/build/lib/iexcode/macros/start_of_the_week.py index 7ed0cd221a679dfedba817b040ea495fa82f0bd7..f0d0881c2177e63d27e98f2e643c2028390b4ca3 100644 --- a/build/lib/iexcode/macros/start_of_the_week.py +++ b/build/lib/iexcode/macros/start_of_the_week.py @@ -57,7 +57,7 @@ def start_of_the_week(grt,branch,wait=False,**kwargs): if branch == 'c': diode = Keithley('b',15) diode.autoscale() - diodeC('In') + diode_c('In') else: foo=input('Do you have a diode in direct beam (y or n)? >') if foo.lower() == 'y' or foo.lower() == 'yes': @@ -267,7 +267,7 @@ def start_of_the_week(grt,branch,wait=False,**kwargs): ###### Check flux: if 'flux' in kwargs['scanType']: if m3r_branch == 'c': - diodeC('In') + diode_c('In') print("\n\n================== Check Flux:") flag=True while flag: diff --git a/iexcode/instruments/AD_utilities.py b/iexcode/instruments/AD_utilities.py index cfe1930890eddd5dc2bde59f1782aea8caa3d855..c7565cb6430b17098f20335c58ebc5cffdd9434a 100644 --- a/iexcode/instruments/AD_utilities.py +++ b/iexcode/instruments/AD_utilities.py @@ -146,13 +146,13 @@ def AD_DoneSingleSave(ADplugin,**kwargs): Save -> Enable e.g. ADplugin="29id_ps2:TIFF1:" - **kwargs: + **kwargs: P=first part of ADplugin if not specified R="cam1:"; other AD have "det1:" """ kwargs.setdefault("P",ADplugin.split(":")[0]+":") kwargs.setdefault("R","cam1:") - caput(kwargs["P"]+kwargs["R"]+"Acquire","Done",wait=True,timeout=5*60);sleep(.1) + AD_Done(ADplugin,**kwargs) caput(kwargs["P"]+kwargs["R"]+"ImageMode","Single");sleep(.5) caput(ADplugin+"EnableCallbacks","Enable");sleep(.1) @@ -165,17 +165,28 @@ def AD_FreeRun(ADplugin,**kwargs): e.g. ADplugin="29id_ps2:TIFF1:" - **kwargs: + **kwargs: P=first part of ADplugin if not specified R="cam1:"; other AD have "det1:" """ kwargs.setdefault("P",ADplugin.split(":")[0]+":") kwargs.setdefault("R","cam1:") - caput(kwargs["P"]+kwargs["R"]+"Acquire","Done",wait=True,timeout=5*60) + AD_Done(ADplugin,**kwargs) caput(ADplugin+"EnableCallbacks","Disable");sleep(.1) caput(kwargs["P"]+kwargs["R"]+"ImageMode","Continuous");sleep(.1) caput(kwargs["P"]+kwargs["R"]+"Acquire","Acquire");sleep(.1) - + +def AD_Done(ADplugin,**kwargs): + """ + sets acquisition to Done + **kwargs: + P=first part of ADplugin if not specified + R="cam1:"; other AD have "det1:" + """ + kwargs.setdefault("P",ADplugin.split(":")[0]+":") + kwargs.setdefault("R","cam1:") + caput(kwargs["P"]+kwargs["R"]+"Acquire","Done",wait=True,timeout=5*60) + sleep(0.1) def AD_snap(ADplugin,**kwargs): """ diff --git a/iexcode/instruments/ARPES.py b/iexcode/instruments/ARPES.py index 29ead324dc675856a7f0195ebd3f78a06bb53f82..8656d2596c7fa89df17ff760f1d62ab258228b3b 100644 --- a/iexcode/instruments/ARPES.py +++ b/iexcode/instruments/ARPES.py @@ -1,13 +1,13 @@ -import numpy as np +import os from time import sleep - +import numpy as np from epics import caget,caput,PV import iexcode.instruments.cfg as iex -from iexcode.instruments.IEX_endstations import Endstation +from iexcode.instruments.IEX_BL_config import Beamline_Config from iexcode.instruments.cameras import _enable_endstation_cameras -from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda +from iexcode.instruments.files_and_folders import check_run,make_user_folders,folder_mda,path_dserv from iexcode.instruments.Logfile import Logfile from iexcode.instruments.staff import staff_detector_dictionary from iexcode.instruments.xrays import _xrays_detector_dictionary, _xrays_reset, xrays_get_all @@ -25,7 +25,7 @@ from iexcode.instruments.shutters import branch_shutter_close from iexcode.instruments.slits import slit3C_get #endstation specific from iexcode.instruments.Lakeshore_335 import Lakeshore_reset -from iexcode.instruments.electron_analyzer import EA_init_Motors,folders_EA,EA +from iexcode.instruments.electron_analyzer import _EA_init_Motors,folders_EA,EA default_ioc = '29idARPES:' ############################################################################# @@ -55,7 +55,7 @@ def ARPES_init(*userName,**kwargs): ARPES_Motors = Motors('ARPES',_ARPES_motor_dictionary(),physical_motors,pseudo_motors) #endstation - iex.BL = Endstation('ARPES',kwargs['scan_ioc'],kwargs['xrays'],kwargs['mode'],ARPES_Motors) + iex.BL = Beamline_Config('ARPES',kwargs['scan_ioc'],kwargs['xrays'],kwargs['mode'],ARPES_Motors) iex.BL.safe_state = ARPES_safe_state iex.BL.endstation_get = ARPES_get_all @@ -77,7 +77,11 @@ def ARPES_init(*userName,**kwargs): #EA if EA.connected: EA.get() - EA_init_Motors(ARPES_Motors) + _EA_init_Motors(ARPES_Motors) + if kwargs['set_folders']: + userPath = os.path.dirname(iex.BL.mda.filepath) + folders_EA(userPath,filePrefix="EA",**kwargs) + else: print("NOTE: Scienta IOC is not running") @@ -148,7 +152,7 @@ def _ARPES_motor_dictionary(): motor_dictionary={} for name in motor_nums.keys(): - p = '29idc:m'+str(motor_nums[name]) + pv = '29idc:m'+str(motor_nums[name]) motor_dictionary.update({name:[pv+'.RBV',pv+'.VAL',pv+'.SPMG',pv]}) return motor_dictionary @@ -205,7 +209,7 @@ def folders_ARPES(user_name,**kwargs): #Set up Scienta folders: if EA.connected: - userPath = "/net/s29data/export/data_29id"+iex.BL.folder+"/"+run+"/"+user_name+"/" + userPath = path_dserv(iex.BL.folder,run,user_name) folders_EA(userPath,filePrefix="EA") else: print_warning_message("EA ioc is not running, h5 folder not set") @@ -257,29 +261,34 @@ def ARPES_get_all(verbose=True): returns a dictionary with the current status of the ARPES endstation and exit slit """ vals={} - + if verbose: + print("\n===========================================================") #sample position motor_dictionary = _ARPES_motor_dictionary() for motor in motor_dictionary.keys(): vals[motor]=ARPES_Motors.get(motor,verbose=False) - #endstation/branch pvs extra_pvs = ARPES_extra_pvs() for key in extra_pvs.keys(): vals.update(key,caget(extra_pvs[key])) if iex.BL.xrays: vals.update('exit_slit',slit3C_get()) - + if verbose: + for key in vals: + print(key+" = "+vals[key]) + #beamline info if iex.BL.xray: beamline_info = xrays_get_all() vals.update(beamline_info) - - if verbose: - print("-----------------------------------------------------------") - for key in vals: - print(key+" = "+vals[key]) - print("-----------------------------------------------------------") + if verbose: + print("-----------------------------------------------------------") + for key in beamline_info: + print(key+" = "+beamline_info[key]) + print("-----------------------------------------------------------") + + if verbose: + print("\n===========================================================") return vals @@ -346,7 +355,7 @@ def _ARPES_scan_before_sequence(**kwargs): #sequence put CAs in passive ca_list = _ARPES_detector_list() for (i,ca) in enumerate(ca_list): - ca_pv = Keithley_pv(ca[0], ca[1])+':read.SCAN PP NMS' + ca_pv = _Keithley_pv(ca[0], ca[1])+':read.SCAN PP NMS' caput(before_scan_pv+".LNK" +str(i+1),ca_pv) caput(before_scan_pv+".STR" +str(i+1),"Passive") @@ -357,7 +366,7 @@ def _ARPES_ca_live_sequence(**kwargs): """ kwargs.setdefault('seq_num',7) - ca_live_sequence_proc = ca_live_sequence(iex.BL.ioc,kwargs['seq_num'],_ARPES_detector_list()) + ca_live_sequence_proc = _ca_live_sequence(iex.BL.ioc,kwargs['seq_num'],_ARPES_detector_list()) return ca_live_sequence_proc def _ARPES_scan_after_sequence(**kwargs): @@ -427,7 +436,7 @@ def _ARPES_detector_triggers_sequence(**kwargs): # do we need to add 29idb:ca ca_list = _ARPES_detector_list() last = len(ca_list) for i,ca in enumerate(ca_list): - ca_pv = Keithley_pv(ca[0], ca[1])+':read.PROC CA NMS' + ca_pv = _Keithley_pv(ca[0], ca[1])+':read.PROC CA NMS' caput(detector_triggers_pv+".LNK" +str(i+1),ca_pv) caput(detector_triggers_pv+".WAIT"+str(i+1),"After"+str(last)) diff --git a/iexcode/instruments/FMB_mirrors.py b/iexcode/instruments/FMB_mirrors.py index 083b9e69e3a6cb39a8a2cca14b7a7d363f458827..86a131768c29cd942579decf6eaac00cceef15ec 100644 --- a/iexcode/instruments/FMB_mirrors.py +++ b/iexcode/instruments/FMB_mirrors.py @@ -2,13 +2,12 @@ from time import sleep from epics import caget, caput -from iexcode.instruments.IEX_endstations import * +import iexcode.instruments.cfg as iex from iexcode.instruments.utilities import read_dict, print_warning_message M0M1_fpath="/home/beams22/29IDUSER/Documents/User_Macros/Macros_29id/IEX_Dictionaries/Dict_IDCal.txt" - -def FMB_mirror_ioc(mirror_num): +def _FMB_mirror_ioc(mirror_num): """ returns the ioc name for the given mirror number: miror_num = 0 / 1 / 3 for M0 / M1 /M3R respectively @@ -24,7 +23,7 @@ def FMB_mirror_status(mirror_num): status =1 when positioned """ ioc = '29id_'+['M0','M1','','M3R'][mirror_num]+":" - pv = FMB_mirror_ioc(mirror_num) + pv = _FMB_mirror_ioc(mirror_num) status=caget(pv+'SYSTEM_STS') return status @@ -33,7 +32,7 @@ def FMB_mirror_axis_position(mirror_num,axis, verbose=True): """ returns the readback and set point of an FMB mirror """ - pv = FMB_mirror_ioc(mirror_num) + pv = _FMB_mirror_ioc(mirror_num) rbv = round(caget(pv+axis+"_MON"),3) sp = round(caget(pv+axis+"_POS_SP"),3) @@ -47,7 +46,7 @@ def FMB_mirror_get(mirror_num,verbose=True): """ get and returns the current mirror position """ - axis_labels=['Tx','Ty','Tz','Rx','Ry','Rz'] + axis_labels=['TX','TY','TX','RX','RY','RZ'] vals=[] message = "\nM"+str(mirror_num)+" @ " for axis in axis_labels: @@ -68,7 +67,7 @@ def FMB_mirror_move(mirror_num,axis,val,verbose=True): "Previously: Move_M0M1 """ - pv = FMB_mirror_ioc(mirror_num) + pv = _FMB_mirror_ioc(mirror_num) axes = ['TX','TY','TZ','RX','RY','RZ'] if axis in axes: caput(pv+axis+"_SP.PREC",3) @@ -91,7 +90,7 @@ def FMB_mirror_move_all(mirror_num,position_list,verbose=True): "Previously: Move_M0M1 """ - pv = FMB_mirror_ioc(mirror_num) + pv = _FMB_mirror_ioc(mirror_num) for axis in ['TX','TY','TZ','RX','RY','RZ']: caput(pv+axis+"_SP.PREC",3) caput(pv+axis+"_POS_SP") @@ -114,7 +113,7 @@ def FMB_mirror_tweak(mirror_num,axis,val,verbose=False): "Previously: Move_M0M1 """ - pv = FMB_mirror_ioc(mirror_num) + pv = _FMB_mirror_ioc(mirror_num) previous_position = FMB_mirror_axis_position(mirror_num,axis,verbose=False) new_position = previous_position[0] + val FMB_mirror_move(mirror_num,axis,new_position,verbose=False) @@ -131,11 +130,11 @@ def FMB_mirror_scan(mirror_num,start,stop,step): TY = vertical RY = Pitch TZ = longitudinal RZ = Roll """ - pv = FMB_mirror_ioc(mirror_num) + pv = _FMB_mirror_ioc(mirror_num) # database sets .PREC==0. We want more digits than that. caput(pv+"_SP.PREC",3) - mda.fillin(pv+"_SP",pv+"_MON",start,stop,step) + iex.BL.mda.fillin(pv+"_SP",pv+"_MON",start,stop,step) diff --git a/iexcode/instruments/IEX_endstations.py b/iexcode/instruments/IEX_BL_config.py similarity index 93% rename from iexcode/instruments/IEX_endstations.py rename to iexcode/instruments/IEX_BL_config.py index ce1abb4360967574c5593955bfa154539cbd6901..aadf0de623595e8ddd51dbc2fdb7c2f64b1d4700 100644 --- a/iexcode/instruments/IEX_endstations.py +++ b/iexcode/instruments/IEX_BL_config.py @@ -4,7 +4,7 @@ from iexcode.instruments.utilities import print_warning_message import iexcode.instruments.cfg as iex """ -Endstation class is used to contain information about ioc, branch, mode +Beamline_Config class is used to contain information about ioc, branch, mode it makes the default stuff work @@ -14,13 +14,13 @@ init kwargs to see which defaults you can change. #For new endstation modify here: endstations_list = ['ARPES','Kappa'] -class Endstation: +class Beamline_Config: """ used for defining which endstation in which you are running for short names and ioc info BL = Endstation('ARPES') - BL.endstaton: name of endstation ("ARPES" / "Kappa" / "Octupole") + BL.endstation_name: name of endstation ("ARPES" / "Kappa" / "Octupole") BL.ioc: string of scan ioc ('29idb:', '29idTest:') BL.mda: scanRecord object of ioc specified by .ioc @@ -85,7 +85,6 @@ class Endstation: if mode in BL_mode_list: - self.mode = mode if mode == 'user': #For new endstation modify here: @@ -119,6 +118,7 @@ class Endstation: self.endstation_get = kwargs['endstation_get'] + ############################################################################################################## ############################## BL commands ############################## ############################################################################################################## @@ -153,4 +153,11 @@ def BL_mda_filepath(): return iex.BL.filepath ############################################################################################################## +def get_all(verbose=True): + """ + returns the current beamline and endstation setting + """ + vals.update(iex.BL.endstation_get(verbose)) + + return vals diff --git a/iexcode/instruments/Kappa.py b/iexcode/instruments/Kappa.py index 2f07614eeb935932a3c2a3d782085f2d525e621a..e5942a5a089b01762a54e0ef0549beab1abc0407 100644 --- a/iexcode/instruments/Kappa.py +++ b/iexcode/instruments/Kappa.py @@ -5,7 +5,7 @@ from math import floor from epics import caget, caput,PV import iexcode.instruments.cfg as iex -from iexcode.instruments.IEX_endstations import Endstation +from iexcode.instruments.IEX_BL_config import Beamline_Config from iexcode.instruments.cameras import _enable_endstation_cameras from iexcode.instruments.staff import staff_detector_dictionary @@ -18,14 +18,14 @@ from iexcode.instruments.utilities import * from iexcode.instruments.userCalcs import userStringSeq_clear, userStringSeq_pvs, userCalcOut_clear from iexcode.instruments.Motors import Motors -from iexcode.instruments.current_amplifiers import SRS, ca_reset_all, Keithley_pv +from iexcode.instruments.current_amplifiers import SRS, ca_reset_all, _Keithley_pv from iexcode.instruments.valves import branch_valve_close from iexcode.instruments.shutters import branch_shutter_close #branch specific from iexcode.instruments.slits import slit3D_get #endstation specific -from iexcode.instruments.Kappa_det import Kappa_Detector +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 @@ -58,7 +58,7 @@ def Kappa_init(*userName,**kwargs): Kappa_Motors = Motors('Kappa',_Kappa_motor_dictionary(),physical_motors,pseudo_motors) #endstation - iex.BL = Endstation('Kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['mode'],Kappa_Motors) + iex.BL = Beamline_Config('Kappa',kwargs['scan_ioc'],kwargs['xrays'],kwargs['mode'],Kappa_Motors) #setting folders if kwargs['set_folders']: @@ -325,31 +325,34 @@ def Kappa_get_all(verbose=True): """ vals = {} + if verbose: + print("\n===========================================================") #sample postion motor_dictionary = _Kappa_motor_dictionary() for motor in motor_dictionary.keys(): vals[motor]=Kappa_Motors.get(motor,verbose=False) - #endstation/branch pvs extra_pvs = Kappa_extra_pvs() for key in extra_pvs.keys(): vals.update(key,caget(extra_pvs[key])) if iex.BL.xrays: vals.update('exit_slit',slit3D_get()) + vals.update({'mesh':mesh.current}) + if verbose: + for key in vals: + print(key+" = "+vals[key]) #beamline info if iex.BL.xray: beamline_info = xrays_get_all() vals.update(beamline_info) - - mesh.get() - vals.update({'mesh':mesh.current}) - - if verbose: - print("-----------------------------------------------------------") - for key in vals: - print(key+" = "+vals[key]) - print("-----------------------------------------------------------") + if verbose: + print("-----------------------------------------------------------") + for key in beamline_info: + print(key+" = "+vals[key]) + print("-----------------------------------------------------------") + if verbose: + print("\n===========================================================") return vals ############################################################################################################## @@ -494,7 +497,7 @@ def _Kappa_detector_triggers_sequence(scan_ioc,scan_dim,**kwargs): # do we ne ca_list = _Kappa_detector_list() last = len(ca_list) for i,ca in enumerate(ca_list): - ca_pv = Keithley_pv(ca[0], ca[1])+':read.PROC CA NMS' + ca_pv = _Keithley_pv(ca[0], ca[1])+':read.PROC CA NMS' caput(detector_triggers_pv+".LNK" +str(i+2),ca_pv) caput(detector_triggers_pv+".WAIT"+str(i+2),"After"+str(last)) @@ -883,4 +886,24 @@ def Kappa_safe_state(**kwargs): branch_valve_close() - \ No newline at end of file +### uan moves tth and th simultaneously +def uan(tth,th): + """ Moves tth and th motors simultaneously in the in the Kappa chamber + """ + if iex.BL.endstation == 'Kappa': + #move tth and th + mvth(th,wait=False) + mvtth(tth,wait=False) + time.sleep(0.2) + + while True: + status = iex.BL.Motors.status() + if status == 0: + time.sleep(0.2) + else: + tth_RBV=round(iex.BL.Motors.get('tth',verbose=False),3) + th_RBV=round(iex.BL.Motors.get('th',verbose=False),3) + print('tth='+str(tth_RBV)+' th='+str(th_RBV)) + break + else: + print("not a defined move") \ No newline at end of file diff --git a/iexcode/instruments/Kappa_Euler.py b/iexcode/instruments/Kappa_Euler.py deleted file mode 100644 index ea025902dca59755f2a9ad60df51847449ad48f4..0000000000000000000000000000000000000000 --- a/iexcode/instruments/Kappa_Euler.py +++ /dev/null @@ -1,120 +0,0 @@ -import numpy as np -from epics import caget, caput - -from iexcode.instruments.userCalcs import userCalcOut_clear -from iexcode.instruments.IEX_endstations import * -from iexcode.instruments.userCalcs import userCalcOut_clear - -#### Obsolete? - -def Bragg_Index_CalcOut(d,eV,th): - n=8 - userCalcOut_pv = userCalcOut_clear(mda,n) - - h=4.135667516e-15 - c=299792458 - f=h*c*1e9*10 - - caput(userCalcOut_pv+".DESC","Bragg_Index") - caput(userCalcOut_pv+".A",d) - caput(userCalcOut_pv+".B",th) - caput(userCalcOut_pv+".C",eV) - caput(userCalcOut_pv+".D",np.pi) - caput(userCalcOut_pv+".E",f) - caput(userCalcOut_pv+".CALC$","SIN(B*D/"+str(180)+")*"+str(2)+"*A*C/E") - - - -def KtoE_th_CalcOut(): - n=1 - userCalcOut_pv = userCalcOut_clear(mda,n) - - caput(userCalcOut_pv+".DESC","KtoE_th") - caput(userCalcOut_pv+".INPA","29idKappa:m8.RBV CP NMS") #A=kth - caput(userCalcOut_pv+".INPB","29idKappa:m7.RBV CP NMS") #B=kap - caput(userCalcOut_pv+".INPC","29idKappa:m1.RBV CP NMS") #C=kphi - caput(userCalcOut_pv+".D",3.141592653589793) - caput(userCalcOut_pv+".E",180) - caput(userCalcOut_pv+".F",50) - caput(userCalcOut_pv+".H",57.045) - caput(userCalcOut_pv+".CALC$","((A-(G-H))*D/E-ATAN(TAN(B*D/E/2.0)*COS(F*D/E)))*E/D") - caput(userCalcOut_pv+".DOPT",0) # Use CAL - -def KtoE_chi_CalcOut(): - n=2 - userCalcOut_pv = userCalcOut_clear(mda,n) - - caput(userCalcOut_pv+".DESC","KtoE_chi") - caput(userCalcOut_pv+".INPA","29idKappa:m8.RBV CP NMS") #A=kth - caput(userCalcOut_pv+".INPB","29idKappa:m7.RBV CP NMS") #B=kap - caput(userCalcOut_pv+".INPC","29idKappa:m1.RBV CP NMS") #C=kphi - caput(userCalcOut_pv+".D",3.141592653589793) - caput(userCalcOut_pv+".E",180) - caput(userCalcOut_pv+".F",50) - caput(userCalcOut_pv+".CALC$","(2*ASIN(SIN(B*D/E/2.0) * SIN(F*D/E)))*E/D") - caput(userCalcOut_pv+".DOPT",0) # Use CAL - -def KtoE_phi_CalcOut(): - n=3 - userCalcOut_pv = userCalcOut_clear(mda,n) - - caput(userCalcOut_pv+".DESC","KtoE_phi") - caput(userCalcOut_pv+".INPA","29idKappa:m8.RBV CP NMS") #A=kth - caput(userCalcOut_pv+".INPB","29idKappa:m7.RBV CP NMS") #B=kap - caput(userCalcOut_pv+".INPC","29idKappa:m1.RBV CP NMS") #C=kphi - caput(userCalcOut_pv+".D",3.141592653589793) - caput(userCalcOut_pv+".E",180) - caput(userCalcOut_pv+".F",50) - caput(userCalcOut_pv+".CALC$","(C*D/E-ATAN(TAN(B*D/E/2.0)*COS(F*D/E)))*E/D") - caput(userCalcOut_pv+".DOPT",0) # Use CAL - - - - -def EtoK_kth_CalcOut(): - n=4 - userCalcOut_pv = userCalcOut_clear(mda,n) - - caput(userCalcOut_pv+".DESC","EtoK_kth") - caput(userCalcOut_pv+".INPA","29idKappa:userCalcOut1.VAL CP NMS") #A=th - caput(userCalcOut_pv+".INPB","29idKappa:userCalcOut2.VAL CP NMS") #B=chi - caput(userCalcOut_pv+".INPC","29idKappa:userCalcOut3.VAL CP NMS") #C=phi - caput(userCalcOut_pv+".D",3.141592653589793) - caput(userCalcOut_pv+".E",180) - caput(userCalcOut_pv+".F",50) - caput(userCalcOut_pv+".CALC$","(A*D/E-ASIN(-TAN(B*D/E/2.0)/TAN(F*D/E)))*E/D") - caput(userCalcOut_pv+".DOPT",0) # Use CAL - -def EtoK_kap_CalcOut(): - n=5 - userCalcOut_pv = userCalcOut_clear(mda,n) - - caput(userCalcOut_pv+".DESC","EtoK_kap") - caput(userCalcOut_pv+".INPA","29idKappa:userCalcOut1.VAL CP NMS") #A=th - caput(userCalcOut_pv+".INPB","29idKappa:userCalcOut2.VAL CP NMS") #B=chi - caput(userCalcOut_pv+".INPC","29idKappa:userCalcOut3.VAL CP NMS") #C=phi - caput(userCalcOut_pv+".D",3.141592653589793) - caput(userCalcOut_pv+".E",180) - caput(userCalcOut_pv+".F",50) - caput(userCalcOut_pv+".CALC$","((2*ASIN(SIN(B*D/E/2.0) / SIN(F*D/E))))*E/D") - caput(userCalcOut_pv+".DOPT",0) # Use CAL - -def EtoK_kphi_CalcOut(): - n=6 - userCalcOut_pv = userCalcOut_clear(mda,n) - - caput(userCalcOut_pv+".DESC","EtoK_kphi") - caput(userCalcOut_pv+".INPA","29idKappa:userCalcOut1.VAL CP NMS") #A=th - caput(userCalcOut_pv+".INPB","29idKappa:userCalcOut2.VAL CP NMS") #B=chi - caput(userCalcOut_pv+".INPC","29idKappa:userCalcOut3.VAL CP NMS") #C=phi - caput(userCalcOut_pv+".D",3.141592653589793) - caput(userCalcOut_pv+".E",180) - caput(userCalcOut_pv+".F",50) - caput(userCalcOut_pv+".CALC$","(C*D/E-ASIN(-TAN(B*D/E/2.0)/TAN(F*D/E)))*E/D") - caput(userCalcOut_pv+".DOPT",0) # Use CAL - - - - - - diff --git a/iexcode/instruments/Kappa_det.py b/iexcode/instruments/Kappa_det.py index 5c3e502e2c64d05d6b78c457c187c29a1eddc9e6..6a392a27a7fb912413c4ab13fb77dd7b2459b4c5 100644 --- a/iexcode/instruments/Kappa_det.py +++ b/iexcode/instruments/Kappa_det.py @@ -7,7 +7,7 @@ from epics import caget, caput ################################ Kappa detector class ############################## ############################################################################################################## det_set_pv = '29idKappa:det:set' -det_list = 'd3', 'd4', 'mcp', 'apd', 'yag' +det_list = ['d3', 'd4', 'mcp', 'apd', 'yag'] class Kappa_Detector: """ diff --git a/iexcode/instruments/Lakeshore_335.py b/iexcode/instruments/Lakeshore_335.py index 5acc6b95dd8ba5c3da389836f2b159966a62fd99..3c2784d571404a2ce8f1cb692b6ca77291bac749 100644 --- a/iexcode/instruments/Lakeshore_335.py +++ b/iexcode/instruments/Lakeshore_335.py @@ -7,7 +7,7 @@ import numpy as np from epics import caget, caput -from iexcode.instruments.IEX_endstations import * +from iexcode.instruments.IEX_BL_config import * from iexcode.instruments.utilities import read_dict def Lakeshore_reset(pv,d): diff --git a/iexcode/instruments/MPA.py b/iexcode/instruments/MPA.py index b63e3f843578318975a84053e273ef23e8c0cff3..767c9e9a7ee13f053892b9c43077d0969b55d817 100644 --- a/iexcode/instruments/MPA.py +++ b/iexcode/instruments/MPA.py @@ -452,4 +452,28 @@ def reset_mpa_HV(): #sock.send("*RST\n") # turn the high voltage on, clearing any current or voltage trips - sock.send(b"HVON\n") \ No newline at end of file + sock.send(b"HVON\n") + +def folder_MPA(run,folder,user_name,file_prefix="mpa"): + if folder == "b": + windows_ioc = "X" + user_name = "" + windows_path = windows_ioc+':\\'+run+"\\mpa" + else: + windowsIOC = "Z" + user_name = user_name+"/" + windows_path=windows_ioc+':\\'+run+"\\"+user_name[:-1]+"\\mpa" + mpa_path="/net/s29data/export/data_29id"+folder+"/"+run+"/"+user_name+"mpa" + print("\nMPA folder: " + mpa_path) + if not (exists(mpa_path)): + mkdir(mpa_path) + FileNumber=1 + else: + FileNumber=get_next_fileNumber(mpa_path,file_prefix) + caput("29iddMPA:det1:MPAFilename",windows_ioc+":/"+run+"/"+user_name+"mpa/mpa_") + + save_plugin='TIFF1' + caput("29iddMPA:"+save_plugin+":FilePath",windows_path) + print("\nMPA folder on Crabby: "+windows_path) + caput("29iddMPA:"+save_plugin+":FileName",file_prefix) + caput("29iddMPA:"+save_plugin+":FileNumber",FileNumber) \ No newline at end of file diff --git a/iexcode/instruments/Motors.py b/iexcode/instruments/Motors.py index a5caf6bb3f5bb9f0ff49a020c5f89630536b45fe..9978ef586fe25f979ca6cae0345c0e9563c3459e 100644 --- a/iexcode/instruments/Motors.py +++ b/iexcode/instruments/Motors.py @@ -217,7 +217,7 @@ class Motors: kwargs.setdefault('cts',0.1) kwargs.setdefault('mpa',False) - from iexcode.instruments.IEX_endstations import BL + from iexcode.instruments.IEX_BL_config import BL rbv_pv,val_pv,sgm_pv,pv = self._motor_dictionary[inner_loop_list[0]] inner_loop_list.insert(0,rbv_pv) @@ -254,9 +254,9 @@ def mvx(val,**kwargs): """ moves x motor in the endstation""" iex.BL.Motors.move('x',val,**kwargs) -def dmvx(val): +def dmvx(delta): """ relative x motor in the endstation""" - iex.BL.Motors.move('x',val,relative=True) + iex.BL.Motors.move('x',delta,relative=True) def scanx(start,stop,step,**kwargs): """ scans the x motor in the endstation""" @@ -271,9 +271,9 @@ def mvy(val,**kwargs): """ moves y motor in the endstation""" iex.BL.Motors.move('y',val,**kwargs) -def dmvy(val): +def dmvy(delta): """ relative y motor in the endstation""" - iex.BL.Motors.move('y',val,relative=True) + iex.BL.Motors.move('y',delta,relative=True) def scany(start,stop,step,**kwargs): """ scans the y motor in the endstation""" @@ -288,9 +288,9 @@ def mvz(val,**kwargs): """ moves z motor in the endstation""" iex.BL.Motors.move('z',val,**kwargs) -def dmvz(val): +def dmvz(delta): """ relative z motor in the endstation""" - iex.BL.Motors.move('z',val,relative=True) + iex.BL.Motors.move('z',delta,relative=True) def scanz(start,stop,step,**kwargs): """ scans the z motor in the endstation""" @@ -305,9 +305,9 @@ def mvkth(val,**kwargs): """ moves kth motor in the endstation""" iex.BL.Motors.move('kth',val,**kwargs) -def dmvkth(val): +def dmvkth(delta): """ relative kth motor in the endstation""" - iex.BL.Motors.move('kth',val,relative=True) + iex.BL.Motors.move('kth',delta,relative=True) def scankth(start,stop,step,**kwargs): """ scans the kth motor in the endstation""" @@ -339,9 +339,9 @@ def mvkap(val,**kwargs): """ moves kap motor in the endstation""" iex.BL.Motors.move('kap',val,**kwargs) -def dmvkap(val): +def dmvkap(delta): """ relative kap motor in the endstation""" - iex.BL.Motors.move('kap',val,relative=True) + iex.BL.Motors.move('kap',delta,relative=True) def scankap(start,stop,step,**kwargs): """ scans the kap motor in the endstation""" @@ -356,9 +356,9 @@ def mvtth(val,**kwargs): """ moves tth motor in the endstation""" iex.BL.Motors.move('tth',val,**kwargs) -def dmvtth(val): +def dmvtth(delta): """ relative tth motor in the endstation""" - iex.BL.Motors.move('tth',val,relative=True) + iex.BL.Motors.move('tth',delta,relative=True) def scantth(start,stop,step,**kwargs): """ scans the tth motor in the endstation""" @@ -373,9 +373,9 @@ def mvth(val,**kwargs): """ moves th motor in the endstation""" iex.BL.Motors.move('th',val,**kwargs) -def dmvth(val): +def dmvth(delta): """ relative th motor in the endstation""" - iex.BL.Motors.move('th',val,relative=True) + iex.BL.Motors.move('th',delta,relative=True) def scanth(start,stop,step,**kwargs): """ scans the th motor in the endstation""" @@ -407,9 +407,9 @@ def mvphi(val,**kwargs): """ moves phi motor in the endstation""" iex.BL.Motors.move('phi',val,**kwargs) -def dmvphi(val): +def dmvphi(delta): """ relative phi motor in the endstation""" - iex.BL.Motors.move('phi',val,relative=True) + iex.BL.Motors.move('phi',delta,relative=True) def scanphi(start,stop,step,**kwargs): """ scans the phi motor in the endstation""" @@ -419,27 +419,7 @@ def dscanphi(start,stop,step): """relative scans of the phi motor in the endstation """ iex.BL.Motors.scan("phi",start,stop,step,relative=True) -### uan moves tth and th simultaneously -def uan(tth,th): - """ Moves tth and th motors simultaneously in the in the Kappa chamber - """ - if iex.BL.endstation == 'Kappa': - #move tth and th - mvth(th,wait=False) - mvtth(tth,wait=False) - time.sleep(0.2) - - while True: - status = iex.BL.Motors.status() - if status == 0: - time.sleep(0.2) - else: - tth_RBV=round(iex.BL.Motors.get('tth',verbose=False),3) - th_RBV=round(iex.BL.Motors.get('th',verbose=False),3) - print('tth='+str(tth_RBV)+' th='+str(th_RBV)) - break - else: - print("not a defined move") + ######## mprint and mvsample ################### def mprint(): """ diff --git a/iexcode/instruments/VLS_PGM.py b/iexcode/instruments/VLS_PGM.py index 8f7bfdc225a080961c962b0d084059f2b535f179..c4bb2d114bdf9eb2eb0fbd30d7c4038ad2d0f055 100644 --- a/iexcode/instruments/VLS_PGM.py +++ b/iexcode/instruments/VLS_PGM.py @@ -7,7 +7,7 @@ import numpy as np from epics import caget,caput -from iexcode.instruments.IEX_endstations import * +from iexcode.instruments.IEX_BL_config import * from iexcode.instruments.utilities import print_warning_message,read_dict diff --git a/iexcode/instruments/bakeout.py b/iexcode/instruments/bakeout.py index 94dfd1a00e1173fabb280bf94cd6090258599878..f232c19053db8dd22a40aef771f8dc59b6469ea6 100644 --- a/iexcode/instruments/bakeout.py +++ b/iexcode/instruments/bakeout.py @@ -52,7 +52,7 @@ def bakout_scan(scan_ioc_name,chamber): print("\nSave Status "+scan_ioc+" "+SaveStatus+" - "+SaveMessage) #setting up scan record - detector_dictionary = bakeout_detector_dictionary(chamber) + detector_dictionary = _bakeout_detector_dictionary(chamber) #caput("29idb:ca1:read.SCAN",0) #trigger_dictionary = {1:"29idb:ca1:read"} @@ -67,7 +67,7 @@ def bakout_scan(scan_ioc_name,chamber): -def bakeout_detector_dictionary(chamber): +def _bakeout_detector_dictionary(chamber): """ returns a dictionary of the default detectors diff --git a/iexcode/instruments/cameras.py b/iexcode/instruments/cameras.py index e91f8d39fb1efcde73b3b41a0be7ec0128bafab1..579ca3e3c9a9ab6ea2feb6af3d91cecfde54194c 100644 --- a/iexcode/instruments/cameras.py +++ b/iexcode/instruments/cameras.py @@ -84,16 +84,36 @@ def cam_snap(cam_num,ADtype='TIFF',**kwargs): ############################################################################################################## def cam_scan_setup(cam_num,ADtype='TIFF',**kwargs): """ - sets up the BL scanRecord to trigger the camera (trigger - 2) + sets up the BL scanRecord for scanning at every point + **kwargs + scanDIM = 1 + detTrig = 2; detectorTrigger number + + # AD_SaveFileSetup + filepath=userpath (from BL_ioc scanRecord)+"/dtype" + (e.g. filepath="/net/s29data/export/data_29id"+folder+"/"+run+"/"+userName+"/"+df) + dtype = taken from ADplugin + FileTemplate="%s%s_%4.4d."+dtype; format for filename first %s = filepath, second %s = prefix + prefix = dtype by default """ + kwargs.update('ADtype',ADtype) ADplugin = _pv_dictionary()[cam_num]+ADtype+":" ADplugin_ScanSetup(ADplugin,iex.BL.mda, **kwargs) -def cam_live(cam_num,ADtype='TIFF',**kwargs): +def cam_live(cam_num): """ puts camera in no save and continuous a.k.a free run """ + ADtype='TIFF' ADplugin = _pv_dictionary()[cam_num]+ADtype+":" - AD_FreeRun(ADplugin,**kwargs) \ No newline at end of file + AD_FreeRun(ADplugin) + +def cam_done(cam_num): + """ + stops camera acquisition (not will stop after current acquisition) + """ + ADtype='TIFF' + ADplugin = _pv_dictionary()[cam_num]+ADtype+":" + AD_Done(ADplugin,**kwargs) \ No newline at end of file diff --git a/iexcode/instruments/cheatsheet.txt b/iexcode/instruments/cheatsheet.txt index 222259ef87bce23f5f407c433a2f37df52105c57..d658910213ce01869737e00d6db9590eceb20a11 100644 --- a/iexcode/instruments/cheatsheet.txt +++ b/iexcode/instruments/cheatsheet.txt @@ -1,33 +1,133 @@ -# beamline -from re import L -from iexcode.instruments.conversions_constants import Lambda2eV, deg2rad, eV2Lambda, rad2deg -from iexcode.instruments.diagnostics import diodeC_read, meshD, meshD_read -from iexcode.instruments.xrays import energy_get, energy_get_all, mvid, switch_gratings +#ARPES: ARPES specific functions +#AD_untilites: functions for common area detector operations -get_all() +#bakeout: functions for monitoring a bakeout -# cameras import -cam_snap(cam_num) +#cameras: used for taking images from epics +cam_snap => takes a single image +cam_scan_setup => configures the scanRecord to take an image at each polarization +cam_live => puts the camera back in live/free-run mode +cam_done => turns off acquisition -#converstions_constants -deg2rad(angle_deg) -rad2deg(angle_rad) -eV2Lambda(eV) -Lambda2eV(Angstrom) +#cfg: config file which holds global variable BL and MPA +usage => import iexcode.instruments.cfg as iex -#diagnostics -diodeC(In_Out) -diodeC_read() +#converstions_constants: +h => Planck's constant (eV/s) +c => speed of light (m/s) +deg2rad => converts degree to radian +rad2deg => converts radian to degrees +eV2Lambda => converts eV to Angstroms +Lambda2eV => converts Angstroms to eV -meshD(In_Out) -meshD_read() +#current_amplifiers: +Keithley => class for Keithley current amplifiers +ca_detector_list => list of detectors which are used in a given branch ('b for beamline) +ca_average => turns on averaging for all Keithleys in ca_list +ca_reset_all => resets all Keithleys in all branches +SRS => class for SRS current amplifiers +current2flux => calculates the flux based on the current reading in an AUX100 photodiode +flux2current => calculates the current reading for a given flux for and AUX100 photodiode -#electron_analyzer -EA.get() -EA.put(KE,PE) -scanEA(EAlist) -scanEA_hv() +#diagnostics: bemaline diagnostics +diagnostics_list_all => prints the name of all the diagnostics_all_in +diagnostic => moves the specified diagnostic in/out +diagnostics_all_out => moves all beamline diagnostics out +diagnostics_all_in => moves all beamline diagnostics in; Note that they can shadow/block downstream diagnostics +mesh_W => moves W-mesh in the A-hutch in/out +diode_c => moves diode in c-branch in/out +diode_c_read => reads the current amplifier for the c-branch diode +diode_d => moves diode in c-branch in/out; located just before the kappa endstation +mesh_d => moves mesh in d-branch in/out; used for normalization +mesh_d_read => reads the current amplifier for the d-branch mesh + + +#electron_analyzer: beamline specific calls to Scienta +EA => electron analyzer class +EA_ioc_init => initializes the ioc after a reboot (eventually goes in AutoSave) +folders_EA => sets the folder for the Scienta spectra saving (called by Folders_ARPES) +SES_slit_get => gets the analyzer slit number +SES_slit_set => sets the analyzer slit to the given value +scanEA => takes a spectra +scanFM => takes a Fermi map +mvth_interp => moves to an interpolated theta value +scanEA_hv => takes a spectra at each photon energy +scanEA_motor => takes a spectra at each motor point +resolution_EA => get the analyzer contribution to the resolution + +#encoder: beamline absolute encoders +encoder_name_list => lists names in encoder dictionary +encoder_sync => syncs all the encoders associated with name +encoders_slit2B_reset_zero => resets the center for the slit2B encoder + +#files_and_folders: general scripts for dealing with files and directories +path_dserv => path to user data directory on the dserve +check_run => returns the current run based on todays date +make_ftp => creates the folders on the ftp server, kip +make_user_folders => creates all the appropriate user folders +folder_mda => creates/set the user folder for the scanRecord +folder_SPEC +get_last_fileNumber => gets the last file number in the directory + +FMB_mirrors: functions for M0,M1,M3R +FMB_mirror_get => get the current position of all axes for a given mirror +FMB_mirror_move => moves the specified axis ('Tx','Ty','Tz','Rx','Ry','Rz') for the given mirror +FMB_mirror_move_all => moves all the axes to the positions specified in position_list +FMB_mirror_tweak => relative moves +FMB_mirror_scan => scan a mirror axis +M0M1_Table => reads the dictionary file to get the previous mirror positions +M0M1_SP => writes the values form M0M1_Table to the set points (still need to push move) + +#hxp_mirrors: Newport hexapods +hxp_sync => syncs the motor setpoint and readback values for a given mirror +hxp_get => gets a mirror position +hxp_get_all => gets all the mirror positions + + +#IEX_BL_config: used to access current beamline configuration, based on instance initialization not pv +Beamline_Config => class to carry all configuration info gets stored in iexcode\instruments\cft BL +BL_ioc => returns the scan ioc +BL_branch => returns the branch (shutter not mirror position) +BL_mode => returns the current mode (user/staff) +BL_mda_prefix => return prefix for mda scanRecord +BL_mda_filepath => returns the file path in mda scanRecord +get_all => gets relavent pv values + +#IEX_VPU: undulator functions +ID_get_all => gets ID_mode, ID_QP_ratio, ID_sp, ID_rbv +ID_off => turns off the ID +ID_start => turns on the ID +ID_restart => turns off the ID and then turns it on with the same set point + +#kappa_angle_calcs: +fourc2kappa => converts between four-circle angles and kappa angles +kappa2fourc => converts between kappa dn four-circle angles + +#kappa_det: defines kappa tth detector class and other functions +Kappa_Detector => for detset etc in kappa chamber + +#kappa: kappa specific functions + +#Logfile: functions for writing logfile.txt, gets set by IEX_BL_config +log_print => print a comment in the logfile +log_update => updates the logfile with the current info (used if script is aborted) +log_name_set => change name of logfile + +#m3r: functions for dealin with m3r +m3r_tweak_pitch => tweaks the pitch of m3r +m3r_table => go to the default position specified branch +m3r_branch => returns the branch based on mirror position +m3r_switch_branch => moves the mirror to the default position for a given branch +m3r_centroid => returns the centroid position for m3r +m3r_align => aligns the m3r + +#Motors: motor class and common name functions +Motor => class definition get set in Beamline_Config +mvx => moves motor x +dmvx => relative move of x +scanx => scan of x motor +dscanx => relative scan of x motor #xrays energy_get_all() diff --git a/iexcode/instruments/conversions_constants.py b/iexcode/instruments/conversions_constants.py index 9bbdd2741d8f2b2cb9e8cb585611fdd380b49835..d98149c488768cf2b3c8e48bf648044d78d59840 100644 --- a/iexcode/instruments/conversions_constants.py +++ b/iexcode/instruments/conversions_constants.py @@ -1,12 +1,13 @@ import numpy as np - from epics import caget ############################################################################################################## ############################## conversions ############################## ############################################################################################################## +#Plank's constant eV/s h=4.135667516e-15 -c=299792458 +#speed of ligh m/s +c=299792458 def deg2rad(angle_deg): angle_rad=angle_deg*np.pi/180 @@ -20,8 +21,7 @@ def eV2Lambda(eV): """ Converts energy (eV) into wavelenght (Angstrom) """ - - Angstrom = h*c/eV*1e9*10 + Angstrom = h*c/eV*1e10 return Angstrom def Lambda2eV(Angstrom): @@ -29,80 +29,6 @@ def Lambda2eV(Angstrom): Converts wavelenghth (Angstrom) into energy (eV) """ - eV = h*c/Angstrom*1e9*10 + eV = h*c/Angstrom*1e10 return eV -############################################################################################################## -############################## Kappa to Euler Conversion ############################## -############################################################################################################## -def Kappa2Fourc(ang1,ang2,ang3,conversion,k_arm=50): - - a,b,c=0,0,0 - if conversion=='Kappa': - a,b,c=EtoK(ang1,ang2,ang3,k_arm) - print(("\n"+"th = "+str(ang1))) - print(("chi = "+str(ang2))) - print(("phi = "+str(ang3))) - print("~~~~~~~~") - print(("kth = "+str(a))) - print(("kap = "+str(b))) - print(("kphi = "+str(c)+"\n")) - elif conversion=='fourc': - a,b,c=KtoE(ang1,ang2,ang3,k_arm) - print(("\n"+"kth = "+str(ang1))) - print(("kap = "+str(ang2))) - print(("kphi = "+str(ang3))) - print("~~~~~~~~") - print(("th = "+str(a))) - print(("chi = "+str(b))) - print(("phi = "+str(c)+"\n")) - else: - print('2nd argument invalid; please choose one of the following:') - print('"Kappa" or "fourc"') - return a,b,c - - - -def EtoK(e_theta,e_chi,e_phi,k_arm=50): - conv = np.pi/180.0 - kth_offset=caget('29idKappa:userCalcOut1.G') - if(abs(e_chi)> 2.0*k_arm): - print("Chi should be no more than twice the Kappa arm offset angle.") - kth,kap,kphi=0,0,0 - else: - print(("Calculating Kappa angles using kth0 = "+str(kth_offset))) - k_ang = k_arm*conv - delta = np.asin( - np.tan(e_chi*conv/2.0) / np.tan(k_ang) ) - k_theta = e_theta*conv - delta - k_kappa = 2.0 * np.asin( np.sin(e_chi*conv/2.0) / np.sin(k_ang)) - k_phi = e_phi*conv - delta - #print k_theta, k_kappa,k_phi - kth = rounder(k_theta)-(57.045-kth_offset) - kap = rounder(k_kappa) - kphi = rounder(k_phi) - #print delta - return (kth,kap,kphi) - - - - -def KtoE(k_theta,k_kappa,k_phi,k_arm=50): - conv = np.pi/180.0 - kth_offset=caget('29idKappa:userCalcOut1.G') - print(("Calculating Euler angles using kth0 = "+str(kth_offset))) - k_ang = k_arm*conv - delta = np.atan( np.tan(k_kappa*conv/2.0) * np.cos(k_ang) ) - e_theta = k_theta*conv - delta - e_chi = 2.0 * np.asin( np.sin(k_kappa*conv/2.0) * np.sin(k_ang) ) - e_phi = k_phi*conv - delta - #print round(e_theta,1),round(e_phi,1),round(e_chi,1) - theta = rounder(e_theta)+(57.045-kth_offset) - chi = rounder(e_chi) # convert from rad to deg - phi = rounder(e_phi) - #print round(delta,1) - return (theta,chi,phi) - -def rounder(val): # convert from rad to deg - conv = np.pi/180.0 - roundVal=round(1000.0*val/conv)/1000.0 - return roundVal \ No newline at end of file diff --git a/iexcode/instruments/current_amplifiers.py b/iexcode/instruments/current_amplifiers.py index 88268a27cc8c0a7f7ff27565234289265a682a1a..ee2944051a08de6c91b96d2f56686588c9e98f77 100644 --- a/iexcode/instruments/current_amplifiers.py +++ b/iexcode/instruments/current_amplifiers.py @@ -11,13 +11,13 @@ def ca_detector_list(branch): returns the list of keithley current amplifiers based on key key: 'ARPES' / 'Staff' """ - ca_list = list(ca_dictionary()[branch].keys()) + ca_list = list(_ca_dictionary()[branch].keys()) return ca_list -def ca_dictionary(): +def _ca_dictionary(): """ - dictionary of connected Kiethlys and thier names + dictionary of connected Keithley and thier names Previously: CA_Name """ @@ -44,7 +44,7 @@ def ca_dictionary(): ############################################################################################################## ################################ Keithley ############################## ############################################################################################################## -def Keithley_pv(ca_crate, ca_num): +def _Keithley_pv(ca_crate, ca_num): """ ca_crate = 'b' / 'c' ... """ @@ -59,9 +59,9 @@ class Keithley: ca_crate = 'b' / 'c' ... """ - self._pv = Keithley_pv(ca_crate, ca_num) + self._pv = _Keithley_pv(ca_crate, ca_num) try: - self.name = ca_dictionary()[ca_crate][ca_num] + self.name = _ca_dictionary()[ca_crate][ca_num] except: self.name = 'CA'+ca_crate+str(ca_num) @@ -189,7 +189,7 @@ def ca_reset_all(rate="Slow"): Previously: Reset_CA_all """ - ca_dict = ca_dictionary() + ca_dict = _ca_dictionary() for ca_crate in ca_dict.keys(): for ca_num in ca_dict[ca_crate].keys(): CA = Keithley(ca_crate,ca_num) @@ -198,7 +198,7 @@ def ca_reset_all(rate="Slow"): caput("29idb:ca5:read.SCAN","Passive") # CA5 in passive print("\nAll the current amplifiers have been reset; ca5 set to passive.") -def ca_live_sequence(ioc,seq_num,detector_list): +def _ca_live_sequence(ioc,seq_num,detector_list): """ creates a string sequence to put keithleys back in live mode @@ -244,7 +244,7 @@ def ca_average(avg_pts,ca_list,rate="Slow",verbose=True): ca.avg(avg_pts,rate=rate,verbose=verbose) -def load_responsivity_curve(): +def _load_responsivity_curve(): """ Loads the responsivity curve for the AUX100 photo diode, used to convert current to flux at a given photon energy @@ -265,7 +265,7 @@ def current2flux(current,hv=None,verbose=True): Previously CA2flux """ try: - curve=load_responsivity_curve() + curve=_load_responsivity_curve() except: print('responsivity curve not loaded') return @@ -295,7 +295,7 @@ def flux2current(flux,hv=None,verbose=True): hv = None; gets the current mono energy; otherwise you will need to specify """ try: - curve=load_responsivity_curve() + curve=_load_responsivity_curve() except: print('responsivity curve not loaded') return diff --git a/iexcode/instruments/diagnostics.py b/iexcode/instruments/diagnostics.py index 84148ad35be7519b9f5dbf36503f4fe2f4c3d459..2933ef8d058a7a4bf280bd4be00c4f76a203a7c8 100644 --- a/iexcode/instruments/diagnostics.py +++ b/iexcode/instruments/diagnostics.py @@ -1,3 +1,4 @@ +from build.lib.iexcode.instruments.current_amplifiers import Keithley,SRS from numpy import nan from epics import caput, caget @@ -9,7 +10,7 @@ import iexcode.instruments.cfg as iex ############################################################################################################## ###### We should make pvs in the 29idb ioc to hold these values: -def diagnostics_dict(): +def _diagnostics_dict(): """ Dictionary of Diagnostic positions In and Out by either motor number or name WARNING: When updating motor values, also update the following screens: @@ -38,16 +39,24 @@ def diagnostics_dict(): "D2B":6, "D3B":7, "D4C":17, "gas-cell":20,"D4D":25,"D5D":28} return diag -def diagnostic_CA_dict(): +def _diagnostic_CA_dict(): CA_dict={ - 'diode_c':'29idb:ca15:' + 'diode_c':Keithley('b',15), + 'mesh_d':SRS("29idMZ0:scaler1.S14", '29idd:A4'), } return CA_dict +def diagnostics_list_all(): + """ + lists all diagnostics + """ + d = _diagnostics_dict() + for key in d.keys(): + print(key) def diagnostic(diagnostic_name,in_out): "Inserts/retracts a diagnostic(motor number or name) either = \"In\" or \"Out\"" - diag=diagnostics_dict() + diag=_diagnostics_dict() if type(diagnostic_name) is int: motor=diagnostic_name name=diag['name'][motor] @@ -66,7 +75,7 @@ def diagnostics_all_out(diode_stay_in=False): Previously: AllDiagOut """ - diag=diagnostics_dict() + diag=_diagnostics_dict() text="" #which motor is Diode of interest @@ -99,7 +108,7 @@ def diagnostics_all_in(): Previously: AllDiagIn and AllMeshIn() """ - diag=diagnostics_dict() + diag=_diagnostics_dict() for motor in list(diag["In"].keys()): position=diag["In"][motor] if type(position) == list: @@ -114,31 +123,31 @@ def mesh_W(In_Out): Previously MeshW """ - diag=diagnostics_dict() + diag=_diagnostics_dict() motor=5; position=diag[In_Out][motor] caput("29idb:m"+str(motor)+".VAL",position,wait=True,timeout=18000) print("\nD1A mesh_W: "+ In_Out) -def diodeC(In_Out): +def diode_c(In_Out): """ Inserts/retracts ARPES (gas-cell) diode; arg = \"In\" or \"Out\" Previously: DiodeC """ - diag=diagnostics_dict() + diag=_diagnostics_dict() motor=20; position=diag[In_Out][motor] caput("29idb:m"+str(motor)+".VAL",position,wait=True,timeout=18000) print("\nARPES Diode: "+ In_Out) -def diodeD(In_Out): +def diode_d(In_Out): """ Inserts/retracts RSXS diode; arg = \"In\" or \"Out\" Previously:DiodeD """ - diag=diagnostics_dict() + diag=_diagnostics_dict() motor=28; position=position=diag[In_Out][motor] if type(position) == list: position=position[1] @@ -146,53 +155,36 @@ def diodeD(In_Out): print("\nRSXS Diode: "+ In_Out) - -def meshC(In_Out,which="postSlit"): - """ - Inserts/retracts ARPES mesh (preSlit or postSlit); arg = \"In\" or \"Out\" - - Previously: MeshC - """ - diag=diagnostics_dict() - if which == "postSlit": - motor=20; position=-31 - elif which == "preSlit": - motor=17; position=diag[In_Out][motor] - - caput("29idb:m"+str(motor)+".VAL",position,wait=True,timeout=18000) - print("\nD4C Au-Mesh: "+ In_Out) - -def meshD(In_Out): +def mesh_d(In_Out): """ Inserts/retracts RSXS mesh (post-slit); arg = \"In\" or \"Out\" Previoulsy: MeshD """ - diag=diagnostics_dict() + diag=_diagnostics_dict() motor=28; position=position=diag[In_Out][motor] if type(position) == list: position=position[0] caput("29idb:m"+str(motor)+".VAL",position,wait=True,timeout=18000) print("\nD5D Au-Mesh: "+ In_Out) -def diagnostic_read(diode_d, quiet=True): +def diagnostic_read(diode_name, verbose=True): """ reads the current amplifier and returns the value - quiet = False to pring """ try: - diode_pv = diagnostic_CA_dict['diode_d'] - val=caget(diode_pv+'read') + det = _diagnostic_CA_dict[diode_name] + val=det.get(verbose) except: diode_pv="not connected" val = nan print('pv not defined') - if not quiet: - print('Diode-D ',val, "(pv = "+diode_pv+")") + if verbose: + print(diode_name,val, "(pv = "+diode_pv+")") return val -def diodeC_read(quiet=True): +def diode_c_read(quiet=True): """ reads the current amplifier and returns the value quiet = False to pring @@ -200,7 +192,7 @@ def diodeC_read(quiet=True): val = diagnostic_read('diode_d',quiet) return val -def diodeD_read(quiet=True): +def diode_d_read(quiet=True): """ reads the current amplifier and returns the value quiet = False to pring @@ -208,7 +200,7 @@ def diodeD_read(quiet=True): val = diagnostic_read('diode_d',quiet) return val -def meshD_read(quiet=True): +def mesh_d_read(quiet=True): """ reads the current amplifier and returns the value quiet = False to pring diff --git a/iexcode/instruments/electron_analyzer.py b/iexcode/instruments/electron_analyzer.py index e80d937c8e4dc24ec889f25957653623fa153ae7..c279f1edcfc30ae852fb6c16adf99d26585d48da 100644 --- a/iexcode/instruments/electron_analyzer.py +++ b/iexcode/instruments/electron_analyzer.py @@ -13,7 +13,7 @@ import numpy as np from scipy.interpolate import interp1d from epics import caput,caget -from iexcode.instruments.IEX_endstations import * +from iexcode.instruments.IEX_BL_config import * from iexcode.instruments.scanRecord import * from iexcode.instruments.conversions_constants import * @@ -21,7 +21,7 @@ from iexcode.instruments.xrays import energy, scanXAS_BL, BL_energy_tables from iexcode.instruments.shutters import branch_shutter_close from iexcode.instruments.VLS_PGM import mono_energy_get from iexcode.instruments.files_and_folders import get_next_fileNumber -from iexcode.instruments.Logfile import * +from iexcode.instruments.Logfile import log_print from iexcode.instruments.Scienta import * global EA @@ -32,7 +32,7 @@ except: print("EA is not connected") ########################################################################### -def EA_init_Motors(Motors): +def _EA_init_Motors(Motors): """ Adds Motors to EA object to be used in scanning """ @@ -92,9 +92,6 @@ def EA_ioc_init(**kwargs): print("C-Shutter is closed for initialization ") -def getSESslit(): - SES=caget("29idc:m8.RBV") - return SES def folders_EA(userPath,filePrefix="EA",**kwargs): """ @@ -170,14 +167,13 @@ def EA_log_update(): entry_list.append(key) pv_list.append(spectra_info[key][0]) format_list.append(spectra_info[key][1]) - logfile_update("ARPES",iex.BL.ioc,entry_list,pv_list,format_list) + iex.BL.mda.log.update(entry_list,pv_list,format_list) except: print("EAlog did not write to file, check for errors.") def log_headerEA():##JM - need to update so that we get the keys from log_EA s="\nscan x y z th chi phi T scan_mode E1 E2 step i f PE lens_mode SES slit # ID_mode hv exit_slit GRT TEY1 TEY2 time\n" - kwargs={'comment': s} - logfile_print("ARPES",iex.BL.ioc,comment='') + log_print(s) def EAsweptTime_estimate(EAlist,overhead=[60,.22]): """ @@ -783,7 +779,7 @@ def resolution_EA(PE,slit_SES): # updated 10/30/17: straight slits scaled to return SES -def SES_slit(val): +def SES_slit_set(val): """ Set the Scienta Slit val w_mm l_mm Shape @@ -801,3 +797,6 @@ def SES_slit(val): caput("29idc:m8.VAL",val,wait=True,timeout=18000) +def SES_slit_get(): + SES=caget("29idc:m8.RBV") + return SES \ No newline at end of file diff --git a/iexcode/instruments/encoders.py b/iexcode/instruments/encoders.py index e3eb8c75061323d44edc985e0eeb0df5c3ef1aac..a2dfcd58e8686c69e3a862cb5ceee96968efa6e8 100644 --- a/iexcode/instruments/encoders.py +++ b/iexcode/instruments/encoders.py @@ -1,6 +1,6 @@ from epics import caput,caget -def encoder_dictionary_entry(name): +def _encoder_dictionary(): """ returns a dictionary with the encoder pvs encoder_dictionary_entry(name) = encoder_ioc, motor_ioc, encoder_list @@ -11,26 +11,32 @@ def encoder_dictionary_entry(name): 'slit3D':("29idMini2:","29idb:",[26,27]), 'ARPES':("29idARPES:","29idARPES:",[1,2,3,4]), } - return d[name] + return d + +def encoder_name_list(): + d = _encoder_dictionary() + for key in d.keys(): + print(key) def encoder_sync(name): """ sync all the encoders for name """ - encoder_ioc, motor_ioc, encoder_list = encoder_dictionary_entry(name) + encoder_ioc, motor_ioc, encoder_list = _encoder_dictionary()[name] for encoder_num in encoder_list: pv = motor_ioc+"m"+str(encoder_num)+".SYNC" caput(pv,1) -def encoders_reset(name,Hcenter,Vcenter): +def encoders_slit2B_reset_zero(): """ - Resetting Slit 2B encoders to 0 for a given position (Hcenter,Vcenter). + Resetting Slit 2B encoders to 0 for the current. Slit size need to be set to 0. Previously: Reset_Slit2B_Encoders """ - encoder_sync('name') - encoder_ioc, motor_ioc, encoder_list = encoder_dictionary_entry(name) + name='slit2B' + encoder_sync(name) + encoder_ioc, motor_ioc, encoder_list = _encoder_dictionary()[name] print('\nCurrent Position:') for e_num in encoder_list: diff --git a/iexcode/instruments/files_and_folders.py b/iexcode/instruments/files_and_folders.py index 1f85d5bc8ec66cfe0552bc5e9f744c89c63e4797..8bb38a7326a3775f6c1046990995ed37bf5b592d 100644 --- a/iexcode/instruments/files_and_folders.py +++ b/iexcode/instruments/files_and_folders.py @@ -26,11 +26,6 @@ def path_dserv(folder,run,user_name): return dataFolder - - - - - ############################################################################################################## ################################ Folders ############################## ############################################################################################################## @@ -193,29 +188,7 @@ def folder_SPEC(run,folder,user_name): # mkdir(MyPath) -def folder_MPA(run,folder,user_name,file_prefix="mpa"): - if folder == "b": - windows_ioc = "X" - user_name = "" - windows_path = windows_ioc+':\\'+run+"\\mpa" - else: - windowsIOC = "Z" - user_name = user_name+"/" - windows_path=windows_ioc+':\\'+run+"\\"+user_name[:-1]+"\\mpa" - mpa_path="/net/s29data/export/data_29id"+folder+"/"+run+"/"+user_name+"mpa" - print("\nMPA folder: " + mpa_path) - if not (exists(mpa_path)): - mkdir(mpa_path) - FileNumber=1 - else: - FileNumber=get_next_fileNumber(mpa_path,file_prefix) - caput("29iddMPA:det1:MPAFilename",windows_ioc+":/"+run+"/"+user_name+"mpa/mpa_") - - save_plugin='TIFF1' - caput("29iddMPA:"+save_plugin+":FilePath",windows_path) - print("\nMPA folder on Crabby: "+windows_path) - caput("29iddMPA:"+save_plugin+":FileName",file_prefix) - caput("29iddMPA:"+save_plugin+":FileNumber",FileNumber) + def _filename_key(filename): return (len(filename), filename) diff --git a/iexcode/instruments/get_all.py b/iexcode/instruments/get_all.py deleted file mode 100644 index c23abbe7e450d8654addf04f1c33ab5a77b179d2..0000000000000000000000000000000000000000 --- a/iexcode/instruments/get_all.py +++ /dev/null @@ -1,28 +0,0 @@ -import numpy as np -from time import sleep - -from epics import PV - -import iexcode.instruments.cfg as iex -from iexcode.instruments.xrays import xrays_get_all - - - -def get_all(verbose=True): - """ - returns the current beamline and endstation setting - - """ - vals={} - if verbose: - print("\n===========================================================") - - if iex.BL.xrays: - vals.update(xrays_get_all(verbose)) - - vals.update(iex.BL.endstation_get) - - if verbose: - print("\n===========================================================") - - return vals \ No newline at end of file diff --git a/iexcode/instruments/hxp_mirrors.py b/iexcode/instruments/hxp_mirrors.py index 0eb90509f2784ff042fbcb4ef78235ec102d02fd..72df87b817ebd017c75325e360759cd3cc5663b5 100644 --- a/iexcode/instruments/hxp_mirrors.py +++ b/iexcode/instruments/hxp_mirrors.py @@ -3,7 +3,7 @@ from epics import caput, caget from iexcode.instruments.utilities import print_warning_message from iexcode.instruments.m3r import m3r_branch -def hxp_ioc(mirror_name): +def _hxp_ioc(mirror_name): """ returns the ioc for a given mirror_name: 'm3a' / 'm4a' / 'm4r' @@ -20,7 +20,7 @@ def hxp_ioc(mirror_name): return ioc -def HXP_synch(mirror_name): +def hxp_sync(mirror_name): """ synchs the rbv and sp for all axes @@ -28,7 +28,7 @@ def HXP_synch(mirror_name): Previously: Sync_m4r """ - pv = hxp_ioc(mirror_name) + pv = _hxp_ioc(mirror_name) try: for m in range(1,7): caput(pv+'m'+str(m)+'.SYNC',1) @@ -36,12 +36,12 @@ def HXP_synch(mirror_name): print_warning_message("Check if ioc is running") -def hxp_print(mirror_name): +def hxp_get_all(mirror_name,verbose=True): """ Previously: Get_HXP """ - pv = hxp_ioc(mirror_name) + pv = _hxp_ioc(mirror_name) Tx=caget(pv+"m1.RBV") Ty=caget(pv+"m2.RBV") @@ -49,16 +49,19 @@ def hxp_print(mirror_name): Rx=caget(pv+"m4.RBV") Ry=caget(pv+"m5.RBV") Rz=caget(pv+"m6.RBV") - print("\n"+mirror_name+" @ "+"%.3f" % Tx, "/","%.3f" % Ty, "/","%.3f" % Tz, "/","%.3f" % Rx, "/","%.3f" % Ry, "/","%.3f" % Rz) + + if verbose: + print("\n"+mirror_name+" @ "+"%.3f" % Tx, "/","%.3f" % Ty, "/","%.3f" % Tz, "/","%.3f" % Rx, "/","%.3f" % Ry, "/","%.3f" % Rz) + return Tx,Ty,Tz,Rx,Ry,Rz -def hxp_get(): +def hxp_get_all(): """ Previously: Get_HXP """ branch = m3r_branch() if branch == 'c': - hxp_print('m3a') - hxp_print('m4a') + hxp_get_all('m3a',verbose=True) + hxp_get_all('m4a',verbose=True) else: - hxp_print('m4r') \ No newline at end of file + hxp_get_all('m4r',verbose=True) \ No newline at end of file diff --git a/iexcode/instruments/kappa_angle_calcs.py b/iexcode/instruments/kappa_angle_calcs.py new file mode 100644 index 0000000000000000000000000000000000000000..47bf0a803bf7c5cebf8de830bd000aadf23a36f3 --- /dev/null +++ b/iexcode/instruments/kappa_angle_calcs.py @@ -0,0 +1,114 @@ + +import numpy as np +from epics import caget +############################################################################################################## +############################## Kappa to Euler Conversion ############################## +############################################################################################################## +def fourc2kappa(theta,chi,phi): + """ + converts four-circle angles to fourc angles + **kwargs: + k_arm: kappa arm angle (default = 50) + kth_offset: default from EPICS + """ + _kappa_fourc_calc(theta,chi,phi,'kappa') + +def kappa2fourc(kth,kappa,kphi,**kwargs): + """ + convert kappa anges to fourc angles + **kwargs: + k_arm: kappa arm angle (default = 50) + kth_offset: default from EPICS + """ + _kappa_fourc_calc(kth,kappa,kphi,'fourc',**kwargs) + +def _kappa_fourc_calc(ang1,ang2,ang3,conversion,**kwargs): + """ + converts kappa angles to four-circle angles + **kwargs: + k_arm: kappa arm angle (default = 50) + kth_offset: from EPICS + """ + a,b,c = 0,0,0 + if conversion == 'kappa': + a,b,c = _euler_to_kappa(ang1,ang2,ang3,**kwargs) + print(("\n"+"th = "+str(ang1))) + print(("chi = "+str(ang2))) + print(("phi = "+str(ang3))) + print("~~~~~~~~") + print(("kth = "+str(a))) + print(("kap = "+str(b))) + print(("kphi = "+str(c)+"\n")) + elif conversion=='fourc': + a,b,c = _kappa_to_euler(ang1,ang2,ang3,**kwargs) + print(("\n"+"kth = "+str(ang1))) + print(("kap = "+str(ang2))) + print(("kphi = "+str(ang3))) + print("~~~~~~~~") + print(("th = "+str(a))) + print(("chi = "+str(b))) + print(("phi = "+str(c)+"\n")) + else: + print('2nd argument invalid; please choose one of the following:') + print('"Kappa" or "fourc"') + return a,b,c + + + +def _euler_to_kappa(e_theta,e_chi,e_phi,**kwargs): + """ + convert from euler to kappa + """ + kwargs.setdefault('k_arm',50) + kwargs.setdefault('kth_offset',_get_kth_offset) + k_arm = kwargs['k_arm'] + kth_offset = kwargs['kth_offset'] + + pi_deg = np.pi/180.0 + + if(abs(e_chi)> 2.0*k_arm): + print("Chi should be no more than twice the Kappa arm offset angle (k_arm = "+str(k_arm)+").") + kth,kap,kphi=0,0,0 + else: + k_ang = k_arm*pi_deg + delta = np.asin( - np.tan(e_chi*pi_deg/2.0) / np.tan(k_ang) ) + + k_theta = e_theta*pi_deg - delta + k_kappa = 2.0 * np.asin( np.sin(e_chi*pi_deg/2.0) / np.sin(k_ang)) + k_phi = e_phi*pi_deg - delta + + kth = np.round_(k_theta/pi_deg)-(57.045-kth_offset) + kap = np.round_(k_kappa/pi_deg) + kphi = np.round_(k_phi/pi_deg) + return (kth,kap,kphi) + +def _kappa_to_euler(k_theta,k_kappa,k_phi,**kwargs): + """ + convert from kappa to euler + """ + kwargs.setdefault('k_arm',50) + kwargs.setdefault('kth_offset',_get_kth_offset) + k_arm = kwargs['k_arm'] + kth_offset = kwargs['kth_offset'] + + pi_deg = np.pi/180.0 + k_ang = k_arm*pi_deg + delta = np.atan( np.tan(k_kappa*pi_deg/2.0) * np.cos(k_ang) ) + e_theta = k_theta*pi_deg - delta + e_chi = 2.0 * np.asin( np.sin(k_kappa*pi_deg/2.0) * np.sin(k_ang) ) + e_phi = k_phi*pi_deg - delta + + theta = np.round_(e_theta/pi_deg,3)+(57.045-kth_offset) + chi = np.round_(e_chi/pi_deg,3) # convert from rad to deg + phi = np.round_(e_phi/pi_deg,3) + return (theta,chi,phi) + + +def _get_kth_offset(verbose=True): + try: + kth_offset=caget('29idKappa:userCalcOut1.G') + except: + kth_offset = 0 + if verbose: + print(("Calculating Euler angles using kth0 = "+str(kth_offset))) + return kth_offset \ No newline at end of file diff --git a/iexcode/instruments/m3r.py b/iexcode/instruments/m3r.py index 7a8f790e26a43711e85f3eddb6fab155762d6daf..a996a86592432ce59e4b82524506d12b8404ec16 100644 --- a/iexcode/instruments/m3r.py +++ b/iexcode/instruments/m3r.py @@ -29,7 +29,7 @@ def m3r_RY_pos_sp_get(): RY_SP = caget('29id_m3r:RY_POS_SP') return RY_SP -def m3R_tweak (axis,val): +def m3r_tweak (axis,val): """ \"TX\" = lateral \"RX\" = Yaw \"TY\" = vertical \"RY\" = Pitch @@ -46,9 +46,9 @@ def m3r_tweak_pitch(sign,val=0.005): """ axis="RY" if sign == "+": - m3R_tweak(axis,val) + m3r_tweak(axis,val) elif sign == "-": - m3R_tweak(axis,-val) + m3r_tweak(axis,-val) def m3r_table(branch): @@ -56,7 +56,6 @@ def m3r_table(branch): Defines the positions used by switch_branch() form M3R WARNING: branch_pv uses: D => (Tx <= 0) and (Ry < 0) - Make sure this remains true or change it """ - branch = branch.lower() positions={ "c":[10,0,0,0,0,0], "d":[-2.5,0,0,-13.955,-16.450,-5.15], @@ -69,6 +68,7 @@ def m3r_table(branch): position = positions[branch] except KeyError: print_warning_message("not a valid branch") + print(list(positions.keys())) position = FMB_mirror_get(3,verbose=False) return position @@ -102,7 +102,7 @@ def m3r_switch_branch(branch): ################################ M3R alignment ############################## ############################################################################################################## -def centroid(t=None,q=1): +def m3r_centroid(t=None,q=1): ''' Return position of centroid, sigma, m3r:RY (mirror pitch) Optional argument t to set camera intergration time. diff --git a/iexcode/instruments/slits.py b/iexcode/instruments/slits.py index 3aa8714d265b2ae2572ef76e7fe0baaed80e0585..a0be522699c34769932496f6dfb5db1e394b39c1 100644 --- a/iexcode/instruments/slits.py +++ b/iexcode/instruments/slits.py @@ -1,12 +1,12 @@ from numpy import inf,nan from epics import caget, caput -from .IEX_endstations import * +from .IEX_BL_config import * from iexcode.instruments.shutters import main_shutter_close from iexcode.instruments.utilities import print_warning_message -from iexcode.instruments.encoders import encoders_reset +from iexcode.instruments.encoders import encoders_reset_zero slit_ioc="29idb:" @@ -294,7 +294,7 @@ def slit2B_encoders_reset(Hcenter,Vcenter): Previously: Reset_Slit2B_Encoders """ - encoders_reset('slit2B',Hcenter,Vcenter) + encoders_reset_zero('slit2B',Hcenter,Vcenter) slits_synch('slit2B') @@ -361,7 +361,7 @@ def slit3D_encoders_reset(Hcenter,Vcenter): Previously: Reset_Slit2B_Encoders """ - encoders_reset('slit3D',Hcenter,Vcenter) + encoders_reset_zero('slit3D',Hcenter,Vcenter) slits_synch('slit3D') def exit_slit(branch, size, verbose=True): diff --git a/iexcode/instruments/utilities.py b/iexcode/instruments/utilities.py index e680a30cde984132f0ffdab4d8d311dff3e9397a..2a1fdcd95ece60a3fd9aa9382995d0ea79211e7c 100644 --- a/iexcode/instruments/utilities.py +++ b/iexcode/instruments/utilities.py @@ -83,20 +83,20 @@ def playsound(sound='FF'): sounds = '/home/beams/29IDUSER/Documents/User_Macros/Macros_29id/Sound_Files/hallelujah.wav' os.system('aplay ' + sounds) -def RangeUp(start,end,step): +def range_up(start,end,step): while start <= end: yield start start += abs(step) -def RangeDown(start,end,step): +def range_down(start,end,step): while start >= end: yield start start -= abs(step) def EgForLoop(): - for hv in RangeDown(2000,500,-500): + for hv in range_down(2000,500,-500): print(hv) - for hv in RangeUp(500,2000,500): + for hv in range_up(500,2000,500): print(hv) def take_closest_value(my_list,my_number): diff --git a/iexcode/instruments/xrays.py b/iexcode/instruments/xrays.py index ff15f4d626828e3a054e7d5b99b3a18991e1afeb..7efd0244f87cc21e0ad84233d62d95d2bfeacf50 100644 --- a/iexcode/instruments/xrays.py +++ b/iexcode/instruments/xrays.py @@ -456,7 +456,7 @@ def scanXAS(start_stop_step_lists,ID_eV=None, **kwargs): #Averaging and Normalization ca_average(kwargs['average_pnts'],ca_detector_list(iex.BL.branch)) if iex.BL.branch=="d": - meshD("In") + mesh_d("In") print_warning_message('MeshD is not automatically removed') #mpa diff --git a/iexcode/launch_ARPES.py b/iexcode/launch_ARPES.py index 5e42fdfbfaa88185a0b350c9091be2ef61ad2a0c..388a8cfc906a0e88eb789067c613130abe67573b 100644 --- a/iexcode/launch_ARPES.py +++ b/iexcode/launch_ARPES.py @@ -1,21 +1,4 @@ -import numpy as np -from time import sleep - -from epics import caget,caput,PV - -#general stuff -import iexcode.instruments.cfg as iex -from iexcode.instruments.cameras import cam_snap -from iexcode.instruments.utilities import playsound -from iexcode.instruments.get_all import get_all - -#xray stuff - from iexcode.instruments.ARPES import * +from iexcode.instruments.diagnostics import diode_c, diode_c_read from iexcode.instruments.electron_analyzer import * - -from iexcode.instruments.current_amplifiers import * -from iexcode.instruments.Lakeshore_335 import * - -BL = Endstation('ARPES') diff --git a/iexcode/launch_Kappa.py b/iexcode/launch_Kappa.py index cc00a4f4ce96f3323227261c49c8be028462806a..16745ea974e08120682cc769144616398e4823f7 100644 --- a/iexcode/launch_Kappa.py +++ b/iexcode/launch_Kappa.py @@ -1,13 +1,12 @@ +from iexcode.instruments.diagnostics import diode_d, mesh_d, mesh_d_read -from iexcode.instruments.Kappa import * -from iexcode.instruments.Kappa_det import * -from iexcode.instruments.Kappa_Euler import * -from iexcode.instruments.current_amplifiers import * -from iexcode.instruments.MPA import * -from iexcode.instruments.vortexs import * +from iexcode.instruments.kappa_angle_calcs import * +from iexcode.instruments.kappa_det import * +from iexcode.instruments.kappa import * +from iexcode.instruments.MPA import * +from iexcode.instruments.vortex import * from iexcode.instruments.spec_stuff import * -BL = Endstation('Kappa') \ No newline at end of file diff --git a/iexcode/launch_all.py b/iexcode/launch_all.py new file mode 100644 index 0000000000000000000000000000000000000000..768f822d0ed802ff3b2f2c0c89dc929256229f29 --- /dev/null +++ b/iexcode/launch_all.py @@ -0,0 +1,10 @@ + +from iexcode.instruments.cameras import * +import iexcode.instruments.cfg as iex +from iexcode.instruments.conversions_constants import * +from iexcode.instruments.current_amplifiers import Keithley,SRS +from iexcode.instruments.utilities import playsound,range_up,range_down,take_closest_value +from iexcode.instruments.diagnostics import diagnostics_list_all, diagnostic +from iexcode.instruments.diagnostics import diagnostics_all_out, diagnostics_all_in, mesh_W +from iexcode.instruments.IEX_BL_config import get_all +from iexcode.instruments.Motors import * diff --git a/iexcode/launch_staff.py b/iexcode/launch_staff.py index 08e2e9318222199ea7d70127d6335018dc6fe852..902b6635942749076c820cf2b0bfe139a5449e86 100644 --- a/iexcode/launch_staff.py +++ b/iexcode/launch_staff.py @@ -1,2 +1,11 @@ -from iexcode.instruments.staff import * +from iexcode.instruments.bakeout import * +from iexcode.instruments.diagnostics import mesh_W +from iexcode.instruments.encoders import * +from iexcode.instruments.files_and_folders import * +from iexcode.instruments.hxp_mirrors import * +from iexcode.instruments.IEX_BL_config import * +from iexcode.instruments.m3r import * + + + diff --git a/iexcode/launch_xrays.py b/iexcode/launch_xrays.py index 475d15cf2abba51b7a60c4b59cde46628bd17d49..fc12149a107aac405653157af6589fec3588b815 100644 --- a/iexcode/launch_xrays.py +++ b/iexcode/launch_xrays.py @@ -1,12 +1,3 @@ -from iexcode.instruments.get_all import * -from iexcode.instruments.diagnostics import * -from iexcode.instruments.FMB_mirrors import * -from iexcode.instruments.valves import * -from iexcode.instruments.hxp_mirrors import * -from iexcode.instruments.IEX_VPU import * -from iexcode.instruments.m3r import * -from iexcode.instruments.slits import * -from iexcode.instruments.resolution import * -from iexcode.instruments.storage_ring import * -from iexcode.instruments.VLS_PGM import * -from iexcode.instruments.xrays import * \ No newline at end of file +from iexcode.instruments.IEX_VPU import ID_get_all,ID_off,ID_start,ID_restart +from iexcode.instruments.m3r import m3r_centroid,m3r_align,m3r_tweak_pitch +from iexcode.instruments.xrays import * diff --git a/iexcode/macros/Kappa_optimization.py b/iexcode/macros/Kappa_optimization.py index 07ac00a4a651cb73586f86ba03482e4fc92778cd..353d2012806a6149a0130583c7f97b1297c9bed8 100644 --- a/iexcode/macros/Kappa_optimization.py +++ b/iexcode/macros/Kappa_optimization.py @@ -1,7 +1,7 @@ import matplotlib.pyplot as plt from epics import caget,caput -from ..instruments.Kappa import * +from ..instruments.kappa import * from ..instruments.Motors import * from .quick_plot import fit_mda, mda_1D diff --git a/iexcode/macros/__init__.py b/iexcode/macros/__init__.py index 8ccf3df1571798ce4fa3a305fa3ac5ca11eff3e5..22fb71cbe6c4dbf4d150e410132792ad6b62713f 100644 --- a/iexcode/macros/__init__.py +++ b/iexcode/macros/__init__.py @@ -5,7 +5,7 @@ from iexcode.instruments.cameras import * from iexcode.instruments.conversions_constants import * from iexcode.instruments.encoders import * from iexcode.instruments.files_and_folders import * -from iexcode.instruments.IEX_endstations import * +from iexcode.instruments.IEX_BL_config import * from iexcode.instruments.Logfile import * from iexcode.instruments.Motors import * from iexcode.instruments.remote_controlers import * diff --git a/iexcode/macros/commissioning.py b/iexcode/macros/commissioning.py index f04c8276e1409022ff9afd039ed2bfc9c12829d2..ca2263ca8c3c395bf521483bded7267b86a110b1 100644 --- a/iexcode/macros/commissioning.py +++ b/iexcode/macros/commissioning.py @@ -14,7 +14,7 @@ from ..instruments.xrays import energy from ..instruments.m3r import M3R_branch from ..instruments.IEX_VPU import ID_switch_mode -from ..instruments.diagnostics import diagnostics_all_out, diagnostics_all_in,diodeC,diodeD +from ..instruments.diagnostics import diagnostics_all_out, diagnostics_all_in,diode_c,diodeD from ..instruments.current_amplifiers import current2flux from ..instruments.slits import set_exit_slit from ..instruments.Logfile import * @@ -22,7 +22,7 @@ from ..instruments.cameras import * from ..instruments.ARPES import * from ..instruments.electron_analyzer import * -from ..instruments.Kappa import * +from ..instruments.kappa import * from .quick_plot import fit_mda, mda_1D @@ -109,7 +109,7 @@ def check_flux(hv=500,ID_mode='RCP',stay=False): SR=round(caget("S:SRcurrentAI.VAL"),2) if m3r_branch() == "c": current_slit=caget('29idb:Slit3CFit.A') - diodeC('In') + diode_c('In') set_exit_slit(50) sleep(10) diode=diodeC_read() @@ -271,11 +271,11 @@ def mono_MIR_GRT_find_offset(grating,slit_list,**kwargs): switch_gratings(grating) exit_slit(50) - diodeC('In') + diode_c('In') slit2B_set(2,0.5,0,0) #set zero order, scan grating pitch - for ang in RangeUp(1.5,5,0.5): + for ang in range_up(1.5,5,0.5): print("\r") mono_zero_order(ang) print("Mirror pitch: "+str(ang)+"\r") @@ -339,7 +339,7 @@ def scan_energy_along_grating(hv,peakBE=84,pts=11,r=0.75,i=1,**kwargs): print("\n--------------- Starting core level vs Slit-2B(V) map ---------------") #Take XPS for each Slit-2V position - for V_center in RangeUp(Vstart,-Vstart,Vstep): + for V_center in range_up(Vstart,-Vstart,Vstep): caput(center_val,V_center,wait=True,timeout=18000) kwargs.update({'comment': "2-V center ="+str(V_center)[0:6]}) EAlist=["BE",peakBE,PE,17*60*i,1] @@ -363,7 +363,7 @@ def scan_mono_energy_drift(start,stop,step,peakBE=84,EF=None,**kwargs): ''' kwargs.setdefault('c','3') - for hv in RangeUp(start,stop,step): + for hv in range_up(start,stop,step): energy(hv) c=int(kwargs['c']) exit_slit_vs_hv(hv,c) @@ -792,7 +792,7 @@ def ID_calibration_scan(ID_start,ID_stop,ID_step,bandwidth=10,QP=None,Harm=1,sca log_print(comment="====== Starting Mono Scan vs ID ======") - for ID_energy in RangeUp(ID_start,ID_stop,ID_step): + for ID_energy in range_up(ID_start,ID_stop,ID_step): print("\n------------------ ID-SP @ "+str(ID_energy)+" ------------------") mono_energy_set(ID_energy) ID_SP_set(ID_energy) diff --git a/iexcode/macros/quick_plot.py b/iexcode/macros/quick_plot.py index f4670aeb1001b40f445fd2511608c627945aef5a..8a169e2e3fb53cf0c7c1c67de2026344cd5bfbbd 100755 --- a/iexcode/macros/quick_plot.py +++ b/iexcode/macros/quick_plot.py @@ -33,7 +33,7 @@ from IEX_plotting_and_analysis.IEX_nData import * try: from epics import caget - from ..instruments.IEX_endstations import BL + from ..instruments.IEX_BL_config import BL from ..instruments.utilities import read_dict,today from ..instruments.slits import apertures_set from IEXcode.iexcode.current_amplifiers import current2flux diff --git a/iexcode/macros/start_of_the_week.py b/iexcode/macros/start_of_the_week.py index 24ff756fe4bb352df7ca0fc5b8cc6379614669d8..be2a73b73f525ab1b999727dde31a7656f8c61a0 100644 --- a/iexcode/macros/start_of_the_week.py +++ b/iexcode/macros/start_of_the_week.py @@ -1,6 +1,6 @@ import matplotlib.pyplot as plt -from ..instruments.diagnostics import diodeC +from ..instruments.diagnostics import diode_c from ..instruments.files_and_folders import check_run from ..instruments.utilities import wait_for_it from ..instruments.current_amplifiers import Keithley @@ -10,7 +10,7 @@ from ..instruments.xrays import * from ..instruments.shutters import * from ..instruments.slits import * -from ..instruments.Kappa import * +from ..instruments.kappa import * from ..instruments.ARPES import * from .commissioning import * @@ -57,7 +57,7 @@ def start_of_the_week(grt,branch,wait=False,**kwargs): if branch == 'c': diode = Keithley('b',15) diode.autoscale() - diodeC('In') + diode_c('In') else: foo=input('Do you have a diode in direct beam (y or n)? >') if foo.lower() == 'y' or foo.lower() == 'yes': @@ -267,7 +267,7 @@ def start_of_the_week(grt,branch,wait=False,**kwargs): ###### Check flux: if 'flux' in kwargs['scanType']: if m3r_branch == 'c': - diodeC('In') + diode_c('In') print("\n\n================== Check Flux:") flag=True while flag: