diff --git a/CHANGES.rst b/CHANGES.rst index b01fcdd219..f79479d062 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -39,6 +39,9 @@ extract_1d - Fixed a bug in the calling of optional MIRI MRS 1d residual fringe correction that could cause defringing to fail in some cases. [#8180] + +- Added a hook to bypass the ``extract_1d`` step for NIRISS SOSS data in + the FULL subarray with warning. [#8225] outlier_detection ----------------- @@ -59,6 +62,10 @@ photom the pipeline put the (variable, calculated per pixel) dispersion back in. Assumes that the dispersion needs to be in Angstroms/pixel to match the required factor of ~10. [#8207] +- Added a hook to bypass the ``photom`` step when the ``extract_1d`` step + was bypassed and came before the ``photom`` step, e.g. for NIRISS SOSS + data in the FULL subarray. [#8225] + refpix ------ diff --git a/docs/jwst/references_general/drizpars_reffile.inc b/docs/jwst/references_general/drizpars_reffile.inc index bbe3c8e771..faeb08009f 100644 --- a/docs/jwst/references_general/drizpars_reffile.inc +++ b/docs/jwst/references_general/drizpars_reffile.inc @@ -46,6 +46,6 @@ filter integer The filter used to obtain the images pixfrac float The pixel "shrinkage" fraction kernel string The kernel function used to distribute flux fillval float Value assigned to pixels with no input flux -wht_type sting The input image weighting type +wht_type string The input image weighting type stepsize integer Output WCS grid interpolation step size =========== ======= =========================================== diff --git a/jwst/extract_1d/extract_1d_step.py b/jwst/extract_1d/extract_1d_step.py index 36a06c9ae2..44c8f71ca2 100644 --- a/jwst/extract_1d/extract_1d_step.py +++ b/jwst/extract_1d/extract_1d_step.py @@ -412,19 +412,16 @@ def process(self, input): self.log.info('Exposure is in the SUBSTRIP256 subarray.') self.log.info('Traces 1 and 2 will be modelled and decontaminated before extraction.') subarray = 'SUBSTRIP256' - elif input_model.meta.subarray.name == 'FULL': - self.log.info('Exposure is in the FULL subarray.') - self.log.info('Traces 1 and 2 will be modelled and decontaminated before extraction.') - subarray = 'FULL' elif input_model.meta.subarray.name == 'SUBSTRIP96': self.log.info('Exposure is in the SUBSTRIP96 subarray.') self.log.info('Traces of orders 1 and 2 will be modelled but only order 1' ' will be decontaminated before extraction.') subarray = 'SUBSTRIP96' else: - self.log.error('The SOSS extraction is implemented for the SUBSTRIP256,' - ' SUBSTRIP96 and FULL subarray only.') - self.log.error('extract_1d will be skipped.') + self.log.error('The SOSS extraction is implemented for the SUBSTRIP256' + 'and SUBSTRIP96 subarrays only. Subarray is currently ' + f'{input_model.meta.subarray.name}.') + self.log.error('Extract1dStep will be skipped.') input_model.meta.cal_step.extract_1d = 'SKIPPED' return input_model diff --git a/jwst/extract_1d/tests/test_expected_skips.py b/jwst/extract_1d/tests/test_expected_skips.py new file mode 100644 index 0000000000..86910c037e --- /dev/null +++ b/jwst/extract_1d/tests/test_expected_skips.py @@ -0,0 +1,31 @@ +import stdatamodels.jwst.datamodels as dm +from jwst.extract_1d import Extract1dStep +from jwst.photom import PhotomStep +import pytest +import numpy as np + + +@pytest.fixture(scope='module') +def mock_niriss_full(): + model = dm.CubeModel((3, 3, 3)) + model.meta.instrument.name = 'NIRISS' + model.meta.instrument.detector = 'NIS' + model.meta.observation.date = '2023-07-22' + model.meta.observation.time = '06:24:45.569' + model.meta.instrument.name = 'NIRISS' + model.meta.instrument.detector = 'NIS' + model.meta.instrument.filter = 'CLEAR' + model.meta.exposure.type = 'NIS_SOSS' + model.meta.subarray.name = 'FULL' + model.data = np.arange(27).reshape((3, 3, 3)) + return model + + +def test_expected_skip_niriss_soss_full(mock_niriss_full): + + with mock_niriss_full as model: + result = Extract1dStep().process(model) + result2 = PhotomStep().process(result) + assert result2.meta.cal_step.photom == 'SKIPPED' + assert result2.meta.cal_step.extract_1d == 'SKIPPED' + assert np.all(result2.data == model.data) diff --git a/jwst/photom/photom.py b/jwst/photom/photom.py index 6e60a43d5c..78dbbed131 100644 --- a/jwst/photom/photom.py +++ b/jwst/photom/photom.py @@ -33,6 +33,14 @@ def __init__(self, message): super().__init__(message) +class DataModelTypeError(Exception): + + def __init__(self, message): + if message is None: + message = "Unexpected DataModel type." + super().__init__(message) + + def find_row(fits_table, match_fields): """ Find a row in a FITS table matching fields. @@ -413,6 +421,9 @@ def calc_niriss(self, ftab): continue self.photom_io(ftab.phot_table[row]) + elif isinstance(self.input, datamodels.CubeModel): + raise DataModelTypeError(f"Unexpected input data model type for NIRISS: {self.input.__class__.__name__}") + elif self.exptype in ['NIS_SOSS']: for spec in self.input.spec: self.specnum += 1 @@ -481,13 +492,13 @@ def calc_miri(self, ftab): photom_corr = miri_imager.time_corr_photom(ftab.timecoeff[row], mid_time) data = np.array( - [(self.filter, self.subarray, ftab.phot_table[row]['photmjsr']+photom_corr, ftab.phot_table[row]['uncertainty'])], + [(self.filter, self.subarray, ftab.phot_table[row]['photmjsr'] + photom_corr, ftab.phot_table[row]['uncertainty'])], dtype=[ ("filter", "O"), ("subarray", "O"), ("photmjsr", "