-
Notifications
You must be signed in to change notification settings - Fork 1
/
Simple_HDF5_Hierarchy_Reader.py
81 lines (70 loc) · 2.64 KB
/
Simple_HDF5_Hierarchy_Reader.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
"""
Programm: Simple_HDF5_Hierarchy_Reader
Author: Daniel Grassinger
License: Modified BSD License (also known as New or Revised BSD)
Date: 25.09.2015
Python: 2.7.6
Description: This little script read a HDF5-File and prints all
the groups and datasets and attributes as a tree.
Usage: readkey(file, startFolder(most times "/"), indentation(as a string) )
"""
def readkeys(f, folder, ebene):
#print "Folder: "+folder
try:
for attr in f[folder].attrs.keys():
print ebene +"Attribut: "+ attr
except AttributeError:
pass
try:
for key in f[folder].keys():
print ebene + "Gruppe: "+ key
readkeys(f,folder+"/"+key, ebene+" ")
except AttributeError:
pass
"""
example:
f = h5py.File("data00000400.h5")
readkeys(f,"/"," ")
example output:
Attribut: openPMD
Attribut: openPMDextension
Attribut: software
Attribut: softwareVersion
Attribut: date
Attribut: meshesPath
Attribut: particlesPath
Attribut: iterationEncoding
Attribut: iterationFormat
Attribut: basePath
Gruppe: data
Gruppe: 400
Attribut: time
Attribut: dt
Attribut: timeUnitSI
Gruppe: fields
Attribut: fieldSolver
Attribut: fieldBoundary
Attribut: particleBoundary
Attribut: currentSmoothing
Attribut: currentSmoothingParameters
Attribut: chargeCorrection
Gruppe: B
Attribut: unitDimension
Attribut: timeOffset
Attribut: geometry
Attribut: gridSpacing
Attribut: axisLabels
Attribut: dataOrder
Attribut: gridUnitSI
Attribut: gridGlobalOffset
Attribut: fieldSmoothing
Gruppe: x
Attribut: unitSI
Attribut: position
Gruppe: y
Attribut: unitSI
Attribut: position
Gruppe: z
Attribut: unitSI
Attribut: position
"""