diff --git a/CHANGES.rst b/CHANGES.rst index c865170ed8..410de55d71 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -136,14 +136,23 @@ residual_fringe - Fix a bug with 1d residual fringe zeroing out negative fluxes instead of ignoring them. [#8261] +source_catalog +-------------- + +- Suppress warnings from ``photutils.background.Background2D`` regarding + NaNs in the input data. [#8308] + tweakreg -------- - Update ``sregion`` after WCS corrections are applied. [#8158] -- Added option to choose IRAFStarFinder and segmentation.SourceFinder +- Add option to choose IRAFStarFinder and segmentation.SourceFinder instead of DAOStarFinder and exposed star finder parameters. [#8203] +- Suppress warnings from ``photutils.background.Background2D`` regarding + NaNs in the input data. [#8308] + 1.13.4 (2024-01-25) =================== diff --git a/jwst/source_catalog/detection.py b/jwst/source_catalog/detection.py index d4af7d07e6..ff65d6ffbe 100644 --- a/jwst/source_catalog/detection.py +++ b/jwst/source_catalog/detection.py @@ -70,23 +70,26 @@ def _background2d(self): bkg_estimator = MedianBackground() filter_size = (3, 3) - try: - bkg = Background2D(self.data, self.box_size, - filter_size=filter_size, - coverage_mask=self.coverage_mask, - sigma_clip=sigma_clip, - bkg_estimator=bkg_estimator) - except ValueError: - # use the entire unmasked array - bkg = Background2D(self.data, self.data.shape, - filter_size=filter_size, - coverage_mask=self.coverage_mask, - sigma_clip=sigma_clip, - bkg_estimator=bkg_estimator, - exclude_percentile=100.) - log.info('Background could not be estimated in meshes. ' - 'Using the entire unmasked array for background ' - f'estimation: bkg_boxsize={self.data.shape}.') + # All data have NaNs. Suppress warnings about them. + with warnings.catch_warnings(): + warnings.filterwarnings(action="ignore", category=AstropyUserWarning) + try: + bkg = Background2D(self.data, self.box_size, + filter_size=filter_size, + coverage_mask=self.coverage_mask, + sigma_clip=sigma_clip, + bkg_estimator=bkg_estimator) + except ValueError: + # use the entire unmasked array + bkg = Background2D(self.data, self.data.shape, + filter_size=filter_size, + coverage_mask=self.coverage_mask, + sigma_clip=sigma_clip, + bkg_estimator=bkg_estimator, + exclude_percentile=100.) + log.info('Background could not be estimated in meshes. ' + 'Using the entire unmasked array for background ' + f'estimation: bkg_boxsize={self.data.shape}.') return bkg @@ -150,8 +153,9 @@ def convolve_data(data, kernel_fwhm, mask=None): """ kernel = make_kernel(kernel_fwhm) + # All data have NaNs. Supress warnings about them. with warnings.catch_warnings(): - warnings.simplefilter('ignore', AstropyUserWarning) + warnings.filterwarnings(action="ignore", category=AstropyUserWarning) return convolve(data, kernel, mask=mask, normalize_kernel=True) diff --git a/jwst/tweakreg/tweakreg_catalog.py b/jwst/tweakreg/tweakreg_catalog.py index 7b7a6543b2..830fafac7b 100644 --- a/jwst/tweakreg/tweakreg_catalog.py +++ b/jwst/tweakreg/tweakreg_catalog.py @@ -200,7 +200,7 @@ def make_tweakreg_catalog(model, snr_threshold, bkg_boxsize=400, starfinder='dao else: raise ValueError(f"Unknown starfinder type: {starfinder}") - # Mask the non-imaging area (e.g. MIRI) + # Mask the non-imaging area, e.g. reference pixels and MIRI non-science area coverage_mask = ((dqflags.pixel['NON_SCIENCE'] + dqflags.pixel['DO_NOT_USE']) & model.dq).astype(bool)