Attributes and Metadata for HDF


The HDF library allows for several ways for the user to provide metadata (data about data) information for the HDF file, data set or image to be written or read. This information is not a requirement for HDF files. The most commonly used method or routine within the HDF library for providing metadata are "Attributes" or text- strings which describe the HDF file, data set (SDS array) or dimensions. There are two types of attributes used in HDF which can be defined in the user's calling program:

Both the predefined and user-defined attributes may be accessed using the general attribute routines for user-defined attributes provided by the HDF library. On the other hand, the predefined attributes may only be accessed using the routines specifically tailored for the predefined attributes (see above). As a result, in later sections, we will focus on using the general attribute routines developed for user-defined attributes.


Previous Main Topic

Next Main Topic

Return to Main Topics

User-defined attributes

User-defined attributes are optional information that can be given and attached to HDF files, scientific data sets, and dimensions (only in the SD API). They are referred to, respectively, as file attributes, array attributes, and dimension attributes. These attributes are at the discretion of, and to be defined by, the user.

The SD interface uses the same functions to access all of the three types of attributes, with the difference being the use and definition of the different identifiers (i.e., file ids for file attributes, SDS ids for array attributes, and dimension ids for dimension attributes). After the proper identifier is obtained, the user can then create and define his attribute (labels, formats, coordinate system, etc.). The attributes in the GR interface work in a similar fashion with indentifiers provided for both the interface or the image in question.

More on user-defined attributes and how to define them is provided in Section 15: Writing a SDS to an HDF File.

Return to top

Predefined attributes

Predefined attributes are attributes that use previously defined or reserved labels and data types. While the user-defined attributes must be defined by the user, the predefined attributes need not be defined and are already understood by the HDF library. However, in the SD API, predefined attributes can only be assigned to scientific data sets (SDS) and dimensions (not files, like is possible with user-defined attributes). In the GR API, there is only one predefined attribute, FILL_ATTR, which fills the "empty" data of an image with default values.

There are seven main predefined attributes:

For labels:

long_name

For units:

units

For formats:

format

For coordinate systems:

cordsys

For Value ranges:

valid_range

For Fill values:

FILL_ATTR, _FILL_VALUE

For Calibration:

scale_factor, scale_factor_err, add_offset, add_offset_err, calibrated_nt

 

The predefined attributes can be accessed by the SD interface in the same general fashion as the user-defined attributes or by using routines developed specifically for the predefined attributes. The ""general"" attribute routines are recommended in most cases.

 

Return to top