Name | znh5md JSON |
Version |
0.2.0
JSON |
| download |
home_page | None |
Summary | High Performance Interface for H5MD Trajectories |
upload_time | 2024-05-17 11:18:39 |
maintainer | None |
docs_url | None |
author | zincwarecode |
requires_python | <4.0,>=3.9 |
license | Apache-2.0 |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[![zincware](https://img.shields.io/badge/Powered%20by-zincware-darkcyan)](https://github.com/zincware)
[![Coverage Status](https://coveralls.io/repos/github/zincware/ZnH5MD/badge.svg?branch=main)](https://coveralls.io/github/zincware/ZnH5MD?branch=main)
[![PyPI version](https://badge.fury.io/py/znh5md.svg)](https://badge.fury.io/py/znh5md)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/zincware/ZnH5MD/HEAD)
# ZnH5MD - High Performance Interface for H5MD Trajectories
ZnH5MD allows easy access to simulation results from H5MD trajectories. It
provides a Python interface and can convert existing data to H5MD files as well
as export to other formats.
```
pip install znh5md["dask"]
```
## Example
In the following example we investigate an H5MD dump from LAMMPS with 1000 atoms
and 201 configurations:
```python
import znh5md
traj = znh5md.DaskH5MD("file.h5", time_chunk_size=500, species_chunk_size=100)
print(traj.file.time_dependent_groups)
# ['edges', 'force', 'image', 'position', 'species', 'velocity']
print(traj.force)
# DaskDataSet(value=dask.array<array, shape=(201, 1000, 3), ...)
print(traj.velocity.slice_by_species(species=1))
# DaskDataSet(value=dask.array<reshape, shape=(201, 500, 3), ...)
print(traj.position.value)
# dask.array<array, shape=(201, 1000, 3), dtype=float64, chunksize=(100, 500, 3), ...>
# You can iterate through the data
for item in traj.position.batch(size=27, axis=0):
for x in item.batch(size=17, axis=1):
print(x.value.compute())
```
## ASE Atoms
You can use ZnH5MD to store ASE Atoms objects in the H5MD format.
> ZnH5MD does not support all features of ASE Atoms objects. It s important to
> note that unsupported parts are silently ignored and no error is raised.
> The ASEH5MD interface will not provide any time and step information.
> If you have a list of Atoms with different PBC values, you can use
> `znh5md.io.AtomsReader(atoms, use_pbc_group=True)`. This will create a `pbc`
> group in `box/` that also contains `step` and `time`. This is not an official
> H5MD specification so it can cause issues with other tools. If you don't
> specify this, the pbc of the first atoms in the list will be applied.
```python
import znh5md
import ase
atoms: list[ase.Atoms]
db = znh5md.io.DataWriter(filename="db.h5")
db.add(znh5md.io.AtomsReader(atoms)) # or znh5md.io.ChemfilesReader
data = znh5md.ASEH5MD("db.h5")
data.get_atoms_list() == atoms
```
## CLI
ZnH5MD provides a small set of CLI tools:
- `znh5md view <file.h5>` to view the File using `ase.visualize`
- `znh5md export <file.h5> <file.xyz>` to export the file to `.xyz` or any other
supported file format
- `znh5md convert <file.xyz> <file.h5>` to save a `file.xyz` as `file.h5` in the
H5MD standard.
## More examples
A complete documentation is still work in progress. In the meantime, I can
recommend looking at the tests, especially `test_znh5md.py` to learn more about
slicing and batching.
Raw data
{
"_id": null,
"home_page": null,
"name": "znh5md",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": null,
"author": "zincwarecode",
"author_email": "zincwarecode@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/48/19/c21742a97804c12a4174c08853f2be3f0b1b5c7b0719725bdb2a191e30be/znh5md-0.2.0.tar.gz",
"platform": null,
"description": "[![zincware](https://img.shields.io/badge/Powered%20by-zincware-darkcyan)](https://github.com/zincware)\n[![Coverage Status](https://coveralls.io/repos/github/zincware/ZnH5MD/badge.svg?branch=main)](https://coveralls.io/github/zincware/ZnH5MD?branch=main)\n[![PyPI version](https://badge.fury.io/py/znh5md.svg)](https://badge.fury.io/py/znh5md)\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/zincware/ZnH5MD/HEAD)\n\n# ZnH5MD - High Performance Interface for H5MD Trajectories\n\nZnH5MD allows easy access to simulation results from H5MD trajectories. It\nprovides a Python interface and can convert existing data to H5MD files as well\nas export to other formats.\n\n```\npip install znh5md[\"dask\"]\n```\n\n## Example\n\nIn the following example we investigate an H5MD dump from LAMMPS with 1000 atoms\nand 201 configurations:\n\n```python\nimport znh5md\n\ntraj = znh5md.DaskH5MD(\"file.h5\", time_chunk_size=500, species_chunk_size=100)\n\nprint(traj.file.time_dependent_groups)\n# ['edges', 'force', 'image', 'position', 'species', 'velocity']\n\nprint(traj.force)\n# DaskDataSet(value=dask.array<array, shape=(201, 1000, 3), ...)\n\nprint(traj.velocity.slice_by_species(species=1))\n# DaskDataSet(value=dask.array<reshape, shape=(201, 500, 3), ...)\n\nprint(traj.position.value)\n# dask.array<array, shape=(201, 1000, 3), dtype=float64, chunksize=(100, 500, 3), ...>\n\n# You can iterate through the data\nfor item in traj.position.batch(size=27, axis=0):\n for x in item.batch(size=17, axis=1):\n print(x.value.compute())\n```\n\n## ASE Atoms\n\nYou can use ZnH5MD to store ASE Atoms objects in the H5MD format.\n\n> ZnH5MD does not support all features of ASE Atoms objects. It s important to\n> note that unsupported parts are silently ignored and no error is raised.\n\n> The ASEH5MD interface will not provide any time and step information.\n\n> If you have a list of Atoms with different PBC values, you can use\n> `znh5md.io.AtomsReader(atoms, use_pbc_group=True)`. This will create a `pbc`\n> group in `box/` that also contains `step` and `time`. This is not an official\n> H5MD specification so it can cause issues with other tools. If you don't\n> specify this, the pbc of the first atoms in the list will be applied.\n\n```python\nimport znh5md\nimport ase\n\natoms: list[ase.Atoms]\n\ndb = znh5md.io.DataWriter(filename=\"db.h5\")\n\ndb.add(znh5md.io.AtomsReader(atoms)) # or znh5md.io.ChemfilesReader\n\ndata = znh5md.ASEH5MD(\"db.h5\")\ndata.get_atoms_list() == atoms\n```\n\n## CLI\n\nZnH5MD provides a small set of CLI tools:\n\n- `znh5md view <file.h5>` to view the File using `ase.visualize`\n- `znh5md export <file.h5> <file.xyz>` to export the file to `.xyz` or any other\n supported file format\n- `znh5md convert <file.xyz> <file.h5>` to save a `file.xyz` as `file.h5` in the\n H5MD standard.\n\n## More examples\n\nA complete documentation is still work in progress. In the meantime, I can\nrecommend looking at the tests, especially `test_znh5md.py` to learn more about\nslicing and batching.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "High Performance Interface for H5MD Trajectories",
"version": "0.2.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "3c21dc5674fa3ca0769adc28730e6f9b8ede4f1769aa11e361d26547adf918fb",
"md5": "ea8faefc669e51a18ca238687d7121f5",
"sha256": "563e5c9b6a1e29864d31c4731416eb4b79f7acfee23cbe8cc53730b247d1125b"
},
"downloads": -1,
"filename": "znh5md-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ea8faefc669e51a18ca238687d7121f5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 20075,
"upload_time": "2024-05-17T11:18:38",
"upload_time_iso_8601": "2024-05-17T11:18:38.531185Z",
"url": "https://files.pythonhosted.org/packages/3c/21/dc5674fa3ca0769adc28730e6f9b8ede4f1769aa11e361d26547adf918fb/znh5md-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4819c21742a97804c12a4174c08853f2be3f0b1b5c7b0719725bdb2a191e30be",
"md5": "80efddc18e97348b744dc83635df4afc",
"sha256": "da60ca2e53f2d74cdc3a5954dbadae912973e4a29456329d2e6406f8d5e794bf"
},
"downloads": -1,
"filename": "znh5md-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "80efddc18e97348b744dc83635df4afc",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 17801,
"upload_time": "2024-05-17T11:18:39",
"upload_time_iso_8601": "2024-05-17T11:18:39.759680Z",
"url": "https://files.pythonhosted.org/packages/48/19/c21742a97804c12a4174c08853f2be3f0b1b5c7b0719725bdb2a191e30be/znh5md-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-05-17 11:18:39",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "znh5md"
}