chemparseplot.parse.eon.con_io#

Public readcon-backed CON/convel helpers for eOn parsers.

All .con / .convel I/O in chemparseplot goes through this module. readcon stays an optional extra (chemparseplot[neb]). Import errors surface only when these helpers are called. Writers omit precision and leave canonical off, which is RoundTrip on readcon>=0.17.1. Corpus selection opens stores read-only and decodes selected frames as they are consumed.

Added in version 1.8.1.

Module Contents#

Functions#

is_con_path

Return True when path looks like an eOn CON/convel file.

_readcon

_metadata_dict

_clone_frame

Copy a frame through the ConFrame constructor so Atom sections travel.

read_con_frames

Read all frames from a CON/convel file as readcon.ConFrame objects.

iter_con_frames

Yield CON frames without retaining the complete trajectory.

iter_corpus_frames

Yield selected stored frames in trajectory and frame-index order.

observation_archive_writer

Open (or create) a readcon-db observation archive for writing.

read_observation_frame

Stored frame index of an observation archive, or None past the end.

read_corpus_trajectory

Frames of one trajectory of a corpus and its trajectory metadata.

read_observation_rows

Every observation of an archive as arrays in the writer’s atom order.

_lattice

_energy_unit

_unit_factor

frame_energy_ev

Return the stored total energy in eV without evaluating a potential.

read_con_as_ase

Read all frames from a CON/convel file as ASE Atoms objects.

read_first_frame

Read the first CON frame and stop. Later frames are not parsed.

read_first_atoms

Read the first frame of a CON file as an ASE Atoms object.

frame_positions_angstrom

Return Cartesian positions in Angstrom using the declared length unit.

frame_with_energy

Return a ConFrame copy with the supplied total energy in eV.

frame_with_positions

Return a ConFrame copy with Cartesian positions replaced.

_normalize_box_headers

Fill empty ASE box headers so a multi-frame file re-parses.

write_con_frames

Write ConFrame objects to path via readcon.write_con.

write_atoms_as_con

Convert ASE Atoms that were never a ConFrame and write CON.

Data#

API#

chemparseplot.parse.eon.con_io.__all__#

[‘CON_SUFFIXES’, ‘frame_energy_ev’, ‘frame_positions_angstrom’, ‘frame_with_energy’, ‘frame_with_pos…

chemparseplot.parse.eon.con_io.CON_SUFFIXES#

(‘.con’, ‘.convel’)

chemparseplot.parse.eon.con_io._READCON_HINT#

“readcon is required for CON I/O. Install with: pip install ‘chemparseplot[neb]’ (readcon>=0.17.1)”

chemparseplot.parse.eon.con_io.is_con_path(path: str | pathlib.Path) → bool[source]#

Return True when path looks like an eOn CON/convel file.

chemparseplot.parse.eon.con_io._readcon()[source]#
chemparseplot.parse.eon.con_io._metadata_dict(frame: Any) → dict[str, Any][source]#
chemparseplot.parse.eon.con_io._clone_frame(frame: Any) → Any[source]#

Copy a frame through the ConFrame constructor so Atom sections travel.

chemparseplot.parse.eon.con_io.read_con_frames(path: str | pathlib.Path) → list[Any][source]#

Read all frames from a CON/convel file as readcon.ConFrame objects.

chemparseplot.parse.eon.con_io.iter_con_frames(path: str | pathlib.Path) → collections.abc.Iterator[Any][source]#

Yield CON frames without retaining the complete trajectory.

chemparseplot.parse.eon.con_io.iter_corpus_frames(path: str | pathlib.Path, *, trajectory: int | None = None, require_energy: bool = False, require_forces: bool = False) → collections.abc.Iterator[Any][source]#

Yield selected stored frames in trajectory and frame-index order.

The corpus is opened read-only. Frame decoding is lazy; selection retains only the trajectory and frame keys, including for compressed stores.

chemparseplot.parse.eon.con_io.observation_archive_writer(directory: str | pathlib.Path, atomic_numbers: collections.abc.Sequence[int], cell: collections.abc.Sequence[float]) → Any[source]#

Open (or create) a readcon-db observation archive for writing.

Returns readcon_db.ObservationArchive for one fixed composition: atomic_numbers in caller order and cell the three orthorhombic box lengths. Rows are appended with append(positions, forces, energy).

Added in version 1.15.0.

chemparseplot.parse.eon.con_io.read_observation_frame(directory: str | pathlib.Path, index: int = 0) → Any | None[source]#

Stored frame index of an observation archive, or None past the end.

directory is the archive directory or its observations.rdb. The frame is in stored (type-grouped) order; its atom ids are the writer’s atom order. The archive is opened read-only and closed again.

Added in version 1.15.0.

chemparseplot.parse.eon.con_io.read_corpus_trajectory(path: str | pathlib.Path, trajectory: int | None = None) → tuple[list[Any], dict[str, Any] | None][source]#

Frames of one trajectory of a corpus and its trajectory metadata.

trajectory defaults to the lowest trajectory id, which is the band in gpridge’s band.con.corpus. The metadata is the dict set_trajectory_metadata stored, or None when none was stored or the installed readcon-db predates trajectory metadata.

Added in version 1.15.0.

chemparseplot.parse.eon.con_io.read_observation_rows(directory: str | pathlib.Path) → dict[str, Any][source]#

Every observation of an archive as arrays in the writer’s atom order.

Returns positions and forces of shape (n, natoms, 3), energies (NaN where a row has none), atomic_numbers and cell ((3, 3) from the first row). directory is the archive directory or its observations.rdb.

Added in version 1.15.0.

chemparseplot.parse.eon.con_io._lattice(lengths: collections.abc.Sequence[float], angles: collections.abc.Sequence[float]) → numpy.ndarray[source]#
chemparseplot.parse.eon.con_io._energy_unit(frame: Any) → str[source]#
chemparseplot.parse.eon.con_io._unit_factor(source: str, target: str) → float[source]#
chemparseplot.parse.eon.con_io.frame_energy_ev(frame: Any) → float | None[source]#

Return the stored total energy in eV without evaluating a potential.

chemparseplot.parse.eon.con_io.read_con_as_ase(path: str | pathlib.Path) → list[source]#

Read all frames from a CON/convel file as ASE Atoms objects.

chemparseplot.parse.eon.con_io.read_first_frame(path: str | pathlib.Path) → Any[source]#

Read the first CON frame and stop. Later frames are not parsed.

chemparseplot.parse.eon.con_io.read_first_atoms(path: str | pathlib.Path)[source]#

Read the first frame of a CON file as an ASE Atoms object.

chemparseplot.parse.eon.con_io.frame_positions_angstrom(frame: Any) → numpy.ndarray[source]#

Return Cartesian positions in Angstrom using the declared length unit.

chemparseplot.parse.eon.con_io.frame_with_energy(frame: Any, energy: float) → Any[source]#

Return a ConFrame copy with the supplied total energy in eV.

The stored number uses the frame’s declared energy unit. Geometry, atom sections, and their unit declarations are retained. ConFrame.set_energy validates that the stored value is finite.

chemparseplot.parse.eon.con_io.frame_with_positions(frame: Any, positions: Any) → Any[source]#

Return a ConFrame copy with Cartesian positions replaced.

Each Atom row is copied and only x / y / z are written. fixed, atom_id, mass, velocities, forces, displacements, and spreads stay. That is correct for an unmoved slice or a pure translation. It is the wrong helper for displacement.con: a rotation or a reorder must drop those sections and let eOn recompute them.

chemparseplot.parse.eon.con_io._normalize_box_headers(frame: Any) → Any[source]#

Fill empty ASE box headers so a multi-frame file re-parses.

ConFrame.from_ase often yields empty header lines. A single frame still reads, but a later frame then stops at the velocity section. Frames that already have a non-empty header are returned unchanged, so a restart rewrite stays byte-identical.

chemparseplot.parse.eon.con_io.write_con_frames(path: str | pathlib.Path, frames: collections.abc.Sequence[Any]) → pathlib.Path[source]#

Write ConFrame objects to path via readcon.write_con.

Precision is omitted and canonical stays off. There is no corpus write.

chemparseplot.parse.eon.con_io.write_atoms_as_con(path: str | pathlib.Path, atoms_list: collections.abc.Sequence[Any], *, energies: collections.abc.Sequence[float | None] | None = None) → pathlib.Path[source]#

Convert ASE Atoms that were never a ConFrame and write CON.

Optional energies (eV) are attached per frame with

Func:

frame_with_energy. from_ase drops displacements and spreads. ASE tags become atom ids only when they are distinct and non-negative; otherwise ids are sequential. Two atoms of one symbol whose masses disagree past the reader tolerance fail at build. Precision is omitted and canonical stays off. Empty box headers are filled so a multi-frame file re-parses.