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

allow ami_analyze step to run on cal files #8451

Merged
merged 2 commits into from
May 7, 2024
Merged
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
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ ami

- Replaced deprecated ``np.mat()`` with ``np.asmatrix()``. [#8415]

- Allow ``ami_analyze`` to run on ``cal`` files. [#8451]

assign_wcs
----------

Expand Down
4 changes: 4 additions & 0 deletions jwst/ami/ami_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import numpy as np
import copy

from jwst.datamodels import CubeModel, ImageModel

from .find_affine2d_parameters import find_rotation
from . import instrument_data
from . import nrm_core
Expand Down Expand Up @@ -73,6 +75,8 @@
# If the input image is 2D, expand all relevant extensions to be 3D
# Incl. those not currently used?
if len(input_model.data.shape) == 2:
if isinstance(input_copy, ImageModel):
input_copy = CubeModel(input_copy)

Check warning on line 79 in jwst/ami/ami_analyze.py

View check run for this annotation

Codecov / codecov/patch

jwst/ami/ami_analyze.py#L78-L79

Added lines #L78 - L79 were not covered by tests
input_copy.data = np.expand_dims(input_copy.data, axis=0)
input_copy.dq = np.expand_dims(input_copy.dq, axis=0)
# input_copy.err = np.expand_dims(input_copy.err, axis=0)
Expand Down
25 changes: 25 additions & 0 deletions jwst/regtest/test_niriss_ami3.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ def run_pipeline(rtdata_module):
return rtdata


@pytest.fixture(scope="module")
def run_step_with_cal(rtdata_module):
rtdata = rtdata_module
# run step?
rtdata.get_data("niriss/ami/jw04478001001_03102_00001_nis_cal.fits")
args = [
'ami_analyze',
rtdata.input,
]
Step.from_cmdline(args)
return rtdata


@pytest.mark.bigdata
@pytest.mark.parametrize("obs, suffix", [("012", "ami-oi"), ("015", "psf-ami-oi")])
def test_niriss_ami3_exp(run_pipeline, obs, suffix, fitsdiff_default_kwargs):
Expand Down Expand Up @@ -45,3 +58,15 @@ def test_niriss_ami3_product(run_pipeline, fitsdiff_default_kwargs):
diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs)
assert diff.identical, diff.report()


@pytest.mark.bigdata
@pytest.mark.parametrize("suffix", ("ami-oi", "amimulti-oi", "amilg"))
def test_niriss_ami3_cal(run_step_with_cal, suffix, fitsdiff_default_kwargs):
rtdata = run_step_with_cal

output = f"jw04478001001_03102_00001_nis_{suffix}.fits"
rtdata.output = output
rtdata.get_truth("truth/test_niriss_ami3/" + output)

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