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
orbytes
oros.PathLike
) – Name of the file containing the discrete trajectory. The discrete trajectory must be stored asnumpy.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)
, wheren
is the number of compounds andf
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 tonumpy.load()
. See there for possible arguments and their description. By default, allow_pickle is set toFalse
.
- 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 filesmdtools.file_handler.save_dtrj()
Save a discrete trajectory to file
Notes
This function simply calls
numpy.load()
and checks whether the loadednumpy.ndarray
is a suitable discrete trajectory.