Skip to main content

pyh5md - Read and write H5MD files

Project description

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[:]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyh5md-1.2.0.tar.gz (9.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyh5md-1.2.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file pyh5md-1.2.0.tar.gz.

File metadata

  • Download URL: pyh5md-1.2.0.tar.gz
  • Upload date:
  • Size: 9.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for pyh5md-1.2.0.tar.gz
Algorithm Hash digest
SHA256 aa887e75402ce9e1eaeef7a614af5ca3e576413be26374262c45450b84412abf
MD5 0b610e9214d888d0c278a33c3f015911
BLAKE2b-256 079f940f307218b9b1812c94c055a504325df98c2040f81a9c487bb717b34c3e

See more details on using hashes here.

File details

Details for the file pyh5md-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: pyh5md-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.2

File hashes

Hashes for pyh5md-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3f71ba75ec64be0d48e246c39ee6866738120760b9f3da8fea5dfe6f2433747c
MD5 777e504b21ccc83cc7ab4dc3e2785565
BLAKE2b-256 a91791b668b5c99b1518fb708873e5dbf3a4ccfdc95ba8d0af8264179f8dd283

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page