
I'm struggling generate the .h5 file of my data like the format shown in the attached figure.
I don't know how to set an "array" in each cell.
I have checked the manual of h5py but I still confused what kind of 'dtype' should I use
or it maybe not simple write like 'dset1 = grp1.create_dataset("Bnx", data = Bn1, dtype='float64')'
So, how can I make it?
Any help is appreciated.
HDF5 supports some data types that have no direct NumPy equivalent. For example, there isn't a NumPy dtype for variable-length strings, variable length data (aka "ragged arrays") or enumerated types references. h5py extends the dtype system with "special types" to tell HDF5 how to store this data. Ref: h5py docs: Special types (There is also an "opaque data type" that can be used to store a few other dtypes, but can NOT be used with object arrays.)
You can use the variable length data dtype to wrangle arrays into a dataset. (Note: the saved data is not an array like your HDFView image. Metadata is attached to the dataset to tell h5py about its contents.) When reading the data, single elements are read as NumPy arrays and slices return an object array whose members are arrays.
Simple example below: