Skip to content
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

(JP-3138) Add regtest for calwebb_detector1 for undersampling correction #7509

Merged
merged 3 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ calwebb_detector1
- Added the call to the undersampling_correction step to the ``calwebb_detector1``
pipeline. [#7501]

- Added regression test for ``calwebb_detector1`` pipeline which now
includes ``undersampling_correction``. [#7509]


datamodels
----------

Expand Down
52 changes: 52 additions & 0 deletions jwst/regtest/test_niriss_image.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
""" Test for the detector1 pipeline using NIRISS image mode, starting with
an uncal file. The undersampling_correction and ramp fitting output
products are saved for comparisons for those two steps.
"""

import pytest
from astropy.io.fits.diff import FITSDiff

from jwst.stpipe import Step


@pytest.fixture(scope="module")
def run_detector1(rtdata_module):
"""Run calwebb_detector1 pipeline on NIRISS imaging data."""
rtdata = rtdata_module

rtdata.get_data("niriss/jw01094001002_02107_00001_nis_uncal.fits")

# Run detector1 pipeline on an _uncal files
args = ["calwebb_detector1", rtdata.input,
"--steps.undersampling_correction.skip=False",
"--steps.undersampling_correction.save_results=True",
"--steps.ramp_fit.save_results=True",
"--steps.persistence.save_trapsfilled=False",
]

Step.from_cmdline(args)


@pytest.mark.bigdata
@pytest.mark.parametrize("suffix", ["undersampling_correction", "rate", "rateints"])
def test_niriss_image_detector1(run_detector1, rtdata_module, fitsdiff_default_kwargs, suffix):
"""Regression test of detector1 pipeline performed on NIRISS imaging data.
"""
_assert_is_same(rtdata_module, fitsdiff_default_kwargs, suffix)


def _assert_is_same(rtdata_module, fitsdiff_default_kwargs, suffix):
"""Assertion helper for the above tests"""
rtdata = rtdata_module
rtdata.input = "jw01094001002_02107_00001_nis_uncal.fits"
output = f"jw01094001002_02107_00001_nis_{suffix}.fits"
rtdata.output = output

rtdata.get_truth(f"truth/test_niriss_image/{output}")

# Set tolerances so the crf, rscd and rateints file comparisons work across
# architectures
fitsdiff_default_kwargs["rtol"] = 1e-4
fitsdiff_default_kwargs["atol"] = 1e-4
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()