This commit is contained in:
1 parent
48bf914a00
commit
de57281d82
2 files changed
+42
-17
No files matched your search
@@ -76,7 +76,14 @@ class OnOpticalCenteringDoneRunXrayCentering(MXAutomationActor):
|
||||
logger.info(
|
||||
f"Calculating gridscan strategy given optical centering results available: {client.sample_info.optical_centering_results is not None}"
|
||||
)
|
||||
strategy = gridscan_strategy_from_optical(client.sample_info.optical_centering_results)
|
||||
strategy = gridscan_strategy_from_optical(
|
||||
client.sample_info.optical_centering_results,
|
||||
client.aare_config.auto_grid_params.box_size_x_um,
|
||||
client.aare_config.auto_grid_params.box_size_y_um,
|
||||
client.aare_config.auto_grid_params.margin_multiplier,
|
||||
client.aare_config.auto_grid_params.exp_time_s,
|
||||
client.aare_config.auto_grid_params.detector_distance_mm,
|
||||
)
|
||||
strategy["omega_deg"] = 0.0
|
||||
logger.info(f"calculated strategy: {strategy}")
|
||||
client.add_task_to_queue(
|
||||
@@ -102,7 +109,14 @@ class OnOpticalCenteringDoneRunMultiGrid(MXAutomationActor):
|
||||
logger.info(
|
||||
f"Calculating gridscan strategy given optical centering results available: {client.sample_info.optical_centering_results is not None}"
|
||||
)
|
||||
strategy = gridscan_strategy_from_optical(client.sample_info.optical_centering_results)
|
||||
strategy = gridscan_strategy_from_optical(
|
||||
client.sample_info.optical_centering_results,
|
||||
client.aare_config.auto_grid_params.box_size_x_um,
|
||||
client.aare_config.auto_grid_params.box_size_y_um,
|
||||
client.aare_config.auto_grid_params.margin_multiplier,
|
||||
client.aare_config.auto_grid_params.exp_time_s,
|
||||
client.aare_config.auto_grid_params.detector_distance_mm,
|
||||
)
|
||||
logger.info(f"calculated strategy: {strategy}")
|
||||
client.add_task_to_queue(
|
||||
MXTaskExecutionMessage(name="multiple_rasters", args=("0,60,120",), kwargs=strategy)
|
||||
|
||||
+26
-15
@@ -10,11 +10,6 @@ from mx_bec.sample_info import OpticalCenteringResults
|
||||
logger = bec_logger.logger
|
||||
|
||||
|
||||
STEP_X_MM = 0.03
|
||||
STEP_Y_MM = 0.02
|
||||
MARGIN = 1.3
|
||||
|
||||
|
||||
def smargon_nudge(
|
||||
phi_deg: float, chi_deg: float, omega_deg: float, nudge_vector: Coordinate
|
||||
) -> Coordinate:
|
||||
@@ -70,7 +65,14 @@ def mock_grid_calculation():
|
||||
return strategy
|
||||
|
||||
|
||||
def gridscan_strategy_from_optical(optical_results: OpticalCenteringResults | None):
|
||||
def gridscan_strategy_from_optical(
|
||||
optical_results: OpticalCenteringResults | None,
|
||||
step_x_um: float,
|
||||
step_y_um: float,
|
||||
margin: float,
|
||||
exp_time_s: float,
|
||||
dtz_mm: float,
|
||||
):
|
||||
if optical_results is None or len(boxes := optical_results.prediction.boxes) == 0:
|
||||
return mock_grid_calculation()
|
||||
else:
|
||||
@@ -85,17 +87,26 @@ def gridscan_strategy_from_optical(optical_results: OpticalCenteringResults | No
|
||||
else:
|
||||
file_prefix = f"AareBecTestGridScan_{secrets.token_hex(6)}"
|
||||
return gridscan_calculation(
|
||||
box_corners[0], box_corners[1], STEP_X_MM, STEP_Y_MM, MARGIN, file_prefix
|
||||
box_corners[0],
|
||||
box_corners[1],
|
||||
step_x_um / 1000,
|
||||
step_y_um / 1000,
|
||||
margin,
|
||||
file_prefix,
|
||||
exp_time_s,
|
||||
dtz_mm,
|
||||
)
|
||||
|
||||
|
||||
def gridscan_calculation(
|
||||
x1_y1: tuple[float, float],
|
||||
x2_y2: tuple[float, float],
|
||||
size_x: float,
|
||||
size_y: float,
|
||||
size_x_mm: float,
|
||||
size_y_mm: float,
|
||||
margin: float,
|
||||
file_prefix: str,
|
||||
exp_time_s: float,
|
||||
dtz_mm: float,
|
||||
):
|
||||
"""calculate a gridscan from box coordinates and params. needs omega added later."""
|
||||
box_x_pixels = abs(x1_y1[0] - x1_y1[0])
|
||||
@@ -105,14 +116,14 @@ def gridscan_calculation(
|
||||
box_y_microns = calc_scam_microns(box_y_pixels, zoom=400)
|
||||
logger.info(f"{box_x_microns=}, {box_y_microns=}")
|
||||
logger.info(f"adding margin to detection boxes of {margin}x")
|
||||
n_x = int(box_x_microns / 1000 / size_x * margin)
|
||||
n_y = int(box_x_microns / 1000 / size_y * margin)
|
||||
n_x = int(box_x_microns / 1000 / size_x_mm * margin)
|
||||
n_y = int(box_x_microns / 1000 / size_y_mm * margin)
|
||||
return {
|
||||
"n_x": n_x,
|
||||
"n_y": n_y,
|
||||
"step_x_mm": size_x,
|
||||
"step_y_mm": size_y,
|
||||
"exp_time_s": 0.01,
|
||||
"step_x_mm": size_x_mm,
|
||||
"step_y_mm": size_y_mm,
|
||||
"exp_time_s": exp_time_s,
|
||||
"file_prefix": file_prefix,
|
||||
"dtz": 200,
|
||||
"dtz": dtz_mm,
|
||||
}
|
||||
Reference in new issue
Block a user