httk.atomistic.models.trajectory¶
Expose trajectory models and views.
Submodules¶
- httk.atomistic.models.trajectory.api
- httk.atomistic.models.trajectory.backend
- httk.atomistic.models.trajectory.jsonl
- httk.atomistic.models.trajectory.like
- httk.atomistic.models.trajectory.plain
- httk.atomistic.models.trajectory.record
- httk.atomistic.models.trajectory.trajectory
- httk.atomistic.models.trajectory.view
Attributes¶
Classes¶
Define the common, frame-oriented trajectory interface. |
|
Define the backend base for all trajectory representations. |
|
Stream a neutral |
|
Represent a mapping whose structure properties have a frame axis. |
|
Store an immutable trajectory in the native backend. |
|
Present any trajectory backend through the canonical trajectory API. |
Package Contents¶
- class httk.atomistic.models.trajectory.TrajectoryAPI[source]¶
Bases:
abc.ABCDefine the common, frame-oriented trajectory interface.
A trajectory has one constant composition for all frames. Trajectories whose number or identity of sites changes are intentionally outside this interface.
- property nframes: int¶
Count frames by streaming them in O(n) time.
Each call requires
frames()to provide a fresh traversal; a one-shot backend must override this default or cache its frames. Random-access backends override this default.- Returns:
The number of frames.
- Return type:
- frame(i)[source]¶
Stream to and return one frame in O(n) time.
Each call requires
frames()to provide a fresh traversal; a one-shot backend must override this default or cache its frames. Random-access backends override this default.- Parameters:
i (int) – Frame index.
- Returns:
The requested
UnitcellStructure.- Raises:
IndexError – If
iis before the first frame or past the end.TypeError – If
iis not an integer.
- Return type:
- abstractmethod frames()[source]¶
Iterate over the frames with a fresh traversal on every call.
A one-shot backend must override the streaming defaults or cache its frames.
- Returns:
A fresh iterator of unit-cell structures.
- Return type:
collections.abc.Iterator[httk.atomistic.models.structure.unitcell.UnitcellStructure]
- property species: tuple[httk.atomistic.models.species.species.Species, Ellipsis]¶
- Abstractmethod:
Return the constant distinct species.
- property species_at_sites: tuple[str, Ellipsis]¶
- Abstractmethod:
Return the constant species name at each site.
- property reference_frames: tuple[int, Ellipsis] | None¶
Return stored reference-frame indexes, or
None.
- class httk.atomistic.models.trajectory.TrajectoryBackend(backend, **hints)[source]¶
Bases:
httk.core.Backend[TrajectoryBackend],httk.atomistic.models.trajectory.api.TrajectoryAPIDefine the backend base for all trajectory representations.
- backend_classes: ClassVar[list[type[httk.core.Backend[Any]]]] = []¶
- class httk.atomistic.models.trajectory.JsonlTrajectory(source, **hints)[source]¶
Bases:
httk.atomistic.models.trajectory.backend.TrajectoryBackendStream a neutral
httk-trajectory-jsonlpayload or path lazily.Frame data remains in the JSONL container and is read as requested.
- Parameters:
source (Any) – A JSONL payload or path to one.
**hints (Any) – Backend-selection hints.
- property header: collections.abc.Mapping[str, Any]¶
Return the neutral JSONL header mapping.
- property species: tuple[httk.atomistic.models.species.species.Species, Ellipsis]¶
Return the constant distinct species.
- property reference_frames: tuple[int, Ellipsis] | None¶
Return stored reference-frame indexes, or
None.
- property observable_names: tuple[str, Ellipsis]¶
Return the names of available per-frame observables.
- frame(i)[source]¶
Read one frame from the JSONL container.
- Parameters:
i (int) – Frame index.
- Returns:
The requested unit-cell structure.
- Raises:
IndexError – If the frame index is out of range.
- Return type:
- type httk.atomistic.models.trajectory.TrajectoryLike = TrajectoryBackend | TrajectoryView | Trajectory | PlainTrajectory | Mapping[str, Any][source]¶
- class httk.atomistic.models.trajectory.PlainTrajectory(obj, **hints)[source]¶
Bases:
httk.atomistic.models.trajectory.backend.TrajectoryBackendRepresent a mapping whose structure properties have a frame axis.
A compact constant property is represented by a one-element leading axis, e.g.
nelements=[2]for any number of frames. Only properties declaringconstanton that axis accept this compact form.- Parameters:
obj (collections.abc.Mapping[str, Any]) – A trajectory property mapping.
**hints (Any) – Backend-selection hints.
- frame(i)[source]¶
Return one frame from the property mapping.
- Parameters:
i (int) – Frame index; negative indexes count from the end.
- Returns:
The requested unit-cell structure.
- Raises:
IndexError – If the frame index is out of range.
KeyError – If a required trajectory property is absent.
TypeError – If the frame index is not an integer.
ValueError – If the frame cannot be represented as a structure.
- Return type:
- frames()[source]¶
Iterate over all frames in source order.
- Returns:
An iterator of unit-cell structures.
- Return type:
collections.abc.Iterator[httk.atomistic.models.structure.unitcell.UnitcellStructure]
- property reference_frames: tuple[int, Ellipsis] | None¶
Return normalized reference-frame indexes, or
None.
- property species: tuple[httk.atomistic.models.species.species.Species, Ellipsis]¶
Return the constant distinct species from the first frame.
- property observable_names: tuple[str, Ellipsis]¶
Return names outside the recognized trajectory and structure properties.
- class httk.atomistic.models.trajectory.Trajectory(frames, observables=None, reference_frames=None)[source]¶
Bases:
httk.atomistic.models.trajectory.backend.TrajectoryBackendStore an immutable trajectory in the native backend.
A trajectory requires at least one frame and keeps one constant composition across all frames.
- Parameters:
frames (collections.abc.Sequence[httk.atomistic.models.structure.like.StructureLike]) – Unit-cell structures to coerce and store.
observables (collections.abc.Mapping[str, collections.abc.Sequence[Any]] | None) – Optional per-frame observable values.
reference_frames (collections.abc.Sequence[int] | None) – Optional indexes of bounded reference frames.
- frame(i)[source]¶
Return one stored frame by index.
- Parameters:
i (int) – Frame index.
- Returns:
The requested unit-cell structure.
- Raises:
IndexError – If the index is out of range.
- Return type:
- frames()[source]¶
Iterate over the stored frames.
- Returns:
An iterator of unit-cell structures.
- Return type:
collections.abc.Iterator[httk.atomistic.models.structure.unitcell.UnitcellStructure]
- property reference_frames: tuple[int, Ellipsis] | None¶
Return the bounded reference-frame indexes, or
None.
- property species: tuple[httk.atomistic.models.species.species.Species, Ellipsis]¶
Return the constant distinct species.
- class httk.atomistic.models.trajectory.TrajectoryView(obj, **hints)[source]¶
Bases:
httk.core.View[httk.atomistic.models.trajectory.backend.TrajectoryBackend],httk.atomistic.models.trajectory.api.TrajectoryAPIPresent any trajectory backend through the canonical trajectory API.
- Parameters:
obj (Any) – A trajectory backend or another accepted trajectory value.
**hints (Any) – Backend-selection hints.
- frame(i)[source]¶
Return one frame by index.
- Parameters:
i (int) – Frame index.
- Returns:
The requested unit-cell structure.
- Return type:
- frames()[source]¶
Iterate over the frames.
- Returns:
An iterator of unit-cell structures.
- Return type:
collections.abc.Iterator[httk.atomistic.models.structure.unitcell.UnitcellStructure]
- property reference_frames: tuple[int, Ellipsis] | None¶
Return stored reference-frame indexes, or
None.
- property species: tuple[httk.atomistic.models.species.species.Species, Ellipsis]¶
Return the constant distinct species.
- property observable_names: tuple[str, Ellipsis]¶
Return the names of available per-frame observables.
- property observable_summaries: tuple[Any, Ellipsis]¶
Return backend-provided observable summaries, if any.
- property last_modified: Any¶
Return the backend modification marker, if available.