amep.trajectory.FieldTrajectory#
- class amep.trajectory.FieldTrajectory(reader)#
Bases:
BaseTrajectory
Field trajectory object.Time-series of per spatial point field values.
- __init__(reader)#
Creates a trajectory object containing data frames for multiple time steps.
Can be viewed as a Sequence of
BaseField
.- 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_field_info
(ftype, key, value)Adds information for the given field to the fields group of the trajectory file.
add_param
(param, value)Adds a parameter to the trajectory.
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_field_info
(ftype[, key])Deletes specific field information.
delete_param
(param)Deletes the given parameter.
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_field_info
([ftype])Returns all parameters of the given field 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.
Attributes
Returns a list of all author names.
Spatial dimension of the simnulation.
Size of the time step used for the simulation.
Returns all stored metadata information as a dictionary.
Total number of loaded frames.
Every which dump file was loaded.
Returns all parameters stored within the trajectory as a dictionary.
reader
Trajectory file directory.
Returns a list of all scripts (filenames) that are stored in the trajectory object.
Returns all software information.
Start fraction.
Array of the number of time steps for each frame.
Stop fraction.
Physical times.
Returns the data type ('particles' or 'field').
AMEP version with which the trajectory file has been created.
- __getitem__(item: int | slice | Iterable[int]) BaseFrame | BaseField | list[BaseField | BaseFrame] #
Get an individual frame or field of a simulation.
Supports slicing as well as iterables of valid integer indices. The return type depends on the type of the trajectory. Also it depends if only one frame or a collection of frames is requested. If a collection of frames is requested a list of frames is returned.
- 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_field_info(ftype: str, key: str, value: int | float | str) None #
Adds information for the given field to the fields group of the trajectory file.
- Parameters:
ftype (str) – Field.
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/continuum.h5amep") >>> traj.add_field_info('p', 'name', 'particle density') >>> traj.add_field_info('c', 'name', 'chemical concentration') >>> print(traj.get_field_info()) {'c': {'name': 'chemical concentration'}, 'p': {'name': 'particle density'}} >>> traj.delete_field_info(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_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_field_info(ftype: str | None, key: str | None = None) None #
Deletes specific field information.
- Parameters:
ftype (str or None) – Field. If None, the information of all fields is deleted.
key (str, optional) – Parameter to delete. If None, all parameters of the given field are deleted. The default is None.
- Return type:
None.
Examples
>>> import amep >>> traj = amep.load.traj("../examples/data/continuum.h5amep") >>> traj.add_field_info('p', 'name', 'particle density') >>> traj.add_field_info('c', 'name', 'chemical concentration') >>> print(traj.get_field_info()) {'c': {'name': 'chemical concentration'}, 'p': {'name': 'particle density'}} >>> traj.delete_field_info(None) >>> print(traj.get_field_info()) {} >>>
- 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_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 dim: int#
Spatial dimension of the simnulation.
- Returns:
x – Spatial dimension.
- Return type:
int
- 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_field_info(ftype: str | None = None) dict #
Returns all parameters of the given field as a dictionary.
- Parameters:
ftype (str or None, optional) – Field. If None, the information of all fields is returned. The default is None.
- Returns:
p – Parameters.
- Return type:
dict
Examples
>>> import amep >>> traj = amep.load.traj("../examples/data/continuum.h5amep") >>> traj.add_field_info('p', 'name', 'particle density') >>> traj.add_field_info('c', 'name', 'chemical concentration') >>> print(traj.get_field_info()) {'c': {'name': 'chemical concentration'}, 'p': {'name': 'particle density'}} >>> traj.delete_field_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.
- 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