nxmx


Namenxmx JSON
Version 0.0.4 PyPI version JSON
download
home_pageNone
SummaryRead HDF5 data conforming to the NXmx application definition of the NeXus format
upload_time2024-10-01 13:57:48
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseBSD 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": null,
    "name": "nxmx",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "NeXus, NXmx",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/32/b7/6cd51f43dd453fd3084dc631ac83ae3642b3a82b644f871a45f849060f27/nxmx-0.0.4.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.4",
    "project_urls": null,
    "split_keywords": [
        "nexus",
        " nxmx"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3d32f1b43d771f1f6d4772f9fa1bcce7da76f73438b6511d08d1324e64d24e8f",
                "md5": "6d544f3e642e4facb147be4b78f21f78",
                "sha256": "b9860916cc25926be46ffa8a122f49ec1156ac5cc924633f37995064e208b04d"
            },
            "downloads": -1,
            "filename": "nxmx-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6d544f3e642e4facb147be4b78f21f78",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 15906,
            "upload_time": "2024-10-01T13:57:47",
            "upload_time_iso_8601": "2024-10-01T13:57:47.206357Z",
            "url": "https://files.pythonhosted.org/packages/3d/32/f1b43d771f1f6d4772f9fa1bcce7da76f73438b6511d08d1324e64d24e8f/nxmx-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "32b76cd51f43dd453fd3084dc631ac83ae3642b3a82b644f871a45f849060f27",
                "md5": "8aef8aec78db6b02c71c9708cee2ffd8",
                "sha256": "baf205d803412675bb613b01217985347704940a774170dfe7114fe1bb5ca7d5"
            },
            "downloads": -1,
            "filename": "nxmx-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "8aef8aec78db6b02c71c9708cee2ffd8",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 22927,
            "upload_time": "2024-10-01T13:57:48",
            "upload_time_iso_8601": "2024-10-01T13:57:48.785074Z",
            "url": "https://files.pythonhosted.org/packages/32/b7/6cd51f43dd453fd3084dc631ac83ae3642b3a82b644f871a45f849060f27/nxmx-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-01 13:57:48",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "nxmx"
}
        
Elapsed time: 1.04458s