Skip to main content

pyh5md : Read and write H5MD files

Copyright 2012-2017,2025 Pierre de Buyl and contributors
License: BSD

pyh5md is a library to read and write easily H5MD files. H5MD is a file format specification based on HDF5 to store molecular data. pyh5md is built on top of h5py, the HDF5 for Python library by Andrew Colette.

pyh5md used to define a complex class structure. Since version 1.0.0.dev1, a light subclassing of h5py's classes is used instead.

Install

It is recommended to install in a virtual environment. Then,

pip install pyh5md

installs pyh5md in that virtual environment. To install from the git repository:

pip install .

Examples

Once pyh5md is installed:

cd examples
python random_walk_1d.py

executes an example program that generates the H5MD file walk_1d.h5.

Usage

To write data to a particles group named "atoms", with a fixed set of positions:

from pyh5md import File, element
kwargs = {'creator': 'pyh5md README example',
	      'author': 'Pierre de Buyl',
          }
with File('new_file.h5', 'w', **kwargs) as f:
    g = f.particles_group('atoms')
    g.create_box(dimension=3, boundary=['none']*3)
    element(g, 'position', store='fixed', data=np.random.random(size=(32, 3)))

To read data from a H5MD file created with, for instance, LAMMPS:

from pyh5md import File, element
with File('dump_3d.h5', 'r') as f:
    g = f.particles_group('all')
    box_edges = element(g, 'box/edges').value[0]
    position = element(g, 'position').value[:]

Metadata

Release files for pyh5md 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyh5md 1.2.0
File Size Uploaded
pyh5md-1.2.0.tar.gz 9.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyh5md 1.2.0
File Interpreter ABI Platform
pyh5md-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 14.1 kB

Release files / pyh5md-1.2.0.tar.gz

Download URL pyh5md-1.2.0.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
aa887e75402ce9e1eaeef7a614af5ca3e576413be26374262c45450b84412abf
BLAKE2b-256 checksum
How to use checksums
079f940f307218b9b1812c94c055a504325df98c2040f81a9c487bb717b34c3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.2

Release files / pyh5md-1.2.0-py3-none-any.whl

Download URL pyh5md-1.2.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3f71ba75ec64be0d48e246c39ee6866738120760b9f3da8fea5dfe6f2433747c
BLAKE2b-256 checksum
How to use checksums
a91791b668b5c99b1518fb708873e5dbf3a4ccfdc95ba8d0af8264179f8dd283
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.2

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.0.0

2 release files

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page