HDF5 Data File Tree Structure : h5tree
#
Print the tree structure of any HDF5 file.
- Note:
The tree subcommand replaces the now-legacy structure subcommand and also replaces the h5toText program from the spec2nexus project.
How to use h5tree#
Print the HDF5 tree of a file:
$ punx tree path/to/file/hdf5/file.hdf5
the help message:
1 [linux,512]$ punx tree -h
2 usage: punx tree [-h] [-a] [-m MAX_ARRAY_ITEMS] infile
3
4 positional arguments:
5 infile HDF5 or NXDL file name
6
7 optional arguments:
8 -h, --help show this help message and exit
9 -a Do not print attributes of HDF5 file structure
10 -m MAX_ARRAY_ITEMS, --max_array_items MAX_ARRAY_ITEMS
11 maximum number of array items to be shown
Example#
Here’s an example tree view of a NeXus HDF5 data file (writer_1_3.h5 from the NeXus documentation [1]):
1 [linux,512]$ punx tree data/writer_1_3.hdf5
2 data/writer_1_3.hdf5 : NeXus data file
3 Scan:NXentry
4 @NX_class = NXentry
5 data:NXdata
6 @NX_class = NXdata
7 @signal = counts
8 @axes = two_theta
9 @two_theta_indices = [0]
10 counts:NX_INT32[31] = [1037, 1318, 1704, '...', 1321]
11 @units = counts
12 two_theta:NX_FLOAT64[31] = [17.926079999999999, 17.925909999999998, 17.925750000000001, '...', 17.92108]
13 @units = degrees
source code documentation#
Describe the tree structure of any HDF5 file
|
Describe the tree structure of any HDF5 file |
- class punx.h5tree.Hdf5TreeView(filename)[source]#
Describe the tree structure of any HDF5 file
Example usage showing default display:
mc = Hdf5TreeView(filename) mc.array_items_shown = 5 show_attributes = False txt = mc.report(show_attributes)
- report(show_attributes=True)[source]#
Return the structure of the HDF5 file in a list of strings.
The work of parsing the datafile is done in this method.
The hierarchy of the file is represented by indentation using spaces. Attributes are signified using
@
. Group/dataset names are separated from their datatypes using:
. A preview of the value of an item follows the=
. For example:1 [ 2 '/tmp/tmpb7iqqapu.hdf5', 3 ' external_data:NXdata', 4 ' @NX_class = NXdata', 5 ' @signal = x', 6 ' x:int64 = 0', 7 ]