kdcount.cluster module

Clustering with KDTree

This module implements Friend-of-Friend clustering with a KDtree as fof.

The Friend-of-Friend clustering algorithm is implemented (Davis et al. 1985 ADSlink:) The algorithm is commonly used in astronomy and cosmology: all points that are within a given ‘linking_length’ are clustered into one object.

class kdcount.cluster.fof(data, linking_length, np=None)[source]

Bases: object

Friend of Friend clustering

Attributes

data (kdcount.models.dataset) data set (positions of particles complied into a KD-Tree
linking_length (float) linking length, in data units
np (int) parallel processes to use (0 to disable)
verbose (boolean) print some verbose information
N (int) number of clusters identified
labels (array_like) the label (cluster id) of each object
length (array_like) number of particles per cluster
offset (array_like) offset of the first particle in indices
indices (array_like) index of particles indices[offset[i]:length[i]] is the indices of particles in cluster i.
center(weights=None)[source]

return the center of each object

find(groupid)[source]

return all of the indices of particles of groupid

sum(weights=None)[source]

return the sum of weights of each object