Skip to content

Commit

Permalink
Handle mask cubes that have NaNs instead of 0s
Browse files Browse the repository at this point in the history
  • Loading branch information
rosteen committed Dec 3, 2024
1 parent b97ea9f commit 3ed5820
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3ed5820

Please sign in to comment.