diff --git a/adcircpy/forcing/tides/hamtide.py b/adcircpy/forcing/tides/hamtide.py index b4de0191..1b5abea8 100644 --- a/adcircpy/forcing/tides/hamtide.py +++ b/adcircpy/forcing/tides/hamtide.py @@ -113,23 +113,18 @@ def _get_interpolation( dy = (self.y[-1] - self.y[0]) / len(self.y) yidx = np.logical_and(self.y >= np.min(yq) - 2.0 * dy, self.y <= np.max(yq) + 2.0 * dy) xi, yi = np.meshgrid(self.x[xidx], self.y[yidx]) - xi = xi.flatten() - yi = yi.flatten() dataset = self._get_dataset(variable, constituent) - zi = dataset[netcdf_variable][yidx, xidx].flatten() - values = griddata( - (xi[~zi.mask], yi[~zi.mask]), - zi[~zi.mask], - (xq, yq), - method='linear', - fill_value=np.nan, - ) + zi = dataset[netcdf_variable][yidx, xidx] + mask = ~zi.mask + if mask.size == 1: + mask = np.array(zi * mask, dtype=bool) + xi = xi[mask].flatten() + yi = yi[mask].flatten() + zi = zi[mask].flatten() + values = griddata((xi, yi), zi, (xq, yq), method='linear', fill_value=np.nan,) nan_idxs = np.where(np.isnan(values)) values[nan_idxs] = griddata( - (xi[~zi.mask], yi[~zi.mask]), - zi[~zi.mask], - (xq[nan_idxs], yq[nan_idxs]), - method='nearest', + (xi, yi), zi, (xq[nan_idxs], yq[nan_idxs]), method='nearest', ) return values