From 1fa421c5cfa92d2e04c33082cd7a490061e31d65 Mon Sep 17 00:00:00 2001 From: appleb_m Date: Mon, 22 Dec 2025 09:40:15 +0100 Subject: [PATCH] DAQ: added has_sufficient_low_res_spots function but forgot to commit it - sorry! --- common/src/aaredaqlib/find_xtal.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/common/src/aaredaqlib/find_xtal.py b/common/src/aaredaqlib/find_xtal.py index 07d5d430..a3328ac1 100644 --- a/common/src/aaredaqlib/find_xtal.py +++ b/common/src/aaredaqlib/find_xtal.py @@ -297,3 +297,22 @@ def raster_centre_of_mass(result_array, images) -> CenterOfMassModel | None: logger.warning("No valid center of mass found") return None +def has_sufficient_low_res_spots( + result_array: np.ndarray, + min_spots_low_res: float, + ) -> bool: + if result_array is None or result_array.size == 0: + logger.warning("Empty result_array passed to has_sufficient_low_res_spots") + return False + + max_val = float(np.nanmax(result_array)) + logger.info(f"Max spots_low_res in raster result_array: {max_val}") + + if max_val < min_spots_low_res: + logger.info( + "Raster rejected: max spots_low_res " + f"{max_val} < required {min_spots_low_res}" + ) + return False + + return True \ No newline at end of file