Commit 98536e60 authored by Nicola Vigano's avatar Nicola Vigano
Browse files

Alignment: fixed fitting of Detector translation, due to first element having to being 0



Thanks Christian for spotting this
Signed-off-by: Nicola Vigano's avatarNicola VIGANÒ <nicola.vigano@esrf.fr>
parent 08326b6e
Pipeline #28105 passed with stages
in 3 minutes and 47 seconds
......@@ -682,20 +682,21 @@ class DetectorTranslationAlongBeam(AlignmentBase):
if use_adjacent_imgs:
shifts_vh = np.cumsum(shifts_vh, axis=0)
img_pos_increments = img_pos[1:] - img_pos[0]
img_shifts_vh = np.concatenate(([[0, 0]], shifts_vh), axis=0)
# Polynomial.fit is supposed to be more numerically stable than polyfit
# (according to numpy)
coeffs_v = Polynomial.fit(img_pos_increments, shifts_vh[:, 0], deg=1).convert().coef
coeffs_h = Polynomial.fit(img_pos_increments, shifts_vh[:, 1], deg=1).convert().coef
coeffs_v = Polynomial.fit(img_pos, img_shifts_vh[:, 0], deg=1).convert().coef
coeffs_h = Polynomial.fit(img_pos, img_shifts_vh[:, 1], deg=1).convert().coef
if self.verbose:
f, axs = plt.subplots(1, 2)
axs[0].scatter(img_pos_increments, shifts_vh[:, 0])
axs[0].plot(img_pos_increments, polyval(img_pos_increments, coeffs_v))
axs[0].scatter(img_pos, img_shifts_vh[:, 0])
axs[0].plot(img_pos, polyval(img_pos, coeffs_v))
axs[0].set_title("Vertical shifts")
axs[1].scatter(img_pos_increments, shifts_vh[:, 1])
axs[1].plot(img_pos_increments, polyval(img_pos_increments, coeffs_h))
axs[1].scatter(img_pos, img_shifts_vh[:, 1])
axs[1].plot(img_pos, polyval(img_pos, coeffs_h))
axs[1].set_title("Horizontal shifts")
plt.show(block=False)
......
......@@ -35,7 +35,7 @@ def bootstrap_dtr(request):
cls.align_images = align_imgs - dark_img
cls.img_pos = (1 + np.arange(6)) * 0.01
cls.expected_shifts_vh = np.array((311.25, 308.9))
cls.expected_shifts_vh = np.array((129.93, 353.18))
cls.reference_shifts_list = [
[-9.39, 11.29],
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment