def interpolate_var_to_points(self,
points,
variable,
method='linear',
indices=None,
slices=None,
mask=None,
**kwargs):
points = np.asarray(points, dtype=np.float64)
just_one = (points.ndim == 1)
points = points.reshape(-1, 2)
if slices is not None:
variable = variable[slices]
x = self.node_lon if variable.shape[0] == len(self.node_lon) else self.node_lat
y = self.node_lat if x is self.node_lon else self.node_lon
interp_func = RegularGridInterpolator((x, y), variable, method=method, bounds_error=False, fill_value=0)
if x is self.node_lon:
vals = interp_func(points, method=method)
else:
vals = interp_func(points[:,::-1], method=method)
if just_one:
return vals[0]
else:
return vals
评论列表
文章目录