From 3ed5820d3dcae626821efba425820e2c8b32902d Mon Sep 17 00:00:00 2001 From: Ricky O'Steen Date: Tue, 3 Dec 2024 10:04:46 -0500 Subject: [PATCH] Handle mask cubes that have NaNs instead of 0s --- .../plugins/spectral_extraction/spectral_extraction.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py index d2a8126257..81ca2a6e9f 100644 --- a/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py +++ b/jdaviz/configs/cubeviz/plugins/spectral_extraction/spectral_extraction.py @@ -499,7 +499,10 @@ def _extract_from_aperture(self, cube, uncert_cube, mask_cube, aperture, # Also apply the cube's original mask array if mask_cube: - mask = np.logical_or(mask, mask_cube.get_component('flux').data.astype('bool')) + mask_from_cube = mask_cube.get_component('flux').data + # Some mask cubes have NaNs where they are not masked instead of 0 + mask_from_cube[np.where(np.isnan(mask_from_cube))] = 0 + mask = np.logical_or(mask, mask_from_cube.astype('bool')) nddata_reshaped = NDDataArray( flux, mask=mask, uncertainty=uncertainties, wcs=wcs, meta=nddata.meta