-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regression tests for MOS/FS spec2 and spec3
- Loading branch information
1 parent
10febe6
commit d06baa7
Showing
2 changed files
with
97 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import pytest | ||
|
||
from astropy.io.fits.diff import FITSDiff | ||
|
||
from jwst.stpipe import Step | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def run_pipeline(rtdata_module): | ||
"""Run the calwebb_spec2 pipeline on a single NIRSpec MOS/FS exposure.""" | ||
|
||
rtdata = rtdata_module | ||
|
||
# Get the MSA metadata file referenced in the input exposure | ||
rtdata.get_data("nirspec/mos/jw02674004001_01_msa.fits") | ||
|
||
# Get the input ASN file and exposures | ||
rtdata.get_data("nirspec/mos/jw02674004001_03101_00001_nrs1_rate.fits") | ||
|
||
# Run the calwebb_spec2 pipeline; save results from intermediate steps | ||
args = ["calwebb_spec2", rtdata.input, | ||
"--steps.assign_wcs.save_results=true", | ||
"--steps.msa_flagging.save_results=true", | ||
"--steps.master_background_mos.save_results=true", | ||
"--steps.extract_2d.save_results=true", | ||
"--steps.srctype.save_results=true", | ||
"--steps.wavecorr.save_results=true", | ||
"--steps.flat_field.save_results=true", | ||
"--steps.pathloss.save_results=true", | ||
"--steps.barshadow.save_results=true"] | ||
Step.from_cmdline(args) | ||
|
||
return rtdata | ||
|
||
|
||
@pytest.mark.bigdata | ||
@pytest.mark.parametrize("suffix", [ | ||
"assign_wcs", "msa_flagging", "extract_2d", "srctype", | ||
"master_background_mos", "wavecorr", "flat_field", "pathloss", "barshadow", | ||
"wavecorr_fs", "flat_field_fs", "pathloss_fs", "barshadow_fs", | ||
"cal", "s2d", "x1d"]) | ||
def test_nirspec_mos_fs_spec2(run_pipeline, fitsdiff_default_kwargs, suffix): | ||
"""Regression test for calwebb_spec2 on a NIRSpec MOS/FS exposure.""" | ||
|
||
# Run the pipeline and retrieve outputs | ||
rtdata = run_pipeline | ||
output = f"jw02674004001_03101_00001_nrs1_{suffix}.fits" | ||
rtdata.output = output | ||
|
||
# Get the truth files | ||
rtdata.get_truth("truth/test_nirspec_mos_fs_spec2/" + output) | ||
|
||
# Compare the results | ||
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs) | ||
assert diff.identical, diff.report() |
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,42 @@ | ||
import pytest | ||
from astropy.io.fits.diff import FITSDiff | ||
import numpy as np | ||
from gwcs import wcstools | ||
|
||
from jwst.stpipe import Step | ||
from stdatamodels.jwst import datamodels | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def run_pipeline(rtdata_module): | ||
"""Run calwebb_spec3 on NIRSpec MOS data.""" | ||
rtdata = rtdata_module | ||
rtdata.get_asn("nirspec/mos/jw02674-o004_20240305t054741_spec3_00001_asn.json") | ||
|
||
# Run the calwebb_spec3 pipeline on the association | ||
args = ["calwebb_spec3", rtdata.input] | ||
Step.from_cmdline(args) | ||
|
||
return rtdata | ||
|
||
|
||
@pytest.mark.bigdata | ||
@pytest.mark.parametrize("suffix", ["cal", "crf", "s2d", "x1d"]) | ||
@pytest.mark.parametrize("source_id", ["s01354", "s12105", "s34946", | ||
"s34949", "s34950", "s34951", "s34952", | ||
"s34953", "s34954", "s34955"]) | ||
def test_nirspec_mos_fs_spec3(run_pipeline, suffix, source_id, fitsdiff_default_kwargs): | ||
"""Check results of calwebb_spec3""" | ||
rtdata = run_pipeline | ||
|
||
output = f"jw02674-o004_{source_id}_nirspec_f290lp-g395m_{suffix}.fits" | ||
rtdata.output = output | ||
rtdata.get_truth(f"truth/test_nirspec_mos_fs_spec3/{output}") | ||
|
||
# Adjust tolerance for machine precision with float32 drizzle code | ||
if suffix == "s2d": | ||
fitsdiff_default_kwargs["rtol"] = 1e-4 | ||
fitsdiff_default_kwargs["atol"] = 1e-5 | ||
|
||
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs) | ||
assert diff.identical, diff.report() |