-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added simple outlier detection step. (#689)
- Loading branch information
Showing
15 changed files
with
202 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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 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 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,8 @@ | ||
.. _outlier_detection_step_args: | ||
|
||
Step Arguments | ||
============== | ||
The `outlier_detection` step has the following optional arguments | ||
that control the behavior of the processing: | ||
|
||
TBD |
This file contains 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,20 @@ | ||
Description | ||
=========== | ||
|
||
Algorithm | ||
--------- | ||
|
||
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 | ||
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: | ||
|
||
- TBD | ||
|
||
The outlier detection step serves as a single interface to apply this general | ||
process to any Roman data, with specific variations of this algorithm for each | ||
type of data. Sub-classes of the outlier detection algorithm have been developed | ||
specifically for | ||
|
||
- TBD |
This file contains 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,13 @@ | ||
.. _outlier_detection_step: | ||
|
||
================= | ||
Outlier Detection | ||
================= | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
description.rst | ||
arguments.rst | ||
|
||
.. automodapi:: romancal.outlier_detection |
This file contains 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 |
---|---|---|
|
@@ -15,3 +15,4 @@ | |
refpix/index.rst | ||
source_detection/index.rst | ||
tweakreg/index.rst | ||
outlier_detection/index.rst |
This file contains 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 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 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 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,3 @@ | ||
from .outlier_detection_step import OutlierDetectionStep | ||
|
||
__all__ = ["OutlierDetectionStep"] |
This file contains 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,38 @@ | ||
""" | ||
Detect and flag outlier in a science image | ||
""" | ||
|
||
import roman_datamodels as rdm | ||
|
||
from ..stpipe import RomanStep | ||
|
||
__all__ = ["OutlierDetectionStep"] | ||
|
||
|
||
class OutlierDetectionStep(RomanStep): | ||
"""Detect and flag outliers in a science image.""" | ||
|
||
def process(self, step_input): | ||
|
||
input_model = rdm.open(step_input) | ||
|
||
# No reference files | ||
# reference_file_model = {} | ||
# Do the outlier detection | ||
# output_model = outlier_detection.do_correction( | ||
# input_model, | ||
# reference_file_model, | ||
# ) | ||
|
||
output_model = input_model | ||
|
||
# Close the input and reference files | ||
input_model.close() | ||
|
||
if self.save_results: | ||
try: | ||
self.suffix = "outlier_detection" | ||
except AttributeError: | ||
self["suffix"] = "outlier_detection" | ||
|
||
return output_model |
Empty file.
41 changes: 41 additions & 0 deletions
41
romancal/outlier_detection/tests/test_outlier_detection.py
This file contains 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,41 @@ | ||
import os | ||
|
||
import pytest | ||
from astropy import units as u | ||
from roman_datamodels import maker_utils | ||
from roman_datamodels.datamodels import ImageModel | ||
|
||
from romancal.outlier_detection import OutlierDetectionStep | ||
|
||
|
||
@pytest.mark.skipif( | ||
os.environ.get("CI") == "true", | ||
reason=( | ||
"Roman CRDS servers are not currently available outside the internal network" | ||
), | ||
) | ||
@pytest.mark.parametrize( | ||
"instrument, exptype", | ||
[ | ||
("WFI", "WFI_IMAGE"), | ||
], | ||
) | ||
def test_outlier_detection_step_interface(instrument, exptype): | ||
"""Test that the basic inferface works for data requiring outlier detection""" | ||
|
||
shape = (20, 20) | ||
|
||
wfi_image = maker_utils.mk_level2_image(shape=shape) | ||
wfi_image.meta.instrument.name = instrument | ||
wfi_image.meta.instrument.detector = "WFI01" | ||
wfi_image.meta.instrument.optical_element = "F158" | ||
wfi_image.meta.exposure.type = exptype | ||
wfi_image.data[3:5, 7:10] = 4 * u.electron / u.s | ||
|
||
wfi_image_model = ImageModel(wfi_image) | ||
|
||
result = OutlierDetectionStep.call(wfi_image_model) | ||
|
||
assert (result.data == wfi_image.data).all() | ||
# Uncomment after adding outlier_detection added to RAD & RDM | ||
# assert result.meta.cal_step.outlier_detection == "COMPLETE" |
This file contains 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 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