diff --git a/config/session_metadata.properties b/config/session_metadata.properties index 76377f8..8e3ae0a 100755 --- a/config/session_metadata.properties +++ b/config/session_metadata.properties @@ -1,5 +1,5 @@ -#Fri Apr 30 17:00:58 CEST 2021 +#Wed May 05 22:02:15 CEST 2021 keywords=List;[] -ownerEmail=String;jgpark10@snu.ac.kr +ownerEmail=String;adirajan@uni-mainz.de contactEmail=String;armin.kleibert@psi.ch -owner=String;Erik Folven +owner=String;Adithya Rajan diff --git a/config/sessions.properties b/config/sessions.properties index 73eaa2e..1f746d2 100755 --- a/config/sessions.properties +++ b/config/sessions.properties @@ -1,2 +1,2 @@ -#Tue May 04 08:05:11 CEST 2021 -SessionCounter=20 +#Tue May 11 10:49:31 CEST 2021 +SessionCounter=24 diff --git a/config/settings.properties b/config/settings.properties index 83a28da..7880c92 100755 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,26 +1,20 @@ -#Tue May 04 16:48:06 CEST 2021 -HARMONIC_ID_1=1 +#Tue May 11 14:15:16 CEST 2021 +proposal=proposal RSYNC_USER= +ENERGY=710 OUTLIERS_THRESHOLD=1000000000 +proposer=proposer +POL_ID_1=Circ_Plus NORM_FILE=/sls/X11MA/data/X11MA/Data1/2021/Yona250121/s250121 AUTO_SWITCH_VALVE=true -DRY_RUN=false -POL_ID_2=Lin_Ver -OFFSET_ID_1=0.0 -ID=ID1_ID2 -OFFSET_ID_2=-1.1 -proposal=proposal -ENERGY=852.5 -proposer=proposer -POL_ID_1=Lin_Hor RSYNC_HOST= sample=sample RSYNC_PATH= +DRY_RUN=false pgroup=pgroup -ALPHA_ID_2=0.0 -ALPHA_ID_1=15.0 +POL_ID_2=Circ_Minus RSYNC_DEL=true +ID=ID1_ID2 AVERAGING_DETECTOR=true -HARMONIC_ID_2=1 FdaBrowser=false authors=author1|author2 diff --git a/config/variables.properties b/config/variables.properties index 7159ee6..87bf68c 100755 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,4 +1,4 @@ -#Wed May 05 17:03:21 CEST 2021 -LastRunDate=210505 -FileSequentialNumber=7364 -DaySequentialNumber=76 +#Tue May 11 14:08:17 CEST 2021 +LastRunDate=210511 +FileSequentialNumber=7542 +DaySequentialNumber=71 diff --git a/devices/girder_x.properties b/devices/girder_x.properties old mode 100644 new mode 100755 diff --git a/devices/image.properties b/devices/image.properties index 9ff5fc4..a43b320 100755 --- a/devices/image.properties +++ b/devices/image.properties @@ -1,4 +1,4 @@ -#Wed May 05 09:55:16 CEST 2021 +#Tue May 11 10:36:23 CEST 2021 spatialCalOffsetY=NaN spatialCalOffsetX=NaN colormapLogarithmic=false @@ -6,7 +6,7 @@ scale=1.0 grayscale=false spatialCalScaleX=NaN spatialCalScaleY=NaN -colormapMax=81.992 +colormapMax=1.0 rescaleOffset=0.0 roiWidth=-1 colormap=Grayscale diff --git a/devices/obj_stig_a.properties b/devices/obj_stig_a.properties old mode 100644 new mode 100755 diff --git a/devices/obj_stig_b.properties b/devices/obj_stig_b.properties old mode 100644 new mode 100755 diff --git a/devices/objective.properties b/devices/objective.properties old mode 100644 new mode 100755 diff --git a/plugins/Eiger.java b/plugins/Eiger.java index 9cb8ae3..eab90e1 100755 --- a/plugins/Eiger.java +++ b/plugins/Eiger.java @@ -358,18 +358,25 @@ public class Eiger extends Panel { }// //GEN-END:initComponents private void comboDepthActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboDepthActionPerformed - try{ - if (!updatingControls){ - ((ch.psi.pshell.device.Camera) getDevice("eiger")).stop(); - TimeUnit.SECONDS.sleep(1); - if (comboDepth.getSelectedIndex()!=comboDepth.getItemCount()) { + comboDepth.setEnabled(false); + new Thread( ()-> { + try{ + ch.psi.pshell.device.Camera eiger = (ch.psi.pshell.device.Camera) getDevice("eiger"); + if (comboDepth.getSelectedIndex()!=comboDepth.getItemCount()) { + if (eiger.isStarted()){ + buttonStopDetectorActionPerformed(null); + eiger.waitState(State.Ready, 10000); //Timeout of 10s + } Integer value = Integer.valueOf((String)comboDepth.getSelectedItem()); - bitDepth.write(value); + bitDepth.write(value); } + } catch (Exception ex){ + showException(ex); + } + finally{ + comboDepth.setEnabled(true); } - } catch (Exception ex){ - showException(ex); - } + }).start(); }//GEN-LAST:event_comboDepthActionPerformed private void buttonStartDetectorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartDetectorActionPerformed @@ -386,31 +393,45 @@ public class Eiger extends Panel { }//GEN-LAST:event_buttonStartDetectorActionPerformed private void comboModeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboModeActionPerformed - try{ - if (!updatingControls){ + comboMode.setEnabled(false); + new Thread( ()-> { + try{ + ch.psi.pshell.device.Camera eiger = (ch.psi.pshell.device.Camera) getDevice("eiger"); + if (eiger.isStarted()){ + buttonStopDetectorActionPerformed(null); + eiger.waitState(State.Ready, 10000); //Timeout of 10s + } Integer value = comboMode.getSelectedIndex(); if (value==1){ value++; } - ((ch.psi.pshell.device.Camera) getDevice("eiger")).stop(); - TimeUnit.SECONDS.sleep(1); mode.write(value); + } catch (Exception ex){ + showException(ex); + } + finally{ + comboMode.setEnabled(true); } - } catch (Exception ex){ - showException(ex); - } + }).start(); }//GEN-LAST:event_comboModeActionPerformed private void spinnerExposureStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerExposureStateChanged - try{ - if (!updatingControls){ - ((ch.psi.pshell.device.Camera) getDevice("eiger")).stop(); - TimeUnit.SECONDS.sleep(1); + spinnerExposure.setEnabled(false); + new Thread( ()-> { + try{ + ch.psi.pshell.device.Camera eiger = (ch.psi.pshell.device.Camera) getDevice("eiger"); + if (eiger.isStarted()){ + buttonStopDetectorActionPerformed(null); + eiger.waitState(State.Ready, 10000); //Timeout of 10s + } exposure.write((Double)spinnerExposure.getValue()); + } catch (Exception ex){ + showException(ex); + } + finally{ + spinnerExposure.setEnabled(true); } - } catch (Exception ex){ - showException(ex); - } + }).start(); }//GEN-LAST:event_spinnerExposureStateChanged private void buttonStopDetectorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStopDetectorActionPerformed diff --git a/script/Test_Autofocus_Armin.py b/script/Test_Autofocus_Armin.py new file mode 100755 index 0000000..b0876ae --- /dev/null +++ b/script/Test_Autofocus_Armin.py @@ -0,0 +1,28 @@ +RANGE_OBJ = 1.0 +STEP_OBJ = 0.1 +RANGE_STIG = 10.0 +STEP_STIG = 1.0 +UPDATE_POSITION = True +AVERAGE = 1 +width, height = eiger.getImageSize() +ROI = Rectangle(width/3, height/3, width/3, height/3,) + +initial_state = objective.read(),obj_stig_a.read(),obj_stig_b.read() +print "Initial state:" , initial_state + +def apply_pos(pos): + objective.write(pos[0]) + obj_stig_a.write(pos[1]) + obj_stig_b.write(pos[2]) + + +r=scan_focus(objective, RANGE_OBJ, STEP_OBJ, roi = ROI, average = AVERAGE, update_position = UPDATE_POSITION) +r=scan_focus(obj_stig_a, RANGE_STIG, STEP_STIG, roi = ROI, average = AVERAGE, update_position = UPDATE_POSITION) +r=scan_focus(obj_stig_b, RANGE_STIG, STEP_STIG, roi = ROI, average = AVERAGE, update_position = UPDATE_POSITION) +r=scan_focus(objective, RANGE_OBJ, STEP_OBJ, roi = ROI, average = AVERAGE, update_position = UPDATE_POSITION) +r=scan_focus(obj_stig_a, RANGE_STIG, STEP_STIG, roi = ROI, average = AVERAGE, update_position = UPDATE_POSITION) +r=scan_focus(obj_stig_b, RANGE_STIG, STEP_STIG, roi = ROI, average = AVERAGE, update_position = UPDATE_POSITION) +r=scan_focus(objective, RANGE_OBJ, STEP_OBJ, roi = ROI, average = AVERAGE, update_position = UPDATE_POSITION) + +final_state = objective.read(),obj_stig_a.read(),obj_stig_b.read() +print "Final state:" , final_state diff --git a/script/Users/federico/2021_may_beamtime.py b/script/Users/federico/2021_may_beamtime.py new file mode 100644 index 0000000..352a867 --- /dev/null +++ b/script/Users/federico/2021_may_beamtime.py @@ -0,0 +1,111 @@ +#otf(start, end, time, delay = 0.0, mode = None, offset = None, alpha = None, name = None, folder = 'TEST') + + +#Sample Na +set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/210512/LMO/") +nr_loops=2 + +TRY.write(21.0) +TRZ.write(8.2) + +time.sleep(30) + +open_vg13() +time.sleep(1) + +caput('X11MA-ES3-MAG1:V', 10) +time.sleep(15) +caput('X11MA-ES3-MAG1:V', 3) +time.sleep(10) + +for i in range(4): + time.sleep(1) + caput('X11MA-KEI10:RANGE', 7) + caput('X11MA-KEI11:RANGE', 8) + caput('X11MA-KEI12:RANGE', 10) + otf(start=520, end=570, time=2.5, delay=30, mode='LINEAR', alpha = 0.0, offset=0.0, name='M052_20K_OK_Lh_Hp_'+i, folder='./') + otf(start=520, end=570, time=2.5, delay=30, mode='LINEAR', alpha = 0.0, offset=0.0, name='M052_20K_OK_Lv_Hp_'+i, folder='./') + +for i in range(2): + time.sleep(1) + caput('X11MA-KEI10:RANGE', 7) + caput('X11MA-KEI11:RANGE', 8) + caput('X11MA-KEI12:RANGE', 10) + otf(start=625, end=675, time=2.5, delay=30, mode='CIRC +', alpha = 0.0, offset=0.0, name='M052_20K_MnL_Cp_Hp_'+i, folder='./') + otf(start=625, end=675, time=2.5, delay=30, mode='CIRC -', alpha = 0.0, offset=0.0, name='M052_20K_MnL_Cm_Hp_'+i, folder='./') + otf(start=625, end=675, time=2.5, delay=30, mode='LINEAR', alpha = 0.0, offset=0.0, name='M052_20K_MnL_Lv_Hp_'+i, folder='./') + otf(start=625, end=675, time=2.5, delay=30, mode='LINEAR', alpha = 0.0, offset=0.0, name='M052_20K_MnL_Lh_Hp_'+i, folder='./') + +caput('X11MA-PGM:energy', 625) +caput('X11MA-ES3-MAG1:V', -10) +time.sleep(15) +caput('X11MA-ES3-MAG1:V', -3) +time.sleep(10) + +for i in range(2): + time.sleep(1) + caput('X11MA-KEI10:RANGE', 7) + caput('X11MA-KEI11:RANGE', 8) + caput('X11MA-KEI12:RANGE', 10) + otf(start=625, end=675, time=2.5, delay=30, mode='CIRC +', alpha = 0.0, offset=0.0, name='M052_20K_MnL_Cp_Hm_'+i, folder='./') + otf(start=625, end=675, time=2.5, delay=30, mode='CIRC -', alpha = 0.0, offset=0.0, name='M052_20K_MnL_Cm_Hm_'+i, folder='./') + otf(start=625, end=675, time=2.5, delay=30, mode='LINEAR', alpha = 0.0, offset=0.0, name='M052_20K_MnL_Lv_Hm_'+i, folder='./') + otf(start=625, end=675, time=2.5, delay=30, mode='LINEAR', alpha = 0.0, offset=0.0, name='M052_20K_MnL_Lh_Hm_'+i, folder='./') + +time.sleep(1) +close_vg13() + +caput('X11MA-PGM:energy', 625) +TRY.write(21.0) +TRZ.write(8.2) +time.sleep(30) + +open_vg13() +time.sleep(1) + + +for i in range(2): + time.sleep(1) + caput('X11MA-KEI10:RANGE', 7) + caput('X11MA-KEI11:RANGE', 8) + caput('X11MA-KEI12:RANGE', 10) + otf(start=625, end=675, time=2.5, delay=30, mode='CIRC +', alpha = 0.0, offset=0.0, name='M054_20K_MnL_Cp_Hm_'+i, folder='./') + otf(start=625, end=675, time=2.5, delay=30, mode='CIRC -', alpha = 0.0, offset=0.0, name='M054_20K_MnL_Cm_Hm_'+i, folder='./') + otf(start=625, end=675, time=2.5, delay=30, mode='LINEAR', alpha = 0.0, offset=0.0, name='M054_20K_MnL_Lv_Hm_'+i, folder='./') + otf(start=625, end=675, time=2.5, delay=30, mode='LINEAR', alpha = 0.0, offset=0.0, name='M054_20K_MnL_Lh_Hm_'+i, folder='./') + +caput('X11MA-PGM:energy', 520) +caput('X11MA-ES3-MAG1:V', 10) +time.sleep(15) +caput('X11MA-ES3-MAG1:V', 3) +time.sleep(10) + + +for i in range(4): + time.sleep(1) + caput('X11MA-KEI10:RANGE', 7) + caput('X11MA-KEI11:RANGE', 8) + caput('X11MA-KEI12:RANGE', 10) + otf(start=520, end=570, time=2.5, delay=30, mode='LINEAR', alpha = 0.0, offset=0.0, name='M054_20K_OK_Lh_Hp_'+i, folder='./') + otf(start=520, end=570, time=2.5, delay=30, mode='LINEAR', alpha = 0.0, offset=0.0, name='M054_20K_OK_Lv_Hp_'+i, folder='./') + +for i in range(2): + time.sleep(1) + caput('X11MA-KEI10:RANGE', 7) + caput('X11MA-KEI11:RANGE', 8) + caput('X11MA-KEI12:RANGE', 10) + otf(start=625, end=675, time=2.5, delay=30, mode='CIRC +', alpha = 0.0, offset=0.0, name='M054_20K_MnL_Cp_Hp_'+i, folder='./') + otf(start=625, end=675, time=2.5, delay=30, mode='CIRC -', alpha = 0.0, offset=0.0, name='M054_20K_MnL_Cm_Hp_'+i, folder='./') + otf(start=625, end=675, time=2.5, delay=30, mode='LINEAR', alpha = 0.0, offset=0.0, name='M054_20K_MnL_Lv_Hp_'+i, folder='./') + otf(start=625, end=675, time=2.5, delay=30, mode='LINEAR', alpha = 0.0, offset=0.0, name='M054_20K_MnL_Lh_Hp_'+i, folder='./') + +caput('X11MA-PGM:energy', 520) +time.sleep(1) +close_vg13() + + + + + + + diff --git a/script/devices/id.py b/script/devices/id.py index 7702dec..215799b 100755 --- a/script/devices/id.py +++ b/script/devices/id.py @@ -143,7 +143,6 @@ def put_id_pol(id, pol, alpha=None): time.sleep(0.5) if alpha is not None: alpha_dev.write(alpha) - def tune_detune(active_id): if get_dry_run(): diff --git a/script/local.py b/script/local.py index f0deb98..461cebf 100755 --- a/script/local.py +++ b/script/local.py @@ -7,7 +7,7 @@ from rsync import * from mathutils import estimate_peak_indexes, fit_gaussians, create_fit_point_list, Gaussian from mathutils import fit_polynomial,fit_gaussian, fit_harmonic, calculate_peaks from mathutils import PolynomialFunction, Gaussian, HarmonicOscillator - +from collections import OrderedDict ProviderCSV.setDefaultItemSeparator(", ") get_context().dataManager.createLogs=False @@ -246,7 +246,7 @@ def otf2(start, end, time, delay = 0.0, mode = None, offset = None, alpha = None run("templates/EnergyScan_v2", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "FOLDER":folder, "FILE":name, "ALPHA":float(alpha) if alpha is not None else None}) -def two_pol(switching="Tune_Detune", sequence="A", measurements=4, exposure=1.0, average=2, name = None): +def two_pol(switching="Tune_Detune", sequence="A", measurements=1, exposure=1.0, average=1, name = None): set_exec_pars(open=False) if name: set_exec_pars(name=name) @@ -259,7 +259,7 @@ def two_pol(switching="Tune_Detune", sequence="A", measurements=4, exposure=1.0, "NUMBER_SCANS":1, "SWITCH_POL": False, \ }) -def two_energies(energy_1, energy_2, measurements=4, exposure=1.0, average=2, name = None): +def two_energies(energy_1, energy_2, measurements=1, exposure=1.0, average=1, name = None): set_exec_pars(open=False) if name: set_exec_pars(name=name) @@ -272,7 +272,7 @@ def two_energies(energy_1, energy_2, measurements=4, exposure=1.0, average=2, na "NUMBER_SCANS":1, "SWITCH_POL": False, \ }) -def take_image(scans=1, switch_pol=False, measurements=4, exposure=1.0, average=2, name = None): +def take_image(scans=1, switch_pol=False, measurements=1, exposure=1.0, average=1, name = None): set_exec_pars(open=False) if name: set_exec_pars(name=name) @@ -285,16 +285,29 @@ def take_image(scans=1, switch_pol=False, measurements=4, exposure=1.0, average= "NUMBER_SCANS":scans, "SWITCH_POL": switch_pol, \ }) -def abs_spec(ranges, roi=None, switch_pol=False, scans=1, exposure=1.0, average=2, name = None): +def abs_spec(ranges, roi=None, switch_pol=False, scans=1, exposure=1.0, average=1, name = None): set_exec_pars(open=False) + + if is_string(ranges): + with open(expand_path("{config}/AbsortionSpectrum/" + ranges + ".abs"), 'r') as f: + ranges = Serializer.decode(f.read(), Serializer.EncoderType.bin)[0] + ranges = to_array(ranges,'d') + + if is_string(roi): + with open(expand_path("{config}/ROIs/" + roi + ".roi"), 'rb') as f: + roi = OrderedDict() + for r in Serializer.decode(f.read(), Serializer.EncoderType.bin)[0]: + roi[str(r[0])] = [int(r[1]), int(r[2]), int(r[3]), int(r[4])] + if name: set_exec_pars(name=name) - if ROI is None: + + if roi is None: if ("DAQ_PANEL_ROIS" in globals()) and (len(DAQ_PANEL_ROIS) > 0): - ROI = DAQ_PANEL_ROIS + roi = DAQ_PANEL_ROIS else: width, height = eiger.getImageSize() - ROI = {"Region1": [0, 0, width, height]} + roi = {"Region1": [0, 0, width, height]} run("templates/EigerAbsSpec", { \ "ROI": roi, "SAVE_SPECTRUM": True, "SAVE_IMAGES":True, "WITH_I0": True, \ @@ -599,58 +612,91 @@ def play_sound(name): #Beamline setup ################################################################################################### -def apply_beamline_setup(ID,ENERGY,POL_ID_1,ALPHA_ID_1,HARMONIC_ID_1,OFFSET_ID_1,POL_ID_2,ALPHA_ID_2,HARMONIC_ID_2,OFFSET_ID_2): +def apply_beamline_setup(id,en=None,pol1=None,alp1=None,har1=None,off1=None,pol2=None,alp2=None,har2=None,off2=None): + print "Seting Beamline: ", en,pol1,alp1,har1,off1,pol2,alp2,har2,off2 if get_dry_run(): return - if ID=='ID1': + if id=='ID1': caput('X11PHS-E:OPT',1) - elif ID=='ID2': + elif id=='ID2': caput('X11PHS-E:OPT',2) - elif ID =='ID1_ID2': + elif id =='ID1_ID2': caput('X11PHS-E:OPT',3) - if ID == "ID1": - #current_pol=POL_IDS[POL_ID_1] #get_id_pol(1) - put_id_pol(1,POL_ID_1, ALPHA_ID_1 if (POL_ID_1=="Lin") else None ) + if id == "ID1": + #current_pol=POL_IDS[pol1] #get_id_pol(1) + if pol1 is not None: + put_id_pol(1,pol1, alp1 if (pol1=="Lin") else None ) caput('X11MA-ID2-GAP:SET',100) #open Gap ID2 - id1_harmonic.write(int(HARMONIC_ID_1)) - put_id_offset(1, float(OFFSET_ID_1)) #offset on ID1 + if har1 is not None: + id1_harmonic.write(int(har1)) + if off1 is not None: + put_id_offset(1, float(off1)) #offset on ID1 - elif ID == "ID2": - #current_pol=POL_IDS[POL_ID_2]#get_id_pol(2) - put_id_pol(2,POL_ID_2, ALPHA_ID_2 if (POL_ID_2=="Lin") else None ) + elif id == "ID2": + #current_pol=POL_IDS[pol2]#get_id_pol(2) + if pol2 is not None: + put_id_pol(2,pol2, alp2 if (pol2=="Lin") else None ) caput('X11MA-ID1-GAP:SET',100) #open Gap ID1 - id2_harmonic.write(int(HARMONIC_ID_2)) - put_id_offset(2, float(OFFSET_ID_2)) #offset on ID2 + if har2 is not None: + id2_harmonic.write(int(har2)) + if off2 is not None: + put_id_offset(2, float(off2)) #offset on ID2 - elif ID == "ID1_ID2": - #polID1=POL_IDS[POL_ID_1] - #polID2=POL_IDS[POL_ID_2] - put_id_pol(1,POL_ID_1, ALPHA_ID_1 if (POL_ID_1=="Lin") else None ) - put_id_pol(2,POL_ID_2, ALPHA_ID_2 if (POL_ID_2=="Lin") else None ) + elif id == "ID1_ID2": + #polID1=POL_IDS[pol1] + #polID2=POL_IDS[pol2] + if pol1 is not None: + put_id_pol(1,pol1, alp1 if (pol1=="Lin") else None ) + if pol2 is not None: + put_id_pol(2,pol2, alp2 if (pol2=="Lin") else None ) #current_pol=polID1 - id1_harmonic.write(int(HARMONIC_ID_1)) - id2_harmonic.write(int(HARMONIC_ID_2)) - put_id_offset(1, float(OFFSET_ID_1)) #offset on ID1 - put_id_offset(2, float(OFFSET_ID_2)) #offset on ID2 + if har1 is not None: + id1_harmonic.write(int(har1)) + if har2 is not None: + id2_harmonic.write(int(har2)) + if off1 is not None: + put_id_offset(1, float(off1)) #offset on ID1 + if off2 is not None: + put_id_offset(2, float(off2)) #offset on ID2 #wait_channel("X11PHS:alldone", 1) - energy.write(ENERGY) + if en is not None: + energy.write(en) + time.sleep(0.5) wait_channel("X11PHS:alldone", 1) + + +def change_pol(id, pol, alpha=None): + print "Changing polarization on id " + str(id), ": " + str(pol) , " - alpha=" + str(alpha) + if get_dry_run(): + return + put_id_pol(id, pol, alpha) + time.sleep(0.5) + wait_channel("X11PHS:alldone", 1) + +def change_offset(id, offset): + print "Changing offset on id " + str(id), ": " + str(offset) + if get_dry_run(): + return + put_id_offset(id, float(offset)) + time.sleep(0.5) + wait_channel("X11PHS:alldone", 1) -def set_beamline_setup(ID,ENERGY,POL_ID_1,ALPHA_ID_1,HARMONIC_ID_1,OFFSET_ID_1,POL_ID_2,ALPHA_ID_2,HARMONIC_ID_2,OFFSET_ID_2): - set_setting("ID", ID) - set_setting("ENERGY", ENERGY) - set_setting("POL_ID_1", POL_ID_1) - set_setting("ALPHA_ID_1", ALPHA_ID_1) - set_setting("HARMONIC_ID_1", HARMONIC_ID_1) - set_setting("OFFSET_ID_1", OFFSET_ID_1) - set_setting("POL_ID_2", POL_ID_2) - set_setting("ALPHA_ID_2", ALPHA_ID_2) - set_setting("HARMONIC_ID_2", HARMONIC_ID_2) - set_setting("OFFSET_ID_2", OFFSET_ID_2) - apply_beamline_setup(ID,ENERGY,POL_ID_1,ALPHA_ID_1,HARMONIC_ID_1,OFFSET_ID_1,POL_ID_2,ALPHA_ID_2,HARMONIC_ID_2,OFFSET_ID_2) + +def set_beamline_setup(id,en=None,pol1=None,alp1=None,har1=None,off1=None,pol2=None,alp2=None,har2=None,off2=None): + set_setting("ID", id) + set_setting("ENERGY", en) + set_setting("POL_ID_1", pol1) + set_setting("ALPHA_ID_1", alp1) + set_setting("HARMONIC_ID_1", har1) + set_setting("OFFSET_ID_1", off1) + set_setting("POL_ID_2", pol2) + set_setting("ALPHA_ID_2", alp2) + set_setting("HARMONIC_ID_2", har2) + set_setting("OFFSET_ID_2", off2) + apply_beamline_setup(id,en,pol1,alp1,har1,off1,pol2,alp2,har2,off2) #Restore beamline initial config def restore_beamline_setup(): @@ -742,9 +788,13 @@ def auto_intensity(): def set_dry_run(value): + """ + """ set_setting("DRY_RUN", bool(value)) def get_dry_run(): + """ + """ return str(get_setting("DRY_RUN")).lower() == "true" def set_outliers_threshold(value): diff --git a/script/templates/AutoFocus.py b/script/templates/AutoFocus.py old mode 100644 new mode 100755 diff --git a/script/templates/Eiger2Img.py b/script/templates/Eiger2Img.py index c499cd6..6026d60 100755 --- a/script/templates/Eiger2Img.py +++ b/script/templates/Eiger2Img.py @@ -1,5 +1,5 @@ #If running from editor -if get_exec_pars().source == CommandSource.ui: +if (get_exec_pars().source == CommandSource.ui) and (get_exec_pars().script == "Eiger2Img") : METHOD = "Two_Pol" SWITCHING = "Tune_Detune" SEQUENCE = "A" @@ -10,8 +10,9 @@ if get_exec_pars().source == CommandSource.ui: ENERGY_1 = 850.0 ENERGY_2= 900.0 SWITCH_POL=False - NUMBER_SCANS =1 + NUMBER_SCANS =1 +print "Starting 2Img: ", METHOD, SWITCHING, SEQUENCE , MEASUREMENTS, AUTO_SAVE, EXPOSURE, AVERAGE, ENERGY_1, ENERGY_2, SWITCH_POL,NUMBER_SCANS #SEQUENCE = "A": C+,C-,C-,C+,C+;C-,C-,C+, #SEQUENCE = "B": C+,C-,C+,C-,C+,-;C+,C-. @@ -70,7 +71,6 @@ def getLEEM(): LEEMtemp=getLEEMtemp() """ - #Initialize vartiables if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true": open_vg10() diff --git a/script/templates/EigerAbsSpec.py b/script/templates/EigerAbsSpec.py index b4ac09f..d4c1119 100755 --- a/script/templates/EigerAbsSpec.py +++ b/script/templates/EigerAbsSpec.py @@ -1,5 +1,5 @@ #If running from editor -if get_exec_pars().source == CommandSource.ui: +if (get_exec_pars().source == CommandSource.ui) and (get_exec_pars().script == "EigerAbsSpec") : ROI = {"Region1": [10,5,20, 10], "Region2": [20,15,20, 10]} SAVE_SPECTRUM = True SAVE_IMAGES = True @@ -10,6 +10,8 @@ if get_exec_pars().source == CommandSource.ui: NUMBER_SCANS =1 RANGES = [[500.0, 1000.0, 100.0]] +print "Starting AbsSpec: ",SAVE_SPECTRUM, SAVE_IMAGES, WITH_I0, SWITCH_POL, EXPOSURE, AVERAGE, NUMBER_SCANS, RANGES + SAVE_DIAGS = True if SWITCH_POL: diff --git a/script/templates/EnergyScan_img.py b/script/templates/EnergyScan_img.py index 54b9d5d..64a8608 100755 --- a/script/templates/EnergyScan_img.py +++ b/script/templates/EnergyScan_img.py @@ -1,5 +1,5 @@ #Parameters -if get_exec_pars().source == CommandSource.ui: +if (get_exec_pars().source == CommandSource.ui) and (get_exec_pars().script == "EnergyScan_img") : E1 = 800 E2 = 820 TIME = 1 #min diff --git a/script/templates/FocusScan.py b/script/templates/FocusScan.py old mode 100644 new mode 100755 diff --git a/script/templates/LEEM_tilt_scan.py b/script/templates/LEEM_tilt_scan.py old mode 100644 new mode 100755 diff --git a/script/test/TestUserScript.py b/script/test/TestUserScript.py new file mode 100644 index 0000000..9b09d44 --- /dev/null +++ b/script/test/TestUserScript.py @@ -0,0 +1,39 @@ +#Constants +AVERAGE = 1 +EXPOSURE = 1.0 +MEASUREMENTS = 1 + +#TakeImage at 710 eV at the given polarization +change_energy(710) +take_image(scans=1, switch_pol=False, measurements=MEASUREMENTS, exposure=EXPOSURE, average=AVERAGE) +time.sleep(2.0) + +#TwoImages Two Pol with C+/C- and ID1 + ID2, tune-detune, at 710 eV +set_beamline_setup(id ="ID1_ID2", en=710, pol1="Circ_Plus", alp1=0.0, har1=1, off1=0.0, pol2="Circ_Minus", alp2=0.0, har2=1, off2=0.0) +two_pol(switching="Tune_Detune", sequence="A", measurements=MEASUREMENTS, exposure=EXPOSURE, average=AVERAGE) +time.sleep(2.0) + +#TwoEnergies with lin hor polarization ID2 only (normal) +set_beamline_setup(id ="ID2", en=710, pol1="Lin_Hor") +two_energies(705, 710, measurements=MEASUREMENTS, exposure=EXPOSURE, average=AVERAGE) +time.sleep(2.0) + +#abs_spec(ranges=[[500.0, 1000.0, 100.0],], switch_pol=False, scans=1, exposure=EXPOSURE, average=AVERAGE) #Use manulally defined ranges and rois defined in GUI +abs_spec(ranges="C_edge", roi="test", switch_pol=False, scans=1, exposure=EXPOSURE, average=AVERAGE) + + + + + + +#Direct functions to change energy, pol, offset: +#change_energy(700) +#change_pol(1, "Circ_Plus" ) #Pol on ID1: "Circ_Plus", "Circ_Minus" , "Lin_Hor", "Lin_Ver" +#change_pol(1, "Lin" , alpha = "0" ) #Lin pol on ID 1 +#change_offset(1, 0.0) #offset on ID1 + +#Auto-switching: +#switch_pol() + +#Restoring beamline state defined in last set_beamline_setut: +#restore_beamline_setup() \ No newline at end of file