Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
check mask #145
  • Loading branch information
AntSimi committed Jul 4, 2022
commit 0a00960de9137035ea25dc47e530c29e42086903
18 changes: 9 additions & 9 deletions src/py_eddy_tracker/dataset/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,14 @@ def load(self):

self.setup_coordinates()

@staticmethod
def get_mask(a):
if len(a.mask.shape):
m = a.mask
else:
m = ones(a.shape, dtype='bool') if a.mask else zeros(a.shape, dtype='bool')
return m

@staticmethod
def c_to_bounds(c):
"""
Expand Down Expand Up @@ -1126,7 +1134,7 @@ def _low_filter(self, grid_name, w_cut, factor=8.0):
bins = (x_array, y_array)

x_flat, y_flat, z_flat = x.reshape((-1,)), y.reshape((-1,)), data.reshape((-1,))
m = ~z_flat.mask
m = ~self.get_mask(z_flat)
x_flat, y_flat, z_flat = x_flat[m], y_flat[m], z_flat[m]

nb_value, _, _ = histogram2d(x_flat, y_flat, bins=bins)
Expand Down Expand Up @@ -1936,14 +1944,6 @@ def regrid(self, other, grid_name, new_name=None):
# self.variables_description[new_name]['infos'] = False
# self.variables_description[new_name]['kwargs']['dimensions'] = ...

@staticmethod
def get_mask(a):
if len(a.mask.shape):
m = a.mask
else:
m = ones(a.shape) if a.mask else zeros(a.shape)
return m

def interp(self, grid_name, lons, lats, method="bilinear"):
"""
Compute z over lons, lats
Expand Down