>>>fSM = h5py.File(filenames, 'r')
>>>fSM.keys()
<KeysViewHDF5 [Frequency', 'cycle']>
>>>fSM['Frequency']
<HDF5 dataset "baseFrequency": shape (), type "<f8">
>>>fSM['acquisition']['drivefield']['baseFrequency']._is_empty
False
<HDF5 dataset "baseFrequency": shape (), type "|f8">, what is the meaning about 'shape()'? blank? And, how to get some values of specific keys, correctly? Thanks!!!
HDF5 using in Python
Have you read the h5py documentation? HDF5 uses groups and datasets to organize the data. Groups are like file folders and datasets are the data files.
keys()
gives the
names of the objects in group.shape
is the
shape of the dataset.This is what your code does:
fSM.keys()
prints the root level objects (which could be groups or
datasets).fSM['Frequency']
prints the 'Frequency' object attributes. It is a
dataset of float values. However, based on shape ()
, it has an undefined shape (and no data values). It's strange (to me) that it prints the dataset name as "baseFrequency" when it is named 'Frequency'. That will take some diagnosis (assuming it's not a typo in your post.fSM['acquisition']['drivefield']['baseFrequency']._is_empty
references a dataset named 'baseFrequency' that is in group
'drivefield' that is a group under the 'acquisition' group. ._is_empty
checks to see if it is empty. The False
value indicates it is not empty.Before you start coding you need to understand the file schema (groups and datasets). The easist way to do that (for a new user) is to open the file with the HDFView utility from The HDF Group. That way you can "see" the file structure. Otherwise you need to write some code to inspect the schema.