I am trying to create a simple test HDF5 file with a dataset that has a compound datatype. I want 1 int,1 float and 1 array of floats. I can create the dataset with proper datatypes and can add data to the int and float entities. I can’t figure out how to add the data to the array entity. Code below. Suggestions are appreciated.
with h5py.File('test.h5', mode='w') as h5f:
h5f.create_group('/group1')
arr = np.random.random((10,2))
h5f.create_dataset('/group1/ds1', shape=(10,),
dtype=[ ('id' , int ), ('time', float), ('matrix', float, (10,2)) ] )
h5f['group1']['ds1']['id'] = [ i for i in range(1,11,1) ]
h5f['group1']['ds1']['time'] = [ i*0.125 for i in range(1,11,1) ]
h5f['group1']['ds1'][0,'matrix'][:,:] = arr[:,:]