Skip to content

Commit

Permalink
added reg tests
Browse files Browse the repository at this point in the history
  • Loading branch information
penaguerrero committed Apr 18, 2024
1 parent 4cefa5b commit 1e3a6dd
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
22 changes: 22 additions & 0 deletions jwst/regtest/test_miri_lrs_slit_spec3.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
""" Test of the spec3 pipeline using MIRI LRS fixed-slit exposures.
This takes an association and generates the level 3 products."""
import pytest
import numpy as np
from gwcs import wcstools

import asdf
from astropy.io.fits.diff import FITSDiff
Expand Down Expand Up @@ -76,3 +78,23 @@ def test_miri_lrs_slit_spec3(run_pipeline, rtdata_module, fitsdiff_default_kwarg
# Compare the results
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()

if "s2d" in output:
# Compare the calculated wavelengths
tolerance = 1e-03
dmt = datamodels.open(rtdata.truth)
dmr = datamodels.open(rtdata.output)
if isinstance(dmt, datamodels.MultiSlitModel):
for slit_idx, slit in enumerate(dmt.slits):
w = slit.meta.wcs
x, y = wcstools.grid_from_bounding_box(w.bounding_box, step=(1, 1), center=True)
_, _, wave = w(x, y)
wlr = dmr.slits[slit_idx].wavelength
assert np.all(np.isclose(wave, wlr, atol=tolerance))
else:
w = dmt.meta.wcs
x, y = wcstools.grid_from_bounding_box(w.bounding_box, step=(1, 1), center=True)
_, _, wave = w(x, y)
wlr = dmr.wavelength
assert np.all(np.isclose(wave, wlr, atol=tolerance))

19 changes: 19 additions & 0 deletions jwst/regtest/test_nirspec_fs_spec3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import pytest

from jwst.stpipe import Step
from stdatamodels.jwst import datamodels


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -42,3 +43,21 @@ def test_nirspec_fs_spec3(run_pipeline, rtdata_module, fitsdiff_default_kwargs,
# Compare the results
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()

if "s2d" in output:
# Compare the calculated wavelengths
tolerance = 1e-03
dmt = datamodels.open(rtdata.truth)
dmr = datamodels.open(rtdata.output)
if isinstance(dmt, datamodels.MultiSlitModel):
w = slit.meta.wcs
x, y = wcstools.grid_from_bounding_box(w.bounding_box, step=(1, 1), center=True)
_, _, wave = w(x, y)
wlr = dmr.slits[slit_idx].wavelength
assert np.all(np.isclose(wave, wlr, atol=tolerance))
else:
w = dmt.meta.wcs
x, y = wcstools.grid_from_bounding_box(w.bounding_box, step=(1, 1), center=True)
_, _, wave = w(x, y)
wlr = dmr.wavelength
assert np.all(np.isclose(wave, wlr, atol=tolerance))
12 changes: 12 additions & 0 deletions jwst/regtest/test_nirspec_mos_spec3.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from astropy.io.fits.diff import FITSDiff

from jwst.stpipe import Step
from stdatamodels.jwst import datamodels


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -36,3 +37,14 @@ def test_nirspec_mos_spec3(run_pipeline, suffix, source_id, fitsdiff_default_kwa

diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()

if "s2d" in output:
# Compare the calculated wavelengths
dmt = datamodels.open(rtdata.truth)
dmr = datamodels.open(rtdata.output)
for slit_idx, slit in enumerate(dmt.slits):
w = slit.meta.wcs
x, y = wcstools.grid_from_bounding_box(w.bounding_box, step=(1, 1), center=True)
_, _, wave = w(x, y)
wlr = dmr.slits[slit_idx].wavelength
assert np.all(np.isclose(wave, wlr, atol=1e-03))

0 comments on commit 1e3a6dd

Please sign in to comment.