hdf5


HDF5 is a "data model", a protocol for storing data. HDF5 files typically end in .h5. You need special tools to open the file and navigate within it. This page focuses on python.

Python

loading an h5 file: hf = h5py.File('./SXS_BBH_0305_Lev6_rhOverM_Asymptotic_GeometricUnits_CoM.h5', 'r')

View the contents of the h5 file: hf.items()
The output may look something like this:
[(u'Extrapolated_N2.dir', ), (u'Extrapolated_N3.dir', ), (u'Extrapolated_N4.dir', ), (u'OutermostExtraction.dir', )]
In this case, I am interested in the contents of a directory called OutermostExtraction, so I will go poke around in there.

View the contents of a directory:
hf_outermost = hf.get('OutermostExtraction.dir')
hf_outermost.values()
The output may look something like this:
[<HDF5 dataset "History.txt": shape (), type "|O">, <HDF5 dataset "Y_l2_m-1.dat": shape (13869, 3), type "<f8">, ...
In this case, I want to look at a specific array.

Load an array: h20 = np.array(hf_outermost.get('Y_l2_m0.dat'))


Back to Resources