Skip to content

Commit

Permalink
Fix ROMS masking iteratively destroying itself
Browse files Browse the repository at this point in the history
  • Loading branch information
mpiannucci committed Feb 8, 2024
1 parent b6b2243 commit 37e474a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions xpublish_wms/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def mask(
if "time" in mask.cf.coords:
mask = mask.cf.isel(time=0).squeeze(drop=True).cf.drop_vars("time")
else:
mask = mask.cf.squeeze(drop=True)
mask = mask.cf.squeeze(drop=True).copy(deep=True)

mask[:-1, :] = mask[:-1, :].where(mask[1:, :] == 1, 0)
mask[:, :-1] = mask[:, :-1].where(mask[:, 1:] == 1, 0)
Expand Down Expand Up @@ -409,7 +409,11 @@ def sel_lat_lng(
if "time" in mask.cf.coords:
mask = mask.cf.isel(time=0).squeeze(drop=True).cf.drop_vars("time")
else:
mask = mask.cf.squeeze(drop=True)
# We apparently need to deep copy because for some reason
# if we dont this function will overwrite the mask in the dataset
# I'm guessing that squeeze is a no-op if there are no length 1
# dimensions
mask = mask.cf.squeeze(drop=True).copy(deep=True)

subset[parameter] = subset[parameter].where(mask == 1)

Expand Down

0 comments on commit 37e474a

Please sign in to comment.