Script execution

This commit is contained in:
x03daop
2017-04-12 10:03:23 +02:00
parent 883b6ef09d
commit 45e57f95bb

View File

@@ -3,9 +3,6 @@ Arguments:
"""
#MOTORS = [Eph]
#POSITIONS = [295.0, 296.0]
MOTORS = [Eph]
POSITIONS = [400.0, 401.0]
LATENCY = 0.0
@@ -19,6 +16,14 @@ CLOSE_SHUTTER_AT_END = True
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
def initialize(self):
super(SpectrumReader, self).initialize()
self.channel_begin_dataset_name = "scan{0}/ScientaChannelBegin{1}".format(self.scan_index + 1, self.region_index + 1)
self.channel_end_dataset_name = "scan{0}/ScientaChannelEnd{1}".format(self.scan_index + 1, self.region_index + 1)
create_dataset(self.channel_begin_dataset_name, 'd')
create_dataset(self.channel_end_dataset_name, 'd')
def setup(self):
ephot = Eph.read()
try:
@@ -29,17 +34,22 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
except AttributeError:
self.ephot_start = ephot
edelta = 0.0
Scienta.lowEnergy.write(self.region['elo'] + edelta)
Scienta.highEnergy.write(self.region['ehi'] + edelta)
elo = self.region['elo'] + edelta
ehi = self.region['ehi'] + edelta
Scienta.lowEnergy.write(elo)
Scienta.highEnergy.write(ehi)
Scienta.stepSize.write(self.region['estep'])
Scienta.setPassEnergy(self.region['epass'])
Scienta.stepTime.write(self.region['tstep'])
Scienta.setIterations(self.region['iter'])
append_dataset(self.channel_begin_dataset_name, elo)
append_dataset(self.channel_end_dataset_name, ehi)
def read(self):
self.setup()
print "Photon energy {ephot} eV. Acquiring spectrum {elo}-{ehi} eV".format(ephot=Eph.read(), elo=Scienta.lowEnergy.value, ehi=Scienta.highEnergy.value)
print "Photon energy {ephot} eV. Acquiring spectrum {elo}-{ehi} eV.".format(ephot=Eph.read(), elo=Scienta.lowEnergy.value, ehi=Scienta.highEnergy.value)
trig_scienta()
time.sleep(0.5)
sp = Scienta.getSpectrum().read()
@@ -62,22 +72,25 @@ class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
ny = Scienta.slices.read()
return ny
scan_index = -1
def do_scan(motors, positions, regions, latency):
sensors = [SampleCurrent, RefCurrent]
scan_index += 1
for (index, region) in enumerate(regions):
reader = SpectrumReader()
reader.initialize()
reader.index = index
reader.scan_index = scan_index
reader.region_index = index
reader.region = region
reader.initialize()
set_device_alias(reader, "ScientaSpectrum{0}".format(index + 1))
sensors.append(reader)
image = ImageReader()
image.initialize()
image.index = index
image.region_index = index
image.region = region
image.initialize()
set_device_alias(image, "ScientaImage{0}".format(index + 1))
sensors.append(image)