Skip to content

Commit

Permalink
Merge branch 'master' into catch-exceptions-abs-align
Browse files Browse the repository at this point in the history
  • Loading branch information
hbushouse committed May 7, 2024
2 parents 8c392b0 + 4342988 commit 89d8f34
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,6 @@ jobs:
# Until we have arm64 runners, we can't automatically test arm64 wheels
- cp3*-macosx_arm64
sdist: true
test_command: python -c "from jwst.lib import winclip; from jwst.cube_build import cube_match_internal, cube_match_sky_pointcloud, cube_match_sky_driz, blot_median; from jwst.straylight import calc_xart"
secrets:
pypi_token: ${{ secrets.PYPI_PASSWORD_STSCI_MAINTAINER }}
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ resample
- Remove sleep in median combination added in 8305 as it did not address
the issue in operation [#8419]

resample_spec
-------------

- Populate the wavelength array in resampled `Slit` and `MultiSlit` models. [#8374]

residual_fringe
---------------

Expand Down
25 changes: 25 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,26 @@ 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):
names = [s.name for s in dmt.slits]
for name in names:
st_idx = [(s.wcs, s.wavelength) for s in dmt.slits if s.name==name]
w = dmt.slits[st_idx].meta.wcs
x, y = wcstools.grid_from_bounding_box(w.bounding_box, step=(1, 1), center=True)
_, _, wave = w(x, y)
sr_idx = [(s.wcs, s.wavelength) for s in dmr.slits if s.name==name]
wlr = dmr.slits[sr_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))

25 changes: 25 additions & 0 deletions jwst/regtest/test_nirspec_fs_spec3.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from astropy.io.fits.diff import FITSDiff
import pytest
import numpy as np
from gwcs import wcstools

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


@pytest.fixture(scope="module")
Expand Down Expand Up @@ -42,3 +45,25 @@ 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):
names = [s.name for s in dmt.slits]
for name in names:
st_idx = [(s.wcs, s.wavelength) for s in dmt.slits if s.name==name]
w = dmt.slits[st_idx].meta.wcs
x, y = wcstools.grid_from_bounding_box(w.bounding_box, step=(1, 1), center=True)
_, _, wave = w(x, y)
sr_idx = [(s.wcs, s.wavelength) for s in dmr.slits if s.name==name]
wlr = dmr.slits[sr_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))
17 changes: 17 additions & 0 deletions jwst/regtest/test_nirspec_mos_spec3.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
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")
Expand Down Expand Up @@ -36,3 +39,17 @@ 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)
names = [s.name for s in dmt.slits]
for name in names:
st_idx = [(s.wcs, s.wavelength) for s in dmt.slits if s.name==name]
w = dmt.slits[st_idx].meta.wcs
x, y = wcstools.grid_from_bounding_box(w.bounding_box, step=(1, 1), center=True)
_, _, wave = w(x, y)
sr_idx = [(s.wcs, s.wavelength) for s in dmr.slits if s.name==name]
wlr = dmr.slits[sr_idx].wavelength
assert np.all(np.isclose(wave, wlr, atol=1e-03))
12 changes: 12 additions & 0 deletions jwst/resample/resample_spec_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
from . import resample_spec, ResampleStep
from ..exp_to_source import multislit_to_container
from ..assign_wcs.util import update_s_region_spectral
from jwst.lib.wcs_utils import get_wavelengths


# Force use of all DQ flagged data except for DO_NOT_USE and NON_SCIENCE
GOOD_BITS = '~DO_NOT_USE+NON_SCIENCE'
Expand Down Expand Up @@ -109,6 +111,16 @@ def process(self, input):
result.meta.asn.table_name = input_models[0].meta.asn.table_name
result.meta.asn.pool_name = input_models[0].meta.asn.pool_name

# populate the result wavelength attribute for MultiSlitModel
if isinstance(result, MultiSlitModel):
for slit_idx, slit in enumerate(result.slits):
wl_array = get_wavelengths(result.slits[slit_idx])
result.slits[slit_idx].wavelength = wl_array
else:
# populate the result wavelength attribute for SlitModel
wl_array = get_wavelengths(result)
result.wavelength = wl_array

return result

def _process_multislit(self, input_models):
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
define_macros = [("NUMPY", "1")]

setup(
# importing these extension modules is tested in `.github/workflows/build.yml`;
# when adding new modules here, make sure to add them to the `test_command` entry there
ext_modules=[
Extension(
"jwst.lib.winclip",
Expand Down

0 comments on commit 89d8f34

Please sign in to comment.