diff --git a/jwst/badpix_selfcal/badpix_selfcal.py b/jwst/badpix_selfcal/badpix_selfcal.py index 2c2b19a857c..1b6b421019c 100644 --- a/jwst/badpix_selfcal/badpix_selfcal.py +++ b/jwst/badpix_selfcal/badpix_selfcal.py @@ -3,6 +3,7 @@ import jwst.datamodels as dm from jwst.outlier_detection.outlier_detection_ifu import medfilt from stdatamodels.jwst.datamodels.dqflags import pixel +import warnings def badpix_selfcal(minimg: np.ndarray, @@ -52,7 +53,9 @@ def badpix_selfcal(minimg: np.ndarray, elif dispaxis == 1: kern_size = (1, kernel_size) - smoothed = medfilt(minimg, kern_size) + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=RuntimeWarning, message="All-NaN") + smoothed = medfilt(minimg, kern_size) minimg_hpf = minimg - smoothed # Flag outliers using percentile cutoff @@ -82,7 +85,7 @@ def apply_flags(input_model: dm.IFUImageModel, flagged_indices: np.ndarray) -> d Flagged data model """ - input_model.dq[flagged_indices] += pixel["DO_NOT_USE"] + pixel["OTHER_BAD_PIXEL"] + input_model.dq[flagged_indices] |= pixel["DO_NOT_USE"] + pixel["OTHER_BAD_PIXEL"] input_model.data[flagged_indices] = np.nan input_model.err[flagged_indices] = np.nan diff --git a/jwst/badpix_selfcal/badpix_selfcal_step.py b/jwst/badpix_selfcal/badpix_selfcal_step.py index bfb6a43aaae..f886b3d4efb 100644 --- a/jwst/badpix_selfcal/badpix_selfcal_step.py +++ b/jwst/badpix_selfcal/badpix_selfcal_step.py @@ -1,5 +1,6 @@ +import warnings from ..stpipe import Step from . import badpix_selfcal import numpy as np @@ -64,7 +65,7 @@ def process(self, input, selfcal_list=None, bkg_list=None): are included in the MIN frame from which outliers are detected. If selfcal_list and/or bkg_list are specified manually, they are appended to any selfcal or background exposures found in the input association file. - If selfcal_list and bkg_list are both set to None and input is + If selfcal_list and bkg_list are both set to None and input is a single science exposure, the step will be skipped with a warning unless the force_single parameter is set True. In that case, the input exposure will be used as the sole background exposure, @@ -96,7 +97,9 @@ def process(self, input, selfcal_list=None, bkg_list=None): selfcal_3d = [] for i, selfcal_model in enumerate(selfcal_list): selfcal_3d.append(selfcal_model.data) - minimg = np.nanmin(np.asarray(selfcal_3d), axis=0) + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", category=RuntimeWarning, message="All-NaN") + minimg = np.nanmin(np.asarray(selfcal_3d), axis=0) bad_indices = badpix_selfcal.badpix_selfcal(minimg, self.flagfrac_lower, self.flagfrac_upper, self.kernel_size, dispaxis) # apply the flags to the science data @@ -155,7 +158,7 @@ def _parse_inputs(input, selfcal_list, bkg_list): if len(sci_models) > 1: raise ValueError("Input data contains multiple science exposures. " - "This is not supported in calwebb_spec2 steps.") + "This is not supported in calwebb_spec2 steps.") input_sci = sci_models[0] elif isinstance(input_data, dm.IFUImageModel) or isinstance(input_data, dm.ImageModel):