def fill_missing(mask, x, y, u, v):
"""Fill missing value with by interpolating the values from nearest
neighbours"""
# Construct the interpolators from the boundary values surrounding the
# missing values.
boundaries = find_boundaries(u.mask, mode='outer')
points = np.stack((y[boundaries], x[boundaries])).T
ip_u = NearestNDInterpolator(points, u[boundaries], rescale=False)
ip_v = NearestNDInterpolator(points, v[boundaries], rescale=False)
# Interpolate only missing values.
missing = (y[mask], x[mask])
u[mask] = ip_u(missing)
v[mask] = ip_v(missing)
评论列表
文章目录