Name | nxmx JSON |
Version |
0.0.3
JSON |
| download |
home_page | |
Summary | Read HDF5 data conforming to the NXmx application definition of the NeXus format |
upload_time | 2023-08-11 17:19:15 |
maintainer | |
docs_url | None |
author | |
requires_python | >=3.9 |
license | BSD 3-Clause License |
keywords |
nexus
nxmx
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Read NXmx-flavour NeXus HDF5 data in Python
[![PyPI release](https://img.shields.io/pypi/v/nxmx.svg)](https://pypi.python.org/pypi/nxmx)
[![Supported Python versions](https://img.shields.io/pypi/pyversions/nxmx.svg)](https://pypi.org/project/nxmx)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)]( https://github.com/ambv/black)
This package provides a neat and tidy Python interface for reading data from [HDF5 files](https://www.hdfgroup.org/solutions/hdf5/) that are structured according to the [NXmx application definition](https://manual.nexusformat.org/classes/applications/NXmx.html) of the [NeXus standard](https://www.nexusformat.org/).
## Installation
`python-nxmx` is available as `nxmx` on PyPI, so you just need Pip.
```Bash
$ pip install nxmx
```
## Getting started
If you have an HDF5 file in NXmx format, inspecting it with `h5ls` will look something like this:
```Bash
$ h5ls -r my-nxmx-file.h5
/ Group
/entry Group
/entry/data Group
/entry/definition Dataset {SCALAR}
/entry/end_time Dataset {SCALAR}
/entry/end_time_estimated Dataset {SCALAR}
/entry/instrument Group
/entry/instrument/beam Group
/entry/instrument/beam/incident_beam_size Dataset {2}
/entry/instrument/beam/incident_wavelength Dataset {SCALAR}
/entry/instrument/beam/total_flux Dataset {SCALAR}
/entry/instrument/detector Group
... etc. ...
```
With `nxmx`, you can access the NXmx data in Python like this:
```Python
import h5py
import nxmx
with h5py.File("my-nxmx-file.h5") as f:
nxmx_data = nxmx.NXmx(f)
```
## A slightly more detailed example
```Python
import h5py
import nxmx
with h5py.File("my-nxmx-file.h5") as f:
nxmx_data = nxmx.NXmx(f)
# Explore the NXmx data structure.
entry, *_ = nxmx_data.entries
print(entry.definition) # Prints "NXmx".
instrument, *_ = entry.instruments
detector, *_ = instrument.detectors
# Get the h5py object underlying an instance of a NX class.
entry_group = entry._handle # entry_group == f["entry"]
# Find instances of a given NX class in a h5py.Group.
beams = nxmx.find_class(instrument._handle, "NXbeam")
# The equivalent for more than one NX class.
beams, detectors = nxmx.find_classes(instrument._handle, "NXbeam", "NXdetector")
# Query attributes of an object in the normal h5py way.
# Suppose out detector has a transformation called "det_z".
transformations, *_ = nxmx.find_class(detector._handle, "NXtransformations")
attrs = transformations["det_z"].attrs # Get the attributes of the "det_z" dataset.
```
Raw data
{
"_id": null,
"home_page": "",
"name": "nxmx",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": "",
"keywords": "NeXus,NXmx",
"author": "",
"author_email": "",
"download_url": "https://files.pythonhosted.org/packages/38/6a/3a2b90433f7b53755605b6b72b5e1726f08e048205812f39b8b00cb45988/nxmx-0.0.3.tar.gz",
"platform": null,
"description": "# Read NXmx-flavour NeXus HDF5 data in Python\n\n[![PyPI release](https://img.shields.io/pypi/v/nxmx.svg)](https://pypi.python.org/pypi/nxmx)\n[![Supported Python versions](https://img.shields.io/pypi/pyversions/nxmx.svg)](https://pypi.org/project/nxmx)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)]( https://github.com/ambv/black)\n\nThis package provides a neat and tidy Python interface for reading data from [HDF5 files](https://www.hdfgroup.org/solutions/hdf5/) that are structured according to the [NXmx application definition](https://manual.nexusformat.org/classes/applications/NXmx.html) of the [NeXus standard](https://www.nexusformat.org/).\n\n## Installation\n`python-nxmx` is available as `nxmx` on PyPI, so you just need Pip.\n```Bash\n$ pip install nxmx\n```\n\n## Getting started\n\nIf you have an HDF5 file in NXmx format, inspecting it with `h5ls` will look something like this:\n```Bash\n$ h5ls -r my-nxmx-file.h5 \n/ Group\n/entry Group\n/entry/data Group\n/entry/definition Dataset {SCALAR}\n/entry/end_time Dataset {SCALAR}\n/entry/end_time_estimated Dataset {SCALAR}\n/entry/instrument Group\n/entry/instrument/beam Group\n/entry/instrument/beam/incident_beam_size Dataset {2}\n/entry/instrument/beam/incident_wavelength Dataset {SCALAR}\n/entry/instrument/beam/total_flux Dataset {SCALAR}\n/entry/instrument/detector Group\n\n... etc. ...\n```\nWith `nxmx`, you can access the NXmx data in Python like this:\n```Python\nimport h5py\nimport nxmx\n\nwith h5py.File(\"my-nxmx-file.h5\") as f:\n nxmx_data = nxmx.NXmx(f)\n```\n\n## A slightly more detailed example\n```Python\nimport h5py\nimport nxmx\n\nwith h5py.File(\"my-nxmx-file.h5\") as f:\n nxmx_data = nxmx.NXmx(f)\n # Explore the NXmx data structure.\n entry, *_ = nxmx_data.entries\n print(entry.definition) # Prints \"NXmx\".\n instrument, *_ = entry.instruments\n detector, *_ = instrument.detectors\n \n # Get the h5py object underlying an instance of a NX class.\n entry_group = entry._handle # entry_group == f[\"entry\"]\n\n # Find instances of a given NX class in a h5py.Group.\n beams = nxmx.find_class(instrument._handle, \"NXbeam\")\n # The equivalent for more than one NX class.\n beams, detectors = nxmx.find_classes(instrument._handle, \"NXbeam\", \"NXdetector\")\n\n # Query attributes of an object in the normal h5py way.\n # Suppose out detector has a transformation called \"det_z\".\n transformations, *_ = nxmx.find_class(detector._handle, \"NXtransformations\")\n attrs = transformations[\"det_z\"].attrs # Get the attributes of the \"det_z\" dataset.\n```\n",
"bugtrack_url": null,
"license": "BSD 3-Clause License",
"summary": "Read HDF5 data conforming to the NXmx application definition of the NeXus format",
"version": "0.0.3",
"project_urls": null,
"split_keywords": [
"nexus",
"nxmx"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "278c27f4b1d726b056f132cdef7f28fbd5805b862042d01f72150e28186ac69e",
"md5": "e1e4fa4cbe8ffdb646e593394d07ced7",
"sha256": "1bfe91db2849055cffe706e4b0dcdfcbf66c07636f1d9c86a255a28f99a06eb1"
},
"downloads": -1,
"filename": "nxmx-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e1e4fa4cbe8ffdb646e593394d07ced7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 15170,
"upload_time": "2023-08-11T17:19:13",
"upload_time_iso_8601": "2023-08-11T17:19:13.748629Z",
"url": "https://files.pythonhosted.org/packages/27/8c/27f4b1d726b056f132cdef7f28fbd5805b862042d01f72150e28186ac69e/nxmx-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "386a3a2b90433f7b53755605b6b72b5e1726f08e048205812f39b8b00cb45988",
"md5": "feaa725d431c7723ac55da1d25ccd012",
"sha256": "82e568a46c8e475be5de3479cd19f2db18b8e4e479254c447e907da6713d3e51"
},
"downloads": -1,
"filename": "nxmx-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "feaa725d431c7723ac55da1d25ccd012",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 22097,
"upload_time": "2023-08-11T17:19:15",
"upload_time_iso_8601": "2023-08-11T17:19:15.201697Z",
"url": "https://files.pythonhosted.org/packages/38/6a/3a2b90433f7b53755605b6b72b5e1726f08e048205812f39b8b00cb45988/nxmx-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-11 17:19:15",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "nxmx"
}