trajectory
A module containing the Trajectory class.
Summary
Classes:
A trajectory object is a sequence of frames. |
Reference
- class Trajectory(
- frames: list[AtomicSystem] | AtomicSystem | None = None,
Bases:
object
A trajectory object is a sequence of frames.
It can be indexed, iterated over, and added to another trajectory. The length of a trajectory is the number of frames in the trajectory. A frame can be checked for membership in a trajectory.
This trajectory class can only handle constant topologies i.e. all frames in the trajectory must have the same topology.
- Parameters:
frames (AtomicSystem | None, optional) – The list of atomic systems in the trajectory. If frames is an AtomicSystem, it is first converted to list of frames. If frames is None, an empty list is created, by default None
- __add__(
- other: Trajectory,
This method allows two trajectories to be added together.
- Parameters:
other (Trajectory) – The other trajectory to add.
- __contains__(
- item: AtomicSystem,
This method allows a frame to be checked for membership in a trajectory.
- Parameters:
item (Frame) – The frame to check for membership in the trajectory.
- Returns:
Whether the frame is in the trajectory.
- Return type:
bool
- __eq__(
- other: Any,
This method allows two trajectories to be compared for equality.
- Parameters:
other (Trajectory) – The other trajectory to compare.
- Returns:
Whether the two trajectories are equal.
- Return type:
Bool
- __getitem__(
- key: int | slice,
This method allows a frame or a trajectory to be retrieved from the trajectory.
For example, if traj is a trajectory, then traj[0] is the first frame of the trajectory. If traj is a trajectory, then traj[0:2] is a trajectory containing the first two frames of the trajectory.
- Parameters:
key (int | slice) – The index or slice to retrieve the frame or trajectory from.
- Returns:
The frame or trajectory retrieved from the trajectory.
- Return type:
- __iter__() Iterable[AtomicSystem] [source]
This method allows a trajectory to be iterated over.
- Returns:
An Iterable over the frames in the trajectory.
- Return type:
Iterable[Frame]
- __len__() int [source]
This method allows the length of a trajectory to be computed.
- Returns:
The number of frames in the trajectory.
- Return type:
int
- __repr__() str [source]
This method allows the string representation of a trajectory to be retrieved.
- Returns:
The string representation of the trajectory.
- Return type:
str
- __str__() str [source]
This method allows the string representation of a trajectory to be retrieved.
- Returns:
The string representation of the trajectory.
- Return type:
str
- append(
- frame: AtomicSystem,
Appends a frame to the trajectory.
- Parameters:
frame (AtomicSystem) – The frame to append.
- check_pbc() bool [source]
Checks if one cell of the trajectory is Cell().
- Returns:
False if one cell of the trajectory is Cell(), True otherwise.
- Return type:
bool
- check_vacuum() bool [source]
Checks if all frames of the trajectory are in vacuum i.e. cell = Cell().
- Returns:
True if all frames of the trajectory are in vacuum, False otherwise.
- Return type:
bool
- copy() Trajectory [source]
Returns a copy of the trajectory.
- Returns:
A copy of the trajectory.
- Return type:
- isclose(
- other: Any,
- rtol: PositiveReal = 1e-09,
- atol: PositiveReal = 0.0,
This method allows two trajectories to be compared for closeness.
- Parameters:
other (Any) – The other object to compare with.
rtol (PositiveReal, optional) – The relative tolerance parameter, by default 1e-9
atol (PositiveReal, optional) – The absolute tolerance parameter, by default 0.0
- Returns:
Whether the two trajectories are close.
- Return type:
Bool
- pop(
- index: int = -1,
Removes a frame from the trajectory at the specified index.
- Parameters:
index (int) – The index of the frame to remove.
- Returns:
The frame removed from the trajectory.
- Return type:
- window(
- window_size: int,
- window_gap: int = 1,
- trajectory_start: int = 0,
- trajectory_stop: int | None = None,
This method allows a window of the trajectory to be retrieved. Window is a sequence of frames from start to stop with a window size and a gap size.
- Parameters:
window_size (int) – The size of the window.
window_gap (int, optional) – The gap size between two windows, by default 1
trajectory_start (int, optional) – The start index of the first window, by default 0
trajectory_stop (int | None, optional) – Stop index of the window generator, by default None, which then set to the length of the trajectory.
- Raises:
PQIndexError – If window_start is less than 0 or greater than the length of the trajectory. If window_stop is less than 0 or greater than the length of the trajectory. If window_size is less than 1 or greater than the length of the trajectory. If window_gap is less than 1 or greater than the length of the trajectory. If window_size is greater than trajectory_stop - trajectory_start.
Warning
If not all frames are included in the windows, a warning is issued.
- Yields:
Iterable[Trajectory] – An iterable over the windows of the trajectory with the specified window size and gap.
- property box_lengths: Np2DNumberArray
The box lengths of the trajectory.
- Type:
- property box_volumes: Np1DNumberArray
The box volumes of the trajectory.
- Type:
- property com_residue_traj: Trajectory
The trajectory with the center of mass of the residues.
- Type:
- property frames: list[AtomicSystem]
The frames in the trajectory.
- Type:
List[AtomicSystem]
- logger = <CustomLogger PQAnalysis.Trajectory (INFO)>