save_dtrj
- mdtools.file_handler.save_dtrj(fname, dtrj, rename=True)[source]
Save a discrete trajectory to file.
Save a discrete trajectory as
numpy.ndarray
to a compressed NumPy .npz archive.Warning
Creating a gzip-compressed
.npz
archive does not work. However bzip2-, xz- and lzma-compressed archives can be created. Note that the created.npz
archive is already compressed bynumpy.savez_compressed()
. Therefore, further compression is usually not reasonable.- Parameters:
fname (
str
orbytes
oros.PathLike
) – Name of the file to write to.dtrj (
array_like
) – The discrete trajectory to save. Must meet the requirements given inmdtools.check.dtrj()
. Note that the shape of dtrj is expanded to(1, f)
if it is only of shape(f,)
.rename (
bool
, optional) – IfTrue
and a file called fname already exists, rename it to'fname.bak_timestamp'
. Seemdtools.file_handler.backup()
for more details.
See also
numpy.savez_compressed()
Save one or multiple arrays in a compressed
.npz
archivemdtools.file_handler.load_dtrj()
Load a discrete trajectory from file
Notes
This function simply checks whether dtrj is a suitable discrete trajectory and then saves it to file using
numpy.savez_compressed()
. Inside the created.npz
archive, the discrete trajectory is stored in the filedtrj.npy
.