From c8b04a0fd4e02d79173a8f50aa4f6976d0633681 Mon Sep 17 00:00:00 2001 From: gac-x03da Date: Tue, 5 Jul 2022 09:57:57 +0200 Subject: [PATCH] Startup --- config/config.properties | 3 +- config/preferences.json | 113 +++++++ config/setup.properties | 4 +- devices/Eph.properties | 17 +- devices/ExitSlitY.properties | 3 +- devices/FocusYRot.properties | 11 +- devices/Manip.properties | 7 +- devices/ManipulatorPhi.properties | 23 +- devices/ManipulatorTheta.properties | 3 +- devices/ManipulatorTilt.properties | 23 +- devices/ManipulatorX.properties | 3 +- devices/ManipulatorY.properties | 3 +- devices/ManipulatorZ.properties | 23 +- devices/OpticsFilterZ.properties | 21 +- devices/RefocusXRot.properties | 17 +- devices/RefocusYRot.properties | 17 +- devices/RefocusYTrans.properties | 17 +- devices/RefocusZRot.properties | 17 +- devices/RefocusZTrans.properties | 17 +- devices/dummy.properties | 23 +- script/users/191121-ActualOvernight.py | 43 +++ script/users/191121-Au-InAsPb-AutoMove.py | 343 +++++++++++++++++++++ script/users/191121-InAs-Overnight.py | 340 ++++++++++++++++++++ script/users/191122-dev-move.py | 316 +++++++++++++++++++ script/users/191122-overnight.py | 88 ++++++ script/users/191122-pretest-overnight.py | 84 +++++ script/users/191123-Au4f-stability-test.py | 88 ++++++ 27 files changed, 1551 insertions(+), 116 deletions(-) create mode 100644 config/preferences.json create mode 100644 script/users/191121-ActualOvernight.py create mode 100644 script/users/191121-Au-InAsPb-AutoMove.py create mode 100644 script/users/191121-InAs-Overnight.py create mode 100644 script/users/191122-dev-move.py create mode 100644 script/users/191122-overnight.py create mode 100644 script/users/191122-pretest-overnight.py create mode 100644 script/users/191123-Au4f-stability-test.py diff --git a/config/config.properties b/config/config.properties index 012be31d..a318451c 100644 --- a/config/config.properties +++ b/config/config.properties @@ -1,4 +1,4 @@ -#Thu Jun 30 12:18:32 CEST 2022 +#Tue Jul 05 09:57:42 CEST 2022 autoSaveScanData=true simulation=false commandExecutionEvents=false @@ -12,6 +12,7 @@ dataScanSaveScript=false dataScanSaveSetpoints=false notifiedTasks=null parallelInitialization=false +fdaSerialization=false dataTransferPath=null scanStreamingPort=-1 saveConsoleSessionFiles=false diff --git a/config/preferences.json b/config/preferences.json new file mode 100644 index 00000000..a8c45d83 --- /dev/null +++ b/config/preferences.json @@ -0,0 +1,113 @@ +{ + "fontShellPanel" : { + "name" : "Monospaced", + "style" : 0, + "size" : 13 + }, + "fontShellCommand" : { + "name" : "SansSerif", + "style" : 0, + "size" : 13 + }, + "fontOutput" : { + "name" : "Monospaced", + "style" : 0, + "size" : 13 + }, + "fontEditor" : { + "name" : "Monospaced", + "style" : 0, + "size" : 13 + }, + "fontPlotLabel" : { + "name" : "SansSerif", + "style" : 0, + "size" : 11 + }, + "fontPlotTick" : { + "name" : "SansSerif", + "style" : 0, + "size" : 10 + }, + "fontPlotTitle" : { + "name" : "SansSerif", + "style" : 1, + "size" : 13 + }, + "fontTerminal" : null, + "tabSize" : 4, + "contentWidth" : 0, + "editorBackground" : null, + "editorForeground" : null, + "simpleEditor" : false, + "hideEditorLineNumbers" : false, + "hideEditorContextMenu" : false, + "consoleLocation" : "Plot", + "dataPanelLocation" : null, + "openDataFilesInDocTab" : false, + "noVariableEvaluationPropagation" : false, + "processingScripts" : [ ], + "asyncViewersUpdate" : false, + "scanPlotDisabled" : false, + "scanTableDisabled" : false, + "cachedDataPanel" : true, + "dataExtensions" : null, + "hideFileName" : false, + "showEmergencyStop" : false, + "showHomingButtons" : false, + "showJogButtons" : false, + "hideScanPanel" : false, + "hideOutputPanel" : false, + "showXScanFileBrowser" : false, + "showXScanDataViewer" : false, + "showQueueBrowser" : false, + "backgroundRendering" : false, + "showImageStatusBar" : true, + "persistRendererWindows" : true, + "defaultRendererColormap" : "Grayscale", + "linePlot" : "ch.psi.pshell.plot.LinePlotJFree", + "matrixPlot" : "ch.psi.pshell.plot.MatrixPlotJFree", + "surfacePlot" : "ch.psi.pshell.plot.SurfacePlotJzy3d", + "timePlot" : "ch.psi.pshell.plot.TimePlotJFree", + "plotsDetached" : false, + "plotLayout" : "Vertical", + "quality" : "High", + "defaultPlotColormap" : "Temperature", + "markerSize" : 2, + "plotBackground" : null, + "gridColor" : null, + "outlineColor" : null, + "disableOffscreenBuffer" : false, + "defaultPanels" : [ { + "deviceClassName" : "ch.psi.pshell.epics.Scaler", + "panelClassName" : "ch.psi.pshell.swing.ScalerPanel" + }, { + "deviceClassName" : "ch.psi.pshell.epics.Scienta", + "panelClassName" : "ScientaPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.Motor", + "panelClassName" : "ch.psi.pshell.swing.MotorPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.ProcessVariable", + "panelClassName" : "ch.psi.pshell.swing.ProcessVariablePanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.MotorGroup", + "panelClassName" : "ch.psi.pshell.swing.MotorGroupPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.DiscretePositioner", + "panelClassName" : "ch.psi.pshell.swing.DiscretePositionerPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.Camera", + "panelClassName" : "ch.psi.pshell.swing.CameraPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.Slit", + "panelClassName" : "ch.psi.pshell.swing.SlitPanel" + }, { + "deviceClassName" : "ch.psi.pshell.device.ReadonlyRegister$ReadonlyRegisterArray", + "panelClassName" : "ch.psi.pshell.swing.DeviceValueChart" + }, { + "deviceClassName" : "ch.psi.pshell.device.ReadonlyRegister$ReadonlyRegisterMatrix", + "panelClassName" : "ch.psi.pshell.swing.DeviceValueChart" + } ], + "scriptPopupDialog" : "None" +} \ No newline at end of file diff --git a/config/setup.properties b/config/setup.properties index 059fe6d8..396962cf 100644 --- a/config/setup.properties +++ b/config/setup.properties @@ -1,7 +1,9 @@ -#Tue May 11 11:36:45 CEST 2021 +#Tue Jul 05 09:57:42 CEST 2022 scriptPath={home}/script sessionsPath={home}/sessions configFileDevices={config}/devices.properties +xscanPath={script} +queuePath={script} extensionsPath={home}/extensions configFileUpdateStrategy={config}/update.properties configPath={home}/config diff --git a/devices/Eph.properties b/devices/Eph.properties index 3a7b9fcd..eb868331 100644 --- a/devices/Eph.properties +++ b/devices/Eph.properties @@ -1,11 +1,12 @@ -#Tue Jul 03 13:27:04 CEST 2018 +#Tue Jul 05 09:57:44 CEST 2022 accessType=ReadWrite -maxValue=2000.0 minValue=50.0 -offset=0.0 -precision=3 -resolution=0.2 -rotation=false -scale=1.0 -sign_bit=0 unit=eV +offset=0.0 +maxValue=2000.0 +precision=3 +rotation=false +sign_bit=0 +scale=1.0 +description=null +resolution=0.2 diff --git a/devices/ExitSlitY.properties b/devices/ExitSlitY.properties index 313cbca2..9b1903c1 100644 --- a/devices/ExitSlitY.properties +++ b/devices/ExitSlitY.properties @@ -1,9 +1,10 @@ -#Fri Sep 20 17:21:48 CEST 2019 +#Tue Jul 05 09:57:44 CEST 2022 offset=0.0 maxValue=5.0 precision=5 rotation=false scale=1.0 +description=null estbilizationDelay=0 maxSpeed=0.5 resolution=0.002 diff --git a/devices/FocusYRot.properties b/devices/FocusYRot.properties index 8e2766cf..8d8c12bf 100644 --- a/devices/FocusYRot.properties +++ b/devices/FocusYRot.properties @@ -1,10 +1,11 @@ -#Mon Jun 13 12:00:47 CEST 2022 +#Tue Jul 05 09:57:44 CEST 2022 +minValue=-10.0 +unit=mrad offset=0.0 maxValue=10.0 precision=3 rotation=false -scale=1.0 -resolution=0.005 -minValue=-10.0 -unit=mrad sign_bit=0 +scale=1.0 +description=null +resolution=0.005 diff --git a/devices/Manip.properties b/devices/Manip.properties index ea924baf..fe517ab3 100644 --- a/devices/Manip.properties +++ b/devices/Manip.properties @@ -1,7 +1,8 @@ -#Tue Mar 27 14:47:42 CEST 2018 +#Tue Jul 05 09:57:44 CEST 2022 accessType=ReadWrite -position_pvs=X03DA-MA\:RETRACTED | X03DA-MA\:YAG | X03DA-MA\:NE | X03DA-MA\:TRCL | X03DA-MA\:SHIELD | X03DA-MA\:CLAMP | X03DA-MA\:HEATER | X03DA-MA\:SAMPLE -positions=Retracted | YAG | Normal emission | Transfer | Shield | Clamping screw | Heater screw | Sample access precision=-1 +description=null +positions=Retracted | YAG | Normal emission | Transfer | Shield | Clamping screw | Heater screw | Sample access readback_pv=X03DA-MA\:STS +position_pvs=X03DA-MA\:RETRACTED | X03DA-MA\:YAG | X03DA-MA\:NE | X03DA-MA\:TRCL | X03DA-MA\:SHIELD | X03DA-MA\:CLAMP | X03DA-MA\:HEATER | X03DA-MA\:SAMPLE stop_pv=X03DA-MA-STOP\:ALL diff --git a/devices/ManipulatorPhi.properties b/devices/ManipulatorPhi.properties index 866f9364..b6e3cfe0 100644 --- a/devices/ManipulatorPhi.properties +++ b/devices/ManipulatorPhi.properties @@ -1,19 +1,20 @@ -#Tue Sep 21 11:45:49 CEST 2021 -precision=4 -scale=1.0 -estbilizationDelay=0 -resolution=0.5 -accessType=ReadWrite -minValue=-180.0 -defaultSpeed=6.0 -sign_bit=0 -monitorByPosition=false -minSpeed=0.6 +#Tue Jul 05 09:57:44 CEST 2022 offset=0.0 maxValue=180.0 +precision=4 rotation=false +scale=1.0 +description=null +estbilizationDelay=0 maxSpeed=6.0 +resolution=0.5 homingType=None +accessType=ReadWrite startRetries=30 +minValue=-180.0 unit=deg +defaultSpeed=6.0 +sign_bit=0 hasEnable=true +monitorByPosition=false +minSpeed=0.6 diff --git a/devices/ManipulatorTheta.properties b/devices/ManipulatorTheta.properties index 9b44f3c4..28be2bce 100644 --- a/devices/ManipulatorTheta.properties +++ b/devices/ManipulatorTheta.properties @@ -1,9 +1,10 @@ -#Fri Sep 20 17:21:48 CEST 2019 +#Tue Jul 05 09:57:44 CEST 2022 offset=0.0 maxValue=200.0 precision=4 rotation=false scale=1.0 +description=null estbilizationDelay=0 maxSpeed=0.5 resolution=0.1 diff --git a/devices/ManipulatorTilt.properties b/devices/ManipulatorTilt.properties index 7c71161d..ac171127 100644 --- a/devices/ManipulatorTilt.properties +++ b/devices/ManipulatorTilt.properties @@ -1,19 +1,20 @@ -#Wed Jun 22 12:27:56 CEST 2022 -precision=4 -scale=1.0 -estbilizationDelay=0 -resolution=0.05 -accessType=ReadWrite -minValue=-20.1 -defaultSpeed=1.4 -sign_bit=0 -monitorByPosition=false -minSpeed=0.01 +#Tue Jul 05 09:57:44 CEST 2022 offset=0.0 maxValue=20.1 +precision=4 rotation=false +scale=1.0 +description=null +estbilizationDelay=0 maxSpeed=1.4 +resolution=0.05 homingType=None +accessType=ReadWrite startRetries=3 +minValue=-20.1 unit=deg +defaultSpeed=1.4 +sign_bit=0 hasEnable=true +monitorByPosition=false +minSpeed=0.01 diff --git a/devices/ManipulatorX.properties b/devices/ManipulatorX.properties index 9cd91d9a..27040179 100644 --- a/devices/ManipulatorX.properties +++ b/devices/ManipulatorX.properties @@ -1,9 +1,10 @@ -#Fri Sep 20 17:21:48 CEST 2019 +#Tue Jul 05 09:57:44 CEST 2022 offset=0.0 maxValue=15.0 precision=4 rotation=false scale=1.0 +description=null estbilizationDelay=0 maxSpeed=0.126 resolution=0.01 diff --git a/devices/ManipulatorY.properties b/devices/ManipulatorY.properties index 9cd91d9a..27040179 100644 --- a/devices/ManipulatorY.properties +++ b/devices/ManipulatorY.properties @@ -1,9 +1,10 @@ -#Fri Sep 20 17:21:48 CEST 2019 +#Tue Jul 05 09:57:44 CEST 2022 offset=0.0 maxValue=15.0 precision=4 rotation=false scale=1.0 +description=null estbilizationDelay=0 maxSpeed=0.126 resolution=0.01 diff --git a/devices/ManipulatorZ.properties b/devices/ManipulatorZ.properties index cad6168a..056a7510 100644 --- a/devices/ManipulatorZ.properties +++ b/devices/ManipulatorZ.properties @@ -1,19 +1,20 @@ -#Sat Jan 23 15:18:04 CET 2021 -precision=4 -scale=1.0 -estbilizationDelay=0 -resolution=0.01 -accessType=ReadWrite -minValue=100.0 -defaultSpeed=1.6 -sign_bit=0 -monitorByPosition=false -minSpeed=0.2 +#Tue Jul 05 09:57:44 CEST 2022 offset=0.0 maxValue=130.0 +precision=4 rotation=false +scale=1.0 +description=null +estbilizationDelay=0 maxSpeed=1.8 +resolution=0.01 homingType=None +accessType=ReadWrite startRetries=3 +minValue=100.0 unit=mm +defaultSpeed=1.6 +sign_bit=0 hasEnable=true +monitorByPosition=false +minSpeed=0.2 diff --git a/devices/OpticsFilterZ.properties b/devices/OpticsFilterZ.properties index 98f9d1d8..a75799d6 100644 --- a/devices/OpticsFilterZ.properties +++ b/devices/OpticsFilterZ.properties @@ -1,18 +1,19 @@ -#Mon Mar 09 17:46:10 CET 2020 -precision=5 -scale=1.0 -estbilizationDelay=0 -resolution=0.006 -minValue=-100.0 -defaultSpeed=3.0 -sign_bit=0 -monitorByPosition=false -minSpeed=0.1 +#Tue Jul 05 09:57:44 CEST 2022 offset=0.0 maxValue=150.0 +precision=5 rotation=false +scale=1.0 +description=null +estbilizationDelay=0 maxSpeed=5.0 +resolution=0.006 homingType=None startRetries=1 +minValue=-100.0 unit=mm +defaultSpeed=3.0 +sign_bit=0 hasEnable=false +monitorByPosition=false +minSpeed=0.1 diff --git a/devices/RefocusXRot.properties b/devices/RefocusXRot.properties index cf6b5f70..7c51f1fb 100644 --- a/devices/RefocusXRot.properties +++ b/devices/RefocusXRot.properties @@ -1,10 +1,11 @@ -#Tue Jul 03 13:27:04 CEST 2018 -maxValue=0.0 +#Tue Jul 05 09:57:44 CEST 2022 minValue=0.0 -offset=0.0 -precision=0 -resolution=NaN -rotation=false -scale=1.0 -sign_bit=0 unit=0.000 +offset=0.0 +maxValue=0.0 +precision=0 +rotation=false +sign_bit=0 +scale=1.0 +description=null +resolution=NaN diff --git a/devices/RefocusYRot.properties b/devices/RefocusYRot.properties index 43a69a8c..c8a1124a 100644 --- a/devices/RefocusYRot.properties +++ b/devices/RefocusYRot.properties @@ -1,10 +1,11 @@ -#Tue Jul 03 13:27:04 CEST 2018 -maxValue=2.0 +#Tue Jul 05 09:57:44 CEST 2022 minValue=-2.0 -offset=0.0 -precision=3 -resolution=0.005 -rotation=false -scale=1.0 -sign_bit=0 unit=mrad +offset=0.0 +maxValue=2.0 +precision=3 +rotation=false +sign_bit=0 +scale=1.0 +description=null +resolution=0.005 diff --git a/devices/RefocusYTrans.properties b/devices/RefocusYTrans.properties index a86702b0..4976b5d8 100644 --- a/devices/RefocusYTrans.properties +++ b/devices/RefocusYTrans.properties @@ -1,10 +1,11 @@ -#Tue Jul 03 13:27:04 CEST 2018 -maxValue=11.0 +#Tue Jul 05 09:57:44 CEST 2022 minValue=-11.0 -offset=0.0 -precision=3 -resolution=0.5 -rotation=false -scale=1.0 -sign_bit=0 unit=mm +offset=0.0 +maxValue=11.0 +precision=3 +rotation=false +sign_bit=0 +scale=1.0 +description=null +resolution=0.5 diff --git a/devices/RefocusZRot.properties b/devices/RefocusZRot.properties index 84932643..904bfb83 100644 --- a/devices/RefocusZRot.properties +++ b/devices/RefocusZRot.properties @@ -1,10 +1,11 @@ -#Tue Jul 03 13:27:04 CEST 2018 -maxValue=10.0 +#Tue Jul 05 09:57:44 CEST 2022 minValue=-10.0 -offset=0.0 -precision=3 -resolution=NaN -rotation=false -scale=1.0 -sign_bit=0 unit=mrad +offset=0.0 +maxValue=10.0 +precision=3 +rotation=false +sign_bit=0 +scale=1.0 +description=null +resolution=NaN diff --git a/devices/RefocusZTrans.properties b/devices/RefocusZTrans.properties index 34c746f4..404b3467 100644 --- a/devices/RefocusZTrans.properties +++ b/devices/RefocusZTrans.properties @@ -1,10 +1,11 @@ -#Tue Jul 03 13:27:04 CEST 2018 -maxValue=5.0 +#Tue Jul 05 09:57:44 CEST 2022 minValue=-5.0 -offset=0.0 -precision=3 -resolution=NaN -rotation=false -scale=1.0 -sign_bit=0 unit=mm +offset=0.0 +maxValue=5.0 +precision=3 +rotation=false +sign_bit=0 +scale=1.0 +description=null +resolution=NaN diff --git a/devices/dummy.properties b/devices/dummy.properties index ea06094c..82219e73 100644 --- a/devices/dummy.properties +++ b/devices/dummy.properties @@ -1,19 +1,20 @@ -#Wed Aug 25 13:47:10 CEST 2021 -precision=3 -scale=1.0 -estbilizationDelay=0 -resolution=NaN -accessType=ReadWrite -minValue=0.0 -defaultSpeed=100.0 -sign_bit=0 -monitorByPosition=false -minSpeed=0.001 +#Tue Jul 05 09:57:44 CEST 2022 offset=0.0 maxValue=1000000.0 +precision=3 rotation=false +scale=1.0 +description=null +estbilizationDelay=0 maxSpeed=100.0 +resolution=NaN homingType=None +accessType=ReadWrite startRetries=1 +minValue=0.0 unit=units +defaultSpeed=100.0 +sign_bit=0 hasEnable=false +monitorByPosition=false +minSpeed=0.001 diff --git a/script/users/191121-ActualOvernight.py b/script/users/191121-ActualOvernight.py new file mode 100644 index 00000000..347fc7ff --- /dev/null +++ b/script/users/191121-ActualOvernight.py @@ -0,0 +1,43 @@ +import ch.psi.pshell.plot.RangeSelectionPlot.RangeSelection as RangeSelection + +REFERENCE_POSITION = {'X':1.2 ,'Y':0.0, 'Z':110.6, 'Theta':-9.1, 'Tilt':0.8, 'Phi':-90.0} +SAMPLE_POSITION = {'X':0.65 ,'Y':0.0, 'Z':115.0, 'Theta':-9.1, 'Tilt':0.8, 'Phi':-90.0} + +def move_to_position(pdict): + ManipulatorX.move(pdict['X']) + ManipulatorY.move(pdict['Y']) + ManipulatorZ.move(pdict['Z']) + ManipulatorTheta.move(pdict['Theta']) + ManipulatorTilt.move(pdict['Tilt']) + ManipulatorPhi.move(pdict['Phi']) + +#Au600 +move_to_position(REFERENCE_POSITION) +rs = RangeSelection(347.0,354.0) +rs.setVars([1., 1., 1, 800.]) #Time, Size, Iteration, photon energy + +set_exec_pars(name="Scan1") + +run("XPSSpectrum", {"save_scienta_image":True, + "ranges":[rs, ], + "ENDSCAN":False, + "pass_energy":100}) + +set_exec_pars(open=False) +set_exec_pars(name="Scan2") + +#flush_data() + +#In600 +move_to_position(SAMPLE_POSITION) +#rs = RangeSelection(140.0,153.0) +rs = RangeSelection(347.0,354.0) + +rs.setVars([1., 1., 1, 800.]) #Time, Size, Iteration, photon energy + +run("XPSSpectrum", {"save_scienta_image":True, + "ranges":[rs, ], + "ENDSCAN":False, + "pass_energy":100}) + +flush_data() diff --git a/script/users/191121-Au-InAsPb-AutoMove.py b/script/users/191121-Au-InAsPb-AutoMove.py new file mode 100644 index 00000000..43db1801 --- /dev/null +++ b/script/users/191121-Au-InAsPb-AutoMove.py @@ -0,0 +1,343 @@ +""" +Line/vector/area/holo scan of multiple spectral regions + +save this script into your script/user folder before editing! + +usage: +1. uncomment one of the MOTORS lines. + add another line if necessary. +2. uncomment one of the scan blocks and adjust the parameters. + add another block if necessary. +3. declare the regions. +4. add the regions to the REGIONS list. +5. run the script. +""" + +# dummy scan (time series) +MOTORS = [Eph] +# photon energy scan (do not include 'ephot' in regions in this case!) +#MOTORS = [Eph] +# phi scan +#MOTORS = [ManipulatorPhi] +# holo scan +#MOTORS = (ManipulatorPhi, ManipulatorTheta) +# 2D YZ scan +#MOTORS = [ManipulatorY, ManipulatorZ] + +# line scan [start, stop, step] +#POSITIONS = [0., 10., 0.5] +#SCAN = 'lscan' + +# vector scan [pos1, pos2, pos3, ...] +POSITIONS = [600., 900.] +SCAN = 'vscan' + +# area scan [(start1, start2), (stop1, stop2), (step1, step2)] +# corresponding to (positioner1, positioner2) +#POSITIONS = [(-1., 114.), (+1., 116.), (20, 20)] +#ZIGZAG = True +#SCAN = 'ascan' + +# holo scan +#PHI_RANGE = (-160.0, 160.0) # (tuple (min, max)) +#THETA_RANGE = (-9.0, 81.0) # (tuple (min, max)) +#STEPS = (40.0, 1.0) # (tuple (phi, theta)) +#ZIGZAG = True +#POSITIONS = [(PHI_RANGE[0], THETA_RANGE[0]), (PHI_RANGE[1], THETA_RANGE[1]), STEPS] +#SCAN = 'ascan' + +# seconds to wait between positioning command and triggering the detector +LATENCY = 0.0 + + +# region setup +# +# for each region, define a python dictionary with the following items. +# optional items can be left unspecified and will default to the indicated values. +# for swept mode, include 'elo', 'ehi', 'estep', 'iter' values, but do not include 'efix'. +# for fixed mode, include 'efix' value, but do not include 'elo', 'ehi', 'estep', 'iter'. +# +# 'name': user-specific name of the region (for graph title and RegionName attribute in data file) +# 'elo': lower kinetic energy boundary of the spectrum +# 'ehi': upper kinetic energy boundary of the spectrum +# 'estep': energy step size +# 'efix': center kinetic energy in fixed mode +# 'epass': pass energy +# 'ephot': photon energy (default: unchanged) +# 'tstep': dwell time in seconds +# 'iter': number of iterations/sweeps (default 1) +# 'cis': True = constant initial state (photoemission line), False = constant final state (Auger peak), (default False) +# 'slit': exit slit (default: unchanged) + +# First window should be set to first photon energy (see energies above) + +REFERENCE_POSITION = {'X':1.2 ,'Y':0.0, 'Z':110.6, 'Theta':-9.1, 'Tilt':0.9, 'Phi':-90.0} +SAMPLE_POSITION = {'X':0.65 ,'Y':0.0, 'Z':115.0, 'Theta':-9.1, 'Tilt':0.9, 'Phi':-90.0} + +REGION1 = {'name': 'AuFermi', 'ephot':600. , 'elo': 595., 'ehi':597.0, 'estep':0.1, 'epass': 20., 'tstep': 1., 'iter': 1, 'cis': False, 'position': 'reference'} +REGION2 = {'name': 'In3d','ephot':600., 'elo': 140., 'ehi':153.0, 'estep':0.1, 'epass': 20., 'tstep': 1., 'iter': 1, 'cis': False, 'position': 'sample'} + +REGION3 = {'name': 'AuFermi', 'ephot':900. , 'elo': 895., 'ehi':897.0, 'estep':0.1, 'epass': 20., 'tstep': 1., 'iter': 1, 'cis': False, 'position': 'reference'} +REGION4 = {'name': 'Au4f', 'ephot':900. , 'elo': 895., 'ehi':897.0, 'estep':0.1, 'epass': 20., 'tstep': 1., 'iter': 1, 'cis': False, 'position': 'reference'} +REGION5 = {'name': 'In3d','ephot':900., 'elo': 440., 'ehi':453.0, 'estep':0.1, 'epass': 20., 'tstep': 1., 'iter': 1, 'cis': False, 'position': 'sample'} + + +# list of region dictionaries to execute at each scan position +REGIONS = [REGION1, REGION2, REGION3, REGION4] + +# close beam shutter and turn off analyser at the end of the scan +CLOSE_SHUTTER_AT_END = True + +def move_to_position(pdict): + ManipulatorX.move(pdict['X']) + ManipulatorY.move(pdict['Y']) + ManipulatorZ.move(pdict['Z']) + ManipulatorTheta.move(pdict['Theta']) + ManipulatorTilt.move(pdict['Tilt']) + ManipulatorPhi.move(pdict['Phi']) + +# --- DO NOT EDIT BELOW THIS LINE! --- + + +set_exec_pars(keep=False) + +def check_region(region): + """ + check region dictionary items and apply defaults where necessary + """ + region['fixed'] = 'efix' in region + if region['fixed']: + region['elo'] = region['efix'] + region['ehi'] = region['efix'] + if 'iter' not in region: + region['iter'] = 1 + print("region {0}: setting default iter = {1}".format(region['name'], region['iter'])) + if 'cis' not in region: + region['cis'] = False + print("region {0}: setting default cis = {1}".format(region['name'], region['cis'])) + +class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray): + def initialize(self): + #super(SpectrumReader, self).initialize() + self.scan_index = -1 + + def create_datasets(self): + path = get_exec_pars().scanPath + self.region_name + "/" + + if self.region['fixed']: + self.channel_center_dataset_name = path + "ScientaChannelCenter" + create_dataset(self.channel_center_dataset_name, 'd') + else: + self.channel_begin_dataset_name = path + "ScientaChannelBegin" + self.channel_end_dataset_name = path + "ScientaChannelEnd" + self.step_energy_dataset_name = path + "ScientaStepEnergy" + create_dataset(self.channel_begin_dataset_name, 'd') + create_dataset(self.channel_end_dataset_name, 'd') + create_dataset(self.step_energy_dataset_name, 'd') + + if 'epass' in self.region: + self.pass_energy_dataset_name = path + "ScientaPassEnergy" + create_dataset(self.pass_energy_dataset_name, 'd') + if 'tstep' in self.region: + self.step_time_dataset_name = path + "ScientaStepTime" + create_dataset(self.step_time_dataset_name, 'd') + if 'iter' in self.region: + self.iterations_dataset_name = path + "ScientaIterations" + create_dataset(self.iterations_dataset_name, 'd') + if 'slit' in self.region: + self.slit_dataset_name = path + "ExitSlit" + create_dataset(self.slit_dataset_name, 'd') + if 'position' in self.region: + position_names = {key:path + "Position"+ key for key in ['X','Y','Z','Theta','Tilt','Phi']} + self.position_dataset_names = position_names + for datanames in self.position_dataset_names.values(): + create_dataset(datanames, 'd') + + + + def setup(self): + # print("spectrum.setup") + + if self.scan_index != get_exec_pars().index: + self.scan_index = get_exec_pars().index + self.create_datasets() + if self.region_index == 0: + print "scan {0}".format(self.scan_index) + + edelta = 0.0 + try: + ephot = self.region['ephot'] + Eph.move(ephot) + except KeyError: + ephot = Eph.take(100) + + if isinstance(ephot, float) and ephot > 0.: + try: + if self.region['cis']: + edelta = ephot - self.ephot_start + except AttributeError: + self.ephot_start = ephot + + elo = self.region['elo'] + edelta + ehi = self.region['ehi'] + edelta + + if self.region['fixed']: + Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Fixed) + Scienta.centerEnergy.write(elo) + append_dataset(self.channel_center_dataset_name, elo) + else: + Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept) + Scienta.lowEnergy.write(elo) + Scienta.highEnergy.write(ehi) + Scienta.stepSize.write(self.region['estep']) + append_dataset(self.channel_begin_dataset_name, elo) + append_dataset(self.channel_end_dataset_name, ehi) + append_dataset(self.step_energy_dataset_name, self.region['estep']) + + try: + Scienta.setPassEnergy(int(self.region['epass'])) + append_dataset(self.pass_energy_dataset_name, self.region['epass']) + except KeyError: + pass + + try: + Scienta.stepTime.write(self.region['tstep']) + append_dataset(self.step_time_dataset_name, self.region['tstep']) + except KeyError: + pass + + try: + Scienta.setIterations(self.region['iter']) + append_dataset(self.iterations_dataset_name, self.region['iter']) + except KeyError: + pass + + try: + ExitSlit.write(self.region['slit']) + append_dataset(self.slit_dataset_name, self.region['slit']) + except KeyError: + pass + + if self.region['position'] == 'sample': + move_to_position(SAMPLE_POSITION) + + for name in SAMPLE_POSITION.keys(): + append_dataset(self.position_dataset_names[name], SAMPLE_POSITION[name]) + + + elif self.region['position'] == 'reference': + move_to_position(REFERENCE_POSITION) + + for name in REFERENCE_POSITION.keys(): + append_dataset(self.position_dataset_names[name], SAMPLE_POSITION[name]) + + Scienta.update() + + def read(self): + # print("spectrum.read") + global current_region_index + current_region_index = self.region_index + self.setup() + print("Acquiring region {0}.".format(self.region['name'])) + trig_scienta() + time.sleep(0.5) + sp = Scienta.getSpectrum().read() + return sp + + def getSize(self): + if self.region['fixed']: + nx = 992 + else: + nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1 + return nx + + +class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix): + def read(self): + # print("image.read") + return Scienta.getDataMatrix().read() + + def getWidth(self): + if self.region['fixed']: + nx = 992 + else: + nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1 + return nx + + def getHeight(self): + ny = Scienta.slices.read() + return ny + +def setup_live_plots(regions): + global live_plots + global current_region_index + names = [region['name'] for region in regions] + live_plots = plot(None, names, title="Live Spectra") + current_region_index = 0 + +def update_live_plots(): + global live_plots + global current_region_index + try: + while get_context().state.running: + y = Scienta.spectrum.take(100) + x = Scienta.spectrumX + try: + series = live_plots[current_region_index].getSeries(0) + series.setData(x, y) + except IndexError: + pass + time.sleep(1.0) + finally: + print "Stopping live spectra" + +def do_scan(scan, motors, positions, regions, latency): + global SENSORS + + SENSORS = [] + + for (index, region) in enumerate(regions): + check_region(region) + + reader = SpectrumReader() + reader.region_index = index + reader.region_name = "region{0}".format(index + 1) + reader.region = region + reader.initialize() + set_device_alias(reader, reader.region_name + "/ScientaSpectrum") + SENSORS.append(reader) + + image = ImageReader() + image.region_index = index + image.region = region + image.initialize() + set_device_alias(image, reader.region_name + "/ScientaImage") + SENSORS.append(image) + + SENSORS.append(SampleCurrent) + SENSORS.append(RefCurrent) + adjust_sensors() + set_adc_averaging() + + if scan == 'ascan': + ascan(motors, SENSORS, positions[0], positions[1], positions[2], latency, False, zigzag = True, before_read=wait_beam, after_read = after_readout) + elif scan == 'lscan': + lscan(motors, SENSORS, positions[0], positions[1], positions[2], latency, False, before_read=wait_beam, after_read = after_readout) + elif scan == 'vscan': + vscan(motors, SENSORS, positions, True, latency,False, before_read=wait_beam, after_read = after_readout) + else: + print('unknown scan mode {}'.format(scan)) + + for (index, region) in enumerate(regions): + set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name']) + set_attribute(get_exec_pars().scanPath + "region{0}/ScientaImage".format(index + 1), "RegionName", region['name']) + set_attribute(get_exec_pars().scanPath, "Regions", [region['name'] for region in regions]) + +try: + setup_live_plots(REGIONS) + task = fork(update_live_plots) + do_scan(SCAN, MOTORS, POSITIONS, REGIONS, LATENCY) +finally: + if CLOSE_SHUTTER_AT_END: + after_scan() + diff --git a/script/users/191121-InAs-Overnight.py b/script/users/191121-InAs-Overnight.py new file mode 100644 index 00000000..3680fbfd --- /dev/null +++ b/script/users/191121-InAs-Overnight.py @@ -0,0 +1,340 @@ +""" +Line/vector/area/holo scan of multiple spectral regions + +save this script into your script/user folder before editing! + +usage: +1. uncomment one of the MOTORS lines. + add another line if necessary. +2. uncomment one of the scan blocks and adjust the parameters. + add another block if necessary. +3. declare the regions. +4. add the regions to the REGIONS list. +5. run the script. +""" + +# dummy scan (time series) +MOTORS = [dummy] +# photon energy scan (do not include 'ephot' in regions in this case!) +#MOTORS = [Eph] +# phi scan +#MOTORS = [ManipulatorPhi] +# holo scan +#MOTORS = (ManipulatorPhi, ManipulatorTheta) +# 2D YZ scan +#MOTORS = [ManipulatorY, ManipulatorZ] + +# line scan [start, stop, step] +POSITIONS = [0.] +SCAN = 'vscan' + +# vector scan [pos1, pos2, pos3, ...] +#POSITIONS = [600., 900.] +#SCAN = 'vscan' + +# area scan [(start1, start2), (stop1, stop2), (step1, step2)] +# corresponding to (positioner1, positioner2) +#POSITIONS = [(-1., 114.), (+1., 116.), (20, 20)] +#ZIGZAG = True +#SCAN = 'ascan' + +# holo scan +#PHI_RANGE = (-160.0, 160.0) # (tuple (min, max)) +#THETA_RANGE = (-9.0, 81.0) # (tuple (min, max)) +#STEPS = (40.0, 1.0) # (tuple (phi, theta)) +#ZIGZAG = True +#POSITIONS = [(PHI_RANGE[0], THETA_RANGE[0]), (PHI_RANGE[1], THETA_RANGE[1]), STEPS] +#SCAN = 'ascan' + +# seconds to wait between positioning command and triggering the detector +LATENCY = 0.0 + + +# region setup +# +# for each region, define a python dictionary with the following items. +# optional items can be left unspecified and will default to the indicated values. +# for swept mode, include 'elo', 'ehi', 'estep', 'iter' values, but do not include 'efix'. +# for fixed mode, include 'efix' value, but do not include 'elo', 'ehi', 'estep', 'iter'. +# +# 'name': user-specific name of the region (for graph title and RegionName attribute in data file) +# 'elo': lower kinetic energy boundary of the spectrum +# 'ehi': upper kinetic energy boundary of the spectrum +# 'estep': energy step size +# 'efix': center kinetic energy in fixed mode +# 'epass': pass energy +# 'ephot': photon energy (default: unchanged) +# 'tstep': dwell time in seconds +# 'iter': number of iterations/sweeps (default 1) +# 'cis': True = constant initial state (photoemission line), False = constant final state (Auger peak), (default False) +# 'slit': exit slit (default: unchanged) + +# First window should be set to first photon energy (see energies above) + +REFERENCE_POSITION = {'X':3.01 ,'Y':0, 'Z':118, 'Theta':-6.2, 'Tilt':0, 'Phi':0} +SAMPLE_POSITION = {'X':3.01 ,'Y':0, 'Z':118, 'Theta':-6.2, 'Tilt':0, 'Phi':0} + +REGION1 = {'name': 'AuFermi', 'ephot':144. , 'elo': 138.5, 'ehi':140, 'estep':0.01, 'epass': 10., 'tstep': 1., 'iter': 1, 'cis': False, 'position': 'reference'} +REGION2 = {'name': 'VB','ephot':144., 'elo': 138.4, 'ehi':139.8, 'estep':0.01, 'epass': 10., 'tstep': 4., 'iter': 1, 'cis': False, 'position': 'sample'} +REGION3 = {'name': 'As3d','ephot':144., 'elo': 96., 'ehi':101.0, 'estep':0.03, 'epass': 10., 'tstep': 1., 'iter': 1, 'cis': False, 'position': 'sample'} + + +# list of region dictionaries to execute at each scan position +REGIONS = [REGION1, REGION2]#, REGION3, REGION4, REGION5] + +# close beam shutter and turn off analyser at the end of the scan +CLOSE_SHUTTER_AT_END = False + +def move_to_position(pdict): + ManipulatorX.move(pdict['X']) + ManipulatorY.move(pdict['Y']) + ManipulatorZ.move(pdict['Z']) + ManipulatorTheta.move(pdict['Theta']) + ManipulatorTilt.move(pdict['Tilt']) + ManipulatorPhi.move(pdict['Phi']) + +# --- DO NOT EDIT BELOW THIS LINE! --- + + +set_exec_pars(keep=False) + +def check_region(region): + """ + check region dictionary items and apply defaults where necessary + """ + region['fixed'] = 'efix' in region + if region['fixed']: + region['elo'] = region['efix'] + region['ehi'] = region['efix'] + if 'iter' not in region: + region['iter'] = 1 + print("region {0}: setting default iter = {1}".format(region['name'], region['iter'])) + if 'cis' not in region: + region['cis'] = False + print("region {0}: setting default cis = {1}".format(region['name'], region['cis'])) + +class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray): + def initialize(self): + #super(SpectrumReader, self).initialize() + self.scan_index = -1 + + def create_datasets(self): + path = get_exec_pars().scanPath + self.region_name + "/" + + if self.region['fixed']: + self.channel_center_dataset_name = path + "ScientaChannelCenter" + create_dataset(self.channel_center_dataset_name, 'd') + else: + self.channel_begin_dataset_name = path + "ScientaChannelBegin" + self.channel_end_dataset_name = path + "ScientaChannelEnd" + self.step_energy_dataset_name = path + "ScientaStepEnergy" + create_dataset(self.channel_begin_dataset_name, 'd') + create_dataset(self.channel_end_dataset_name, 'd') + create_dataset(self.step_energy_dataset_name, 'd') + + if 'epass' in self.region: + self.pass_energy_dataset_name = path + "ScientaPassEnergy" + create_dataset(self.pass_energy_dataset_name, 'd') + if 'tstep' in self.region: + self.step_time_dataset_name = path + "ScientaStepTime" + create_dataset(self.step_time_dataset_name, 'd') + if 'iter' in self.region: + self.iterations_dataset_name = path + "ScientaIterations" + create_dataset(self.iterations_dataset_name, 'd') + if 'slit' in self.region: + self.slit_dataset_name = path + "ExitSlit" + create_dataset(self.slit_dataset_name, 'd') + if 'position' in self.region: + position_names = {key:path + "Position"+ key for key in ['X','Y','Z','Theta','Tilt','Phi']} + self.position_dataset_names = position_names + for datanames in self.position_dataset_names.values(): + create_dataset(datanames, 'd') + + + + def setup(self): + # print("spectrum.setup") + + if self.scan_index != get_exec_pars().index: + self.scan_index = get_exec_pars().index + self.create_datasets() + if self.region_index == 0: + print "scan {0}".format(self.scan_index) + + edelta = 0.0 + try: + ephot = self.region['ephot'] + Eph.move(ephot) + except KeyError: + ephot = Eph.take(100) + + if isinstance(ephot, float) and ephot > 0.: + try: + if self.region['cis']: + edelta = ephot - self.ephot_start + except AttributeError: + self.ephot_start = ephot + + elo = self.region['elo'] + edelta + ehi = self.region['ehi'] + edelta + + if self.region['fixed']: + Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Fixed) + Scienta.centerEnergy.write(elo) + append_dataset(self.channel_center_dataset_name, elo) + else: + Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept) + Scienta.lowEnergy.write(elo) + Scienta.highEnergy.write(ehi) + Scienta.stepSize.write(self.region['estep']) + append_dataset(self.channel_begin_dataset_name, elo) + append_dataset(self.channel_end_dataset_name, ehi) + append_dataset(self.step_energy_dataset_name, self.region['estep']) + + try: + Scienta.setPassEnergy(int(self.region['epass'])) + append_dataset(self.pass_energy_dataset_name, self.region['epass']) + except KeyError: + pass + + try: + Scienta.stepTime.write(self.region['tstep']) + append_dataset(self.step_time_dataset_name, self.region['tstep']) + except KeyError: + pass + + try: + Scienta.setIterations(self.region['iter']) + append_dataset(self.iterations_dataset_name, self.region['iter']) + except KeyError: + pass + + try: + ExitSlit.write(self.region['slit']) + append_dataset(self.slit_dataset_name, self.region['slit']) + except KeyError: + pass + + if self.region['position'] == 'sample': + move_to_position(SAMPLE_POSITION) + + for name in SAMPLE_POSITION.keys(): + append_dataset(self.position_dataset_names[name], SAMPLE_POSITION[name]) + + + elif self.region['position'] == 'reference': + move_to_position(REFERENCE_POSITION) + + for name in REFERENCE_POSITION.keys(): + append_dataset(self.position_dataset_names[name], SAMPLE_POSITION[name]) + + Scienta.update() + + def read(self): + # print("spectrum.read") + global current_region_index + current_region_index = self.region_index + self.setup() + print("Acquiring region {0}.".format(self.region['name'])) + trig_scienta() + time.sleep(0.5) + sp = Scienta.getSpectrum().read() + return sp + + def getSize(self): + if self.region['fixed']: + nx = 992 + else: + nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1 + return nx + + +class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix): + def read(self): + # print("image.read") + return Scienta.getDataMatrix().read() + + def getWidth(self): + if self.region['fixed']: + nx = 992 + else: + nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1 + return nx + + def getHeight(self): + ny = Scienta.slices.read() + return ny + +def setup_live_plots(regions): + global live_plots + global current_region_index + names = [region['name'] for region in regions] + live_plots = plot(None, names, title="Live Spectra") + current_region_index = 0 + +def update_live_plots(): + global live_plots + global current_region_index + try: + while get_context().state.running: + y = Scienta.spectrum.take(100) + x = Scienta.spectrumX + try: + series = live_plots[current_region_index].getSeries(0) + series.setData(x, y) + except IndexError: + pass + time.sleep(1.0) + finally: + print "Stopping live spectra" + +def do_scan(scan, motors, positions, regions, latency): + global SENSORS + + SENSORS = [] + + for (index, region) in enumerate(regions): + check_region(region) + + reader = SpectrumReader() + reader.region_index = index + reader.region_name = "region{0}".format(index + 1) + reader.region = region + reader.initialize() + set_device_alias(reader, reader.region_name + "/ScientaSpectrum") + SENSORS.append(reader) + + image = ImageReader() + image.region_index = index + image.region = region + image.initialize() + set_device_alias(image, reader.region_name + "/ScientaImage") + SENSORS.append(image) + + SENSORS.append(SampleCurrent) + SENSORS.append(RefCurrent) + adjust_sensors() + set_adc_averaging() + + if scan == 'ascan': + ascan(motors, SENSORS, positions[0], positions[1], positions[2], latency, False, zigzag = True, before_read=wait_beam, after_read = after_readout) + elif scan == 'lscan': + lscan(motors, SENSORS, positions[0], positions[1], positions[2], latency, False, before_read=wait_beam, after_read = after_readout) + elif scan == 'vscan': + vscan(motors, SENSORS, positions, True, latency,False, before_read=wait_beam, after_read = after_readout) + else: + print('unknown scan mode {}'.format(scan)) + + for (index, region) in enumerate(regions): + set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name']) + set_attribute(get_exec_pars().scanPath + "region{0}/ScientaImage".format(index + 1), "RegionName", region['name']) + set_attribute(get_exec_pars().scanPath, "Regions", [region['name'] for region in regions]) + +try: + setup_live_plots(REGIONS) + task = fork(update_live_plots) + do_scan(SCAN, MOTORS, POSITIONS, REGIONS, LATENCY) +finally: + if CLOSE_SHUTTER_AT_END: + after_scan() + diff --git a/script/users/191122-dev-move.py b/script/users/191122-dev-move.py new file mode 100644 index 00000000..8413213f --- /dev/null +++ b/script/users/191122-dev-move.py @@ -0,0 +1,316 @@ +""" +Discrete scan (vector scan) of multiple spectral regions +""" + +# scan positioner: Eph = photon energy +#MOTORS = (ManipulatorPhi, ManipulatorTheta) +#MOTORS = [ManipulatorPhi] +MOTORS = [dummy] +# comma-separated discrete list of scan positions +#POSITIONS = [(PHI_RA +#POSITIONS = [(PNGE[0], THETA_RANGE[0]), (PHI_RANGE[1], THETA_RANGE[1]), STEPS] +#POSITIONS = [-175., 180., 5.] +# seconds to wait between positioning command and triggering the detector +LATENCY = 0.0 + +# region setup +# +# for each region, define a python dictionary with the following items. +# optional items can be left unspecified and will default to the indicated values. +# for swept mode, include 'elo', 'ehi', 'estep', 'iter' values, but do not include 'efix'. +# for fixed mode, include 'efix' value, but do not include 'elo', 'ehi', 'estep', 'iter'. +# +# 'name': user-specific name of the region (for graph title and RegionName attribute in data file) +# 'elo': lower kinetic energy boundary of the spectrum +# 'ehi': upper kinetic energy boundary of the spectrum +# 'estep': energy step size +# 'efix': center kinetic energy in fixed mode +# 'epass': pass energy +# 'tstep': dwell time in seconds +# 'iter': number of iterations/sweeps (default 1) +# 'cis': True = constant initial state (photoemission line), False = constant final state (Auger peak), (default False) +# 'slit': exit slit (default current value) + +#REGION1 = {'name': 'VB62eV', 'ephot': 62, 'efix': 1222.1, 'epass': 200., 'tstep': 20., 'iter': 1, 'cis': False} +#REGION2 = {'name': 'off-resonance', 'ephot': 1235.0, 'efix': 1219.4, 'epass': 200., 'tstep': 20., 'iter': 1, 'cis': False} +#REGION1 = {'name': 'VB62eV', 'ephot': 62, 'elo': 49.0, 'ehi': 58.0, 'estep': 0.002, 'epass': 10, 'tstep': 0.5, 'iter': 1, 'cis': False} +#REGION1 = {'name': 'VB62eVzoom', 'elo': 54.0, 'ehi': 58.0, 'estep': 0.002, 'epass': 10.0, 'tstep': 0.5, 'iter': 1, 'cis': True} + +# close beam shutter and turn off analyser at the end of the scan +CLOSE_SHUTTER_AT_END = False + + +# --- DO NOT EDIT BELOW THIS LINE! --- + +set_exec_pars(keep=False) + +def check_region(region): + """ + check region dictionary items and apply defaults where necessary + """ + region['fixed'] = 'efix' in region + if region['fixed']: + region['elo'] = region['efix'] + region['ehi'] = region['efix'] + if 'iter' not in region: + region['iter'] = 1 + print("region {0}: setting default iter = {1}".format(region['name'], region['iter'])) + if 'cis' not in region: + region['cis'] = False + print("region {0}: setting default cis = {1}".format(region['name'], region['cis'])) + if 'slit' not in region: + region['slit'] = ExitSlit.read() + print("region {0}: setting default slit = {1}".format(region['name'], region['slit'])) + +class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray): + def initialize(self): + #super(SpectrumReader, self).initialize() + self.scan_index = -1 + + def create_datasets(self): + path = get_exec_pars().scanPath + self.region_name + "/" + + self.channel_begin_dataset_name = path + "ScientaChannelBegin" + self.channel_end_dataset_name = path + "ScientaChannelEnd" + self.channel_center_dataset_name = path + "ScientaChannelCenter" + self.pass_energy_dataset_name = path + "ScientaPassEnergy" + self.step_energy_dataset_name = path + "ScientaStepEnergy" + self.step_time_dataset_name = path + "ScientaStepTime" + self.iterations_dataset_name = path + "ScientaIterations" + self.slit_dataset_name = path + "ExitSlit" + + create_dataset(self.channel_begin_dataset_name, 'd') + create_dataset(self.channel_end_dataset_name, 'd') + create_dataset(self.channel_center_dataset_name, 'd') + create_dataset(self.pass_energy_dataset_name, 'd') + create_dataset(self.step_energy_dataset_name, 'd') + create_dataset(self.step_time_dataset_name, 'd') + create_dataset(self.iterations_dataset_name, 'd') + create_dataset(self.slit_dataset_name, 'd') + + def setup(self): + if self.scan_index != get_exec_pars().index: + self.scan_index = get_exec_pars().index + self.create_datasets() + if self.region_index == 0: + print "scan {0}".format(self.scan_index) + + #ephot = Eph.read() + #try: + # if self.region['cis']: + # edelta = ephot - self.ephot_start + # else: + # edelta = 0.0 + #except AttributeError: + # self.ephot_start = ephot + edelta = 0.0 + + elo = self.region['elo'] + edelta + ehi = self.region['ehi'] + edelta + + try: + Eph.write(self.region['ephot']) + except KeyError: + pass + + if self.region['fixed']: + Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Fixed) + Scienta.centerEnergy.write(elo) + else: + Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept) + Scienta.lowEnergy.write(elo) + Scienta.highEnergy.write(ehi) + Scienta.stepSize.write(self.region['estep']) + + Scienta.setPassEnergy(int(self.region['epass'])) + Scienta.stepTime.write(self.region['tstep']) + Scienta.setIterations(self.region['iter']) + ExitSlit.write(self.region['slit']) + Scienta.update() + + if self.region['fixed']: + append_dataset(self.channel_center_dataset_name, elo) + else: + append_dataset(self.channel_begin_dataset_name, elo) + append_dataset(self.channel_end_dataset_name, ehi) + append_dataset(self.step_energy_dataset_name, self.region['estep']) + + append_dataset(self.pass_energy_dataset_name, self.region['epass']) + append_dataset(self.step_time_dataset_name, self.region['tstep']) + append_dataset(self.iterations_dataset_name, self.region['iter']) + append_dataset(self.slit_dataset_name, self.region['slit']) + + def read(self): + global current_region_index + current_region_index = self.region_index + self.setup() + print("Acquiring region {0}.".format(self.region['name'])) + trig_scienta() + time.sleep(0.5) + sp = Scienta.getSpectrum().read() + return sp + + def getSize(self): + if self.region['fixed']: + nx = 992 + else: + nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1 + return nx + + +class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix): + def read(self): + return Scienta.getDataMatrix().read() + + def getWidth(self): + if self.region['fixed']: + nx = 992 + else: + nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1 + return nx + + def getHeight(self): + ny = Scienta.slices.read() + return ny + +def setup_live_plots(regions): + global live_plots + global current_region_index + names = [region['name'] for region in regions] + live_plots = plot(None, names, title="Live Spectra") + current_region_index = 0 + +def update_live_plots(): + global live_plots + global current_region_index + try: + while get_context().state.running: + y = Scienta.spectrum.take(100) + x = Scienta.spectrumX + try: + series = live_plots[current_region_index].getSeries(0) + series.setData(x, y) + except IndexError: + pass + time.sleep(1.0) + finally: + print "Stopping live spectra" + +def do_scan(motors, positions, regions, latency): + global SENSORS + + SENSORS = [] + + + for (index, region) in enumerate(regions): + + check_region(region) + + + reader = SpectrumReader() + reader.region_index = index + reader.region_name = "region{0}".format(index + 1) + reader.region = region + reader.initialize() + set_device_alias(reader, reader.region_name + "/ScientaSpectrum") + SENSORS.append(reader) + + image = ImageReader() + image.region_index = index + image.region = region + image.initialize() + set_device_alias(image, reader.region_name + "/ScientaImage") + SENSORS.append(image) + + + SENSORS.append(SampleCurrent) + SENSORS.append(RefCurrent) + adjust_sensors() + set_adc_averaging() + + #ascan(motors, SENSORS, positions[0], positions[1], positions[2], latency, False, zigzag = True, before_read=wait_beam, after_read = after_readout) + #lscan(motors, SENSORS, positions[0], positions[1], positions[2], latency, False, before_read=wait_beam, after_read = after_readout) + vscan(motors, SENSORS, positions, True, latency,False, before_read=wait_beam, after_read = after_readout) + + + for (index, region) in enumerate(regions): + set_attribute(get_exec_pars().scanPath + "region{0}/ScientaSpectrum".format(index + 1), "RegionName", region['name']) + set_attribute(get_exec_pars().scanPath + "region{0}/ScientaImage".format(index + 1), "RegionName", region['name']) + set_attribute(get_exec_pars().scanPath, "Regions", [region['name'] for region in regions]) + + + +class PhysicalLocation(): + def __init__(self, X, Y, Z, theta, tilt, phi): + self.X = X + self.Y = Y + self.Z = Z + self.theta = theta + self.tilt = tilt + self.phi = phi + + def move_to_location(self): + ManipulatorX.move(self.X) + ManipulatorY.move(self.Y) + ManipulatorZ.move(self.Z) + ManipulatorTheta.move(self.theta) + ManipulatorTilt.move(self.tilt) + ManipulatorPhi.move(self.phi) + +#VARS +sample = PhysicalLocation(-4.1,-0.5,115.1,-8.8,0.7,-90.0) +goldReference = PhysicalLocation(-3.4,4.4,111.6,-8.8,0.7,90.0) +dosing = PhysicalLocation(-4.1,-0.5,115.1,51.0,0.7,-90.0) + +sample.move_to_location() + +energies = [300,400,500] + +for e in energies: + try: + Eph.move(e) + + goldReference.move_to_location() + + goldRegions = goldRegion(e, "fixed") + + do_scan(MOTORS, POSITIONS, goldRegions, LATENCY) + + sample.move_to_location() + + sampleRegions = + + do_scan(MOTORS, POSITIONS, sampleRegions, LATENCY) + +def goldRegion(energy, scan_type): + if scan_type == "fixed": + return [{'name': 'Au', 'ephot': 1237.7, 'efix': 1222.1, 'epass': 50., 'tstep': 5., 'iter': 1, 'cis': False}] + elif scan_type == "swept": + return [{'name': 'Au', 'elo': 54.0, 'ehi': 58.0, 'estep': 0.002, 'epass': 10.0, 'tstep': 0.5, 'iter': 1, 'cis': False}] + +def sampleRegion(energy, scan_type): + epass = 10.0 + tstep = 0.5 + estep = 0.002 + if scan_type == "In4d": + e1 = energy - 4.5 - 18 + e2 = energy - 4.5 - 17 + return [{'name': scan_type, 'elo': 54.0, 'ehi': 58.0, 'estep': estep, 'epass': epass, 'tstep': tstep, 'iter': 1, 'cis': False}] + + elif scan_type == "Sb4d": + e1 = energy - 4.5 - 33 + e2 = energy - 4.5 - 32 + + elif scan_type == "In3d": + e1 = energy - 4.5 - 451 + e2 = energy - 4.5 - 444 + return [{'name': scan_type, 'elo': 54.0, 'ehi': 58.0, 'estep': estep, 'epass': epass, 'tstep': tstep, 'iter': 1, 'cis': False}] + + + + goldReference.move_to_location() + thisregion = + + + sample.move_to_location() + thisregion = {'name': 'In3d', 'ephot': 1237.7, 'efix': 1222.1, 'epass': 50., 'tstep': 5., 'iter': 1, 'cis': False} \ No newline at end of file diff --git a/script/users/191122-overnight.py b/script/users/191122-overnight.py new file mode 100644 index 00000000..b74f3e4e --- /dev/null +++ b/script/users/191122-overnight.py @@ -0,0 +1,88 @@ + + +import ch.psi.pshell.plot.RangeSelectionPlot.RangeSelection as RangeSelection + +REFERENCE_POSITION = {'X':1.4 ,'Y':0.0, 'Z':110.6, 'Theta':-9.1, 'Tilt':0.8, 'Phi':-90.0} +SAMPLE_POSITION = {'X':1.4 ,'Y':0.6, 'Z':116.5, 'Theta':-9.1, 'Tilt':0.8, 'Phi':-90.0} + +def move_to_position(pdict): + ManipulatorX.move(pdict['X']) + ManipulatorY.move(pdict['Y']) + ManipulatorZ.move(pdict['Z']) + ManipulatorTheta.move(pdict['Theta']) + ManipulatorTilt.move(pdict['Tilt']) + ManipulatorPhi.move(pdict['Phi']) + + +binding_center_Au_Ef=0.; +window_Au_Ef=4.; +time_Au_Ef = 15. + +binding_center_Au_4f=86.; +window_Au_4f=15.; +time_Au_4f = 2. + +binding_center_As_3d=43.; +window_As_3d=15.; +time_As_3d=50. + +energies = [1450,950,450] + +exit_slit_dict = {1450:50, 950:25, 450:25} +pass_energy_dict = {1450:50, 950:20, 450:20} + +for e in energies: + + photon_energy = float(e) + ExitSlit.write(exit_slit_dict[e]) + + ##################################################### + #Au-fermi + set_exec_pars(name="Au-Fermi-"+str(e)+"eV") + move_to_position(REFERENCE_POSITION) + + center_Au = photon_energy - 4.5 - binding_center_Au_Ef + rs = RangeSelection(center_Au-window_Au_Ef/2.,center_Au+window_Au_Ef/2.) + rs.setVars([time_Au_Ef, 0.05, 1, photon_energy]) #Time, Size, Iteration, photon energy + + + + run("XPSSpectrum", {"save_scienta_image":True, + "ranges":[rs, ], + "ENDSCAN":False, + "pass_energy":pass_energy_dict[e]}) + + set_exec_pars(open=False) + + ##################################################### + #Au-4f + set_exec_pars(name="Au-4f-"+str(e)+"eV") + center_Au_4f = photon_energy - 4.5 - binding_center_Au_4f + rs = RangeSelection(center_Au_4f-window_Au_4f/2.,center_Au_4f+window_Au_4f/2.) + rs.setVars([time_Au_4f, 0.05, 1, photon_energy]) #Time, Size, Iteration, photon energy + + + run("XPSSpectrum", {"save_scienta_image":True, + "ranges":[rs, ], + "ENDSCAN":False, + "pass_energy":pass_energy_dict[e]}) + + set_exec_pars(open=False) + + ##################################################### + #As + set_exec_pars(name="As-3d-"+str(e)+"eV") + move_to_position(SAMPLE_POSITION) + center_As_3d = photon_energy - 4.5 - binding_center_As_3d + rs = RangeSelection(center_As_3d-window_As_3d/2.,center_As_3d+window_As_3d/2.) + + rs.setVars([time_As_3d, 0.05, 1, photon_energy]) #Time, Size, Iteration, photon energy + + run("XPSSpectrum", {"save_scienta_image":True, + "ranges":[rs, ], + "ENDSCAN":False, + "pass_energy":pass_energy_dict[e]}) + + set_exec_pars(open=False) + + diff --git a/script/users/191122-pretest-overnight.py b/script/users/191122-pretest-overnight.py new file mode 100644 index 00000000..c3626407 --- /dev/null +++ b/script/users/191122-pretest-overnight.py @@ -0,0 +1,84 @@ + + +import ch.psi.pshell.plot.RangeSelectionPlot.RangeSelection as RangeSelection + +REFERENCE_POSITION = {'X':1.4 ,'Y':0.0, 'Z':110.6, 'Theta':-9.1, 'Tilt':0.8, 'Phi':-90.0} +SAMPLE_POSITION = {'X':1.4 ,'Y':0.6, 'Z':116.5, 'Theta':-9.1, 'Tilt':0.8, 'Phi':-90.0} + +def move_to_position(pdict): + ManipulatorX.move(pdict['X']) + ManipulatorY.move(pdict['Y']) + ManipulatorZ.move(pdict['Z']) + ManipulatorTheta.move(pdict['Theta']) + ManipulatorTilt.move(pdict['Tilt']) + ManipulatorPhi.move(pdict['Phi']) + + +binding_center_Au_Ef=0.; +window_Au_Ef=4.; +time_Au_Ef = 0.01 + +binding_center_Au_4f=86.; +window_Au_4f=15.; +time_Au_4f = 0.01 + +binding_center_As_3d=43.; +window_As_3d=15.; +time_As_3d=0.01 + +energies = [1450,950,450] + +for e in energies: + + photon_energy = float(e) + + ##################################################### + #Au-fermi + set_exec_pars(name="Au-Fermi-"+str(e)+"eV") + move_to_position(REFERENCE_POSITION) + + center_Au = photon_energy - 4.5 - binding_center_Au_Ef + rs = RangeSelection(center_Au-window_Au_Ef/2.,center_Au+window_Au_Ef/2.) + rs.setVars([time_Au_Ef, 0.05, 1, photon_energy]) #Time, Size, Iteration, photon energy + + + + run("XPSSpectrum", {"save_scienta_image":True, + "ranges":[rs, ], + "ENDSCAN":False, + "pass_energy":50}) + + set_exec_pars(open=False) + + ##################################################### + #Au-4f + set_exec_pars(name="Au-4f-"+str(e)+"eV") + center_Au_4f = photon_energy - 4.5 - binding_center_Au_4f + rs = RangeSelection(center_Au_4f-window_Au_4f/2.,center_Au_4f+window_Au_4f/2.) + rs.setVars([time_Au_4f, 0.05, 1, photon_energy]) #Time, Size, Iteration, photon energy + + + run("XPSSpectrum", {"save_scienta_image":True, + "ranges":[rs, ], + "ENDSCAN":False, + "pass_energy":50}) + + set_exec_pars(open=False) + + ##################################################### + #As + set_exec_pars(name="As-3d-"+str(e)+"eV") + move_to_position(SAMPLE_POSITION) + center_As_3d = photon_energy - 4.5 - binding_center_As_3d + rs = RangeSelection(center_As_3d-window_As_3d/2.,center_As_3d+window_As_3d/2.) + + rs.setVars([time_As_3d, 0.05, 1, photon_energy]) #Time, Size, Iteration, photon energy + + run("XPSSpectrum", {"save_scienta_image":True, + "ranges":[rs, ], + "ENDSCAN":False, + "pass_energy":50}) + + set_exec_pars(open=False) + + diff --git a/script/users/191123-Au4f-stability-test.py b/script/users/191123-Au4f-stability-test.py new file mode 100644 index 00000000..b74f3e4e --- /dev/null +++ b/script/users/191123-Au4f-stability-test.py @@ -0,0 +1,88 @@ + + +import ch.psi.pshell.plot.RangeSelectionPlot.RangeSelection as RangeSelection + +REFERENCE_POSITION = {'X':1.4 ,'Y':0.0, 'Z':110.6, 'Theta':-9.1, 'Tilt':0.8, 'Phi':-90.0} +SAMPLE_POSITION = {'X':1.4 ,'Y':0.6, 'Z':116.5, 'Theta':-9.1, 'Tilt':0.8, 'Phi':-90.0} + +def move_to_position(pdict): + ManipulatorX.move(pdict['X']) + ManipulatorY.move(pdict['Y']) + ManipulatorZ.move(pdict['Z']) + ManipulatorTheta.move(pdict['Theta']) + ManipulatorTilt.move(pdict['Tilt']) + ManipulatorPhi.move(pdict['Phi']) + + +binding_center_Au_Ef=0.; +window_Au_Ef=4.; +time_Au_Ef = 15. + +binding_center_Au_4f=86.; +window_Au_4f=15.; +time_Au_4f = 2. + +binding_center_As_3d=43.; +window_As_3d=15.; +time_As_3d=50. + +energies = [1450,950,450] + +exit_slit_dict = {1450:50, 950:25, 450:25} +pass_energy_dict = {1450:50, 950:20, 450:20} + +for e in energies: + + photon_energy = float(e) + ExitSlit.write(exit_slit_dict[e]) + + ##################################################### + #Au-fermi + set_exec_pars(name="Au-Fermi-"+str(e)+"eV") + move_to_position(REFERENCE_POSITION) + + center_Au = photon_energy - 4.5 - binding_center_Au_Ef + rs = RangeSelection(center_Au-window_Au_Ef/2.,center_Au+window_Au_Ef/2.) + rs.setVars([time_Au_Ef, 0.05, 1, photon_energy]) #Time, Size, Iteration, photon energy + + + + run("XPSSpectrum", {"save_scienta_image":True, + "ranges":[rs, ], + "ENDSCAN":False, + "pass_energy":pass_energy_dict[e]}) + + set_exec_pars(open=False) + + ##################################################### + #Au-4f + set_exec_pars(name="Au-4f-"+str(e)+"eV") + center_Au_4f = photon_energy - 4.5 - binding_center_Au_4f + rs = RangeSelection(center_Au_4f-window_Au_4f/2.,center_Au_4f+window_Au_4f/2.) + rs.setVars([time_Au_4f, 0.05, 1, photon_energy]) #Time, Size, Iteration, photon energy + + + run("XPSSpectrum", {"save_scienta_image":True, + "ranges":[rs, ], + "ENDSCAN":False, + "pass_energy":pass_energy_dict[e]}) + + set_exec_pars(open=False) + + ##################################################### + #As + set_exec_pars(name="As-3d-"+str(e)+"eV") + move_to_position(SAMPLE_POSITION) + center_As_3d = photon_energy - 4.5 - binding_center_As_3d + rs = RangeSelection(center_As_3d-window_As_3d/2.,center_As_3d+window_As_3d/2.) + + rs.setVars([time_As_3d, 0.05, 1, photon_energy]) #Time, Size, Iteration, photon energy + + run("XPSSpectrum", {"save_scienta_image":True, + "ranges":[rs, ], + "ENDSCAN":False, + "pass_energy":pass_energy_dict[e]}) + + set_exec_pars(open=False) + +