From ad1579a3cae0b16bd9a5afc9a75f05fe9adac44a Mon Sep 17 00:00:00 2001 From: Martin Teichmann <martin.teichmann@xfel.eu> Date: Wed, 14 Dec 2022 11:28:21 +0100 Subject: [PATCH] improve readability of integration --- src/toolbox_scs/detectors/hrixs.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/toolbox_scs/detectors/hrixs.py b/src/toolbox_scs/detectors/hrixs.py index 5889812..22bdf3e 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: -- GitLab