-
Notifications
You must be signed in to change notification settings - Fork 174
JP-3342: Reorganize outlier detection documentation #8880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0167d72
first draft of reorganized docs
emolter b0dd4f6
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter e165dba
fixes from self-review, split arguments by mode
emolter 8c381fc
caught a few typos
emolter e55b85c
better organize overall flow of docs, remove unnecessary automodapi
emolter 2b0985a
fix build failures from improper indentation
emolter d119598
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter c072611
fix suggested by @jemorrison
emolter 7d8d0e8
changes based on @melanieclarke review
emolter 98f6397
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter aefd262
missed one suggested change
emolter 287cbb5
Merge branch 'main' of https://github.com/spacetelescope/jwst into JP…
emolter 5653c9d
fix second round of comments from Melanie
emolter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
reorganize outlier detection documentation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
6D40
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,42 @@ | ||
Description | ||
=========== | ||
.. _outlier_design: | ||
|
||
:Classes: `jwst.outlier_detection.OutlierDetectionStep` | ||
:Aliases: outlier_detection | ||
Overview | ||
======== | ||
|
||
This module provides the sole interface to all methods of performing outlier | ||
detection on JWST observations. | ||
|
||
Processing multiple datasets together allows for the identification of bad pixels | ||
or cosmic-rays that remain in each of the input images, many times at levels which | ||
melanieclarke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
were not detectable by the :ref:`jump <jump_step>` step. The ``outlier_detection`` step | ||
implements the following algorithm to identify and flag any remaining cosmic-rays or | ||
other artifacts left over from previous calibrations: | ||
|
||
#. build a stack of input data | ||
|
||
- all inputs will need to have the same WCS since outlier detection assumes | ||
the same flux for each point on the sky, and variations from one image to | ||
the next would indicate a problem with the detector during readout of that pixel | ||
- if needed, each input will be resampled to a common output WCS | ||
|
||
#. create a median image from the stack of input data | ||
|
||
- this median operation will ignore any input pixels which have a weight | ||
which is too low (<70% max weight) | ||
|
||
#. create "blotted" data from the median image to exactly match each original | ||
input dataset | ||
|
||
#. perform a statistical comparison (pixel-by-pixel) between the median blotted | ||
data with the original input data to look for pixels with values that are | ||
different from the mean value by more than some specified sigma | ||
based on the noise model | ||
|
||
- the noise model used relies on the error array computed by previous | ||
calibration steps based on the readnoise and calibration errors | ||
|
||
#. flag the DQ array for the input data for any pixel (or affected neighboring | ||
pixels) identified as a statistical outlier | ||
|
||
The outlier detection step serves as a single interface to apply this general | ||
process to any JWST data, with specific variations of this algorithm for each | ||
type of data. Sub-classes of the outlier detection algorithm have been developed | ||
specifically for: | ||
|
||
#. Imaging data | ||
#. IFU spectroscopic data | ||
#. TSO data | ||
#. coronagraphic data | ||
#. spectroscopic data | ||
|
||
This allows the outlier_detection step to be tuned to the variations in each type | ||
of JWST data. | ||
|
||
Reference Files | ||
=============== | ||
|
||
The ``outlier_detection`` step uses the PARS-OUTLIERDETECTIONSTEP parameter reference file. | ||
|
||
.. include:: ../references_general/pars-outlierdetectionstep_reffile.inc | ||
or cosmic rays that remain in each of the input images, often at levels which | ||
were not detectable by the :ref:`jump <jump_step>` step. | ||
The ``outlier_detection`` step supports multiple | ||
algorithms and determines the appropriate algorithm for the type of observation | ||
being processed. This step supports: | ||
|
||
* **Image modes**: 'FGS_IMAGE', 'MIR_IMAGE', 'NRC_IMAGE', 'NIS_IMAGE' | ||
- See :ref:`outlier-detection-imaging` for algorithm details | ||
* **Slit-like Spectroscopic modes**: 'MIR_LRS-FIXEDSLIT', 'NRS_FIXEDSLIT', 'NRS_MSASPEC' | ||
- See :ref:`outlier-detection-spec` for algorithm details | ||
* **Time-Series-Observation (TSO) modes**: 'MIR_LRS-SLITLESS', 'NRC_TSGRISM', 'NIS_SOSS', 'NRS_BRIGHTOBJ', 'NRC_TSIMAGE' | ||
- See :ref:`outlier-detection-tso` for algorithm details | ||
* **IFU Spectroscopic modes**: 'MIR_MRS', 'NRS_IFU' | ||
- See :ref:`outlier-detection-ifu` for algorithm details | ||
* **Coronagraphic Image modes**: 'MIR_LYOT', 'MIR_4QPM', 'NRC_CORON' | ||
- See :ref:`outlier-detection-coron` for algorithm details | ||
|
||
This step uses the following logic to apply the appropriate algorithm to the | ||
input data: | ||
|
||
#. Interpret inputs (Association, ModelContainer, ModelLibrary, or CubeModel) | ||
to identify all input observations to be processed | ||
|
||
#. Read in parameters set by user. See :ref:`outlier_detection_step_args` for the full list | ||
of parameters. | ||
|
||
#. Select outlier detection algorithm based on exposure type in input model ``meta.exposure.type``. | ||
|
||
#. Instantiate and run outlier detection class determined for the exposure type | ||
using parameter values interpreted from inputs. | ||
|
||
#. Update DQ arrays with flags and set SCI, ERR, and variance arrays to NaN at the location | ||
of identified outliers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,30 @@ | ||
.. _outlier-detection-coron: | ||
|
||
Outlier Detection for Coronagraphic Data | ||
======================================== | ||
Coronagraphic Data | ||
================== | ||
|
||
This module serves as the interface for applying ``outlier_detection`` to coronagraphic | ||
image observations. | ||
|
||
Specifically, this routine performs the following operations: | ||
image observations. A :py:class:`~jwst.datamodels.CubeModel` serves as the basic format | ||
for all processing performed by this step. This routine performs the following operations: | ||
|
||
#. Extract parameter settings from input model and merge them with any user-provided values. | ||
See :ref:`outlier detection arguments <outlier_detection_step_args>` for the full list | ||
of parameters. | ||
|
||
#. Convert input data, as needed, to make sure it is in a format that can be processed. | ||
A :py:class:`~jwst.datamodels.CubeModel` serves as the basic format for all processing | ||
performed by this step. | ||
#. Do not attempt resampling; data are assumed to be aligned and have an identical WCS. | ||
This is true automatically for a CubeModel. | ||
|
||
#. Create a median image preserving the spatial dimensions of the cube. | ||
#. Create a median image over the `groups` (exposures, planes of cube) axis, | ||
preserving the spatial (x,y) dimensions of the cube. | ||
melanieclarke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
* The ``maskpt`` parameter sets the percentage of the weight image values to | ||
use, and any pixel with a weight below this value gets flagged as "bad" and | ||
ignored when resampled. | ||
use, and any pixel with a weight below this value gets flagged as "bad". | ||
|
||
#. Perform statistical comparison between median image and original image to identify outliers. | ||
|
||
The core detection algorithm uses the following to generate an outlier mask | ||
|
||
melanieclarke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
.. math:: | image\_input - image\_median | > SNR*input\_err | ||
|
||
#. Update input data model DQ arrays with mask of detected outliers. | ||
|
||
.. automodapi:: jwst.outlier_detection.coron | ||
#. Update DQ arrays with flags and set SCI, ERR, and variance arrays to NaN at the location | ||
of identified outliers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,48 @@ | ||
.. _outlier-detection-ifu: | ||
|
||
Outlier Detection for IFU Data | ||
Integral Field Unit (IFU) Data | ||
============================== | ||
|
||
This module serves as the interface for applying ``outlier_detection`` to IFU | ||
observations, like those taken with NIRSpec and MIRI. The code implements the | ||
basic outlier detection algorithm searching for pixels that are consistent outliers | ||
in the calibrated images created by the :ref:`calwebb_spec2 <calwebb_spec2>` pipeline. | ||
After launch it was discovered the | ||
bad pixels on the MIRI detectors vary with time. The pixels varied from usable to unusable, and at times, | ||
back to usable on a time frame that was too short (sometimes as short as 2 days) to fold into the bad pixel mask applied | ||
in the :ref:`calwebb_detector1 <calwebb_detector1>` pipeline. | ||
At this time it is believed that NIRSpec IFU data also have bad pixels that vary with time, though the time variation is | ||
still under study. | ||
observations, like those taken with NIRSpec and MIRI. A :ref:`Stage 3 association <asn-level3-techspecs>`, | ||
which is loaded into a :py:class:`~jwst.datamodels.ModelContainer` object, | ||
serves as the basic format for all processing performed by this step. | ||
|
||
After launch it was discovered that the bad pixels on the MIRI detectors vary with time. | ||
The pixels varied from usable to unusable, and at times, back to usable on a time frame that was too short | ||
(sometimes as short as 2 days) to fold into the bad pixel mask applied in the | ||
:ref:`calwebb_detector1 <calwebb_detector1>` pipeline. At this time it is believed that NIRSpec IFU data | ||
also have bad pixels that vary with time, though the time variation is still under study. | ||
The outlier detection step is designed to flag these pixels as outliers, in addition | ||
to cosmic ray hits that were not flagged by the jump step. | ||
|
||
The basis of the outlier detection flagging for IFU data is to look for pixels on the detector | ||
that are regularly discrepant from their neighbors, with a sharper division than could be explained | ||
by the detector PSF. The algorithm flags pixels that are outliers when compared to their neighbors for a set of | ||
input files contained in an association. The neighbor pixel differences are the neighbors in the spatial direction. | ||
For MIRI data neighbor differences are found to the left and right of every | ||
science pixel, while for NIRSpec data the neighbor differences are | ||
determined from pixels above and below every science pixel. The difference between the MIRI MRS and NIRPSpec algorithm for finding the | ||
spatial pixel differences is due to the opposite dispersion directions between the two instruments. | ||
The pixel differences for each input model | ||
in the association are determined and stored in a stack of pixel differences. | ||
For each pixel the minimum difference | ||
through this stack is determined and normalized. The normalization uses a local median of the difference array | ||
(set by the kernel size). A pixel is flagged as an outlier if this normalized minimum difference | ||
is greater than the input threshold percentage. Pixels that are found to be outliers are flaged in in the DQ array. | ||
|
||
|
||
|
||
.. automodapi:: jwst.outlier_detection.ifu | ||
by the detector PSF. | ||
This routine performs the following operations: | ||
|
||
#. Extract parameter settings for the input ModelContainer and merge them with any user-provided values. | ||
See :ref:`outlier detection arguments <outlier_detection_step_args>` for the full list of parameters. | ||
|
||
#. Loop over cal files, computing nearest-neighbor differences for each pixel | ||
in the along-dispersion direction. | ||
For MIRI, with the dispersion axis along the y axis, the neighbors that are used to | ||
to find the differences are to the left and right of each pixel being examined. | ||
For NIRSpec, with the dispersion along the x axis, the neighbors that are used to | ||
find the differences are above and below the pixel being examined. | ||
The smaller of the two (left, right or up, down) differences is stored as the difference value for each | ||
pixel. This avoids artifacts from bright edges. | ||
|
||
#. Compare the nearest-neighbor differences across science exposures to find the minimum | ||
neighbor difference at each detector pixel. | ||
|
||
#. Determine a local spatial median of the minimum difference array using a median filter with a kernel size | ||
set by the user according to the ``kernel_size`` parameter. | ||
|
||
#. Normalize the minimum difference array by the local median. | ||
|
||
#. Select outliers by flagging those normalized minimum values larger than the ``threshold_percent`` | ||
parameter. | ||
|
||
#. Update DQ arrays with flags and set SCI, ERR, and variance arrays to NaN at the location | ||
of identified outliers. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.