PeriodicKDTree

class sknano.core.analysis.PeriodicKDTree(data, boxsize=None, lattice=None, center=None, leafsize=10, verbose=False)[source] [edit on github][source]

Bases: scipy.spatial.KDTree

kd-tree for quick nearest-neighbor lookup with periodic boundaries

See scipy.spatial.kdtree for details on kd-trees.

Searches with periodic boundaries are implemented by mapping all initial data points to one canonical periodic image, building an ordinary kd-tree with these points, then querying this kd-tree multiple times, if necessary, with all the relevant periodic images of the query point.

Note that to ensure that no two distinct images of the same point appear in the results, it is essential to restrict the maximum distance between a query point and a data point to half the smallest box dimension.

Methods

count_neighbors(other, r[, p]) Count how many nearby pairs can be formed.
innernode(split_dim, split, less, greater)
leafnode(idx)
node
query(x[, k, eps, p, distance_upper_bound]) Query the kd-tree for nearest neighbors
query_ball_point(x, r[, p, eps]) Find all points within distance r of point(s) x.
query_ball_tree(other, r[, p, eps]) Find all pairs of points whose distance is at most r
query_pairs(r[, p, eps]) Find all pairs of points within a distance.
sparse_distance_matrix(other, max_distance) Compute a sparse distance matrix