From cd48e36318e5f1811d4522566dcde75bf545c1e6 Mon Sep 17 00:00:00 2001 From: Carlo Russo Date: Tue, 18 Jun 2024 11:38:04 +0200 Subject: [PATCH] Added warning on masking when NetCDF fill values are inside the mask map --- src/lisflood/global_modules/add1.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lisflood/global_modules/add1.py b/src/lisflood/global_modules/add1.py index fe9abade..08a7cbbd 100755 --- a/src/lisflood/global_modules/add1.py +++ b/src/lisflood/global_modules/add1.py @@ -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) @@ -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