load_dtrj

mdtools.file_handler.load_dtrj(fname, **kwargs)[source]

Load a discrete trajectory from file.

Load a discrete trajectory stored as numpy.ndarray from a binary NumPy .npy file or from a (compressed) NumPy .npz archive.

Parameters:
  • fname (str or bytes or os.PathLike) – Name of the file containing the discrete trajectory. The discrete trajectory must be stored as numpy.ndarray either in a binary NumPy .npy file or in a (compressed) NumPy .npz archive. If loading from an .npz archive, this function first tries to read the discrete trajectory from the file “dtrj.npy”. If this file is not present in the archive, the discrete trajectory is read from the first file in the archive.

    The discrete trajectory must be of shape (n, f), where n is the number of compounds and f is the number of frames. The shape can also be (f,), in which case the array is expanded to shape (1, f).

    The array must only contain integers or floats whose fractional part is zero, because the elements of a discrete trajectory are interpreted as the indices of the states in which a given compound is at a given frame.

  • kwargs (dict, optional) – Additional keyword arguments to parse to numpy.load(). See there for possible arguments and their description. By default, allow_pickle is set to False.

Returns:

dtrj (numpy.ndarray) – The discrete trajectory loaded from the given file.

See also

numpy.load()

Load arrays or pickled objects from .npy, .npz or pickled files

mdtools.file_handler.save_dtrj()

Save a discrete trajectory to file

Notes

This function simply calls numpy.load() and checks whether the loaded numpy.ndarray is a suitable discrete trajectory.