Commit 5b605233 authored by Nicola Vigano's avatar Nicola Vigano
Browse files

DetectorTranslationAlongBeam: return complete list of shifts (with initial zeros)


Signed-off-by: Nicola Vigano's avatarNicola VIGANÒ <nicola.vigano@esrf.fr>
parent 0535ee49
Pipeline #28337 passed with stages
in 3 minutes and 2 seconds
...@@ -717,27 +717,25 @@ class DetectorTranslationAlongBeam(AlignmentBase): ...@@ -717,27 +717,25 @@ class DetectorTranslationAlongBeam(AlignmentBase):
cc_vs = np.fft.fftfreq(img_shape[-2], 1 / img_shape[-2]) cc_vs = np.fft.fftfreq(img_shape[-2], 1 / img_shape[-2])
cc_hs = np.fft.fftfreq(img_shape[-1], 1 / img_shape[-1]) cc_hs = np.fft.fftfreq(img_shape[-1], 1 / img_shape[-1])
shifts_vh = np.empty((num_imgs - 1, 2)) shifts_vh = np.empty((num_imgs, 2))
for ii, cc in enumerate(ccs): for ii, cc in enumerate(ccs):
(f_vals, fv, fh) = self.extract_peak_region_2d(cc, peak_radius=peak_fit_radius, cc_vs=cc_vs, cc_hs=cc_hs) (f_vals, fv, fh) = self.extract_peak_region_2d(cc, peak_radius=peak_fit_radius, cc_vs=cc_vs, cc_hs=cc_hs)
shifts_vh[ii, :] = self.refine_max_position_2d(f_vals, fv, fh) shifts_vh[ii+1, :] = self.refine_max_position_2d(f_vals, fv, fh)
if use_adjacent_imgs: if use_adjacent_imgs:
shifts_vh = np.cumsum(shifts_vh, axis=0) shifts_vh = np.cumsum(shifts_vh, axis=0)
img_shifts_vh = np.concatenate(([[0, 0]], shifts_vh), axis=0)
# Polynomial.fit is supposed to be more numerically stable than polyfit # Polynomial.fit is supposed to be more numerically stable than polyfit
# (according to numpy) # (according to numpy)
coeffs_v = Polynomial.fit(img_pos, img_shifts_vh[:, 0], deg=1).convert().coef coeffs_v = Polynomial.fit(img_pos, shifts_vh[:, 0], deg=1).convert().coef
coeffs_h = Polynomial.fit(img_pos, img_shifts_vh[:, 1], deg=1).convert().coef coeffs_h = Polynomial.fit(img_pos, shifts_vh[:, 1], deg=1).convert().coef
if self.verbose: if self.verbose:
f, axs = plt.subplots(1, 2) f, axs = plt.subplots(1, 2)
axs[0].scatter(img_pos, img_shifts_vh[:, 0]) axs[0].scatter(img_pos, shifts_vh[:, 0])
axs[0].plot(img_pos, polyval(img_pos, coeffs_v)) axs[0].plot(img_pos, polyval(img_pos, coeffs_v))
axs[0].set_title("Vertical shifts") axs[0].set_title("Vertical shifts")
axs[1].scatter(img_pos, img_shifts_vh[:, 1]) axs[1].scatter(img_pos, shifts_vh[:, 1])
axs[1].plot(img_pos, polyval(img_pos, coeffs_h)) axs[1].plot(img_pos, polyval(img_pos, coeffs_h))
axs[1].set_title("Horizontal shifts") axs[1].set_title("Horizontal shifts")
plt.show(block=False) plt.show(block=False)
......
...@@ -38,6 +38,7 @@ def bootstrap_dtr(request): ...@@ -38,6 +38,7 @@ def bootstrap_dtr(request):
cls.expected_shifts_vh = np.array((129.93, 353.18)) cls.expected_shifts_vh = np.array((129.93, 353.18))
cls.reference_shifts_list = [ cls.reference_shifts_list = [
[0, 0],
[-9.39, 11.29], [-9.39, 11.29],
[-5.02, 3.81], [-5.02, 3.81],
[-3.67, 9.73], [-3.67, 9.73],
......
Supports Markdown
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