import h5py import numpy as np # Open hdf5 file in read mode h5f = h5py.File('bn_dist_z2.h5', 'r') # Extract the thermal properties thermal_properties = h5f['Thermal_properties'].value # Unpack information, note that there is a column with identifiers identifiers, logT0s, gammas, lam_Ps = np.transpose(thermal_properties) # Parameters were saved as string, so let's transform them into np arrays of floats logT0s, gammas, lam_Ps = np.array(logT0s, dtype=float), np.array( gammas, dtype=float), np.array(lam_Ps, dtype=float) # Any desired b-N distribution can be retrieved using the identifiers. # For instance the identifier with index 20 is index = 20 print('Id : {}'.format(identifiers[index].decode())) # With corresponding thermal Parameters print('logT0 = {}, gamma = {}, lambdaP {}'.format(logT0s[index], gammas[index], lam_Ps[index])) # To retrieve the corresponding logb vs. logNHI distribution simply call the h5f object # using the identifier as key bN_data = h5f[identifiers[index]].value h5f.close()