Skip to main content

Read HDF5 data conforming to the NXmx application definition of the NeXus format

Project description

Read NXmx-flavour NeXus HDF5 data in Python

PyPI release Supported Python versions Code style: black

This package provides a neat and tidy Python interface for reading data from HDF5 files that are structured according to the NXmx application definition of the NeXus standard.

Installation

python-nxmx is available as nxmx on PyPI, so you just need Pip.

$ pip install nxmx

Getting started

If you have an HDF5 file in NXmx format, inspecting it with h5ls will look something like this:

$ 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:

import h5py
import nxmx

with h5py.File("my-nxmx-file.h5") as f:
    nxmx_data = nxmx.NXmx(f)

A slightly more detailed example

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.

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

nxmx-0.0.7.tar.gz (44.4 kB view details)

Uploaded Source

Built Distribution

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

nxmx-0.0.7-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file nxmx-0.0.7.tar.gz.

File metadata

  • Download URL: nxmx-0.0.7.tar.gz
  • Upload date:
  • Size: 44.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nxmx-0.0.7.tar.gz
Algorithm Hash digest
SHA256 39391f66840b3cb3a3576f3716e37aebb087b0824c2a7aeffa7914e5661e97ae
MD5 14ac61c8bbfa5191941ef57888eebf66
BLAKE2b-256 90e4196e03d40c23351356a389ece25c18cdc2f896aaff465e77d1215afaaca3

See more details on using hashes here.

Provenance

The following attestation bundles were made for nxmx-0.0.7.tar.gz:

Publisher: publish-to-pypi.yml on dials/nxmx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file nxmx-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: nxmx-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nxmx-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f902feb5e9e64113850f421d43889ade9a2656b4fb130b16130611030e64214d
MD5 fb8472d0dd2cab73c3231478ffaa246c
BLAKE2b-256 970deada5e428d97fba92492c3e25ca5adbd9c16961bdbd699174251e498fb2e

See more details on using hashes here.

Provenance

The following attestation bundles were made for nxmx-0.0.7-py3-none-any.whl:

Publisher: publish-to-pypi.yml on dials/nxmx

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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