def maskMeshByDistance(x,y,d,grid):
"""Filters all (x,y) coordinates that are more than d
in meshgrid given some actual coordinates (x,y).
Args:
x (numpy.ndarray): x-coordinates.
y (numpy.ndarray): y-coordinates.
d (float): Maximum distance.
grid (numpy.ndarray): Numpy meshgrid.
Returns:
idxs (list): List of booleans.
"""
#Convert x/y into useful array
xy=np.vstack((x,y))
#Compute distances to nearest neighbors
tree = cKDTree(xy.T)
xi = _ndim_coords_from_arrays(tuple(grid))
dists, indexes = tree.query(xi)
#Get indices of distances that are further apart than d
idxs = (dists > d)
return idxs,
评论列表
文章目录