Skip to content

Commit

Permalink
JP-1694: fix outlier detection (#5601)
Browse files Browse the repository at this point in the history
* testing

* add background to blot image to correctly set up noise image

* Added DO_NOT_USE to NON_SCIENCE pixels after flat fielding

* update change log

* update from review

* Update CHANGES.rst
  • Loading branch information
jemorrison authored Jan 14, 2021
1 parent 4fd2126 commit a54efd3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ datamodels

- Updated schemas for new keywords CROWDFLD, PRIDTYPE, PRIDTPTS, PATTNPTS, SMGRDPAT,
changed name of SUBPXPNS to SUBPXPTS, and new allowed values for PATTTYPE. [#5618]

flat_field
----------

- Added DO_NOT_USE to pixels flagged as NON_SCIENCE for non-nirspec data [#5601]

outlier_detection
-----------------

- Account for the background subtracted data in the blot image for determining the noise image used in flagging outliers [#5601]

set_telescope_pointing
----------------------
Expand Down
5 changes: 5 additions & 0 deletions jwst/flatfield/flat_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,11 @@ def apply_flat_field(science, flat, inverse=False):
# Combine the science and flat DQ arrays
science.dq = np.bitwise_or(science.dq, flat_dq)

# Find all pixels in the flat that have a DQ value of NON_SCIENCE
# add the DO_NOT_USE flag to these pixels. We don't want to use these pixels
# in futher steps
flag_nonsci = np.bitwise_and(science.dq, dqflags.pixel['NON_SCIENCE']).astype(np.bool)
science.dq[flag_nonsci] = np.bitwise_or(science.dq[flag_nonsci], dqflags.pixel['DO_NOT_USE'])

#
# The following functions are for NIRSpec spectrographic data.
Expand Down
4 changes: 2 additions & 2 deletions jwst/outlier_detection/outlier_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def flag_cr(sci_image, blot_image, **pars):
exptime = sci_image.meta.exposure.exposure_time

sci_data = sci_image.data * exptime
blot_data = blot_image.data * exptime
blot_data = (blot_image.data + subtracted_background) * exptime
blot_deriv = abs_deriv(blot_data)

err_data = np.nan_to_num(sci_image.err)
Expand All @@ -421,7 +421,7 @@ def flag_cr(sci_image, blot_image, **pars):
#
# Model the noise and create a CR mask
diff_noise = np.abs(sci_data - blot_data)
ta = np.sqrt(np.abs(blot_data + subtracted_background) + err_data ** 2)
ta = np.sqrt(np.abs(blot_data) + err_data ** 2)
t2 = scl1 * blot_deriv + snr1 * ta
tmp1 = np.logical_not(np.greater(diff_noise, t2))

Expand Down

0 comments on commit a54efd3

Please sign in to comment.