structuretoolkit.analyse.spatial.get_cluster_positions

structuretoolkit.analyse.spatial.get_cluster_positions#

structuretoolkit.analyse.spatial.get_cluster_positions(structure: Atoms, positions: ndarray | None = None, eps: float = 1.0, buffer_width: float | None = None, return_labels: bool = False) ndarray | tuple[ndarray, ndarray][source]#

Cluster positions according to the distances. Clustering algorithm uses DBSCAN:

https://scikit-learn.org/stable/modules/generated/sklearn.cluster.DBSCAN.html

Example I:

` analyse = Analyze(some_ase_structure) positions = analyse.cluster_points(eps=2) `

This example should return the atom positions, if no two atoms lie within a distance of 2. If there are at least two atoms which lie within a distance of 2, their entries will be replaced by their mean position.

Example II:

` analyse = Analyze(some_ase_structure) print(analyse.cluster_positions([3*[0.], 3*[1.]], eps=3)) `

This returns [0.5, 0.5, 0.5] (if the cell is large enough)

Parameters:
  • positions (numpy.ndarray) – Positions to consider. Default: atom positions

  • eps (float) – The maximum distance between two samples for one to be considered as in the neighborhood of the other.

  • buffer_width (float) – Buffer width to consider across the periodic boundary conditions. If too small, it is possible that atoms that are meant to belong together across PBC are missed. Default: Same as eps

  • return_labels (bool) – Whether to return the labels given according to the grouping together with the mean positions

Returns:

Mean positions label (numpy.ndarray): Labels of the positions (returned when return_labels = True)

Return type:

positions (numpy.ndarray)