update multi-region scan script
This commit is contained in:
@@ -108,7 +108,7 @@ ps1=ch.psi.pshell.epics.AreaDetector|X03DA-ES-PS1:cam1 X03DA-ES-PS1:image1|||tru
|
||||
op-ps1=ch.psi.pshell.epics.AreaDetector|X03DA-OP-PS1:cam1 X03DA-OP-PS1:image1|||true
|
||||
OpticsCameraCentroidX=ch.psi.pshell.epics.ChannelDouble|X03DA-OP-PS1:Stats2:CentroidX_RBV|Read||true
|
||||
OpticsCameraSigmaX=ch.psi.pshell.epics.ChannelDouble|X03DA-OP-PS1:Stats2:SigmaX_RBV|Read||true
|
||||
$dummy=ch.psi.pshell.epics.Motor|XXX|||true
|
||||
dummy=ch.psi.pshell.epics.Motor|XXX|||true
|
||||
img=ch.psi.pshell.imaging.CameraSource|Scienta|||true
|
||||
cam1=ch.psi.pshell.imaging.MjpegSource|http://x03da-cam-1/axis-cgi/mjpg/video.cgi||-200|
|
||||
cam2=ch.psi.pshell.imaging.MjpegSource|http://x03da-cam-2/axis-cgi/mjpg/video.cgi||-1000|
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
"""
|
||||
Arguments:
|
||||
|
||||
"""
|
||||
|
||||
MOTORS = [Eph]
|
||||
VECTOR = [295.0, 296.0]
|
||||
LATENCY = 0.0
|
||||
|
||||
REGION1 = {'elo': 240.0, 'ehi': 242.0, 'estep': 0.1, 'epass': 100, 'tstep': 0.1, 'iter': 1}
|
||||
REGION2 = {'elo': 241.0, 'ehi': 243.0, 'estep': 0.2, 'epass': 100, 'tstep': 0.1, 'iter': 1}
|
||||
REGIONS = [REGION1, REGION2]
|
||||
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
|
||||
|
||||
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
|
||||
def setup(self):
|
||||
Scienta.lowEnergy.write(self.region['elo'])
|
||||
Scienta.highEnergy.write(self.region['ehi'])
|
||||
Scienta.stepSize.write(self.region['estep'])
|
||||
Scienta.setPassEnergy(self.region['epass'])
|
||||
Scienta.stepTime.write(self.region['tstep'])
|
||||
Scienta.setIterations(self.region['iter'])
|
||||
|
||||
def read(self):
|
||||
print "acquiring spectrum {0}-{1} eV".format(self.region['elo'], self.region['ehi'])
|
||||
self.setup()
|
||||
trig_scienta()
|
||||
time.sleep(0.5)
|
||||
sp = Scienta.getSpectrum().read()
|
||||
return sp
|
||||
|
||||
def getSize(self):
|
||||
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):
|
||||
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
|
||||
return nx
|
||||
|
||||
def getHeight(self):
|
||||
ny = Scienta.slices.read()
|
||||
return ny
|
||||
|
||||
|
||||
SENSORS = [SampleCurrent, RefCurrent]
|
||||
|
||||
for (index, region) in enumerate(REGIONS):
|
||||
reader = SpectrumReader()
|
||||
reader.initialize()
|
||||
reader.index = index
|
||||
reader.region = region
|
||||
set_device_alias(reader, "ScientaSpectrum{0}".format(index + 1))
|
||||
SENSORS.append(reader)
|
||||
|
||||
image = ImageReader()
|
||||
image.initialize()
|
||||
image.index = index
|
||||
image.region = region
|
||||
set_device_alias(image, "ScientaImage{0}".format(index + 1))
|
||||
SENSORS.append(image)
|
||||
|
||||
adjust_sensors()
|
||||
set_adc_averaging()
|
||||
set_preference(Preference.PLOT_TYPES, {'Scienta spectrum':1})
|
||||
|
||||
vscan(MOTORS, SENSORS, VECTOR, True, LATENCY,False, before_read=wait_beam, after_read = after_readout)
|
||||
@@ -102,6 +102,7 @@ diag_channels.append(Scienta.numChannels) #diag_channels.append(ChannelDo
|
||||
diag_channels.append(Scienta.lowEnergy) #diag_channels.append(ChannelDouble("LowEnergy", "X03DA-SCIENTA:cam1:LOW_ENERGY_RBV"))
|
||||
diag_channels.append(Scienta.centerEnergy) #diag_channels.append(ChannelDouble("CenterEnergy", "X03DA-SCIENTA:cam1:CENTRE_ENERGY_RBV"))
|
||||
diag_channels.append(Scienta.highEnergy) #diag_channels.append(ChannelDouble("HighEnergy", "X03DA-SCIENTA:cam1:HIGH_ENERGY_RBV"))
|
||||
diag_channels.append(ChannelDouble("ScientaDwellTime", "X03DA-SCIENTA:cam1:AcquireTime_RBV"))
|
||||
|
||||
#TODO: These are not of Scienta device interface. Should be included?
|
||||
#diag_channels.append(ChannelDouble("AcquisitionModeNum", "X03DA-SCIENTA:cam1:ACQ_MODE_RBV"))
|
||||
|
||||
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