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: