diff --git a/src/toolbox_scs/detectors/hrixs.py b/src/toolbox_scs/detectors/hrixs.py index 3dabbdd73be14cec52e408c9d3a4c49ae501e72e..24f87bc7aad902187693b27e73a9971a8957f6f0 100644 --- a/src/toolbox_scs/detectors/hrixs.py +++ b/src/toolbox_scs/detectors/hrixs.py @@ -164,13 +164,6 @@ def to_fwhm(sigma): return abs(sigma * FWHM_COEFF) -# ----------------------------------------------------------------------------- -# Centroid - -THRESHOLD = 510 # pixel counts above which a hit candidate is assumed -CURVE_A = 2.19042931e-02 # curvature parameters as determined elsewhere -CURVE_B = -3.02191568e-07 - def decentroid(res): res = np.array(res) ret = np.zeros(shape=(res.max(axis=0) + 1).astype(int)) @@ -180,14 +173,6 @@ def decentroid(res): return ret -# ----------------------------------------------------------------------------- -# Integral - -FACTOR = 1 -RANGE = [300, 400] -BINS = abs(np.subtract(*RANGE)) * FACTOR - - class hRIXS: """The hRIXS analysis, especially curvature correction @@ -251,7 +236,6 @@ class hRIXS: CURVE_B = 0 # integral - FACTOR = FACTOR BINS = 100 METHOD = 'centroid' # ['centroid', 'integral'] @@ -270,8 +254,7 @@ class hRIXS: if not params: params = ('proposal', 'x_range', 'y_range', 'threshold', 'curve_a', 'curve_b', - 'factor', 'range', 'bins', - 'method', 'fields') + 'bins', 'method', 'fields') return {param: getattr(self, param.upper()) for param in params} def from_run(self, runNB, proposal=None, extra_fields=()): @@ -449,7 +432,7 @@ class hRIXS: margin = 10 ret = np.zeros((len(data["hRIXS_det"]), bins - 2 * margin)) if self.USE_DARK: - dark_image = self.dark_image[self.X_RANGE, self.Y_RANGE] + dark_image = self.dark_image.values[self.X_RANGE, self.Y_RANGE] images = data["hRIXS_det"].values[:, self.X_RANGE, self.Y_RANGE] x, y = np.ogrid[:images.shape[1], :images.shape[2]] diff --git a/src/toolbox_scs/test/test_hrixs.py b/src/toolbox_scs/test/test_hrixs.py index 7b75cdef6a103f53f033645b34f15fba979f8588..1b5957d0d572ad04091650b0f48fc812de5da84f 100644 --- a/src/toolbox_scs/test/test_hrixs.py +++ b/src/toolbox_scs/test/test_hrixs.py @@ -22,6 +22,12 @@ class TestHRIXS(unittest.TestCase): 28517.704705882363) self.assertEqual(data['spectrum'][1, 50].coords['energy'], 90) + h.dark_image = xa.DataArray(np.ones((100, 200)), dims=('x', 'y')) + h.USE_DARK = True + h.integrate(data) + self.assertEqual(data['spectrum'][1, 50].values[()], + 28516.704705882363) + def test_centroid(self): data = xa.Dataset() img = np.array([ @@ -60,6 +66,12 @@ class TestHRIXS(unittest.TestCase): [0, 0, 0, 1, 0, 0, 0, 0, 0, 0], ]) + def test_getparam(self): + # this is just a smoke test + h = hRIXS() + d = h.get_params() + self.assertEqual(d['bins'], 100) + if __name__ == "__main__": unittest.main()