读取符合NXmx应用定义的NeXus格式的HDF5数据
项目描述
在Python中读取符合NXmx风格的NeXus HDF5数据
此包提供了一个整洁的Python接口,用于读取符合HDF5文件的结构,这些文件按照NXmx应用定义和NeXus标准。
安装
python-nxmx
在PyPI上作为nxmx
提供,因此您只需要Pip。
$ pip install nxmx
入门
如果您有一个NXmx格式的HDF5文件,使用h5ls
检查它将类似于以下内容
$ 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. ...
使用nxmx
,您可以在Python中这样访问NXmx数据
import h5py
import nxmx
with h5py.File("my-nxmx-file.h5") as f:
nxmx_data = nxmx.NXmx(f)
一个更详细的示例
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.
项目详情
下载文件
下载适用于您的平台文件。如果您不确定选择哪个,请了解更多关于安装包的信息。
源分发
nxmx-0.0.4.tar.gz (22.9 kB 查看哈希值)
构建分发
nxmx-0.0.4-py3-none-any.whl (15.9 kB 查看哈希值)
关闭
nxmx-0.0.4.tar.gz 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | baf205d803412675bb613b01217985347704940a774170dfe7114fe1bb5ca7d5 |
|
MD5 | 8aef8aec78db6b02c71c9708cee2ffd8 |
|
BLAKE2b-256 | 32b76cd51f43dd453fd3084dc631ac83ae3642b3a82b644f871a45f849060f27 |
关闭
nxmx-0.0.4-py3-none-any.whl 的哈希值
算法 | 哈希摘要 | |
---|---|---|
SHA256 | b9860916cc25926be46ffa8a122f49ec1156ac5cc924633f37995064e208b04d |
|
MD5 | 6d544f3e642e4facb147be4b78f21f78 |
|
BLAKE2b-256 | 3d32f1b43d771f1f6d4772f9fa1bcce7da76f73438b6511d08d1324e64d24e8f |