Keck-DataReductionPipelines / KCWI_DRP

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

Inconsistent flag values after DAR #132

Open yuguangchen1 opened 2 years ago

yuguangchen1 commented 2 years ago

Hi!

This is partly related to #98, but since it is important for post DRP data processing, I figured that it might be worthwhile to start a separate issue.

The problem is that when performing the DAR correction, Line 222-228 in CorrectDar.py uses the shift() function from Scipy, which conducts 3rd-order spline to interpolate subpixel values for all cubes, including the flag cube. This causes the following problem:

  1. The 8-bit values in the flag cubes no longer work, since they are spline-interpolated and is wavelength-dependent.
  2. The padded flag cube has a rippling effect near the boundary of the actual FoV, and a bug of flag=0 near the edges of the FITS cube.
  3. Since the intensity cube is now spline-interpolated, the 0-valued pixels after the interpolation are no longer exactly 0, but some random number very close to 0. This is problematic since flag =32 (low signal flat) and 64 (outside slice illuminated area) doesn't seem to have been implemented in the flag cube. And it is impossible to determine the good and bad pixels, when trying to combine multiple exposures together.

I think keeping the 3rd-order spline for the intensity and the error cubes are fine, especially since it gives a consistent covarience between adjuncent pixels, which is an improvement to the IDL pipeline. So it is only the flag extension that need to be fixed.

Thanks!