From f470186cf680faf9e837f55d1b7d948bb595dd68 Mon Sep 17 00:00:00 2001 From: jemorrison Date: Mon, 26 Aug 2024 13:02:03 -0700 Subject: [PATCH 1/7] fixed cube build and added a deprecated warning for mrs_imatch --- jwst/cube_build/ifu_cube.py | 8 ++++++-- jwst/mrs_imatch/mrs_imatch_step.py | 10 ++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/jwst/cube_build/ifu_cube.py b/jwst/cube_build/ifu_cube.py index 0085d30153..3cd627338d 100644 --- a/jwst/cube_build/ifu_cube.py +++ b/jwst/cube_build/ifu_cube.py @@ -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. @@ -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, @@ -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) diff --git a/jwst/mrs_imatch/mrs_imatch_step.py b/jwst/mrs_imatch/mrs_imatch_step.py index 56fc8b2676..dccd6efe3c 100644 --- a/jwst/mrs_imatch/mrs_imatch_step.py +++ b/jwst/mrs_imatch/mrs_imatch_step.py @@ -9,7 +9,7 @@ import numpy as np from jwst.datamodels import ModelContainer - +import warnings from .. stpipe import Step from wiimatch.match import match_lsq from astropy.stats import sigma_clipped_stats as sigclip @@ -29,16 +29,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 + warnings.warn("mrs_imatch deprecated", RuntimeWarning) + chm = {} + all_models2d = ModelContainer(images) for m in all_models2d: ch = m.meta.instrument.channel if ch not in chm: From e97b11b152ece39c3a363562f0ec6d94d75c8e4a Mon Sep 17 00:00:00 2001 From: jemorrison Date: Mon, 26 Aug 2024 13:20:58 -0700 Subject: [PATCH 2/7] updated change log --- CHANGES.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 62082b7580..76e147ae9f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -28,6 +28,7 @@ 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 ------------- @@ -55,6 +56,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 ----------------- From 2e54815a2af6c7a355ed6c60a6b1b1fb8680d72d Mon Sep 17 00:00:00 2001 From: jemorrison Date: Mon, 26 Aug 2024 13:31:44 -0700 Subject: [PATCH 3/7] updated docs to note deprecation and default is to skip --- docs/jwst/mrs_imatch/description.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/jwst/mrs_imatch/description.rst b/docs/jwst/mrs_imatch/description.rst index 6741a00438..33b380da7a 100644 --- a/docs/jwst/mrs_imatch/description.rst +++ b/docs/jwst/mrs_imatch/description.rst @@ -8,6 +8,10 @@ Description Overview -------- + +This step has been deprecated in JWST calibration pipeline version 11.1. +The mrs_imatch step is skipped in the default running of 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 From 7c0dbfb61017679602ac01bcb1993accc417ceca Mon Sep 17 00:00:00 2001 From: jemorrison Date: Wed, 28 Aug 2024 13:19:04 -0700 Subject: [PATCH 4/7] updates from review --- docs/jwst/mrs_imatch/description.rst | 2 +- jwst/mrs_imatch/mrs_imatch_step.py | 4 ++-- jwst/mrs_imatch/tests/test_configuration.py | 15 ++++++++++++++- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/docs/jwst/mrs_imatch/description.rst b/docs/jwst/mrs_imatch/description.rst index 33b380da7a..18c61f5653 100644 --- a/docs/jwst/mrs_imatch/description.rst +++ b/docs/jwst/mrs_imatch/description.rst @@ -10,7 +10,7 @@ Overview -------- This step has been deprecated in JWST calibration pipeline version 11.1. -The mrs_imatch step is skipped in the default running of the calwebb_spec3 pipeline. +The ``mrs_imatch`` step is 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 diff --git a/jwst/mrs_imatch/mrs_imatch_step.py b/jwst/mrs_imatch/mrs_imatch_step.py index dccd6efe3c..40cefc54a3 100644 --- a/jwst/mrs_imatch/mrs_imatch_step.py +++ b/jwst/mrs_imatch/mrs_imatch_step.py @@ -37,8 +37,8 @@ class MRSIMatchStep(Step): def process(self, images): # Provide warning to user this code is deprecated - warnings.warn("mrs_imatch deprecated", RuntimeWarning) - + self.log.warning('mrs_imatch is deprecated') + chm = {} all_models2d = ModelContainer(images) for m in all_models2d: diff --git a/jwst/mrs_imatch/tests/test_configuration.py b/jwst/mrs_imatch/tests/test_configuration.py index 39dbe5cabe..5e6642a36c 100644 --- a/jwst/mrs_imatch/tests/test_configuration.py +++ b/jwst/mrs_imatch/tests/test_configuration.py @@ -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""" From 82911e35940798095443e898c4703c463c714770 Mon Sep 17 00:00:00 2001 From: jemorrison Date: Wed, 28 Aug 2024 13:23:44 -0700 Subject: [PATCH 5/7] fix typo --- CHANGES.rst | 2 +- jwst/mrs_imatch/mrs_imatch_step.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 76e147ae9f..f3e2902767 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -28,7 +28,7 @@ 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] +- Fixed a bug when ``cube_build`` was called from the ``mrs_imatch`` step. [#8728] documentation ------------- diff --git a/jwst/mrs_imatch/mrs_imatch_step.py b/jwst/mrs_imatch/mrs_imatch_step.py index 40cefc54a3..6cf77f03f1 100644 --- a/jwst/mrs_imatch/mrs_imatch_step.py +++ b/jwst/mrs_imatch/mrs_imatch_step.py @@ -38,7 +38,7 @@ def process(self, images): # 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: From cccc198318542db4e6a981199cf677a885078ede Mon Sep 17 00:00:00 2001 From: jemorrison Date: Thu, 29 Aug 2024 09:10:22 -0700 Subject: [PATCH 6/7] remove import --- jwst/mrs_imatch/mrs_imatch_step.py | 1 - 1 file changed, 1 deletion(-) diff --git a/jwst/mrs_imatch/mrs_imatch_step.py b/jwst/mrs_imatch/mrs_imatch_step.py index 6cf77f03f1..543da7b208 100644 --- a/jwst/mrs_imatch/mrs_imatch_step.py +++ b/jwst/mrs_imatch/mrs_imatch_step.py @@ -9,7 +9,6 @@ import numpy as np from jwst.datamodels import ModelContainer -import warnings from .. stpipe import Step from wiimatch.match import match_lsq from astropy.stats import sigma_clipped_stats as sigclip From eb5fc1f66272c6fbe4ab3e3a8e4fb42b041d179b Mon Sep 17 00:00:00 2001 From: jemorrison Date: Fri, 30 Aug 2024 09:11:47 -0700 Subject: [PATCH 7/7] clean up --- CHANGES.rst | 1 + docs/jwst/mrs_imatch/description.rst | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index f3e2902767..590632e7c7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -28,6 +28,7 @@ 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 diff --git a/docs/jwst/mrs_imatch/description.rst b/docs/jwst/mrs_imatch/description.rst index 18c61f5653..4a8a1e37d9 100644 --- a/docs/jwst/mrs_imatch/description.rst +++ b/docs/jwst/mrs_imatch/description.rst @@ -9,8 +9,8 @@ Description Overview -------- -This step has been deprecated in JWST calibration pipeline version 11.1. -The ``mrs_imatch`` step is skipped by default in the calwebb_spec3 pipeline. +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