I have an hdf5 file containing a group with an attribute of the following format (h5dump):
ATTRIBUTE "PrioInfo" {
DATATYPE H5T_COMPOUND {
H5T_STRING {
STRSIZE 128;
STRPAD H5T_STR_NULLTERM;
CSET H5T_CSET_ASCII;
CTYPE H5T_C_S1;
} "FuncName";
H5T_STD_I32LE "FuncPrio";
}
Now i read this attribute, modify it and close the hdf5 file
>>> f =h5py.File("ooa_pop-Sapiens_ooa__500000.qdf", "r+")
>>> ooa = f['Populations']['Sapiens_ooa']
>>> ooa.attrs['PrioInfo']
array([('ConfinedMove', 8), ('Fertility', 2), ('GetOld', 8),
('MultiEvaluator', 5), ('NPPCapacity', 1), ('RandomPair', 3),
('Verhulst', 6), ('WeightedMove', 7)],
dtype=[('FuncName', 'S128'), ('FuncPrio', '<i4')])
>>> prios = ooa.attrs['PrioInfo']
>>> prios[6] = ('Verhulst2', 8)
>>> del ooa.attrs['PrioInfo']
>>> ooa.attrs['PrioInfo'] = prios
>>> f.flush()
>>> f.close()
In the h5dump of the modified hdf5 file the attibute's type has changed:
ATTRIBUTE "PrioInfo" {
DATATYPE H5T_COMPOUND {
H5T_STRING {
STRSIZE 128;
STRPAD H5T_STR_NULLPAD;
CSET H5T_CSET_ASCII;
CTYPE H5T_C_S1;
} "FuncName";
H5T_STD_I32LE "FuncPrio";
}
And all the strings are displayed by h5dump with over a hundred zeros of padding:
"ConfinedMove\000\000\000\000\000\000\000\000...\000\000\000"
How can i force the type of the string to have "STRPAD H5T_STR_NULLTERM" instead of "STRPAD H5T_STR_NULLPAD"?