From 581a7ccf17964db3eb4fecf78aaaba3230d561e4 Mon Sep 17 00:00:00 2001 From: David Perl Date: Wed, 9 Sep 2026 15:44:35 +0200 Subject: [PATCH] fix: make xraycenter line scan on box center and twice box height --- src/aare/daq/operations/raster/service.py | 32 ++++++++--------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/src/aare/daq/operations/raster/service.py b/src/aare/daq/operations/raster/service.py index c0d26b69..8343ece1 100644 --- a/src/aare/daq/operations/raster/service.py +++ b/src/aare/daq/operations/raster/service.py @@ -246,28 +246,18 @@ class RasterService: target_point=prediction_result.target_point, focus=prediction_result.focus, ) - target_point = prediction_result.target_point + prediction_box = prediction_result.box - if y_padding_fraction_each_side is None: - local_contact_config = self.ctx.deps.cfg.local_contact_config - prediction_type = getattr(prediction_box, "type", None) + if prediction_box is not None: + box_y_height_px = abs(prediction_box.box.bottom_y - prediction_box.box.top_y) + box_y_center_px = prediction_box.box.top_y + box_y_height_px / 2 + else: + box_y_center_px = None - if prediction_type == MLBoxType.LOOP_FACE: - y_padding_fraction_each_side = ( - local_contact_config.line_scan_loop_face_y_padding_fraction_each_side - ) - elif prediction_type == MLBoxType.LOOP_ALL: - y_padding_fraction_each_side = ( - local_contact_config.line_scan_loop_all_y_padding_fraction_each_side - ) - else: - y_padding_fraction_each_side = float( - cfg_get("daq.auto_raster.line_scan_y_padding_fraction", 0.15) - ) - if target_point is not None: - target_y_pxl = target_point[1] + if box_y_center_px is not None: + target_y_pxl = box_y_center_px y_delta_mm = abs(target_y_pxl - beam_y_pxl) * geom.pixel_in_mm if y_retarget_threshold_mm is None: @@ -323,9 +313,9 @@ class RasterService: if prediction_box is not None and prediction_box.box is not None and grid_size_mm.y > 0: box_height_pxl = abs(prediction_box.box.bottom_y - prediction_box.box.top_y) - padded_height_mm = ( - box_height_pxl * geom.pixel_in_mm * (1.0 + 2.0 * y_padding_fraction_each_side) - ) + padded_height_px = box_height_pxl * 2 + padded_height_mm = padded_height_px* geom.pixel_in_mm + n_y = max(1, ceil(padded_height_mm / grid_size_mm.y)) self.logger.info( "Computed second auto-center raster y size from ML box height",