From 919a4e774ebe1a2a48bd1198eed33daee5a854f1 Mon Sep 17 00:00:00 2001
From: Johannes Niskanen <niskanen@max-exfl099.desy.de>
Date: Tue, 31 May 2022 14:07:13 +0200
Subject: [PATCH] jhns_centroid'.

---
 src/toolbox_scs/detectors/hrixs.py | 54 +-----------------------------
 1 file changed, 1 insertion(+), 53 deletions(-)

diff --git a/src/toolbox_scs/detectors/hrixs.py b/src/toolbox_scs/detectors/hrixs.py
index 7615961..6b9f7ea 100644
--- a/src/toolbox_scs/detectors/hrixs.py
+++ b/src/toolbox_scs/detectors/hrixs.py
@@ -392,60 +392,8 @@ class hRIXS:
         self.CURVE_B, self.CURVE_A, *_ = args
         return self.CURVE_A, self.CURVE_B
 
+    
     def centroid(self, data, bins=None, return_hits=False):
-        if bins is None:
-            bins = self.BINS
-        hit_x = []
-        hit_y = []
-        hits = []
-        ret = np.zeros((len(data["hRIXS_det"]), bins))
-        for image, r in zip(data["hRIXS_det"], ret):
-            use_image = image.to_numpy()
-            if self.USE_DARK_MASK:
-                use_image[self.dark_mask] = np.mean(use_image[self.MASK_AVG_Y,
-                                                              self.MASK_AVG_X], (0, 1))
-                if self.USE_DARK:
-                    use_image = use_image - self.dark_im_array_m
-            else:
-                if self.USE_DARK:
-                    use_image = use_image - self.dark_im_array
-            c = centroid(
-                use_image[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
-
-            rc = np.array(c)
-            
-            if return_hits:
-                hit_x.append(rc[:, 0])
-                hit_y.append(rc[:, 1])
-                hits.append(rc)
-
-            hy, hx = np.histogram(
-                rc[:, 0], bins=bins,
-                range=(0, self.Y_RANGE.stop - self.Y_RANGE.start))
-            r[:] = hy
-
-        data = data.assign_coords(
-            energy=np.linspace(self.Y_RANGE.start, self.Y_RANGE.stop, bins)
-            * self.ENERGY_SLOPE + self.ENERGY_INTERCEPT)
-        #**********************************************
-        # If hits were requested, assign them to data
-        #**********************************************
-        if return_hits:
-            data = data.assign(hits=(("trainId"), hits),
-                        xhits=(("trainId"), hit_x),
-                        yhits=(("trainId"), hit_y))
-        #**********************************************
-        # Always assign the spectrum to data
-        #**********************************************
-        data = data.assign(spectrum=(("trainId", "energy"), ret))
-        return data
-
-    def centroid_jhns(self, data, bins=None, return_hits=False):
         #*************************************************************
         # Carry out hit finding on data and bin them in grid
         # Allows for 
-- 
GitLab