attribute units

Greetings,

I am trying to figure out how to attach units to some metadata that I try to
store as attributes with an HDF5 data set.

Here is an example of the metadata I am talking about:
      <imageRaster>
        <numberOfRows>5923</numberOfRows>
        <numberOfColumns>6048</numberOfColumns>
        <rowSpacing units="s">6.06688654869458333E-09</rowSpacing>
        <columnSpacing units="s">1.21951219625771046E-04</columnSpacing>
       
<groundRangeResolution>2.14232081144331898E+00</groundRangeResolution>
        <azimuthResolution>1.10000002384185791E+00</azimuthResolution>
        <azimuthLooks>1.00000000000000000E+00</azimuthLooks>
        <rangeLooks>1.00000000000000000E+00</rangeLooks>
      </imageRaster>

Row and column spacing can be expressed in different ways: meters or
seconds. Without units attached these attributes remain ambiguous. I have
not seen anything in the documentation that explains how to do this with
attributes.

Any suggestions are greatly appreciated.

Cheers,
Rudi

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/attribute-units-tp1526251p1526251.html
Sent from the hdf-forum mailing list archive at Nabble.com.

I'm not sure you can attach attributes to attributes, so what I would do is this:
1) create a atomic types based on the type of data fields used in the metadata.
2) commit the atomic types to the file, named as the unit in question, e.g. "meters", "seconds", etc.
3) create a compound type to hold the metadata that uses said committed types for the fields, and commit *that* type to the file.
4) create attributes attached to the compound type, named after the field in the compound type, of the atomic types defined above.
5) attach the metadata attributes using the above committed compound type.

It's a bit complicated, but I think that's about the only way to do what you want at this time. It is, at least, decipherable on some level :slight_smile:

Here's a brief example in h5dump output:
      DATATYPE "Antenna" H5T_COMPOUND {
         H5T_ARRAY { [3] H5T_IEEE_F64BE } "delta XYZ";
      } ATTRIBUTE "delta XYZ" {
            DATATYPE "/Types/meters"
            DATASPACE SIMPLE { ( 1 ) / ( 1 ) }
            DATA {
            (0): 0
            }
         }

      DATATYPE "meters" H5T_IEEE_F64BE;

rudigens wrote:

···

Greetings,

I am trying to figure out how to attach units to some metadata that I try to
store as attributes with an HDF5 data set.

Here is an example of the metadata I am talking about:
      <imageRaster>
        <numberOfRows>5923</numberOfRows>
        <numberOfColumns>6048</numberOfColumns>
        <rowSpacing units="s">6.06688654869458333E-09</rowSpacing>
        <columnSpacing units="s">1.21951219625771046E-04</columnSpacing>
       <groundRangeResolution>2.14232081144331898E+00</groundRangeResolution>
        <azimuthResolution>1.10000002384185791E+00</azimuthResolution>
        <azimuthLooks>1.00000000000000000E+00</azimuthLooks>
        <rangeLooks>1.00000000000000000E+00</rangeLooks>
      </imageRaster>

Row and column spacing can be expressed in different ways: meters or
seconds. Without units attached these attributes remain ambiguous. I have
not seen anything in the documentation that explains how to do this with
attributes.

Any suggestions are greatly appreciated.

Cheers,
Rudi

John,

John Knutson-2 wrote:

I'm not sure you can attach attributes to attributes, so what I would do
is this:
1) create a atomic types based on the type of data fields used in the
metadata.
2) commit the atomic types to the file, named as the unit in question,
e.g. "meters", "seconds", etc.
3) create a compound type to hold the metadata that uses said committed
types for the fields, and commit *that* type to the file.
4) create attributes attached to the compound type, named after the
field in the compound type, of the atomic types defined above.
5) attach the metadata attributes using the above committed compound type.

It's a bit complicated, but I think that's about the only way to do what
you want at this time. It is, at least, decipherable on some level :slight_smile:

Here's a brief example in h5dump output:
      DATATYPE "Antenna" H5T_COMPOUND {
         H5T_ARRAY { [3] H5T_IEEE_F64BE } "delta XYZ";
      } ATTRIBUTE "delta XYZ" {
            DATATYPE "/Types/meters"
            DATASPACE SIMPLE { ( 1 ) / ( 1 ) }
            DATA {
            (0): 0
            }
         }

      DATATYPE "meters" H5T_IEEE_F64BE;

I guess compound data types it is. Pretty convoluted but perfectly
acceptable.

That would probably also the way to include valid value ranges and such that
the user could use to verify whether the attribute is reliable. Think in
terms of adding a schema to the XML that I originally posted. This is all
well worked out for attributes that you define for variables but not for
"metadata". The only reason I actually need this type of metadata is the
fact that the data can be in a geometry that is not in some form of map
projection.

Talking about map projections, what is the "standard procedure" to include
those parameters. Is the netcdf-4 CF convention acceptable?

Thanks for your support.

Cheers,
Rudi

···

--
View this message in context: http://hdf-forum.184993.n3.nabble.com/attribute-units-tp1526251p1530374.html
Sent from the hdf-forum mailing list archive at Nabble.com.