From 6f5701e700b4c7650c51115b0c1bdcd5ced864ac Mon Sep 17 00:00:00 2001 From: appleb_m Date: Tue, 25 Nov 2025 18:01:22 +0100 Subject: [PATCH] find_Xtal - COM calculation bug fix --- common/src/aaredaqlib/find_xtal.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/aaredaqlib/find_xtal.py b/common/src/aaredaqlib/find_xtal.py index 3034d3e1..7efc468c 100644 --- a/common/src/aaredaqlib/find_xtal.py +++ b/common/src/aaredaqlib/find_xtal.py @@ -263,10 +263,10 @@ def com_nan_check(com): else: return True -def get_result_list_from_com(images, com): +def get_result_list_from_com(images, com: CenterOfMassModel): if not com_nan_check(com): return None - cy, cx = com[::-1] + cy, cx = com.n_x, com.n_y start_x, end_x = round(cx - 1), round(cx + 1) start_y, end_y = round(cy - 1), round(cy + 1) logger.info(f"range x {start_x} {end_x}, y {start_y} {end_y}") @@ -285,7 +285,7 @@ def get_com_image_number(com, images): def raster_centre_of_mass(result_array, r:RasterGridRequest) -> CenterOfMassModel | None: # grid_mm_x and grid_mm_y are relative to the top left corner of raster grid com = ndimage.center_of_mass(result_array) - if com or not com_nan_check(com): + if com or not np.isnan(com[0]) or not np.isnan(com[1]): logger.info(f"Center of mass: {com}") return CenterOfMassModel(n_x=com[0], n_y=com[1]) else: