forked from spacetelescope/jwst
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JP-3547: Flux conservation for spectral resampling (spacetelescope#8596)
Co-authored-by: Ned Molter <[email protected]> Co-authored-by: Tyler Pauly <[email protected]>
- Loading branch information
1 parent
859ac8e
commit 7d97170
Showing
14 changed files
with
1,227 additions
and
558 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
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
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.. resample_: | ||
Python Interface to Drizzle: ResampleData() | ||
=========================================== | ||
Python Interface to Drizzle: ResampleData() and ResampleSpecData() | ||
================================================================== | ||
|
||
.. automodapi:: jwst.resample.resample | ||
.. automodapi:: jwst.resample.resample_spec |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
.. resample_step_: | ||
Python Step Interface: ResampleStep() | ||
===================================== | ||
Python Step Interface: ResampleStep() and ResampleSpecStep() | ||
============================================================ | ||
|
||
.. automodapi:: jwst.resample.resample_step | ||
.. automodapi:: jwst.resample.resample_spec_step |
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
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
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,57 @@ | ||
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") | ||
def run_pipeline(rtdata_module): | ||
""" | ||
Run the calwebb_spec3 pipeline on a NIRSpec FS moving target. | ||
""" | ||
rtdata = rtdata_module | ||
|
||
# Get the ASN file and input exposures | ||
rtdata.get_asn('nirspec/fs/jw01245-o002_20240701t053319_spec3_00001_asn.json') | ||
|
||
# Run the calwebb_spec3 pipeline; save results from intermediate steps | ||
args = ["calwebb_spec3", rtdata.input, | ||
"--steps.outlier_detection.save_results=true", | ||
"--steps.resample_spec.save_results=true", | ||
"--steps.extract_1d.save_results=true"] | ||
Step.from_cmdline(args) | ||
|
||
|
||
@pytest.mark.bigdata | ||
@pytest.mark.parametrize("suffix", ["cal", "crf", "s2d", "x1d"]) | ||
def test_nirspec_fs_spec3_moving_target( | ||
run_pipeline, rtdata_module, fitsdiff_default_kwargs, suffix): | ||
"""Test spec3 pipeline on a NIRSpec FS moving target.""" | ||
rtdata = rtdata_module | ||
|
||
output = f"jw01245-o002_s000000001_nirspec_clear-prism-s200a1-subs200a1_{suffix}.fits" | ||
rtdata.output = output | ||
rtdata.get_truth(f"truth/test_nirspec_fs_spec3_moving_target/{output}") | ||
|
||
# Adjust tolerance for machine precision with float32 drizzle code | ||
if suffix == "s2d": | ||
fitsdiff_default_kwargs["rtol"] = 1e-2 | ||
fitsdiff_default_kwargs["atol"] = 2e-4 | ||
|
||
# Compare the results | ||
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs) | ||
assert diff.identical, diff.report() | ||
|
||
# Check output wavelength array against its own wcs | ||
if suffix == "s2d": | ||
tolerance = 1e-03 | ||
dmr = datamodels.open(rtdata.output) | ||
|
||
w = dmr.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)) |
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
Oops, something went wrong.