diff --git a/src/toolbox_scs/detectors/hrixs.py b/src/toolbox_scs/detectors/hrixs.py index 3de1a47a5e6a18a1de5a5952ca84723b28240f94..6282d85f15c4bd1d9721fc1e1793a48d12a3f825 100644 --- a/src/toolbox_scs/detectors/hrixs.py +++ b/src/toolbox_scs/detectors/hrixs.py @@ -197,7 +197,7 @@ def _esrf_centroid(image, threshold=THRESHOLD, curvature=(CURVE_A, CURVE_B)): return res -def _new_centroid(image, threshold=THRESHOLD, curvature=(CURVE_A, CURVE_B)): +def _new_centroid(image, threshold=THRESHOLD, std_threshold=3.5, curvature=(CURVE_A, CURVE_B)): """find the position of photons with sub-pixel precision A photon is supposed to have hit the detector if the intensity within a @@ -208,7 +208,8 @@ def _new_centroid(image, threshold=THRESHOLD, curvature=(CURVE_A, CURVE_B)): """ base = image.mean() corners = image[1:, 1:] + image[:-1, 1:] + image[1:, :-1] + image[:-1, :-1] - threshold = corners.mean() + 3.5 * corners.std() + if threshold is None: + threshold = corners.mean() + std_threshold * corners.std() middle = corners[1:-1, 1:-1] candidates = ( (middle > threshold) @@ -283,7 +284,8 @@ class hRIXS: Y_RANGE = np.s_[:] # centroid - THRESHOLD = THRESHOLD # pixel counts above which a hit candidate is assumed + THRESHOLD = None # pixel counts above which a hit candidate is assumed + STD_THRESHOLD = 3.5 # same as THRESHOLD, in standard deviations CURVE_A = CURVE_A # curvature parameters as determined elsewhere CURVE_B = CURVE_B @@ -347,6 +349,7 @@ class hRIXS: c = centroid( image.to_numpy()[self.X_RANGE, self.Y_RANGE].T, threshold=self.THRESHOLD, + std_threshold=self.STD_THRESHOLD, curvature=(self.CURVE_A, self.CURVE_B)) if not len(c): continue