Skip to content

Commit

Permalink
Added warning on masking when NetCDF fill values are inside the mask map
Browse files Browse the repository at this point in the history
  • Loading branch information
doc78 committed Jun 18, 2024
1 parent ff47d43 commit cd48e36
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/lisflood/global_modules/add1.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ def compressArray(map, pcr=True, name=None):
mapnp = pcr2numpy(map,np.nan)
mapnp1 = np.ma.masked_array(mapnp, maskinfo.info.mask)
else:
if map.mask is not np.bool_(0):
if (map.mask[maskinfo.info.mask==False].any()==True):
# warning: fill values masking is different from the area mask map, and some values in the area mask map contains invalid fill values
warnings.warn(LisfloodWarning("Warning in compress array: map '{}' has fill values inside the area mask map!".format(name)))
mapnp1 = np.ma.masked_array(map, maskinfo.info.mask)
mapC = np.ma.compressed(mapnp1)

Expand Down Expand Up @@ -489,6 +493,10 @@ def loadmap_base(name, pcr=False, lddflag=False, timestampflag='exact', averagey
# masking
try:
maskinfo = MaskInfo.instance()
if mapnp.mask is not np.bool_(0):
if (mapnp.mask[maskinfo.info.mask==False].any()==True):
## warning: fill values masking is different from the area mask map, and some values in the area mask map contains invalid fill values
warnings.warn(LisfloodWarning("Warning: map {} (binding: '{}') has fill values inside the area mask map!".format(filename, name)))
mapnp.mask = maskinfo.info.mask
except (KeyError, AttributeError):
pass
Expand Down

0 comments on commit cd48e36

Please sign in to comment.