Skip to content

Commit

Permalink
telluricCorrect: use FFT rather than xcorr to determine pixel shift
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-simpson committed Dec 7, 2024
1 parent ed3e235 commit 467b8ad
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions geminidr/core/primitives_telluric.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,14 +395,27 @@ def telluricCorrect(self, adinputs=None, **params):
else:
trans = ext_std.TELLABS

pixel_shift = peak_finding.cross_correlate_subpixels(
ext.data, trans, sampling)
pixel_shift = 0.01 * np.round(pixel_shift * 100)
if pixel_shift is None:
# Old cross-correlation method
#pixel_shift = peak_finding.cross_correlate_subpixels(
# ext.data, trans, sampling)
#pixel_shift = 0.01 * np.round(pixel_shift * 100)

pixels = np.arange(ext.shape[0])
dx_all = np.arange(-10, 10.001, 0.05)
fft_all = np.zeros_like(dx_all)
for i, dx in enumerate(dx_all):
shift_trans = np.interp(pixels + dx, pixels, trans,
left=np.nan, right=np.nan)
fft_all[i] = abs(np.fft.fft(at.divide0(ext.data,
shift_trans))[0])
try:
best = peak_finding.pinpoint_peaks(-fft_all, [fft_all.argmin()])[0]
except IndexError:
log.warning("Cannot determine cross-correlation"
f"peak for {ext.id}")
pixel_shift = None # needs to exist for later
else:
pixel_shift = 0.01 * np.round(np.interp(best, np.arange(fft_all.size), dx_all))
log.stdinfo(f"Shift for extension {ext.id} is "
f"{pixel_shift:.2f} pixels")
pixel_shifts.append(pixel_shift)
Expand Down

0 comments on commit 467b8ad

Please sign in to comment.