Keck-DataReductionPipelines / KCWI_DRP

KCWI python DRP
BSD 3-Clause "New" or "Revised" License
8 stars 12 forks source link

IDL vs python DRP Wavelength Offset #119

Open prusinski opened 2 years ago

prusinski commented 2 years ago

We've noticed an offset in the wavelength scales when comparing python and IDL reduced cubes for the same object. For data taken with the small slicer and BL grating (0.5 Å dispersion), the two spectra are offset by 0.5 Å (see figure below).

IDL_py_wave_comparison

We compared this with an ESI spectrum of the same object (see second and third figures) and the easy solution is to simply adjust CRVAL3 or CRPIX3 in the header based on the dispersion so that the spectra overlap since the offset is relatively linear across the bandpass.

IDL_py_ESI_wave_comparison

IDL_py_ESI_wave_comparison_large

However, we've noticed this issue with with data taken with the BM grating and medium slicer (1 Å dispersion). In the figure below, py and py2 are two different data reduction iterations with the python DRP and IDL is the spectrum taken from the IDL reduced cube. In this case, the spectra are again offset by the instrument dispersion (1 Å) with the IDL spectrum likely being accurate. The concern is that the python reduced spectra have different lengths and starting positions but the spectra still overlap. As with the above example, the IDL and python reduced spectra have different wavelength array lengths - is it obvious why they would differ so much?

IDL_py_wave_offset

This issue seems to be slightly different than issue #112, but we're curious if this might have something to do with the way python treats bin edges vs. bin centers in arrays. In all of the above plots, we've consistently used the default where='pre' in matplotlib.pyplot.step to avoid an additional offset. Perhaps this might simply be a counting issue (starting on zero vs. one) between IDL and python that wasn't changed over during the port?