From f455daa88f2d05b31cad136cad5aac6fec728e29 Mon Sep 17 00:00:00 2001 From: gac-x03da Date: Wed, 17 May 2023 17:52:02 +0200 Subject: [PATCH] Closedown --- config/config.properties | 4 +- config/settings.properties | 14 +- config/variables.properties | 8 +- script/XPSSpectrum.py | 2 + script/staff/xps-multiple_peaks.py | 64 --- .../MultiRegionScan_G1XPS.py | 10 +- .../MultiRegionScan_G2XPS.py | 8 +- .../MultiRegionScan_msft_20230406.py | 372 ----------------- .../MultiRegionScan_msft_AllXPS.py | 374 ----------------- .../MultiRegionScan_msft_G1HighStat.py | 387 ------------------ .../MultiRegionScan_msft_G2HighStat.py | 386 ----------------- 11 files changed, 24 insertions(+), 1605 deletions(-) delete mode 100644 script/staff/xps-multiple_peaks.py delete mode 100644 script/users/msft-constantinou_p/MultiRegionScan_msft_20230406.py delete mode 100644 script/users/msft-constantinou_p/MultiRegionScan_msft_AllXPS.py delete mode 100644 script/users/msft-constantinou_p/MultiRegionScan_msft_G1HighStat.py delete mode 100644 script/users/msft-constantinou_p/MultiRegionScan_msft_G2HighStat.py diff --git a/config/config.properties b/config/config.properties index 4b0b42be..03cad658 100644 --- a/config/config.properties +++ b/config/config.properties @@ -1,4 +1,4 @@ -#Tue Apr 25 18:59:26 CEST 2023 +#Wed May 10 17:54:48 CEST 2023 autoSaveScanData=true simulation=false commandExecutionEvents=false @@ -27,7 +27,7 @@ dataServerPort=-1 hideServerMessages=false serverPort=8080 versionTrackingEnabled=true -dataPath={data}/{year}/{month}/weichuang_lebin/weichuang-{date}-{time}-{name} +dataPath={data}/{year}/{month}/hadjadj/pshell-{date}-{time}-{name} serverEnabled=false dataScanReleaseRecords=true depthDimension=2 diff --git a/config/settings.properties b/config/settings.properties index cc271bce..6942b92b 100644 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,7 +1,7 @@ -#Wed Apr 26 18:00:51 CEST 2023 -pgroup=p20789 -proposal=20221940 -proposer=weichuang_lebin -prefix=weichuang -sample=uzh6 -authors=weichuang/lebin +#Wed May 10 17:54:48 CEST 2023 +pgroup=p20771 +proposal=20221849 +proposer=hadjadj +prefix= +sample= +authors= diff --git a/config/variables.properties b/config/variables.properties index 8c69bae5..74c7c27b 100644 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,4 +1,4 @@ -#Tue May 02 07:28:36 CEST 2023 -LastRunDate=230502 -FileSequentialNumber=16885 -DaySequentialNumber=7 +#Sun May 14 16:15:22 CEST 2023 +LastRunDate=230514 +FileSequentialNumber=17096 +DaySequentialNumber=6 diff --git a/script/XPSSpectrum.py b/script/XPSSpectrum.py index 94b255b8..4155b742 100644 --- a/script/XPSSpectrum.py +++ b/script/XPSSpectrum.py @@ -109,6 +109,8 @@ try: time.sleep(5.0) if len(vars)>4: region_name = vars[4] + if len(vars)>5: + Scienta.setPassEnergy(int (vars[5])) Scienta.lowEnergy.write(adjusted_ranges[cur_range][0]) Scienta.highEnergy.write(adjusted_ranges[cur_range][1]) diff --git a/script/staff/xps-multiple_peaks.py b/script/staff/xps-multiple_peaks.py deleted file mode 100644 index 09318c59..00000000 --- a/script/staff/xps-multiple_peaks.py +++ /dev/null @@ -1,64 +0,0 @@ -import ch.psi.pshell.plot.RangeSelectionPlot.RangeSelection as RangeSelection - -# caution: do not insert multiple runs in the same script! -# earlier runs are overwritten! - -ranges = [] - -# overview spec: -#rs = RangeSelection(100.0,800.0) -#rs.setVars([0.3, 0.2, 1.0, 800.0]) #Time, Size, Iteration, photon energy -#ranges.append(rs) - -# Au 4f -rs = RangeSelection(105.0,114.0) # before 105 to 115 ---- -1eV -rs.setVars([0.4, 0.05, 3, 200., "Au 4f"]) #Time, Size, Iteration, photon energy -ranges.append(rs) - -# C 1s -rs = RangeSelection(107.0,113.0) # before 105 to 115 ---- -4eV -rs.setVars([0.4, 0.05, 3, 400., "C 1s"]) #Time, Size, Iteration, photon energy -ranges.append(rs) - -# Au 4d5/2 -rs = RangeSelection(100.0,114.0) # before 100 to 110 ---- +4eV, center was 445eV -rs.setVars([0.4, 0.05, 3, 447., "Au 4d5/2"]) #Time, Size, Iteration, photon energy -ranges.append(rs) - -# N 1s -rs = RangeSelection(110.0,115.0) # before 105 to 115 ---- -5eV -rs.setVars([0.4, 0.05, 3, 515., "N 1s"]) #Time, Size, Iteration, photon energy -ranges.append(rs) - -# overview -rs = RangeSelection(100.0,800.0) -rs.setVars([0.3, 0.2, 1, 800., "overview"]) #Time, Size, Iteration, photon energy -ranges.append(rs) - -# Zn 2p -rs = RangeSelection(107.0,112.0) # before 105 to 115 --- -5eV -rs.setVars([0.4, 0.05, 3, 1135., "Zn 2p"]) #Time, Size, Iteration, photon energy -ranges.append(rs) - - - - - -# Zn 3d -#rs = RangeSelection(205.0,215.0) -#rs.setVars([0.4, 0.05, 3, 225.]) #Time, Size, Iteration, photon energy -#ranges.append(rs) - - - -# Au 4d3/2 -#rs = RangeSelection(100.0,115.0) -#rs.setVars([0.4, 0.05, 3, 465., "Au 4d3/2"]) #Time, Size, Iteration, photon energy -#ranges.append(rs) - - - -run("XPSSpectrum", {"save_scienta_image":True, - "ranges":ranges, - "ENDSCAN":True, - "pass_energy":50}) diff --git a/script/users/msft-constantinou_p/MultiRegionScan_G1XPS.py b/script/users/msft-constantinou_p/MultiRegionScan_G1XPS.py index e5ed4131..40b2be9e 100644 --- a/script/users/msft-constantinou_p/MultiRegionScan_G1XPS.py +++ b/script/users/msft-constantinou_p/MultiRegionScan_G1XPS.py @@ -61,35 +61,35 @@ REGION_A3 = {'name': 'As3d', 'elo': 21., 'ehi':27., 'estep':0.02, 'epass': 20., REGION_B1 = {'name': 'MoEF', 'ephot': 150., 'elo': 143., 'ehi':148., 'estep': 0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} REGION_B2 = {'name': 'In4d', 'elo': 124., 'ehi':131., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_B3 = {'name': 'As3d', 'elo': 101., 'ehi':107., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_B4 = {'name': 'Survey', 'elo': 40., 'ehi':150., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} +REGION_B4 = {'name': 'Survey', 'elo': 40., 'ehi':150., 'estep':0.10, 'epass': 20., 'tstep': 0.1, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_B5 = {'name': 'Al2p', 'elo': 68., 'ehi':75., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} # -- Region E @ 250 eV (G1 600) REGION_C1 = {'name': 'MoEF', 'ephot': 250., 'elo': 243., 'ehi':248., 'estep': 0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} REGION_C2 = {'name': 'In4d', 'elo': 224., 'ehi':231., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_C3 = {'name': 'As3d', 'elo': 201., 'ehi':207., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_C4 = {'name': 'Survey', 'elo': 140., 'ehi':250., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} +REGION_C4 = {'name': 'Survey', 'elo': 140., 'ehi':250., 'estep':0.10, 'epass': 20., 'tstep': 0.1, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_C5 = {'name': 'Al2p', 'elo': 168., 'ehi':175., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} # -- Region C @ 350 eV (G1 600) REGION_D1 = {'name': 'MoEF', 'ephot': 350., 'elo': 343., 'ehi':348., 'estep': 0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} REGION_D2 = {'name': 'In4d', 'elo': 324., 'ehi':331., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_D3 = {'name': 'As3d', 'elo': 301., 'ehi':307., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_D4 = {'name': 'Survey', 'elo': 240., 'ehi':350., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} +REGION_D4 = {'name': 'Survey', 'elo': 240., 'ehi':350., 'estep':0.10, 'epass': 20., 'tstep': 0.1, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_D5 = {'name': 'Al2p', 'elo': 268., 'ehi':275., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} # -- Region C @ 450 eV (G1 600) REGION_E1 = {'name': 'MoEF', 'ephot': 450., 'elo': 443., 'ehi':448., 'estep': 0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} REGION_E2 = {'name': 'In4d', 'elo': 424., 'ehi':431., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_E3 = {'name': 'As3d', 'elo': 401., 'ehi':407., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_E4 = {'name': 'Survey', 'elo': 340., 'ehi':450., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} +REGION_E4 = {'name': 'Survey', 'elo': 340., 'ehi':450., 'estep':0.10, 'epass': 20., 'tstep': 0.1, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_E5 = {'name': 'Al2p', 'elo': 468., 'ehi':475., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} # -- Region D @ 550 eV (G1 600) REGION_F1 = {'name': 'MoEF', 'ephot': 550., 'elo': 543., 'ehi':548., 'estep': 0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} REGION_F2 = {'name': 'In4d', 'elo': 524., 'ehi':531., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_F3 = {'name': 'As3d', 'elo': 501., 'ehi':507., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_F4 = {'name': 'Survey', 'elo': 440., 'ehi':550., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} +REGION_F4 = {'name': 'Survey', 'elo': 440., 'ehi':550., 'estep':0.10, 'epass': 20., 'tstep': 0.1, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_F5 = {'name': 'Al2p', 'elo': 468., 'ehi':475., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} # CHOOSE THE REGIONS TO RUN diff --git a/script/users/msft-constantinou_p/MultiRegionScan_G2XPS.py b/script/users/msft-constantinou_p/MultiRegionScan_G2XPS.py index 536723d7..5e03a4ae 100644 --- a/script/users/msft-constantinou_p/MultiRegionScan_G2XPS.py +++ b/script/users/msft-constantinou_p/MultiRegionScan_G2XPS.py @@ -56,7 +56,7 @@ SAMPLE_POSITION = {'X': 2.30,'Y': 3.00, 'Z': 114.00, 'Theta': -9., 'Tilt': -2.0, REGION_A1 = {'name': 'MoEF', 'ephot': 650., 'elo': 643., 'ehi':648., 'estep':0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} REGION_A2 = {'name': 'In4d', 'elo': 623., 'ehi':631., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_A3 = {'name': 'As3d', 'elo': 600., 'ehi':607., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_A4 = {'name': 'Survey', 'elo': 540., 'ehi':650., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} +REGION_A4 = {'name': 'Survey', 'elo': 540., 'ehi':650., 'estep':0.10, 'epass': 20., 'tstep': 0.1, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_A5 = {'name': 'Al2p', 'elo': 566., 'ehi':575., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_A6 = {'name': 'In3d', 'elo': 190., 'ehi':205., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} @@ -64,7 +64,7 @@ REGION_A6 = {'name': 'In3d', 'elo': 190., 'ehi':205., 'estep':0.02, 'epass': 20. REGION_B1 = {'name': 'MoEF', 'ephot': 750., 'elo': 743., 'ehi':748., 'estep':0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} REGION_B2 = {'name': 'In4d', 'elo': 723., 'ehi':731., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_B3 = {'name': 'As3d', 'elo': 700., 'ehi':707., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_B4 = {'name': 'Survey', 'elo': 640., 'ehi':750., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} +REGION_B4 = {'name': 'Survey', 'elo': 640., 'ehi':750., 'estep':0.10, 'epass': 20., 'tstep': 0.1, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_B5 = {'name': 'Al2p', 'elo': 666., 'ehi':675., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_B6 = {'name': 'In3d', 'elo': 290., 'ehi':305., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} @@ -72,7 +72,7 @@ REGION_B6 = {'name': 'In3d', 'elo': 290., 'ehi':305., 'estep':0.02, 'epass': 20. REGION_C1 = {'name': 'MoEF', 'ephot': 850., 'elo': 843., 'ehi':848., 'estep':0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} REGION_C2 = {'name': 'In4d', 'elo': 823., 'ehi':831., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_C3 = {'name': 'As3d', 'elo': 800., 'ehi':807., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_C4 = {'name': 'Survey', 'elo': 740., 'ehi':850., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} +REGION_C4 = {'name': 'Survey', 'elo': 740., 'ehi':850., 'estep':0.10, 'epass': 20., 'tstep': 0.1, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_C5 = {'name': 'Al2p', 'elo': 766., 'ehi':775., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_C6 = {'name': 'In3d', 'elo': 390., 'ehi':405., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} @@ -80,7 +80,7 @@ REGION_C6 = {'name': 'In3d', 'elo': 390., 'ehi':405., 'estep':0.02, 'epass': 20. REGION_D1 = {'name': 'MoEF', 'ephot': 1050., 'elo': 1043., 'ehi':1048., 'estep':0.02, 'epass': 20., 'tstep': 4.0, 'iter': 1, 'cis': False, 'position': 'reference'} REGION_D2 = {'name': 'In4d', 'elo': 1024., 'ehi':1032., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_D3 = {'name': 'As3d', 'elo': 1001., 'ehi':1008., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_D4 = {'name': 'Survey', 'elo': 940., 'ehi':1050., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} +REGION_D4 = {'name': 'Survey', 'elo': 940., 'ehi':1050., 'estep':0.10, 'epass': 20., 'tstep': 0.1, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_D5 = {'name': 'Al2p', 'elo': 966., 'ehi':975., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} REGION_D6 = {'name': 'In3d', 'elo': 590., 'ehi':605., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} diff --git a/script/users/msft-constantinou_p/MultiRegionScan_msft_20230406.py b/script/users/msft-constantinou_p/MultiRegionScan_msft_20230406.py deleted file mode 100644 index 69781e9e..00000000 --- a/script/users/msft-constantinou_p/MultiRegionScan_msft_20230406.py +++ /dev/null @@ -1,372 +0,0 @@ -""" -repeated xps scans with reference sample - -usage -===== - -1. set the NUMBER_OF_ITERATIONS -2. set the REFERENCE_POSITION and SAMPLE_POSITION -3. set the REGION parameters - -troubleshooting -=============== - -if the script runs through very quickly without measuring anything: -check that all position values include a decimal point!!! - -""" - -# dummy scan (time series) -MOTORS = [dummy] - -# number of cycles (integer - not decimal point!) -# (actual number of cycles is + 1) -NUMBER_OF_CYCLES = 10 -POSITIONS = [1., 10., NUMBER_OF_CYCLES] -SCAN = 'lscan' - -# 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) -# 'position': 'reference' or 'sample' - -REFERENCE_POSITION = {'X': 3.40,'Y': 8.17, 'Z': 113.50, 'Theta': -9., 'Tilt': -2.0, 'Phi': -90.} -SAMPLE_POSITION = {'X': 3.45,'Y': 3.00, 'Z': 113.50, 'Theta': -9., 'Tilt': -2.0, 'Phi': -90.} - -# DEFINE THE REGIONS -# -- Region A @ 578 eV -REGION_A1 = {'name': 'MoEF', 'ephot': 578., 'elo': 572., 'ehi':575., 'estep': 0.02, 'epass': 20., 'tstep': 3.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_A2 = {'name': 'In4d', 'elo': 551., 'ehi':559., 'estep':0.02, 'epass': 20., 'tstep': 0.5, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_A3 = {'name': 'As3d', 'elo': 529., 'ehi':535., 'estep':0.02, 'epass': 20., 'tstep': 0.5, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_A4 = {'name': 'In3d', 'elo': 118., 'ehi':133., 'estep':0.02, 'epass': 20., 'tstep': 0.1, 'iter': 1, 'cis': False, 'position': 'sample'} -# -- Region B @ 1050 eV -REGION_B1 = {'name': 'MoEF', 'ephot': 1050., 'elo': 1045., 'ehi':1047, 'estep':0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_B2 = {'name': 'In4d', 'elo': 1025., 'ehi':1031., 'estep':0.02, 'epass': 20., 'tstep': 0.5, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_B3 = {'name': 'As3d', 'elo': 1002., 'ehi':1007., 'estep':0.02, 'epass': 20., 'tstep': 0.5, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_B4 = {'name': 'In3d', 'elo': 590., 'ehi':605., 'estep':0.02, 'epass': 20., 'tstep': 0.1, 'iter': 1, 'cis': False, 'position': 'sample'} -# -- Region C @ 70 eV -REGION_C1 = {'name': 'MoEF', 'ephot': 70., 'elo': 64., 'ehi':67., 'estep': 0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_C2 = {'name': 'In4d', 'elo': 44., 'ehi':51., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_C3 = {'name': 'As3d', 'elo': 21., 'ehi':27., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} - -# CHOOSE THE REGIONS TO RUN -# -- @578eV High-Stat XPS of relevant core-levels (run 10 cyles) -# REGIONS = [REGION_A1,REGION_A2,REGION_A3,REGION_A4] -# -- @1050eV High-Stat XPS of relevant core-levels (run 10 cyles) -REGIONS = [REGION_B1,REGION_B2,REGION_B3,REGION_B4] -# -- @70eV High-Stat XPS of relevant core-levels (run 10 cyles) -# REGIONS = [REGION_C1,REGION_C2,REGION_C3] - - -# close beam shutter and turn off analyser at the end of the scan -# True or False -CLOSE_SHUTTER_AT_END = False - - -# --- DO NOT EDIT BELOW THIS LINE! --- - -set_exec_pars(keep=False) -set_exec_pars(compression=True) - -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'])) - -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']) - -class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray): - """ - pseudo-device class to acquire and read out a Scienta spectrum per region. - - this devices starts the spectrum acquisition and organises the data file. - """ - 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" - create_dataset(self.channel_begin_dataset_name, 'd') - create_dataset(self.channel_end_dataset_name, 'd') - if self.region['fixed']: - self.channel_center_dataset_name = path + "ScientaChannelCenter" - create_dataset(self.channel_center_dataset_name, 'd') - else: - self.step_energy_dataset_name = path + "ScientaStepEnergy" - 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() - - print "scan {0}, region {1} ({2})".format(self.scan_index, self.region_index, self.region['name']) - - 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.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.1) - sp = Scienta.getSpectrum().read() - append_dataset(self.channel_begin_dataset_name, Scienta.getChannelBegin().getValue()) - append_dataset(self.channel_end_dataset_name, Scienta.getChannelEnd().getValue()) - return sp - - def getSize(self): - # this is called before the scan starts - we have to predict the spectrum size - # wrong values don't seem to affect the data files, however - if self.region['fixed']: - nx = 1066 - else: - nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1 - return nx - - -class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix): - """ - pseudo-device class to read out the Scienta image per region. - - this device just reads out the Scienta image that has been acquired by SpectrumReader. - """ - def read(self): - # print("image.read") - return Scienta.getDataMatrix().read() - - def getWidth(self): - # this is called before the scan starts - we have to predict the spectrum size - # wrong values don't seem to affect the data files, however - if self.region['fixed']: - nx = 1066 - else: - nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1 - return nx - - def getHeight(self): - # this is called before the scan starts - the number of slices is an independent parameter - ny = Scienta.slices.read() - return ny - -class SimpleDeviceReader(Readable): - """ - pseudo-device class to read out another device once per region. - - the device must be set assigned to the source attribute. - """ - def read(self): - return self.source.read() - - -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): - """ - set up detectors and run the scan - - for each region we have to add a SpectrumReader and an ImageReader pseudo-device to the SENSORS list. - the order SpectrumReader, ImageReader is important because the SpectrumReader triggers the Scienta, - whereafter the ImageReader reads the image. - """ - 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) - - dev = SimpleDeviceReader() - dev.source = SampleCurrent - set_device_alias(dev, reader.region_name + "/SampleCurrent") - SENSORS.append(dev) - - dev = SimpleDeviceReader() - dev.source = RefCurrent - set_device_alias(dev, reader.region_name + "/RefCurrent") - SENSORS.append(dev) - - 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/msft-constantinou_p/MultiRegionScan_msft_AllXPS.py b/script/users/msft-constantinou_p/MultiRegionScan_msft_AllXPS.py deleted file mode 100644 index aa3669f2..00000000 --- a/script/users/msft-constantinou_p/MultiRegionScan_msft_AllXPS.py +++ /dev/null @@ -1,374 +0,0 @@ -""" -repeated xps scans with reference sample - -usage -===== - -1. set the NUMBER_OF_ITERATIONS -2. set the REFERENCE_POSITION and SAMPLE_POSITION -3. set the REGION parameters - -troubleshooting -=============== - -if the script runs through very quickly without measuring anything: -check that all position values include a decimal point!!! - -""" - -# dummy scan (time series) -MOTORS = [dummy] - -# number of cycles (integer - not decimal point!) -# (actual number of cycles is + 1) -NUMBER_OF_CYCLES = 0 -POSITIONS = [1., 10., NUMBER_OF_CYCLES] -SCAN = 'lscan' - -# 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) -# 'position': 'reference' or 'sample' - -REFERENCE_POSITION = {'X': 2.30,'Y': 7.60, 'Z': 114.00, 'Theta': -9., 'Tilt': -2.0, 'Phi': -90.} -SAMPLE_POSITION = {'X': 2.30,'Y': 3.00, 'Z': 114.00, 'Theta': -9., 'Tilt': -2.0, 'Phi': -90.} - -# DEFINE THE REGIONS -# -- Region A @ 70 eV (G1 600) -REGION_A1 = {'name': 'MoEF', 'ephot': 70., 'elo': 64., 'ehi':67., 'estep': 0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_A2 = {'name': 'In4d', 'elo': 44., 'ehi':51., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_A3 = {'name': 'As3d', 'elo': 21., 'ehi':27., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_A4 = {'name': 'Survey', 'elo': 10., 'ehi':70., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} - -# -- Region B @ 578 eV (G2 1200) -REGION_B1 = {'name': 'MoEF', 'ephot': 578., 'elo': 572., 'ehi':575., 'estep': 0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_B2 = {'name': 'In4d', 'elo': 551., 'ehi':559., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_B3 = {'name': 'As3d', 'elo': 529., 'ehi':535., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_B4 = {'name': 'In3d', 'elo': 118., 'ehi':133., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -# -- Region C @ 1050 eV (G2 1200) -REGION_C1 = {'name': 'MoEF', 'ephot': 1050., 'elo': 1042.5, 'ehi':1045.5, 'estep':0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_C2 = {'name': 'In4d', 'elo': 1025., 'ehi':1032., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_C3 = {'name': 'As3d', 'elo': 1002., 'ehi':1008., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_C4 = {'name': 'In3d', 'elo': 590., 'ehi':605., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -# -- Region D @ 1050 eV (G2 1200) -REGION_D1 = {'name': 'MoEF', 'ephot': 1050., 'elo': 1042.5, 'ehi':1045.5, 'estep':0.02, 'epass': 50., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_D2 = {'name': 'Survey', 'elo': 300., 'ehi':1050., 'estep':0.20, 'epass': 50., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} - -# CHOOSE THE REGIONS TO RUN -## (G1 600) -# REGIONS = [REGION_A1,REGION_A2,REGION_A3,REGION_A4] -## (G2 1200) -REGIONS = [REGION_B1,REGION_B2,REGION_B3,REGION_B4,REGION_C1,REGION_C2,REGION_C3,REGION_C4,REGION_D1,REGION_D2] - -# close beam shutter and turn off analyser at the end of the scan -# True or False -CLOSE_SHUTTER_AT_END = False - - -# --- DO NOT EDIT BELOW THIS LINE! --- - -set_exec_pars(keep=False) -set_exec_pars(compression=True) - -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'])) - -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']) - -class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray): - """ - pseudo-device class to acquire and read out a Scienta spectrum per region. - - this devices starts the spectrum acquisition and organises the data file. - """ - 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" - create_dataset(self.channel_begin_dataset_name, 'd') - create_dataset(self.channel_end_dataset_name, 'd') - if self.region['fixed']: - self.channel_center_dataset_name = path + "ScientaChannelCenter" - create_dataset(self.channel_center_dataset_name, 'd') - else: - self.step_energy_dataset_name = path + "ScientaStepEnergy" - 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() - - print "scan {0}, region {1} ({2})".format(self.scan_index, self.region_index, self.region['name']) - - 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.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.1) - sp = Scienta.getSpectrum().read() - append_dataset(self.channel_begin_dataset_name, Scienta.getChannelBegin().getValue()) - append_dataset(self.channel_end_dataset_name, Scienta.getChannelEnd().getValue()) - return sp - - def getSize(self): - # this is called before the scan starts - we have to predict the spectrum size - # wrong values don't seem to affect the data files, however - if self.region['fixed']: - nx = 1066 - else: - nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1 - return nx - - -class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix): - """ - pseudo-device class to read out the Scienta image per region. - - this device just reads out the Scienta image that has been acquired by SpectrumReader. - """ - def read(self): - # print("image.read") - return Scienta.getDataMatrix().read() - - def getWidth(self): - # this is called before the scan starts - we have to predict the spectrum size - # wrong values don't seem to affect the data files, however - if self.region['fixed']: - nx = 1066 - else: - nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1 - return nx - - def getHeight(self): - # this is called before the scan starts - the number of slices is an independent parameter - ny = Scienta.slices.read() - return ny - -class SimpleDeviceReader(Readable): - """ - pseudo-device class to read out another device once per region. - - the device must be set assigned to the source attribute. - """ - def read(self): - return self.source.read() - - -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): - """ - set up detectors and run the scan - - for each region we have to add a SpectrumReader and an ImageReader pseudo-device to the SENSORS list. - the order SpectrumReader, ImageReader is important because the SpectrumReader triggers the Scienta, - whereafter the ImageReader reads the image. - """ - 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) - - dev = SimpleDeviceReader() - dev.source = SampleCurrent - set_device_alias(dev, reader.region_name + "/SampleCurrent") - SENSORS.append(dev) - - dev = SimpleDeviceReader() - dev.source = RefCurrent - set_device_alias(dev, reader.region_name + "/RefCurrent") - SENSORS.append(dev) - - 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/msft-constantinou_p/MultiRegionScan_msft_G1HighStat.py b/script/users/msft-constantinou_p/MultiRegionScan_msft_G1HighStat.py deleted file mode 100644 index 4f97a523..00000000 --- a/script/users/msft-constantinou_p/MultiRegionScan_msft_G1HighStat.py +++ /dev/null @@ -1,387 +0,0 @@ -""" -repeated xps scans with reference sample - -usage -===== - -1. set the NUMBER_OF_ITERATIONS -2. set the REFERENCE_POSITION and SAMPLE_POSITION -3. set the REGION parameters - -troubleshooting -=============== - -if the script runs through very quickly without measuring anything: -check that all position values include a decimal point!!! - -""" - -# dummy scan (time series) -MOTORS = [dummy] - -# number of cycles (integer - not decimal point!) -# (actual number of cycles is + 1) -NUMBER_OF_CYCLES = 0 -POSITIONS = [1., 10., NUMBER_OF_CYCLES] -SCAN = 'lscan' - -# 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) -# 'position': 'reference' or 'sample' - -REFERENCE_POSITION = {'X': 2.30,'Y': 7.60, 'Z': 114.00, 'Theta': -9., 'Tilt': -2.0, 'Phi': -90.} -SAMPLE_POSITION = {'X': 2.30,'Y': 3.00, 'Z': 114.00, 'Theta': -9., 'Tilt': -2.0, 'Phi': -90.} - -# DEFINE THE REGIONS -# -- Region A @ 70 eV (G1 600) -REGION_A1 = {'name': 'MoEF', 'ephot': 70., 'elo': 63., 'ehi':68., 'estep': 0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_A2 = {'name': 'In4d', 'elo': 44., 'ehi':51., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_A3 = {'name': 'As3d', 'elo': 21., 'ehi':27., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} - -# -- Region B @ 150 eV (G1 600) -REGION_B1 = {'name': 'MoEF', 'ephot': 150., 'elo': 143., 'ehi':146., 'estep': 0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_B2 = {'name': 'In4d', 'elo': 124., 'ehi':131., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_B3 = {'name': 'As3d', 'elo': 101., 'ehi':107., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_B4 = {'name': 'Survey', 'elo': 40., 'ehi':150., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_B5 = {'name': 'Al2p', 'elo': 68., 'ehi':75., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} - -# -- Region E @ 250 eV (G1 600) -REGION_E1 = {'name': 'MoEF', 'ephot': 250., 'elo': 243., 'ehi':246., 'estep': 0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_E2 = {'name': 'In4d', 'elo': 224., 'ehi':231., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_E3 = {'name': 'As3d', 'elo': 201., 'ehi':207., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_E4 = {'name': 'Survey', 'elo': 140., 'ehi':250., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_E5 = {'name': 'Al2p', 'elo': 168., 'ehi':175., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} - -# -- Region C @ 350 eV (G1 600) -REGION_C1 = {'name': 'MoEF', 'ephot': 350., 'elo': 343., 'ehi':346., 'estep': 0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_C2 = {'name': 'In4d', 'elo': 324., 'ehi':331., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_C3 = {'name': 'As3d', 'elo': 301., 'ehi':307., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_C4 = {'name': 'Survey', 'elo': 240., 'ehi':350., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_C5 = {'name': 'Al2p', 'elo': 268., 'ehi':275., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} - -# -- Region D @ 550 eV (G1 600) -REGION_D1 = {'name': 'MoEF', 'ephot': 550., 'elo': 543., 'ehi':546., 'estep': 0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_D2 = {'name': 'In4d', 'elo': 524., 'ehi':531., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_D3 = {'name': 'As3d', 'elo': 501., 'ehi':507., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_D4 = {'name': 'Survey', 'elo': 440., 'ehi':550., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_D5 = {'name': 'Al2p', 'elo': 468., 'ehi':475., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} - -# CHOOSE THE REGIONS TO RUN -## (G1 600) -## REGIONS = [REGION_A1,REGION_A2,REGION_A3,REGION_A4] -## (G1 600) - Full photon energy dependence -REGIONS = [REGION_A1,REGION_A2,REGION_A3,REGION_B1,REGION_B2,REGION_B3,REGION_B4,REGION_B5,REGION_E1,REGION_E2,REGION_E3,REGION_E4,REGION_E5,REGION_C1,REGION_C2,REGION_C3,REGION_C4,REGION_C5,REGION_D1,REGION_D2,REGION_D3,REGION_D4,REGION_D5] - -# close beam shutter and turn off analyser at the end of the scan -# True or False -CLOSE_SHUTTER_AT_END = False - - -# --- DO NOT EDIT BELOW THIS LINE! --- - -set_exec_pars(keep=False) -set_exec_pars(compression=True) - -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'])) - -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']) - -class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray): - """ - pseudo-device class to acquire and read out a Scienta spectrum per region. - - this devices starts the spectrum acquisition and organises the data file. - """ - 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" - create_dataset(self.channel_begin_dataset_name, 'd') - create_dataset(self.channel_end_dataset_name, 'd') - if self.region['fixed']: - self.channel_center_dataset_name = path + "ScientaChannelCenter" - create_dataset(self.channel_center_dataset_name, 'd') - else: - self.step_energy_dataset_name = path + "ScientaStepEnergy" - 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() - - print "scan {0}, region {1} ({2})".format(self.scan_index, self.region_index, self.region['name']) - - 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.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.1) - sp = Scienta.getSpectrum().read() - append_dataset(self.channel_begin_dataset_name, Scienta.getChannelBegin().getValue()) - append_dataset(self.channel_end_dataset_name, Scienta.getChannelEnd().getValue()) - return sp - - def getSize(self): - # this is called before the scan starts - we have to predict the spectrum size - # wrong values don't seem to affect the data files, however - if self.region['fixed']: - nx = 1066 - else: - nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1 - return nx - - -class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix): - """ - pseudo-device class to read out the Scienta image per region. - - this device just reads out the Scienta image that has been acquired by SpectrumReader. - """ - def read(self): - # print("image.read") - return Scienta.getDataMatrix().read() - - def getWidth(self): - # this is called before the scan starts - we have to predict the spectrum size - # wrong values don't seem to affect the data files, however - if self.region['fixed']: - nx = 1066 - else: - nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1 - return nx - - def getHeight(self): - # this is called before the scan starts - the number of slices is an independent parameter - ny = Scienta.slices.read() - return ny - -class SimpleDeviceReader(Readable): - """ - pseudo-device class to read out another device once per region. - - the device must be set assigned to the source attribute. - """ - def read(self): - return self.source.read() - - -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): - """ - set up detectors and run the scan - - for each region we have to add a SpectrumReader and an ImageReader pseudo-device to the SENSORS list. - the order SpectrumReader, ImageReader is important because the SpectrumReader triggers the Scienta, - whereafter the ImageReader reads the image. - """ - 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) - - dev = SimpleDeviceReader() - dev.source = SampleCurrent - set_device_alias(dev, reader.region_name + "/SampleCurrent") - SENSORS.append(dev) - - dev = SimpleDeviceReader() - dev.source = RefCurrent - set_device_alias(dev, reader.region_name + "/RefCurrent") - SENSORS.append(dev) - - 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/msft-constantinou_p/MultiRegionScan_msft_G2HighStat.py b/script/users/msft-constantinou_p/MultiRegionScan_msft_G2HighStat.py deleted file mode 100644 index 00c4c5d0..00000000 --- a/script/users/msft-constantinou_p/MultiRegionScan_msft_G2HighStat.py +++ /dev/null @@ -1,386 +0,0 @@ -""" -repeated xps scans with reference sample - -usage -===== - -1. set the NUMBER_OF_ITERATIONS -2. set the REFERENCE_POSITION and SAMPLE_POSITION -3. set the REGION parameters - -troubleshooting -=============== - -if the script runs through very quickly without measuring anything: -check that all position values include a decimal point!!! - -""" - -# dummy scan (time series) -MOTORS = [dummy] - -# number of cycles (integer - not decimal point!) -# (actual number of cycles is + 1) -NUMBER_OF_CYCLES = 0 -POSITIONS = [1., 10., NUMBER_OF_CYCLES] -SCAN = 'lscan' - -# 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) -# 'position': 'reference' or 'sample' - -REFERENCE_POSITION = {'X': 2.30,'Y': 7.60, 'Z': 114.00, 'Theta': -9., 'Tilt': -2.0, 'Phi': -90.} -SAMPLE_POSITION = {'X': 2.30,'Y': 3.00, 'Z': 114.00, 'Theta': -9., 'Tilt': -2.0, 'Phi': -90.} - -# DEFINE THE REGIONS -# -- Region A @ 650 eV (G2 1200) -REGION_A1 = {'name': 'MoEF', 'ephot': 650., 'elo': 642., 'ehi':645.5, 'estep':0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_A2 = {'name': 'In4d', 'elo': 623., 'ehi':631., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_A3 = {'name': 'As3d', 'elo': 600., 'ehi':607., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_A4 = {'name': 'In3d', 'elo': 190., 'ehi':205., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_A5 = {'name': 'Al2p', 'elo': 566., 'ehi':575., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_A6 = {'name': 'Survey', 'elo': 540., 'ehi':650., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} - -# -- Region B @ 750 eV (G2 1200) -REGION_B1 = {'name': 'MoEF', 'ephot': 750., 'elo': 742., 'ehi':745.5, 'estep':0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_B2 = {'name': 'In4d', 'elo': 723., 'ehi':731., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_B3 = {'name': 'As3d', 'elo': 700., 'ehi':707., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_B4 = {'name': 'In3d', 'elo': 290., 'ehi':305., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_B5 = {'name': 'Al2p', 'elo': 666., 'ehi':675., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_B6 = {'name': 'Survey', 'elo': 640., 'ehi':750., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} - -# -- Region D @ 850 eV (G2 1200) -REGION_D1 = {'name': 'MoEF', 'ephot': 850., 'elo': 842., 'ehi':845.5, 'estep':0.02, 'epass': 20., 'tstep': 2.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_D2 = {'name': 'In4d', 'elo': 823., 'ehi':831., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_D3 = {'name': 'As3d', 'elo': 800., 'ehi':807., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_D4 = {'name': 'In3d', 'elo': 390., 'ehi':405., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_D5 = {'name': 'Al2p', 'elo': 766., 'ehi':775., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_D6 = {'name': 'Survey', 'elo': 740., 'ehi':850., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} - -# -- Region C @ 1050 eV (G2 1200) -REGION_C1 = {'name': 'MoEF', 'ephot': 1050., 'elo': 1042., 'ehi':1045.5, 'estep':0.02, 'epass': 20., 'tstep': 4.0, 'iter': 1, 'cis': False, 'position': 'reference'} -REGION_C2 = {'name': 'In4d', 'elo': 1023., 'ehi':1031., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_C3 = {'name': 'As3d', 'elo': 1000., 'ehi':1007., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_C4 = {'name': 'In3d', 'elo': 590., 'ehi':605., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_C5 = {'name': 'Al2p', 'elo': 966., 'ehi':975., 'estep':0.02, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} -REGION_C6 = {'name': 'Survey', 'elo': 940., 'ehi':1050., 'estep':0.10, 'epass': 20., 'tstep': 1.0, 'iter': 1, 'cis': False, 'position': 'sample'} - -# CHOOSE THE REGIONS TO RUN -## (G1 600) -# REGIONS = [REGION_A1,REGION_A2,REGION_A3,REGION_A4] -## (G2 1200) -REGIONS = [REGION_A1,REGION_A2,REGION_A3,REGION_A4,REGION_A5,REGION_A6,REGION_B1,REGION_B2,REGION_B3,REGION_B4,REGION_B5,REGION_B6,REGION_D1,REGION_D2,REGION_D3,REGION_D4,REGION_D5,REGION_D6,REGION_C1,REGION_C2,REGION_C3,REGION_C4,REGION_C5,REGION_C6] - -# close beam shutter and turn off analyser at the end of the scan -# True or False -CLOSE_SHUTTER_AT_END = False - - -# --- DO NOT EDIT BELOW THIS LINE! --- - -set_exec_pars(keep=False) -set_exec_pars(compression=True) - -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'])) - -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']) - -class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray): - """ - pseudo-device class to acquire and read out a Scienta spectrum per region. - - this devices starts the spectrum acquisition and organises the data file. - """ - 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" - create_dataset(self.channel_begin_dataset_name, 'd') - create_dataset(self.channel_end_dataset_name, 'd') - if self.region['fixed']: - self.channel_center_dataset_name = path + "ScientaChannelCenter" - create_dataset(self.channel_center_dataset_name, 'd') - else: - self.step_energy_dataset_name = path + "ScientaStepEnergy" - 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() - - print "scan {0}, region {1} ({2})".format(self.scan_index, self.region_index, self.region['name']) - - 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.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.1) - sp = Scienta.getSpectrum().read() - append_dataset(self.channel_begin_dataset_name, Scienta.getChannelBegin().getValue()) - append_dataset(self.channel_end_dataset_name, Scienta.getChannelEnd().getValue()) - return sp - - def getSize(self): - # this is called before the scan starts - we have to predict the spectrum size - # wrong values don't seem to affect the data files, however - if self.region['fixed']: - nx = 1066 - else: - nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1 - return nx - - -class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix): - """ - pseudo-device class to read out the Scienta image per region. - - this device just reads out the Scienta image that has been acquired by SpectrumReader. - """ - def read(self): - # print("image.read") - return Scienta.getDataMatrix().read() - - def getWidth(self): - # this is called before the scan starts - we have to predict the spectrum size - # wrong values don't seem to affect the data files, however - if self.region['fixed']: - nx = 1066 - else: - nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1 - return nx - - def getHeight(self): - # this is called before the scan starts - the number of slices is an independent parameter - ny = Scienta.slices.read() - return ny - -class SimpleDeviceReader(Readable): - """ - pseudo-device class to read out another device once per region. - - the device must be set assigned to the source attribute. - """ - def read(self): - return self.source.read() - - -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): - """ - set up detectors and run the scan - - for each region we have to add a SpectrumReader and an ImageReader pseudo-device to the SENSORS list. - the order SpectrumReader, ImageReader is important because the SpectrumReader triggers the Scienta, - whereafter the ImageReader reads the image. - """ - 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) - - dev = SimpleDeviceReader() - dev.source = SampleCurrent - set_device_alias(dev, reader.region_name + "/SampleCurrent") - SENSORS.append(dev) - - dev = SimpleDeviceReader() - dev.source = RefCurrent - set_device_alias(dev, reader.region_name + "/RefCurrent") - SENSORS.append(dev) - - 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() -