Skip to content
Snippets Groups Projects

Cumulative updates from beamtime 2776 (van Kuiken)

Merged Martin Teichmann requested to merge p2776 into master
1 file
+ 9
8
Compare changes
  • Side-by-side
  • Inline
@@ -58,7 +58,7 @@ def find_curvature(image, frangex=None, frangey=None,
return curv[:-1][::-1]
def find_curvature(img, args, plot=False):
def find_curvature(img, args, plot=False, **kwargs):
def parabola(x, a, b, c, s=0, h=0, o=0):
return (a*x + b)*x + c
def gauss(y, x, a, b, c, s, h, o=0):
@@ -68,7 +68,7 @@ def find_curvature(img, args, plot=False):
if plot:
plt.figure(figsize=(10,10))
plt.imshow(img, cmap='gray', aspect='auto', vmin=26000, vmax=27000, interpolation='nearest')
plt.imshow(img, cmap='gray', aspect='auto', interpolation='nearest', **kwargs)
plt.plot(x[0, :], parabola(x[0, :], *args))
args, _ = leastsq(lambda args: (gauss(y, x, *args) - img).ravel(), args)
@@ -317,16 +317,17 @@ class hRIXS:
return data
def find_curvature(self, runNB, proposal=None, plot=True):
def find_curvature(self, runNB, proposal=None, plot=True, args=None, **kwargs):
data = self.from_run(runNB, proposal)
image = data['hRIXS_det'].sum(dim='trainId') \
.to_numpy()[self.X_RANGE, self.Y_RANGE].T
spec = (image - image[:10, :].mean()).mean(axis=1)
mean = np.average(np.arange(len(spec)), weights=spec)
args = find_curvature(
image, (-2e-7, 0.02, mean - 0.02 * image.shape[1] / 2, 3,
spec.max(), image.mean()), plot=plot)
if args is None:
spec = (image - image[:10, :].mean()).mean(axis=1)
mean = np.average(np.arange(len(spec)), weights=spec)
args = (-2e-7, 0.02, mean - 0.02 * image.shape[1] / 2, 3,
spec.max(), image.mean())
args = find_curvature(image, args, plot=plot, **kwargs)
self.CURVE_B, self.CURVE_A, *_ = args
return self.CURVE_A, self.CURVE_B
Loading