Skip to content

Commit

Permalink
JP-3587: Clean up NIRSpec IFU flat field SCI/ERR/DQ flagging (spacete…
Browse files Browse the repository at this point in the history
…lescope#8385)

Co-authored-by: Howard Bushouse <[email protected]>
  • Loading branch information
drlaw1558 and hbushouse authored Apr 19, 2024
1 parent e4ddbcd commit d57f633
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ extract_1d

- Replaced deprecated ``np.trapz`` with ``np.trapezoid()``. [#8415]

flat_field
----------

- Update the flatfield code for NIRSpec IFU data to ensure that SCI=ERR=NaN and
DQ has the DO_NOT_USE flag set outside the footprint of the IFU slices [#8385]

general
-------

Expand Down
11 changes: 9 additions & 2 deletions jwst/flatfield/flat_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -1627,9 +1627,9 @@ def flat_for_nirspec_ifu(output_model, f_flat_model, s_flat_model, d_flat_model,
"""
any_updated = False
exposure_type = output_model.meta.exposure.type
flat = np.ones_like(output_model.data)
flat = np.ones_like(output_model.data) * np.nan
flat_dq = np.zeros_like(output_model.dq)
flat_err = np.zeros_like(output_model.data)
flat_err = np.zeros_like(output_model.data) * np.nan

try:
list_of_wcs = nirspec.nrs_ifu_wcs(output_model)
Expand Down Expand Up @@ -1726,6 +1726,13 @@ def flat_for_nirspec_ifu(output_model, f_flat_model, s_flat_model, d_flat_model,

any_updated = True

# Ensure consistency between NaN-valued pixels and the DO_NOT_USE flag
indx = np.where((flat_dq & dqflags.pixel['DO_NOT_USE']) != 0)
flat[indx] = np.nan
flat_err[indx] = np.nan
indx = np.where(~ np.isfinite(flat))
flat_dq[indx] = flat_dq[indx] | dqflags.pixel['DO_NOT_USE']

# That's all folks
return flat, flat_dq, flat_err, any_updated

Expand Down

0 comments on commit d57f633

Please sign in to comment.