amep.trajectory.ParticleTrajectory#

class amep.trajectory.ParticleTrajectory(reader)#

Bases: BaseTrajectory

Particle trajectory object. Time-series of per-particle data such as coordinates, velocities, forces, etc.

__init__(reader) None#

Creates a trajectory object containing data frames for multiple time steps.

Parameters:

reader (BaseReader) – Reader of the data.

Return type:

None.

Methods

__init__(reader)

Creates a trajectory object containing data frames for multiple time steps.

add_author_info(author, key, value)

Adds author information for the given author to the trajectory.

add_param(param, value)

Adds a parameter to the trajectory.

add_particle_info(ptype, key, value)

Adds information for the given particle type to the particles group of the trajectory file.

add_script(path)

Adds a script in text format to the hdf5 file.

add_software_info(key, value)

Add software information to the hdf5 trajectory file.

animate(filename, **kwargs)

Wrapper to amep.plot.animate_trajectory.

delete_author_info(author[, key])

Deletes all information (key=None) or specific information given by the key keyword of the given author.

delete_param(param)

Deletes the given parameter.

delete_particle_info(ptype[, key])

Deletes specific particle information.

delete_script(filename)

Deletes the script of the given filename.

delete_software_info([key])

Deletes all software information (key=None) or specific information given by the key keyword.

get_author_info(author)

Returns all information for the given author.

get_particle_info([ptype])

Returns all parameters of the given particle type as a dictionary.

get_script(filename[, store, directory])

Returns a stored script as a list of lines and stores it as a file in the given directory if store is True.

nojump([new])

Generates the nojump coordinates for all particles and all frames based on the jump data determined from self.__get_jumps().

Attributes

authors

Returns a list of all author names.

dim

dt

Size of the time step used for the simulation.

info

Returns all stored metadata information as a dictionary.

nframes

Total number of loaded frames.

nth

Every which dump file was loaded.

params

Returns all parameters stored within the trajectory as a dictionary.

reader

savedir

Trajectory file directory.

scripts

Returns a list of all scripts (filenames) that are stored in the trajectory object.

software

Returns all software information.

start

Start fraction.

steps

Array of the number of time steps for each frame.

stop

Stop fraction.

times

Physical times.

type

Returns the data type ('particles' or 'field').

version

AMEP version with which the trajectory file has been created.

add_author_info(author: str, key: str, value: int | float | str) None#

Adds author information for the given author to the trajectory.

Parameters:
  • author (str) – Author name.

  • key (str) – Name or category of the information to be added.

  • value (int or float or str) – Information to be added.

Return type:

None.

add_param(param: str, value: int | float | str) None#

Adds a parameter to the trajectory.

Parameters:
  • param (str) – Parameter.

  • value (str or float or int) – Value of the parameter.

Raises:

ValueError – Raises an error if param is not of type str.

Return type:

None.

add_particle_info(ptype: int, key: str, value: int | float | str) None#

Adds information for the given particle type to the particles group of the trajectory file.

Parameters:
  • ptype (int) – Particle type.

  • key (str) – Name of the parameter.

  • value (int/float/str) – Value of the parameter.

Return type:

None.

Examples

>>> import amep
>>> traj = amep.load.traj("../examples/data/lammps.h5amep")
>>> traj.add_particle_info(1, 'name', 'active')
>>> traj.add_particle_info(2, 'name', 'passive')
>>> print(traj.get_particle_info())
{1: {'name': 'active'}, 2: {'name': 'passive'}}
>>> traj.delete_particle_info(None)
>>>
add_script(path: Path | str) None#

Adds a script in text format to the hdf5 file.

Parameters:

path (str or Path) – Path of the script to add.

Return type:

None.

add_software_info(key: str, value: str | int | float) None#

Add software information to the hdf5 trajectory file.

Parameters:
  • key (str) – Name of the parameter.

  • value (str or int or float) – Value of the parameter.

Return type:

None.

animate(filename: str, **kwargs) None#

Wrapper to amep.plot.animate_trajectory.

Parameters:
  • filename (str) – File in which the video should be saved.

  • **kwargs – All keyword arguments are forwarded to amep.plot.animate_trajectory.

Return type:

None

property authors: list[str]#

Returns a list of all author names.

Returns:

keys – List of author names.

Return type:

list

delete_author_info(author: str, key: str | None = None) None#

Deletes all information (key=None) or specific information given by the key keyword of the given author.

Parameters:
  • author (str) – Author name.

  • key (str or None, optional) – Info that should be deleted. If None, all info is deleted. The default is None.

Return type:

None.

delete_param(param: str) None#

Deletes the given parameter.

Parameters:

param (str) – Parameter.

Raises:

ValueError – Raises an error if param is not of type str.

Return type:

None.

delete_particle_info(ptype: int | None, key: str | None = None) None#

Deletes specific particle information.

Parameters:
  • ptype (int or None) – Particle type. If None, the information of all particles is deleted.

  • key (str, optional) – Parameter to delete. If None, all parameters of the given particle type are deleted. The default is None.

Return type:

None.

Examples

>>> import amep
>>> traj = amep.load.traj("../examples/data/lammps.h5amep")
>>> traj.add_particle_info(1, 'name', 'active')
>>> traj.add_particle_info(2, 'name', 'passive')
>>> print(traj.get_particle_info())
{1: {'name': 'active'}, 2: {'name': 'passive'}}
>>> traj.delete_particle_info(None)
>>> print(traj.get_particle_info())
{}
>>>
delete_script(filename: str) None#

Deletes the script of the given filename.

Parameters:

filename (str) – Filename.

Return type:

None.

delete_software_info(key: str | None = None) None#

Deletes all software information (key=None) or specific information given by the key keyword.

Parameters:

key (str or None, optional) – Information that should be deleted. If None, all information is deleted. The default is None.

Return type:

None.

property dt#

Size of the time step used for the simulation.

get_author_info(author: str) dict#

Returns all information for the given author.

Parameters:

author (str) – Author name.

Returns:

p – Author information.

Return type:

dict

get_particle_info(ptype: int | None = None) dict#

Returns all parameters of the given particle type as a dictionary.

Parameters:

ptype (int or None, optional) – Particle type. If None, the information of all particle types is returned. The default is None.

Returns:

p – Parameters.

Return type:

dict

Examples

>>> import amep
>>> traj = amep.load.traj("../examples/data/lammps.h5amep")
>>> traj.add_particle_info(1, 'name', 'active')
>>> traj.add_particle_info(2, 'name', 'passive')
>>> print(traj.get_particle_info())
{1: {'name': 'active'}, 2: {'name': 'passive'}}
>>> traj.delete_particle_info(None)
>>>
get_script(filename: str, store: bool = False, directory: str = '.') list#

Returns a stored script as a list of lines and stores it as a file in the given directory if store is True.

Parameters:
  • filename (str) – File name.

  • store (bool, optional) – If True, the script is stored in a file. The default is False.

  • directory (str, optional) – Directory in which the file is stored if store is True. The default is ‘.’.

Returns:

decoded – List of lines.

Return type:

list

property info: dict#

Returns all stored metadata information as a dictionary.

Returns:

Metadata.

Return type:

dict

property nframes#

Total number of loaded frames.

nojump(new: bool = False) None#

Generates the nojump coordinates for all particles and all frames based on the jump data determined from self.__get_jumps().

Note

Note that this method only gives correct results if the particles do not move further than half the box size between two frames.

Parameters:

new (bool, optional) – If True, the nojump coordinates are calculated again and existing nojump coordinates are overwritten. If False, nojump checks whether nojump coordinates already exist and will only calculate them if no nojump coordinates are available. The default is False.

Return type:

None.

property nth#

Every which dump file was loaded.

property params: dict#

Returns all parameters stored within the trajectory as a dictionary.

Returns:

p – Parameter dictionary.

Return type:

dict

property savedir#

Trajectory file directory.

property scripts: list#

Returns a list of all scripts (filenames) that are stored in the trajectory object.

Returns:

keys – List of filenames.

Return type:

list

property software: dict#

Returns all software information.

Returns:

keys – Software information.

Return type:

dict

property start#

Start fraction.

property steps#

Array of the number of time steps for each frame.

property stop#

Stop fraction.

property times#

Physical times.

property type: str#

Returns the data type (‘particles’ or ‘field’).

Returns:

Data type.

Return type:

str

property version#

AMEP version with which the trajectory file has been created.

Returns:

ver – Version.

Return type:

str