amep.load.traj#
- amep.load.traj(directory: str, trajfile: str = 'traj.h5amep', savedir: str | None = None, mode: str = 'lammps', reload: bool = False, deleteold: bool = False, verbose: bool = False, **kwargs) FieldTrajectory | ParticleTrajectory #
Loads simulation data as trajectory object.
Some remote storage systems do not allow full access necessary for reading, creating and editing HDF5 files used by AMEP (‘.h5amep’). In such cases it is possible to read the simulation data on the remote storage system but save the h5amep file locally. Below you can find an example.
- Parameters:
directory (str) – Simulation directory or, if wanting to load a h5amep file, the path including the trajectory name and file ending “.h5amep” can be given (see example).
trajfile (str, optional) – Name of the hdf5 trajectory file that is created when an object of this class is initialized. The default is TRAJFILENAME.
savedir (str or None, optional) – Target directory in which the trajectory file will be saved. If None, the simulation directory is used. For mode=’h5amep’, savedir is ignored. The default is None.
mode (str, optional) – Loading mode. Available modes are ‘lammps’, ‘fields’, and ‘h5amep’. The default is ‘lammps’.
reload (bool, optional) – If True, all dump files will be loaded again, otherwise it will be tried to load an existing h5amep file. The default is False.
deleteold (bool, optional) – If True, an existing old h5amep trajectory file #<filename> will be removed. The default is False.
verbose (bool, optional) – If True, runtime information is printed. The default is False.
**kwargs – Are forwared to the reader.
- Returns:
Trajectory object.
- Return type:
amep.trajectory.ParticleTrajectory or amep.trajectory.FieldTrajectory
Examples
Minimal example for loading lammps trajectory from path “data”:
>>> import amep >>> traj = amep.load.traj("data") >>> traj = amep.load.traj("data", reload=True) # data will be read again
Shortcuts to load an h5amep file directly:
>>> traj = amep.load.traj("data/traj.h5amep") >>> traj = amep.load.traj( ... "data", trajfile="traj.h5amep", mode="h5amep" ... ) >>>
Fix for working with remote files and insufficient access rights: Save the h5amep file locally while importing/loading the simulation data for the first time:
>>> traj = amep.load.traj( ... "/path/to/sftp:host=192.168.255.255/remote/directory/", ... savedir="/path/to/local/directory/" ... ) >>>