def _get_neighbours(obs_coords, raw_coords, raw, nnear):
"""
Returns <nnear> neighbour values per <obs_coords> coordinate pair
Parameters
----------
obs_coords : array of float of shape (num_points,ndim)
in the neighbourhood of these coordinate pairs we look for neighbours
raw_coords : array of float of shape (num_points,ndim)
from these coordinate pairs the neighbours are selected
raw : array of float of shape (num_points,...)
this is the data corresponding to the coordinate pairs raw_coords
nnear : integer
number of neighbours to be selected per coordinate pair of obs_coords
"""
# plant a tree
tree = cKDTree(raw_coords)
# retrieve nearest neighbour indices
ix = tree.query(obs_coords, k=nnear)[1]
# return the values of the nearest neighbours
return raw[ix]
评论列表
文章目录