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-3798: Transfer datamodel wcsinfo during Spec2Pipeline MOS+FS processing #8947

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions changes/8947.pipeline.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Transfer wcsinfo metadata to new MultiSlitModel created during ``calwebb_spec2`` processing of NIRSpec MSA data.
1 change: 1 addition & 0 deletions jwst/pipeline/calwebb_spec2.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,7 @@

# First process MOS slits through all remaining steps
calib_mos.update(calibrated)
calib_mos.meta.wcsinfo = calibrated.meta.wcsinfo.instance

Check warning on line 611 in jwst/pipeline/calwebb_spec2.py

View check run for this annotation

Codecov / codecov/patch

jwst/pipeline/calwebb_spec2.py#L611

Added line #L611 was not covered by tests
if len(calib_mos.slits) > 0:
calib_mos = self.master_background_mos.run(calib_mos)
calib_mos = self.wavecorr.run(calib_mos)
Expand Down
86 changes: 86 additions & 0 deletions jwst/regtest/test_nirspec_mos_movingtarget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import pytest

from astropy.io.fits.diff import FITSDiff

from jwst.stpipe import Step


@pytest.fixture(scope="module")
def run_spec2_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/jw01444003001_01_msa.fits")

# Get the input ASN file and exposures
rtdata.get_data("nirspec/mos/jw01444003001_04102_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.fixture(scope="module")
def run_spec3_pipeline(run_spec2_pipeline, rtdata_module):
"""Run calwebb_spec3 on NIRSpec MOS data."""
rtdata = rtdata_module
rtdata.get_data("nirspec/mos/jw01444-o003_20240815t170722_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", [
"assign_wcs", "msa_flagging", "extract_2d", "srctype",
"master_background_mos", "wavecorr", "flat_field", "pathloss", "barshadow",
"cal", "s2d", "x1d"])
def test_nirspec_mos_mt_spec2(run_spec2_pipeline, fitsdiff_default_kwargs, suffix):
"""Regression test for calwebb_spec2 on a NIRSpec MOS Moving Target exposure."""

# Run the pipeline and retrieve outputs
rtdata = run_spec2_pipeline
output = f"jw01444003001_04102_00001_nrs1_{suffix}.fits"
rtdata.output = output

# Get the truth files
rtdata.get_truth("truth/test_nirspec_mos_movingtarget/" + output)

# Compare the results
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()


@pytest.mark.bigdata
@pytest.mark.parametrize("suffix", ["cal", "crf", "s2d", "x1d"])
@pytest.mark.parametrize("source_id", ["v000000001"])
def test_nirspec_mos_mt_spec3(run_spec3_pipeline, fitsdiff_default_kwargs, suffix, source_id):
"""Regression test for calwebb_spec3 on a NIRSpec MOS Moving Target exposure."""

# Run the pipeline and retrieve outputs
rtdata = run_spec3_pipeline
output = f"jw01444-o003_{source_id}_nirspec_clear-prism_{suffix}.fits"
rtdata.output = output

# Get the truth files
rtdata.get_truth("truth/test_nirspec_mos_movingtarget/" + output)

# Compare the results
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()
Loading