Skip to content
Snippets Groups Projects
Commit 48881719 authored by Martin Teichmann's avatar Martin Teichmann
Browse files

inline parabola function into hRIXS class

parent 0c651870
No related branches found
No related tags found
1 merge request!231improve the integation code
...@@ -246,10 +246,6 @@ RANGE = [300, 400] ...@@ -246,10 +246,6 @@ RANGE = [300, 400]
BINS = abs(np.subtract(*RANGE)) * FACTOR BINS = abs(np.subtract(*RANGE)) * FACTOR
def parabola(x, a, b, c=0):
return (a * x + b) * x + c
class hRIXS: class hRIXS:
"""The hRIXS analysis, especially curvature correction """The hRIXS analysis, especially curvature correction
...@@ -449,6 +445,9 @@ class hRIXS: ...@@ -449,6 +445,9 @@ class hRIXS:
* self.ENERGY_SLOPE + self.ENERGY_INTERCEPT) * self.ENERGY_SLOPE + self.ENERGY_INTERCEPT)
return data.assign(spectrum=(("trainId", "energy"), ret)) return data.assign(spectrum=(("trainId", "energy"), ret))
def parabola(self, x):
return (self.CURVE_B * x + self.CURVE_A) * x
def integrate(self, data): def integrate(self, data):
"""calculate a spectrum by integration """calculate a spectrum by integration
...@@ -479,7 +478,7 @@ class hRIXS: ...@@ -479,7 +478,7 @@ class hRIXS:
image = image.values[self.X_RANGE, self.Y_RANGE].T image = image.values[self.X_RANGE, self.Y_RANGE].T
x = np.arange(image.shape[1])[None, :] x = np.arange(image.shape[1])[None, :]
y = np.arange(image.shape[0])[:, 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) ysf = np.floor(ys)
rang = (10, bins + 10) rang = (10, bins + 10)
lhy, lhx = np.histogram(ysf.ravel(), bins=bins, range=rang, lhy, lhx = np.histogram(ysf.ravel(), bins=bins, range=rang,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment