def from_hdf5(fpath, dataset="data"):
"""Loading data from hdf5 files that was stored by \
:meth:`~wradlib.io.to_hdf5`
Parameters
----------
fpath : string
path to the hdf5 file
dataset : string
name of the Dataset in which the data is stored
"""
f = h5py.File(fpath, mode="r")
# Check whether Dataset exists
if dataset not in f.keys():
print("Cannot read Dataset <%s> from hdf5 file <%s>" % (dataset, f))
f.close()
sys.exit()
data = np.array(f[dataset][:])
# get metadata
metadata = {}
for key in f[dataset].attrs.keys():
metadata[key] = f[dataset].attrs[key]
f.close()
return data, metadata
评论列表
文章目录