Script execution
This commit is contained in:
154
script/users/Granas/xps_measure_2.py
Normal file
154
script/users/Granas/xps_measure_2.py
Normal file
@@ -0,0 +1,154 @@
|
||||
"""
|
||||
author chritstoph seitz
|
||||
|
||||
starting the xps measurement
|
||||
|
||||
Fermi edge of C1s test
|
||||
"""
|
||||
|
||||
#my debug
|
||||
def my_debug(str_):
|
||||
open("/sls/X03DA/data/gac-03da/Data1/2018/10/Granas/XPSstuff/commands/debugging.txt",'a').write(time.strftime("%H:%M")+" "+ str_+"\n")
|
||||
print(str_)
|
||||
|
||||
"""
|
||||
here the copy of XPSSpectrum starts
|
||||
|
||||
"""
|
||||
|
||||
#Parameters (global variables):
|
||||
# ranges: list of RangeSelection havinf args = (step_size, step_time, iterations)
|
||||
# pass_energy
|
||||
# save_scienta_image
|
||||
#
|
||||
# skip_iteration: if set to 1 then skips after end of current iteration
|
||||
|
||||
global ranges, pass_energy, skip_iteration, ENDSCAN
|
||||
""" old settings
|
||||
ranges = []
|
||||
# (eph, min, max, step, time, iter)
|
||||
ranges.append((1300.0, 577.0, 593.0, 0.1, 0.2, 1700))
|
||||
ranges.append((1300.0, 713.0, 722.0, 0.1, 0.2, 1000))
|
||||
ranges.append((1300.0, 1294.5, 1297.0, 0.02, 1, 2))
|
||||
pass_energy = 50
|
||||
skip_iteration = False
|
||||
ENDSCAN = True
|
||||
"""
|
||||
|
||||
ranges = []
|
||||
|
||||
select_edge_tmp = "O1s "
|
||||
pass_energy = 20 #O1s
|
||||
#save_scienta_image = True
|
||||
|
||||
skip_iteration = False
|
||||
ENDSCAN = True
|
||||
|
||||
# (eph, min, max, step, time, iter)
|
||||
if "O1s" in select_edge_tmp:
|
||||
pass_energy = 50 #C1s
|
||||
ranges.append((650.0, 645., 647.0, 0.1, 0.2, 10)) # O1s
|
||||
elif "C1s" in select_edge_tmp:
|
||||
ranges.append((390.0, 384.4, 387.0, 0.1, 0.2, 20)) # C1s
|
||||
|
||||
from ch.psi.pshell.data.LayoutDefault import ATTR_WRITABLE_DIMENSION as ATTR_WRITABLE_DIMENSION
|
||||
|
||||
cur_range = 0
|
||||
cur_iteration = 0
|
||||
|
||||
Scienta.acquisitionMode = Scienta.AcquisitionMode.Swept
|
||||
ret=[]
|
||||
|
||||
set_exec_pars(open = True)
|
||||
|
||||
#Global arguments
|
||||
Scienta.passEnergy = pass_energy
|
||||
|
||||
names=[]
|
||||
names.append("Online Spectrum")
|
||||
for i in range(len(ranges)):
|
||||
names.append(str(ranges[i][0]))
|
||||
plots = plot(None, names)
|
||||
spectrum_series = plots[0].getSeries(0)
|
||||
def plot_cur_spectrum():
|
||||
global spectrum_series
|
||||
try:
|
||||
while get_context().state.running:
|
||||
y = Scienta.spectrum.take(100)
|
||||
x = Scienta.spectrumX
|
||||
spectrum_series.setData(x, y)
|
||||
time.sleep(1.0)
|
||||
finally:
|
||||
print "Stopping spectrum plotting"
|
||||
task = None
|
||||
|
||||
try:
|
||||
for cur_range in range(len(ranges)):
|
||||
cur_iteration = 0
|
||||
skip_iteration = False
|
||||
params = ranges[cur_range]
|
||||
Eph.move(params[0])
|
||||
time.sleep(5.0)
|
||||
Scienta.lowEnergy.write(params[1])
|
||||
Scienta.highEnergy.write(params[2])
|
||||
Scienta.update()
|
||||
|
||||
Scienta.stepSize.write(params[3])
|
||||
Scienta.stepTime.write(params[4])
|
||||
Scienta.setIterations(1)
|
||||
|
||||
set_adc_averaging()
|
||||
|
||||
#iterations done in script
|
||||
xdata = None
|
||||
ydata = None
|
||||
image_data = None
|
||||
task = fork(plot_cur_spectrum)
|
||||
|
||||
path="scan" + str(cur_range+1) + "/"
|
||||
for cur_iteration in range(params[5]):
|
||||
plots[cur_range+1].setTitle(str(params[0]) + " - iteration " + str(cur_iteration+1))
|
||||
while True:
|
||||
wait_beam()
|
||||
trig_scienta()
|
||||
spectrum_array = Scienta.spectrum.read()
|
||||
if beam_ok:
|
||||
break
|
||||
if ydata is None:
|
||||
ydata = spectrum_array
|
||||
else:
|
||||
for k in range (len(spectrum_array)):
|
||||
ydata[k] = ydata[k] + spectrum_array[k]
|
||||
if xdata is None:
|
||||
xdata = Scienta.spectrumX
|
||||
plots[cur_range+1].getSeries(0).setData(xdata, ydata)
|
||||
if skip_iteration:
|
||||
break
|
||||
save_dataset(path + "ScientaSpectrum", ydata)
|
||||
set_attribute(path, "Iterations",cur_iteration+1)
|
||||
if cur_iteration==0:
|
||||
save_dataset(path + "ScientaChannels", xdata)
|
||||
set_attribute(path + "ScientaChannels", ATTR_WRITABLE_DIMENSION, 1)
|
||||
set_attribute(path, "Range Low", params[1])
|
||||
set_attribute(path, "Range High", params[2])
|
||||
set_attribute(path, "Step Time", params[4])
|
||||
set_attribute(path, "Step Size", params[3])
|
||||
set_attribute(path, "Pass Energy", pass_energy)
|
||||
set_attribute(path, "Readables", ["ScientaSpectrum",])
|
||||
set_attribute(path, "Writables", ["ScientaChannels",])
|
||||
create_diag_datasets(path)
|
||||
append_diag_datasets(path)
|
||||
|
||||
plots[cur_range+1].setTitle(str(params[0]))
|
||||
ret.append((xdata, ydata))
|
||||
|
||||
finally:
|
||||
cur_range = -1
|
||||
if not Scienta.isReady():
|
||||
Scienta.stop()
|
||||
Scienta.update()
|
||||
task[0].cancel(True)
|
||||
if ENDSCAN:
|
||||
after_scan()
|
||||
|
||||
set_return(to_array(ret,'o'))
|
||||
Reference in New Issue
Block a user