Commit 0eb2053e authored by thopri's avatar thopri
Browse files

added exception to catch bathymetries with zeros along boundaries as PyNEMO...

added exception to catch bathymetries with zeros along boundaries as PyNEMO mask generator doesn't support
parent a13ea7f5
......@@ -93,10 +93,12 @@ class Mask(object):
self.data = self.bathy_nc.variables['Bathymetry']
except:
self.data = self.bathy_nc.variables['deptho']
if sum(self.data[:, 0]) + sum(self.data[0, :]) + sum(self.data[:, -1]) + sum(self.data[-1, :]) == 0:
raise BaseException('zeros around boundaries of bathymetry is not supported by PyNEMO mask generator')
self.data = np.asarray(self.data[:, :])
self.data = np.around((self.data + .5).clip(0, 1))
#apply default 1px border
self.apply_border_mask(1)
self.apply_border_mask(1)
except KeyError:
self.logger.error('Bathymetry file does not have Bathymetry variable')
raise
......@@ -105,6 +107,7 @@ class Mask(object):
raise
def save_mask(self, mask_file):
"""Reads the mask data from the mask file"""
if mask_file == None:
......
......@@ -694,6 +694,9 @@ def _get_mask(Setup, mask_gui):
mask = Mask_File(Setup.settings['bathy'])
mask.apply_border_mask(Constants.DEFAULT_MASK_PIXELS)
bdy_msk = mask.data
except BaseException:
raise Exception('PyNEMO mask generator does not support zeros along all '
'boundaries please use valid bathymetry or mask file')
except:
return
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment