Files
x03da/script/QueuedHoloScan.py
2021-11-03 18:20:11 +01:00

116 lines
3.4 KiB
Python

"""
parametric holo scan of one spectral regions for pshell queue
parameters:
phi_range: (tuple (min, max)) defaults to hard-coded PHI_RANGE
theta_range: (tuple (min, max)) defaults to hard-coded THETA_RANGE
steps: (tuple (phi, theta)) defaults to hard-coded STEPS
region: (dict)
optional items can be left unspecified and will default to the indicated values.
for swept mode, include 'elo', 'ehi', 'estep', 'iter' values, but do not include 'efix'.
for fixed mode, include 'efix' value, but do not include 'elo', 'ehi', 'estep', 'iter'.
'name': user-specific name of the region
'elo': lower kinetic energy boundary of the spectrum
'ehi': upper kinetic energy boundary of the spectrum
'estep': energy step size
'efix': center kinetic energy in fixed mode
'epass': pass energy
'ephot': photon energy (default: unchanged)
'tstep': dwell time in seconds
'iter': number of iterations/sweeps (default 1)
'slit': exit slit (default: unchanged)
motors: (sequence, optional) position devices
sensors: (sequence, optional) sensor devices
"""
MOTORS = (ManipulatorPhi, ManipulatorTheta)
SENSORS = (Counts, SampleCurrent, RefCurrent, MachineCurrent, EnergyDistribution, AngleDistribution, Scienta.dataMatrix)
PHI_RANGE = (-170.0, 170.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]
LATENCY=0.0
REGION = {'name': 'Tb 4d', 'elo': 892.5, 'ehi': 899.0, 'estep': 0.1, 'epass': 50., 'tstep': 0.8, 'iter': 1}
# close beam shutter and turn off analyser at the end of the scan
CLOSE_SHUTTER_AT_END = False
# --- DO NOT EDIT BELOW THIS LINE! ---
set_exec_pars(keep=False)
set_exec_pars(compression=True)
def check_region(region):
"""
check region dictionary items and apply defaults where necessary
"""
region['fixed'] = 'efix' in region
if region['fixed']:
region['elo'] = region['efix']
region['ehi'] = region['efix']
if 'iter' not in region:
region['iter'] = 1
def set_region(params):
try:
ephot = self.region['ephot']
Eph.move(ephot)
except KeyError:
ephot = Eph.take(100)
elo = self.region['elo']
ehi = self.region['ehi']
if self.region['fixed']:
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Fixed)
Scienta.centerEnergy.write(elo)
else:
Scienta.setAcquisitionMode(ch.psi.pshell.epics.Scienta.AcquisitionMode.Swept)
Scienta.lowEnergy.write(elo)
Scienta.highEnergy.write(ehi)
Scienta.stepSize.write(self.region['estep'])
try:
Scienta.setPassEnergy(int(self.region['epass']))
except KeyError:
pass
try:
Scienta.stepTime.write(self.region['tstep'])
except KeyError:
pass
try:
Scienta.setIterations(self.region['iter'])
except KeyError:
pass
try:
ExitSlit.write(self.region['slit'])
except KeyError:
pass
Scienta.update()
# main
check_region(region)
set_region(region)
adjust_sensors()
set_adc_averaging()
try:
ascan(motors, sensors, positions[0], positions[1], positions[2], latency, False, zigzag=zigzag, before_read=before_readout, after_read = after_readout, check_positions=False)
finally:
if CLOSE_SHUTTER_AT_END:
after_scan()