Skip to content

Commit

Permalink
workaround missing mask problem
Browse files Browse the repository at this point in the history
  • Loading branch information
keflavich committed Jan 22, 2025
1 parent 14fa698 commit b242b85
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions spectral_cube/cube_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,13 @@ def update(self, n=1):
dx = outwcs.spectral.proj_plane_pixel_scales()[0]
log_(f"Channel mode: dx={dx}. Looping over {len(channels)} channels and {len(cubes)} cubes")

# workaround: some cubes exist with no mask, which breaks downstream when 'None' is passed into
# subcube_slices_from_mask. In theory, this operation is lazy and therefore cheap
for cube in cubes:
if cube.mask is None:
# cube == cube is a lazy shorthand for 'isfinite'
cube = cube.with_mask(cube == cube)

mincube_slices = [cube[cube.shape[0]//2:cube.shape[0]//2+1]
.subcube_slices_from_mask(cube[cube.shape[0]//2:cube.shape[0]//2+1].mask,
spatial_only=True)
Expand Down

0 comments on commit b242b85

Please sign in to comment.