save_dtrj
- mdtools.file_handler.save_dtrj(fname, dtrj, rename=True)[source]
Save a discrete trajectory to file.
Save a discrete trajectory as
numpy.ndarrayto a compressed NumPy .npz archive.Warning
Creating a gzip-compressed
.npzarchive does not work. However bzip2-, xz- and lzma-compressed archives can be created. Note that the created.npzarchive is already compressed bynumpy.savez_compressed(). Therefore, further compression is usually not reasonable.- Parameters:
fname (
strorbytesoros.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) – IfTrueand 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
.npzarchivemdtools.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.npzarchive, the discrete trajectory is stored in the filedtrj.npy.