pyfrp_idx_module.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:PyFRAP 作者: alexblaessle 项目源码 文件源码
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,
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号