airsspy.convert#

Lossless conversion between AIRSS .res and extended XYZ formats.

Supports round-tripping all data including forces (stored as extra columns 8-10 on atom lines in .res), per-atom spins, REM metadata, and all TITL fields. Output .res files are fully compatible with cryan and other AIRSS tools.

Module Contents#

Functions#

res_to_extxyz

Convert a (packed) .res file to extxyz.

extxyz_to_res

Convert an extxyz file to individual .res files (one per structure).

extract_structure

Extract a single structure by label from a packed .res or extxyz file.

API#

airsspy.convert.res_to_extxyz(res_path: str | pathlib.Path, extxyz_path: str | pathlib.Path) int[source]#

Convert a (packed) .res file to extxyz.

Returns the number of structures converted.

airsspy.convert.extxyz_to_res(extxyz_path: str | pathlib.Path, output_dir: str | pathlib.Path) int[source]#

Convert an extxyz file to individual .res files (one per structure).

Each structure is written to <output_dir>/<label>.res. If output_dir doesn’t exist, it is created.

Returns the number of structures converted.

airsspy.convert.extract_structure(source_path: str | pathlib.Path, label: str, output_path: str | pathlib.Path, input_format: str | None = None) bool[source]#

Extract a single structure by label from a packed .res or extxyz file.

Args: source_path: Path to packed .res or extxyz file. label: Structure label to match (from TITL field 1 or atoms.info[‘label’]). output_path: Path to write the extracted structure. The format is determined by the file extension (.res or .xyz/.extxyz). input_format: Force input format (‘res’, ‘extxyz’, or None for auto-detect).

Returns: True if the structure was found and written, False otherwise.