Skip to content

Commit

Permalink
JP-3649 Fix cube build error when called from mrs_imatch and add depr…
Browse files Browse the repository at this point in the history
…ecated warning for mrs_imatch (#8728)
  • Loading branch information
melanieclarke authored Aug 30, 2024
2 parents 13c47a8 + fb1a6bc commit c2d87f7
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ cube_build

- Removed direct setting of the ``self.skip`` attribute from within the step
itself. [#8600]

- Fixed a bug when ``cube_build`` was called from the ``mrs_imatch`` step. [#8728]

documentation
-------------
Expand Down Expand Up @@ -55,6 +57,11 @@ master_background
- Either of ``"background"`` or ``"bkg"`` in slit name now defines the slit
as a background slit, instead of ``"bkg"`` only. [#8600]

mrs_imatch
----------

- Added a deprecation warning and set the default to skip=True for the step. [#8728]

outlier_detection
-----------------

Expand Down
4 changes: 4 additions & 0 deletions docs/jwst/mrs_imatch/description.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Description

Overview
--------

This step has been deprecated and will be
skipped by default in the calwebb_spec3 pipeline.

The ``mrs_imatch`` step "matches" image intensities of several input
2D MIRI MRS images by fitting polynomials to cube intensities (cubes built
from the input 2D images), in such a way as to minimize - in the least squares
Expand Down
8 changes: 6 additions & 2 deletions jwst/cube_build/ifu_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ def build_ifucube_single(self):

coord1, coord2, corner_coord, wave, dwave, flux, err, slice_no, \
rois_pixel, roiw_pixel, weight_pixel, \
softrad_pixel, scalerad_pixel = pixelresult
softrad_pixel, scalerad_pixel, _, _ = pixelresult

build_cube = True
if wave is None: # there is no valid data on the detector. Pixels are flagged as DO_NOT_USE.
Expand Down Expand Up @@ -870,6 +870,9 @@ def build_ifucube_single(self):
linear = 0
if self.linear_wavelength:
linear = 1
x_det = None
y_det = None
debug_cube = -1
result = cube_wrapper_driz(instrument, flag_dq_plane,
start_region, end_region,
self.overlap_partial, self.overlap_full,
Expand All @@ -878,7 +881,8 @@ def build_ifucube_single(self):
xi1, eta1, xi2, eta2, xi3, eta3, xi4, eta4,
dwave,
self.cdelt3_normal,
self.cdelt1, self.cdelt2, cdelt3_mean, linear)
self.cdelt1, self.cdelt2, cdelt3_mean, linear,
x_det, y_det, debug_cube)

spaxel_flux, spaxel_weight, spaxel_var, spaxel_iflux, _ = result
self.spaxel_flux = self.spaxel_flux + np.asarray(spaxel_flux, np.float64)
Expand Down
9 changes: 5 additions & 4 deletions jwst/mrs_imatch/mrs_imatch_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import numpy as np

from jwst.datamodels import ModelContainer

from .. stpipe import Step
from wiimatch.match import match_lsq
from astropy.stats import sigma_clipped_stats as sigclip
Expand All @@ -29,16 +28,18 @@ class MRSIMatchStep(Step):
# General sky matching parameters:
bkg_degree = integer(min=0, default=1) # Degree of the polynomial for background fitting
subtract = boolean(default=False) # subtract computed sky from 'images' cube data?
skip = boolean(default=True) # Step must be turned on by parameter reference or user
"""

reference_file_types = []

def process(self, images):
all_models2d = ModelContainer(images)

chm = {}
# Provide warning to user this code is deprecated
self.log.warning('mrs_imatch is deprecated')

chm = {}
all_models2d = ModelContainer(images)
for m in all_models2d:
ch = m.meta.instrument.channel
if ch not in chm:
Expand Down
15 changes: 14 additions & 1 deletion jwst/mrs_imatch/tests/test_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,22 @@ def test_imatch_background_subtracted(tmp_cwd, miri_dither_ch12):
# test if background subtracted - raise error
with pytest.raises(ValueError):
step = MRSIMatchStep()
step.run(new_container)
step.call(new_container, skip=False)


def test_imatch_default_run(tmp_cwd, miri_dither_ch12):
""" Test mrs_imatch test is skipped by default """

all_models = ModelContainer(miri_dither_ch12)

# test if default running results in skipping step
step = MRSIMatchStep()
results = step.call(all_models)
n = len(all_models)
for i in range(n):
assert results[i].meta.cal_step.mrs_imatch =='SKIPPED'


def test_imatch_background_reset(tmp_cwd, miri_dither_ch12):
""" Test if background polynomial is already determined - reset it"""

Expand Down

0 comments on commit c2d87f7

Please sign in to comment.