Adding header attributes to an hdf5 file

I'm trying to add an attribute to a group of my hdf5 file for a citation so
that when I call the header of the file (h5dump -H example.h5) it shows the
attribute name 'Citation' as well as the text of the citation in my script.
A comparison would be using netcdf files you can call (ncdump -h example.nc)
to show such a description. I am programming in python, so far the only
result I have been able to get from calling the header is the following:

ATTRIBUTE "Citation" {
DATATYPE H5T_STRING {
STRSIZE 126;
STRPAD H5T_STR_NULLTERM;
CSET H5T_CSET_ASCII;
CTYPE H5T_C_S1;
}
DATASPACE SCALAR
}

So it shows that I'm trying to use a string, but instead of showing the
contents of that string it just shows the variable's metadata.

Thanks in advance for the help!

For h5dump, if you add the –A option (h5dump –AH example.h5) it will show the contents of the string – it shows the values of all the attributes in addition to the metadata that you see with –H. If you want the value of a specific attribute, -a <path to attribute> is an available h5dump option.

I don’t know how this translates to python, but if you use –AH with h5dump you should be able to tell that the actual string is in the file header.

···

From: Hdf-forum [mailto:hdf-forum-bounces@lists.hdfgroup.org] On Behalf Of Pat Tresslar
Sent: Friday, August 08, 2014 9:53 AM
To: hdf-forum@lists.hdfgroup.org
Subject: [Hdf-forum] Adding header attributes to an hdf5 file

I'm trying to add an attribute to a group of my hdf5 file for a citation so that when I call the header of the file (h5dump -H example.h5) it shows the attribute name 'Citation' as well as the text of the citation in my script. A comparison would be using netcdf files you can call (ncdump -h example.nc<http://example.nc>) to show such a description. I am programming in python, so far the only result I have been able to get from calling the header is the following:

ATTRIBUTE "Citation" {
DATATYPE H5T_STRING {
STRSIZE 126;
STRPAD H5T_STR_NULLTERM;
CSET H5T_CSET_ASCII;
CTYPE H5T_C_S1;
}
DATASPACE SCALAR
}
So it shows that I'm trying to use a string, but instead of showing the contents of that string it just shows the variable's metadata.
Thanks in advance for the help!