Files
x09lb/script/local.py
gac-x09lb f1a32a6b92
2022-11-11 13:27:32 +01:00

68 lines
2.7 KiB
Python

###################################################################################################
# Deployment specific global definitions - executed after startup.py
###################################################################################################
def trig_ccd():
if ccd.dataMatrix in SENSORS:
if ccd.isSimulated():
time.sleep(0.1)
else:
image_id = ccd.currentImageCount
ccd.start()
ccd.waitReady(-1)
ccd.waitNewImage(5000, image_id)
def is_beam_ok():
return True
def wait_beam():
if not is_beam_ok():
print "Waiting for beam..."
while not beam_ok:
time.sleep(0.1)
print "Beam ok"
def before_readout():
wait_beam()
trig_ccd()
def after_readout(rec, scan):
if not is_beam_ok():
rec.invalidate()
def after_scan():
pass
def scan_2d(range_x, range_y, steps_x, steps_y, exposures=None, settling_time=0.1, zigzag=True, compression=False, dry_run=False):
"""Relative area scan on sample sample_x and sample_y. A 2D scan is performed if 'exposures' is not defined.
Otherwise a 3D scan is performed, where the third dimension correspond to the exposure indexes.
Args:
range_x(float or list): the relative range for sample x [start, stop]. If a float value is used, the range is set to [-value, value].
range_y(float or list): the relative range for sample y [start, stop]. If a float value is used, the range is set to [-value, value].
steps_x(int): number of steps for sample_x
steps_y(int): number of steps for sample_y
exposures(list of float, optional): f specified, samples for each exposure time value in each xy position.
settling_time(float, optional): time in seconds to wait after positioners are set, before sampling sensors.
zigzag(boolean, optional): if True each fast changing dimension revert direction after finishing a line.
compression(boolean, optional): if True images are saved compressed.
dry_run(boolean, optional): if True uses dummy_x and dummy_y instead of sample_x and sample_y.
Returns:
ScanResult object
"""
if type(range_x)==float: range_x =[-range_x, range_x]
if type(range_y)==float: range_y =[-range_y, range_y]
return run("templates/Scan2D", { \
"DRY_RUN": dry_run, \
"RANGE_X": [float(range_x[0]), float(range_x[1])], \
"RANGE_Y": [float(range_y[0]), float(range_y[1])], \
"STEPS": [int(steps_x), int(steps_y)], \
"EXPOSURES": exposures, \
"SETTLING_TIME": settling_time, \
"ZIGZAG": zigzag, \
"COMPRESSION": compression
})