feat: add multi-raster
This commit is contained in:
1 parent
66105af285
commit
dc247745b2
2 files changed
+61
-7
No files matched your search
@@ -58,6 +58,16 @@ TASK_FORMS: dict[str, list[tuple[str, int | float | str]]] = {
|
||||
("dtz", 250),
|
||||
("file_prefix", "AareBecTestGridScan"),
|
||||
],
|
||||
"multiple_rasters": [
|
||||
("omegas_deg_list", "0, 30, 60, 90"),
|
||||
("n_x", 4),
|
||||
("n_y", 3),
|
||||
("step_x_mm", 0.05),
|
||||
("step_y_mm", 0.05),
|
||||
("exp_time_s", 0.1),
|
||||
("dtz", 250),
|
||||
("file_prefix", "AareBecTestGridScan"),
|
||||
],
|
||||
"aaredaq_rotation_scan": [
|
||||
("exp_time_s", 0.05),
|
||||
("incr_omega_deg", 0.1),
|
||||
|
||||
+51
-7
@@ -15,12 +15,15 @@ from bec_lib.logger import bec_logger
|
||||
from mx_bec.devices.smargopolo_smargon import Smargon
|
||||
from mx_bec.endpoints import StateEndpoints, TaskEndpoints
|
||||
from mx_bec.jfjoch import RasterScan
|
||||
from mx_bec.messages import MXMeasurementSequenceMessage, MXTaskQueueChangedMessage
|
||||
from mx_bec.messages import (
|
||||
MXMeasurementSequenceMessage,
|
||||
MXTaskExecutionMessage,
|
||||
MXTaskQueueChangedMessage,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from pxii_bec.macros.beamline_planner import StateChangePlanner
|
||||
|
||||
from mx_bec.messages import MXTaskExecutionMessage
|
||||
from mx_bec.service import AareBec
|
||||
|
||||
logger = bec_logger.logger
|
||||
@@ -45,6 +48,12 @@ class MxTasks:
|
||||
self._busy_lock = RLock()
|
||||
self._planner: StateChangePlanner | None = None
|
||||
|
||||
def _request_task(self, name: str, *args, **kwargs):
|
||||
"""Submit a task request to the AareBec service."""
|
||||
msg = MXTaskExecutionMessage(name=name, args=args, kwargs=kwargs)
|
||||
logger.info(f"Requesting task: {msg}")
|
||||
self._client.connector.xadd(TaskEndpoints.task_request(), {"data": msg})
|
||||
|
||||
@property
|
||||
def planner(self) -> StateChangePlanner:
|
||||
"""The beamline state planner, built on first use: `init_beamline_environment` needs the
|
||||
@@ -166,11 +175,17 @@ class MxTasks:
|
||||
file_prefix: str | None = None,
|
||||
dtz: float | None = None,
|
||||
transmission: float | None = None,
|
||||
smargon_top_left: SmargonCoordinate | None = None,
|
||||
auto_center: bool = False,
|
||||
) -> None:
|
||||
"""Have AareDAQ run an n_x by n_y raster scan from the current Smargon position
|
||||
(`smargon_top_left` is left unset), optionally auto-centering afterwards."""
|
||||
smargon = self._client.devices.smargon
|
||||
smargon_top_left = smargon_top_left or SmargonCoordinate(
|
||||
sh_mm=Coordinate(x=smargon.x.get(), y=smargon.x.get(), z=smargon.x.get()),
|
||||
chi_deg=smargon.chi.get(),
|
||||
phi_deg=smargon.phi.get(),
|
||||
)
|
||||
request = RasterGridRequest(
|
||||
n_x=n_x,
|
||||
n_y=n_y,
|
||||
@@ -180,15 +195,44 @@ class MxTasks:
|
||||
file_prefix=file_prefix,
|
||||
dtz=dtz,
|
||||
transmission=transmission,
|
||||
smargon_top_left=SmargonCoordinate(
|
||||
sh_mm=Coordinate(x=smargon.x.get(), y=smargon.x.get(), z=smargon.x.get()),
|
||||
chi_deg=smargon.chi.get(),
|
||||
phi_deg=smargon.phi.get(),
|
||||
),
|
||||
smargon_top_left=smargon_top_left,
|
||||
)
|
||||
result = self._client.aaredaq.raster_scan(request, auto_center=auto_center)
|
||||
logger.info(f"AareDAQ raster scan done: {len(result.r)} grid(s) collected")
|
||||
|
||||
@task
|
||||
def multiple_rasters(
|
||||
self,
|
||||
omegas_deg_list: str,
|
||||
n_x: int,
|
||||
n_y: int,
|
||||
step_x_mm: float,
|
||||
step_y_mm: float,
|
||||
exp_time_s: float,
|
||||
file_prefix: str | None = None,
|
||||
dtz: float | None = None,
|
||||
) -> None:
|
||||
"""Run multiple raster scans at different omega values"""
|
||||
omegas = [float(ang) for ang in omegas_deg_list.split(",")]
|
||||
smargon = self._client.devices.smargon
|
||||
smargon_top_left = SmargonCoordinate(
|
||||
sh_mm=Coordinate(x=smargon.x.get(), y=smargon.x.get(), z=smargon.x.get()),
|
||||
chi_deg=smargon.chi.get(),
|
||||
phi_deg=smargon.phi.get(),
|
||||
)
|
||||
for i, omega in enumerate(omegas):
|
||||
self.aaredaq_raster_scan(
|
||||
n_x,
|
||||
n_y,
|
||||
step_x_mm,
|
||||
step_y_mm,
|
||||
exp_time_s,
|
||||
file_prefix=f"{file_prefix}_{i}_{omega:%.2f}deg",
|
||||
dtz=dtz,
|
||||
smargon_top_left=smargon_top_left,
|
||||
)
|
||||
logger.info(f"Raster {i + 1} out of {len(omegas)} done.")
|
||||
|
||||
@task
|
||||
def xray_centering(self, dbid: int, strategy: dict):
|
||||
self.aaredaq_raster_scan(**strategy)
|
||||
|
||||
Reference in new issue
Block a user