|
|
|
@@ -14,19 +14,19 @@ usage:
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
# dummy scan (time series)
|
|
|
|
|
#MOTORS = [dummy]
|
|
|
|
|
MOTORS = [dummy]
|
|
|
|
|
# photon energy scan (do not include 'ephot' in regions in this case!)
|
|
|
|
|
#MOTORS = [Eph]
|
|
|
|
|
# phi scan
|
|
|
|
|
#MOTORS = [ManipulatorPhi]
|
|
|
|
|
# holo scan
|
|
|
|
|
MOTORS = (ManipulatorPhi, ManipulatorTheta)
|
|
|
|
|
#MOTORS = (ManipulatorPhi, ManipulatorTheta)
|
|
|
|
|
# 2D YZ scan
|
|
|
|
|
#MOTORS = [ManipulatorY, ManipulatorZ]
|
|
|
|
|
|
|
|
|
|
# line scan [start, stop, step]
|
|
|
|
|
#POSITIONS = [0., 10., 0.5]
|
|
|
|
|
#SCAN = 'lscan'
|
|
|
|
|
POSITIONS = [0., 5., 0.5]
|
|
|
|
|
SCAN = 'lscan'
|
|
|
|
|
|
|
|
|
|
# vector scan [pos1, pos2, pos3, ...]
|
|
|
|
|
#POSITIONS = [200., 300., 400., 500.]
|
|
|
|
@@ -39,13 +39,12 @@ MOTORS = (ManipulatorPhi, ManipulatorTheta)
|
|
|
|
|
#SCAN = 'ascan'
|
|
|
|
|
|
|
|
|
|
# holo scan
|
|
|
|
|
#PHI_RANGE = (-170.0, 170.0) # (tuple (min, max))
|
|
|
|
|
PHI_RANGE = (-160.0, 160.0) # (tuple (min, max))
|
|
|
|
|
THETA_RANGE = (-9.5, 80.5) # (tuple (min, max))
|
|
|
|
|
STEPS = (40.0, 1.0) # (tuple (phi, theta))
|
|
|
|
|
ZIGZAG = True
|
|
|
|
|
POSITIONS = [(PHI_RANGE[0], THETA_RANGE[0]), (PHI_RANGE[1], THETA_RANGE[1]), STEPS]
|
|
|
|
|
SCAN = 'ascan'
|
|
|
|
|
#PHI_RANGE = (-160.0, 160.0) # (tuple (min, max))
|
|
|
|
|
#THETA_RANGE = (-9.0, 81.0) # (tuple (min, max))
|
|
|
|
|
#STEPS = (40.0, 1.0) # (tuple (phi, theta))
|
|
|
|
|
#ZIGZAG = True
|
|
|
|
|
#POSITIONS = [(PHI_RANGE[0], THETA_RANGE[0]), (PHI_RANGE[1], THETA_RANGE[1]), STEPS]
|
|
|
|
|
#SCAN = 'ascan'
|
|
|
|
|
|
|
|
|
|
# seconds to wait between positioning command and triggering the detector
|
|
|
|
|
LATENCY = 0.0
|
|
|
|
@@ -70,15 +69,14 @@ LATENCY = 0.0
|
|
|
|
|
# 'cis': True = constant initial state (photoemission line), False = constant final state (Auger peak), (default False)
|
|
|
|
|
# 'slit': exit slit (default: unchanged)
|
|
|
|
|
|
|
|
|
|
REGION1 = {'name': 'Tb 4d', 'elo': 892.5, 'ehi': 899.0, 'estep': 0.1, 'epass': 50., 'tstep': 0.8, 'iter': 1, 'cis': False}
|
|
|
|
|
REGION2 = {'name': 'Au 4f', 'efix': 957.2, 'epass': 20., 'tstep': 0.8, 'iter': 1, 'cis': False}
|
|
|
|
|
REGION1 = {'name': 'peak 1', 'efix': 200., 'epass': 50., 'tstep': 2., 'iter': 1, 'cis': False}
|
|
|
|
|
REGION2 = {'name': 'peak 2', 'efix': 300., 'epass': 50., 'tstep': 3., 'iter': 1, 'cis': False}
|
|
|
|
|
|
|
|
|
|
# list of region dictionaries to execute at each scan position
|
|
|
|
|
REGIONS = [REGION1, REGION2]
|
|
|
|
|
#REGIONS = [REGION1]
|
|
|
|
|
|
|
|
|
|
# close beam shutter and turn off analyser at the end of the scan
|
|
|
|
|
CLOSE_SHUTTER_AT_END = True
|
|
|
|
|
CLOSE_SHUTTER_AT_END = False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# --- DO NOT EDIT BELOW THIS LINE! ---
|
|
|
|
@@ -102,6 +100,11 @@ def check_region(region):
|
|
|
|
|
print("region {0}: setting default cis = {1}".format(region['name'], region['cis']))
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
@@ -109,15 +112,15 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
|
|
|
|
|
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.channel_begin_dataset_name = path + "ScientaChannelBegin"
|
|
|
|
|
self.channel_end_dataset_name = path + "ScientaChannelEnd"
|
|
|
|
|
self.step_energy_dataset_name = path + "ScientaStepEnergy"
|
|
|
|
|
create_dataset(self.channel_begin_dataset_name, 'd')
|
|
|
|
|
create_dataset(self.channel_end_dataset_name, 'd')
|
|
|
|
|
create_dataset(self.step_energy_dataset_name, 'd')
|
|
|
|
|
|
|
|
|
|
if 'epass' in self.region:
|
|
|
|
@@ -138,10 +141,8 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
|
|
|
|
|
if self.scan_index != get_exec_pars().index:
|
|
|
|
|
self.scan_index = get_exec_pars().index
|
|
|
|
|
self.create_datasets()
|
|
|
|
|
if self.region_index == 0:
|
|
|
|
|
print "scan {0}".format(self.scan_index)
|
|
|
|
|
|
|
|
|
|
print "scan {0}, region {1}".format(self.scan_index, self.region_index)
|
|
|
|
|
print "scan {0}, region {1} ({2})".format(self.scan_index, self.region_index, self.region['name'])
|
|
|
|
|
|
|
|
|
|
edelta = 0.0
|
|
|
|
|
try:
|
|
|
|
@@ -169,8 +170,6 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
|
|
|
|
|
Scienta.lowEnergy.write(elo)
|
|
|
|
|
Scienta.highEnergy.write(ehi)
|
|
|
|
|
Scienta.stepSize.write(self.region['estep'])
|
|
|
|
|
append_dataset(self.channel_begin_dataset_name, elo)
|
|
|
|
|
append_dataset(self.channel_end_dataset_name, ehi)
|
|
|
|
|
append_dataset(self.step_energy_dataset_name, self.region['estep'])
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
@@ -198,42 +197,64 @@ class SpectrumReader(ReadonlyRegisterBase, ReadonlyRegisterArray):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
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']))
|
|
|
|
|
# print("Acquiring region {0}.".format(self.region['name']))
|
|
|
|
|
trig_scienta()
|
|
|
|
|
time.sleep(0.5)
|
|
|
|
|
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 = 992
|
|
|
|
|
nx = 1066
|
|
|
|
|
else:
|
|
|
|
|
nx = int((self.region['ehi'] - self.region['elo']) / self.region['estep']) + 1
|
|
|
|
|
return nx
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ImageReader(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
|
|
|
|
|
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 = 992
|
|
|
|
|
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
|
|
|
|
@@ -258,6 +279,13 @@ def update_live_plots():
|
|
|
|
|
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 = []
|
|
|
|
@@ -280,8 +308,16 @@ def do_scan(scan, motors, positions, regions, latency):
|
|
|
|
|
set_device_alias(image, reader.region_name + "/ScientaImage")
|
|
|
|
|
SENSORS.append(image)
|
|
|
|
|
|
|
|
|
|
SENSORS.append(SampleCurrent)
|
|
|
|
|
SENSORS.append(RefCurrent)
|
|
|
|
|
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()
|
|
|
|
|
|
|
|
|
|