diff --git a/src/toolbox_scs/detectors/hrixs.py b/src/toolbox_scs/detectors/hrixs.py index 588981245274a78bde4ef0b5a466f5454e848b8e..22bdf3e3843e87c68aecd829b5cf1d7b8494dfe9 100644 --- a/src/toolbox_scs/detectors/hrixs.py +++ b/src/toolbox_scs/detectors/hrixs.py @@ -477,14 +477,14 @@ class hRIXS: dark_image = self.dark_image[self.X_RANGE, self.Y_RANGE] images = data["hRIXS_det"].values[:, self.X_RANGE, self.Y_RANGE] - x = np.arange(images.shape[1])[:, None] - y = np.arange(images.shape[2])[None, :] - self.parabola(x) - quo, rem = divmod(y, 1) - quo = np.array([[[0]], [[1]]]) + quo - margin - rem = rem * np.array([[[1]], [[-1]]]) + np.array([[[0]], [[1]]]) - wrong = (quo < 0) | (quo >= bins - 2 * margin) - quo[wrong] = rem[wrong] = 0 - quo = quo.astype(int).ravel() + x, y = np.ogrid[:images.shape[1], :images.shape[2]] + quo, rem = divmod(y - self.parabola(x), 1) + quo = np.array([quo, quo + 1]) + rem = np.array([rem, 1 - rem]) + wrong = (quo < margin) | (quo >= bins - margin) + quo[wrong] = margin + rem[wrong] = 0 + quo = (quo - margin).astype(int).ravel() for image, r in zip(images, ret): if self.USE_DARK: