Keyword scans for 2D

This commit is contained in:
gac-x06da
2025-03-14 12:32:12 +01:00
committed by mohacsi_i
parent 34d4d6ef8c
commit a5f844b816
2 changed files with 47 additions and 23 deletions

View File

@@ -24,41 +24,68 @@ class PlotUpdate(AutoUpdates):
# plt = self.figure.plot(dev_x, dev_y)
# plt.set(title=f"PXIII: Scan {info.scan_number}", x_label=dev_x, y_label=dev_y)
def keyword_handler(self, info: ScanInfo) -> None:
"""Simple keyword handler
def plot_handler(self, info: ScanInfo) -> None:
"""Simple keyword handler for 'plot'
This simple keyword handler looks for the keyword 'datasource' in the scan arguments.
This simple keyword handler looks for the keyword 'plot' in the scan arguments.
This allows the user to explictly specify the desired data source. Useful for alignment
scans.
"""
print(info.scan_report_devices)
dev_x = info.scan_report_devices[0]
if "kwargs" in self._scan_msg.info:
dev_y = self._scan_msg.info["kwargs"].get("datasource", None)
det = self._scan_msg.info["kwargs"].get("plot", None)
else:
dev_y = None
if not dev_y:
det = None
if not det:
return
plt1 = self.get_default_figure()
# clear_all() will throw RPCResponseTimeoutError
try:
# This will throw RPCResponseTimeoutError
plt1.clear_all()
except RPCResponseTimeoutError:
pass
# plot() will throw RPCResponseTimeoutError
try:
# TODO: What about 2D scans?
# This will throw RPCResponseTimeoutError
plt1.plot(x_name=dev_x, y_name=dev_y)
if len(info.scan_report_devices)==2:
# 2D plot
dev_x = info.scan_report_devices[0]
dev_y = info.scan_report_devices[1]
plt1.plot(
x_name=dev_x,
y_name=dev_y,
z_name=det,
title=f"Scan {info.scan_number}",
x_label=dev_x,
y_label=dev_y,
z_label=det
)
elif len(info.scan_report_devices)==1:
# 1D plot
dev_x = info.scan_report_devices[0]
plt1.plot(
x_name=dev_x,
y_name=det,
title=f"Scan {info.scan_number}",
x_label=dev_x,
y_label=det,
)
else:
# Default is 1D
dev_x = info.scan_report_devices[0]
plt1.plot(
x_name=dev_x,
y_name=det,
title=f"Scan {info.scan_number}",
x_label=dev_x,
y_label=det,
)
except RPCResponseTimeoutError:
pass
try:
# This will throw RPCResponseTimeoutError
plt1.set(title=f"PXIII: Scan {info.scan_number}", x_label=dev_x, y_label=dev_y)
except RPCResponseTimeoutError:
pass
except AttributeError:
pass
# plt1.add_dap(dev_x, dev_y, dap="LinearModel")
# plt1.add_dap(dev_x, det, dap="LinearModel")
def handler(self, info: ScanInfo) -> None:
"""Dock configuration handler"""
@@ -70,4 +97,5 @@ class PlotUpdate(AutoUpdates):
# self.run_grid_scan_update(info)
# return
super().handler(info)
self.keyword_handler(info)
self.plot_handler(info)

View File

@@ -27,10 +27,6 @@ abs_press:
softwareTrigger: false
sldi_cenx:
description: FE slit-diaphragm horizontal center
deviceClass: ophyd.EpicsMotor