From 48881719c8a4c5fa620038ecefe4321eedb5b769 Mon Sep 17 00:00:00 2001
From: Martin Teichmann <martin.teichmann@xfel.eu>
Date: Thu, 8 Dec 2022 11:50:09 +0100
Subject: [PATCH] inline parabola function into hRIXS class

---
 src/toolbox_scs/detectors/hrixs.py | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/toolbox_scs/detectors/hrixs.py b/src/toolbox_scs/detectors/hrixs.py
index c143833..ae983c3 100644
--- a/src/toolbox_scs/detectors/hrixs.py
+++ b/src/toolbox_scs/detectors/hrixs.py
@@ -246,10 +246,6 @@ RANGE = [300, 400]
 BINS = abs(np.subtract(*RANGE)) * FACTOR
 
 
-def parabola(x, a, b, c=0):
-    return (a * x + b) * x + c
-
-
 class hRIXS:
     """The hRIXS analysis, especially curvature correction
 
@@ -449,6 +445,9 @@ class hRIXS:
             * self.ENERGY_SLOPE + self.ENERGY_INTERCEPT)
         return data.assign(spectrum=(("trainId", "energy"), ret))
 
+    def parabola(self, x):
+        return (self.CURVE_B * x + self.CURVE_A) * x
+
     def integrate(self, data):
         """calculate a spectrum by integration
 
@@ -479,7 +478,7 @@ class hRIXS:
             image = image.values[self.X_RANGE, self.Y_RANGE].T
             x = np.arange(image.shape[1])[None, :]
             y = np.arange(image.shape[0])[:, None]
-            ys = (y - parabola(x, self.CURVE_B, self.CURVE_A))
+            ys = y - self.parabola(x)
             ysf = np.floor(ys)
             rang = (10, bins + 10)
             lhy, lhx = np.histogram(ysf.ravel(), bins=bins, range=rang,
-- 
GitLab