112 lines
3.8 KiB
Python
112 lines
3.8 KiB
Python
""" Demo scans for Tomcat at the microXAS test bench
|
|
"""
|
|
|
|
def bl_check_beam():
|
|
""" Checks beamline status"""
|
|
return True
|
|
|
|
|
|
|
|
def demostepscan(scan_start, scan_end, steps, exp_time=0.005, burst_at_each_point=1, settling_time=0, sync='event'):
|
|
""" Demo step scan with GigaFrost
|
|
|
|
This is a small BEC user-space demo step scan at the microXAS testbench
|
|
using the gigafrost in software triggering mode. It tries to be a
|
|
standard BEC scan, while still setting up the environment.
|
|
|
|
Example:
|
|
--------
|
|
demostepscan(scan_start=-32, scan_end=148, steps=180, exp_time=0.005, burst_at_each_point=5)
|
|
"""
|
|
if not bl_check_beam():
|
|
raise RuntimeError("Beamline is not in ready state")
|
|
|
|
scan_ntotal = burst_at_each_point * (steps + 1)
|
|
|
|
# Move to start position
|
|
t_modes = {'event': 1, 'pso': 2, 'inp0': 3, 'inp1': 1}
|
|
cfg = {'ntotal': scan_ntotal, 'trigger': t_modes[sync]}
|
|
dev.es1_ddaq.configure(d=cfg)
|
|
# Configure gigafrost
|
|
cfg = {
|
|
"ntotal": scan_ntotal, "nimages": burst_at_each_point,
|
|
"exposure": 1000*exp_time, "period": 2000*exp_time}
|
|
dev.gfclient.configure(d=cfg)
|
|
# Configure PSO trigger (trigger is normally disabled in fly mode)
|
|
dev.es1_psod.configure(d={})
|
|
dev.es1_psod.software_trigger = True
|
|
|
|
# Explicitly arm trigger (and detector in future)
|
|
dev.es1_psod.prepare()
|
|
|
|
print("Handing over to 'scans.line_scan'")
|
|
wait_time = 0.1 + 2*exp_time * burst_at_each_point
|
|
scans.line_scan(
|
|
dev.es1_roty, scan_start, scan_end,
|
|
steps=steps, exp_time=wait_time, relative=False, settling_time=settling_time)
|
|
|
|
# Cleanup: disable SW trigger
|
|
dev.es1_psod.software_trigger = False
|
|
|
|
|
|
|
|
|
|
|
|
def demosequencescan(scan_start, gate_high, gate_low, repeats=1, repmode="PosNeg",
|
|
exp_time=0.005, exp_frames=180, sync='pso'):
|
|
""" Demo sequence scan with GigaFrost
|
|
|
|
This is a small BEC user-space sequence scan at the microXAS testbench
|
|
triggering the gigafrost in gate-enable mode. It tries to do everything
|
|
through BEC, so while still setting up the environment.
|
|
|
|
NOTE: It's not exactlythe same as the AeroScript template version.
|
|
|
|
Example:
|
|
--------
|
|
demostepscan(scan_start=-32, scan_end=148, steps=180, exp_time=0.005, burst_at_each_point=5)
|
|
"""
|
|
if not bl_check_beam():
|
|
raise RuntimeError("Beamline is not in ready state")
|
|
|
|
# Synthetic values
|
|
scan_velocity = gate_high / (exp_time * exp_frames)
|
|
scan_acceleration = 500
|
|
scan_safedistance = 10
|
|
scan_accdistance = scan_safedistance + 0.5* scan_velocity * scan_velocity / scan_acceleration
|
|
scan_ntotal = exp_frames * repeats
|
|
|
|
# Move to start position
|
|
t_modes = {'event': 1, 'pso': 2, 'inp0': 3, 'inp1': 1}
|
|
cfg = {'ntotal': scan_ntotal, 'trigger': t_modes[sync]}
|
|
dev.es1_ddaq.configure(d=cfg)
|
|
# Configure gigafrost
|
|
cfg = {
|
|
"ntotal": scan_ntotal, "nimages": exp_frames,
|
|
"exposure": 1000*exp_time, "period": 2000*exp_time}
|
|
dev.gfclient.configure(d=cfg)
|
|
|
|
# Fill PSO vectors according to scan direction
|
|
psoBounds = []
|
|
if repmode in ("pos", "Pos"):
|
|
psoBounds.append(scan_accdistance)
|
|
for ii in range(repeats):
|
|
psoBounds += [gate_high, gate_low]
|
|
psoBounds[-1] = 10* (scan_accdistance+gate_low)
|
|
|
|
dev.es1_psod.configure(d={'distance': psoBounds, 'wmode': 'toggle'})
|
|
|
|
# Explicitly arm trigger (and detector in future)
|
|
dev.es1_psod.prepare()
|
|
|
|
print("Handing over to 'scans.line_scan'")
|
|
wait_time = 0.1 + 2*exp_time * burst_at_each_point
|
|
scans.line_scan(
|
|
dev.es1_roty, scan_start, scan_end,
|
|
steps=steps, exp_time=wait_time, relative=False, settling_time=settling_time)
|
|
|
|
# Cleanup: disable SW trigger
|
|
dev.es1_psod.software_trigger = False
|
|
|
|
|