ase-hdf5
ase-hdf5 provides a simple I/O for converting list[ase.Atoms] <—> HDF5.
Quickstart
Install the package with pip install -q ase-hdf5.
Then, a simple example of writing a list of ase.Atoms to a file:
import ase
from ase_hdf5 import ASEH5Trajectory
atoms_list: list[ase.Atoms] = get_my_atoms_list() # with extra per-atom arrays.
traj_writer = ASEH5Trajectory(
immutable=["numbers", "mol-id", "atom-type"],
mutable=["positions"]
)
# write to file.
traj_writer.write(atoms_list, "atoms_list.h5")
We can run a simple check that the read-in version is equivalent:
def atoms_are_equal(atoms1: ase.Atoms, atoms2: ase.Atoms) -> bool:
""" Check if two ase.Atoms objects are equal. """
_basic_properties = ["cell", "positions", "numbers"]
_extra_properties = ["mol-id", "atom-type"]
# all close because default writing converts to float32.
for prop in _basic_properties:
if not np.allclose(getattr(atoms1, prop), getattr(atoms2, prop)):
return False
for prop in _extra_properties:
if (
prop in atoms1.arrays
and prop in atoms2.arrays
and not np.array_equal(atoms1.arrays[prop], atoms2.arrays[prop])
):
return False
return True
# read in result.
atoms_list_read = traj_writer.read("atoms_list.h5")
for atom1, atom2 in zip(atoms_list, atoms_list_read):
assert atoms_are_equal(atom1, atom2)
Metadata
Release files for ase-hdf5 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ase_hdf5-0.1.6.tar.gz | 11.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ase_hdf5-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.0 kB
Release files / ase_hdf5-0.1.6.tar.gz
| Download URL | ase_hdf5-0.1.6.tar.gz |
|---|---|
| Size | 11.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e25ab98fb871508666e9d5172ff795f0c7dfbd0277bf471a428d8a461877ccd
|
|
BLAKE2b-256 checksum How to use checksums |
b4bb55c414a395ad649bed31d7a6f2f3d6b2943f6a20d8675ced4e22890c0b95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|
Release files / ase_hdf5-0.1.6-py3-none-any.whl
| Download URL | ase_hdf5-0.1.6-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7c56ee8d6a6695becd5853aa00884c3ebc3086b6418068c91f5e50246f829b10
|
|
BLAKE2b-256 checksum How to use checksums |
8a496e140ec5a09bf8cd3acaa68a3ff04947540723e9ec72868ac3b68d3e5d43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.9
|