Files
x09lb/script/templates/RegineSpiral.py
gac-x09lb cbc3241b73 Startup
2023-08-17 10:02:32 +02:00

88 lines
2.6 KiB
Python

"""
Arguments:
DRY_RUN (BOOL)
CENTER_X, CENTER_Y (FLOAT)
NPOINTS (INT)
RADIUS (FLOAT)
EXPOSURES (list or None)
SETTLING_TIME (double)
ZIGZAG (BOOLEAN)
COMPRESSION (BOOLEAN)
NOISE (FLOAT)
"""
import random
import math
position_plot = None if "POSITION_PLOT" not in globals() else POSITION_PLOT
#Debugging
if (get_exec_pars().args is None) and (get_exec_pars().script=="RegineSpiral"):
DRY_RUN = True
CENTER_X = 11458.0
CENTER_Y = 10398.0
EXPOSURES = [1,2] #unit:s
NPOINTS = 100
RADIUS = 10
SETTLING_TIME = 1.0
ZIGZAG = False
COMPRESSION = True
position_plot=None
if not position_plot: position_plot=plot(None, title="Motor Positions")[0]
#Constants
SENSORS = [current,ccd.dataMatrix, interf_0, interf_1]
#SENSORS = [ccd.dataMatrix]
POSITIONERS = [dummy_x, dummy_y] if DRY_RUN else [sample_x, sample_y]
ENABLED_PLOTS = [ccd.dataMatrix]
CUSTOM_PLOT_TYPES = {ccd.dataMatrix:"ch.psi.pshell.plot.MatrixPlotRenderer"}
RANGE_X=[-RADIUS * math.sqrt(NPOINTS)*2 + CENTER_X, RADIUS * math.sqrt(NPOINTS)*2 + CENTER_X]
RANGE_Y=[-RADIUS * math.sqrt(NPOINTS)*2 + CENTER_Y, RADIUS * math.sqrt(NPOINTS)*2 + CENTER_Y]
position_plot.clear()
position_plot.addSeries(LinePlotSeries("positions"))
position_plot.getAxis(AxisId.X).label = POSITIONERS[0].name
position_plot.getAxis(AxisId.X).setRange(RANGE_X[0], RANGE_X[1])
position_plot.getAxis(AxisId.Y).label = POSITIONERS[1].name
position_plot.getAxis(AxisId.Y).setRange(RANGE_Y[0], RANGE_Y[1])
def after_read(record, scan):
after_readout(record, scan)
position_plot.getSeries(0).appendData(record[POSITIONERS[0]], record[POSITIONERS[1]])
if EXPOSURES:
POSITIONERS = POSITIONERS + [exposure_index()]
SENSORS = SENSORS + [exposure()]
RANGE_E=[0, len(EXPOSURES)-1]
def gen():
th = 137.508*math.pi/180
for n in range(NPOINTS):
r = RADIUS * math.sqrt(n)
xpos = CENTER_X + r * math.cos(th*n)
ypos = CENTER_Y + r * math.sin(th*n)
if EXPOSURES:
range_e = range(len(EXPOSURES))
for e in range_e:
yield([xpos,ypos,e])
else:
yield([xpos,ypos])
try:
r = vscan(POSITIONERS, SENSORS , gen(), False,\
SETTLING_TIME, relative=False, zigzag = False, initial_move=False, \
before_read=before_readout, after_read = after_read, \
manual_range=RANGE_X, manual_range_y=RANGE_Y, \
compression = COMPRESSION, enabled_plots=ENABLED_PLOTS, \
keep=False, check_positions=False, plot_types=CUSTOM_PLOT_TYPES)
set_return(r)
finally:
after_scan()