update multi-region scan script
This commit is contained in:
98
script/users/AlXPSTimeEvolution.py
Normal file
98
script/users/AlXPSTimeEvolution.py
Normal file
@@ -0,0 +1,98 @@
|
||||
#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
|
||||
from ch.psi.pshell.data.LayoutDefault import ATTR_WRITABLE_DIMENSION as ATTR_WRITABLE_DIMENSION
|
||||
|
||||
Scienta.acquisitionMode = Scienta.AcquisitionMode.Swept
|
||||
|
||||
try:
|
||||
xdata = None
|
||||
ydata = None
|
||||
image_data = None
|
||||
|
||||
while True: # iterations
|
||||
|
||||
while True: # check beam
|
||||
|
||||
path="scan 1/"
|
||||
Scienta.passEnergy = pass_energy
|
||||
Scienta.lowEnergy.write(ranges[cur_range].min)
|
||||
Scienta.highEnergy.write(ranges[cur_range].max)
|
||||
Scienta.stepTime.write(vars[0])
|
||||
Scienta.stepSize.write(vars[1])
|
||||
Scienta.setIterations(1)
|
||||
Scienta.update()
|
||||
set_adc_averaging()
|
||||
wait_beam()
|
||||
trig_scienta()
|
||||
spectrum1 = Scienta.spectrum.read()
|
||||
|
||||
path="scan 2/"
|
||||
Scienta.passEnergy = pass_energy
|
||||
Scienta.lowEnergy.write(ranges[cur_range].min)
|
||||
Scienta.highEnergy.write(ranges[cur_range].max)
|
||||
Scienta.stepTime.write(vars[0])
|
||||
Scienta.stepSize.write(vars[1])
|
||||
Scienta.setIterations(1)
|
||||
Scienta.update()
|
||||
set_adc_averaging()
|
||||
wait_beam()
|
||||
trig_scienta()
|
||||
spectrum2 = 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 save_scienta_image:
|
||||
image_array = Scienta.dataMatrix.read()
|
||||
if image_data is None:
|
||||
image_data = image_array
|
||||
else:
|
||||
for k in range (len(image_data)):
|
||||
for j in range (len(image_data[0])):
|
||||
image_data[k][j] = image_data[k][j] + image_array[k][j]
|
||||
if skip_iteration:
|
||||
break
|
||||
save_dataset(path + "ScientaSpectrum", ydata)
|
||||
set_attribute(path, "Iterations",cur_iteration+1)
|
||||
if save_scienta_image:
|
||||
save_dataset(path + "ScientaImage", image_data)
|
||||
if cur_iteration==0:
|
||||
save_dataset(path + "ScientaChannels", xdata)
|
||||
set_attribute(path + "ScientaChannels", ATTR_WRITABLE_DIMENSION, 1)
|
||||
set_attribute(path, "Range Low", ranges[cur_range].min)
|
||||
set_attribute(path, "Range High", ranges[cur_range].max)
|
||||
set_attribute(path, "Step Time",vars[0])
|
||||
set_attribute(path, "Step Size",vars[1])
|
||||
set_attribute(path, "Pass Energy",pass_energy)
|
||||
set_attribute(path, "Readables", ["ScientaSpectrum","ScientaImage"] if save_scienta_image else ["ScientaSpectrum",])
|
||||
set_attribute(path, "Writables", ["ScientaChannels",])
|
||||
create_diag_datasets(path)
|
||||
append_diag_datasets(path)
|
||||
|
||||
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