58 lines
1.8 KiB
Python
58 lines
1.8 KiB
Python
|
|
|
|
def rock(steps, exp_time, scan_start=None, scan_end=None,datasource=None, visual=True, **kwargs):
|
|
"""Demo step scan with plotting
|
|
|
|
This is a simple user-space demo step scan with the BEC. It be a
|
|
standard BEC scan, while still setting up the environment.
|
|
|
|
Example:
|
|
--------
|
|
ascan(dev.dccm_energy, 12,13, steps=21, exp_time=0.1, datasource=dev.dccm_xbpm)
|
|
"""
|
|
# Dummy method to check beamline status
|
|
if not bl_check_beam():
|
|
raise RuntimeError("Beamline is not in ready state")
|
|
|
|
motor = dev.dccm_theta2
|
|
if scan_start is None:
|
|
scan_start = -0.05/dev.dccm_energy.user_readback.get()
|
|
if scan_end is None:
|
|
scan_end = 0.05/dev.dccm_energy.user_readback.get()
|
|
|
|
|
|
if visual:
|
|
# Get or create scan specific window
|
|
window = None
|
|
for _, val in bec.gui.windows.items():
|
|
if val.title == "CurrentScan":
|
|
window = val.widget
|
|
window.clear_all()
|
|
if window is None:
|
|
window = bec.gui.new("CurrentScan")
|
|
|
|
# Draw a simploe plot in the window
|
|
dock = window.add_dock(f"ScanDisplay {motor}")
|
|
plt1 = dock.add_widget("BECWaveformWidget")
|
|
plt1.plot(x_name=motor, y_name=datasource)
|
|
plt1.set_x_label(motor)
|
|
plt1.set_y_label(datasource)
|
|
plt1.add_dap(motor, datasource, dap="LinearModel")
|
|
window.show()
|
|
|
|
print("Handing over to 'scans.line_scan'")
|
|
s = scans.line_scan(
|
|
motor, scan_start, scan_end, steps=steps, exp_time=exp_time, datasource=datasource, relative=True, **kwargs
|
|
)
|
|
|
|
if visual:
|
|
# If fitting via GUI
|
|
firt_par = plt1.get_dap_params()
|
|
else:
|
|
# Without GUI
|
|
firt_par = bec.dap.LinearModel.fit(s, motor.name, motor.name, datasource.name, datasource.name)
|
|
|
|
# Move to fitted maximum
|
|
|
|
return s, firt_par
|