sitator.util package

Submodules

sitator.util.elbow module

sitator.util.elbow.index_of_elbow(points)

Returns the index of the “elbow” in points.

Decently fast and pretty approximate. Performs worse with disproportionately long “flat” tails. For example, in a dataset with a nearly right-angle elbow, it overestimates the elbow by 1 starting at a before/after ratio of 1/4.

sitator.util.mcl module

sitator.util.mcl.markov_clustering(transition_matrix, expansion=2, inflation=2, pruning_threshold=1e-05, iterlimit=100)

Compute the Markov Clustering of a graph. See https://micans.org/mcl/.

Because we’re dealing with matrixes that are stochastic already, there’s no need to add artificial loop values.

Implementation inspired by https://github.com/GuyAllard/markov_clustering

sitator.util.progress module

sitator.util.zeo module

class sitator.util.zeo.Zeopy(path_to_zeo)

Bases: object

A wrapper for the Zeo++ network tool.

Warning:Do not use a single instance of Zeopy in parallel.
static ase2cuc(at)

Convert an ase.Atoms to the CUC format.

See http://www.maciejharanczyk.info/Zeopp/input.html

Returns:A string in CUC format.
static parse_nt2(nt2lines)
static parse_v1_cell(v1lines)
voronoi(structure, radial=False)
Parameters:structure (Atoms) – The ASE Atoms to compute the Voronoi decomposition of.

Module contents

class sitator.util.DotProdClassifier

Bases: object

Assign vectors to clusters indicated by a representative vector using a cosine metric.

Cluster centers can be given through set_cluster_centers() or approximated using the custom method described in the appendix of the main landmark analysis paper (fit_centers()).

Parameters:
  • threshold (float) – Similarity threshold for joining a cluster. In cos-of-angle-between-vectors (i.e. 1 is exactly the same, 0 is orthogonal)
  • max_converge_iters (int) – Maximum number of iterations. If the algorithm hasn’t converged by then, it will exit with a warning.
  • min_samples (float or int) – filter out clusters with low sample counts. If an int, filters out clusters with fewer samples than this. If a float, filters out clusters with fewer than floor(min_samples * n_assigned_samples) samples assigned to them.
cluster_centers
cluster_counts
fit_centers
fit_predict

Fit the data vectors X and return their cluster labels.

n_clusters
predict

Return a predicted cluster label for vectors X.

Parameters:threshold (float) – alternate threshold. Defaults to None, when self.threshold is used.
Returns:an array of labels. -1 indicates no assignment.
Returns:an array of confidences in assignments. Normalzied values from 0 (no confidence, no label) to 1 (identical to cluster center).
set_cluster_centers
class sitator.util.PBCCalculator

Bases: object

Performs calculations on collections of 3D points under PBC.

all_in_unit_cell()
average()

Average position of a “cloud” of points using the shift-and-wrap hack.

Copies the points.

Assumes that the points are relatively close (within a half unit cell) together, and that the first point is not a particular outsider (the cell is centered at that point). If the average is weighted, the maximally weighted point will be taken as the center.

Can be a weighted average with the semantics of :func:numpy.average.

cell_centroid
distances()

Compute the Euclidean distances from pt1 to all points in pts2, using shift-and-wrap.

Makes a copy of pts2 unless in_place == True.

Returns ndarray len(pts2):
 distances
is_in_image_of_cell()
is_in_unit_cell()
min_image()

Find the minimum image of pt relative to ref. In place in pt.

Uses the brute force algorithm for correctness; returns the minimum image.

Assumes that ref and pt are already in the same cell (though not necessarily the <0,0,0> cell – any periodic image will do).

Returns int[3] minimg:
 Which image was the minimum image.
pairwise_distances()

Compute the pairwise distance matrix of pts with itself.

Returns ndarray (len(pts), len(pts)):
 distances
time_average()

Do multiple PBC correct means. Frames is n_frames x n_pts x 3.

Returns a time average the size of one frame.

to_cell_coords()

Convert to cell coordinates in place.

to_real_coords()

Convert to real coords from crystal coords in place.

wrap_point()

Wrap a single point into the unit cell, IN PLACE. 3D only.

wrap_points()

Wrap points into a unit cell, IN PLACE. 3D only.

class sitator.util.RecenterTrajectory

Bases: object

run

Recenter a trajectory.

Recenters traj on the center of mass of the atoms indicated by static_mask, IN PLACE.

Parameters:
  • structure (ase.Atoms) – An atoms representing the structure of the simulation.
  • static_mask (ndarray) – Boolean mask indicating which atoms to recenter on
  • positions (ndarray) – (n_frames, n_atoms, 3), modified in place
  • velocities (ndarray, optional) – Same; modified in place if provided
  • masses (None or dict or ndarray) –

    The masses to use when computing the center of mass.

    • If None, masses from structure.get_masses() will
      be used.
    • If a dict, expected to map chemical symbols to masses
    • If an ndarray, must have n_atoms elements giving the
      masses of all atoms in the system.