Creating an HDF File in IDL

The following IDL commands should be used to create a new HDF file:

HDF_OPEN: Call this procedure first to open an HDF file. The CREATE keyword must be set if you want to create a new file instead of open an existing one.

HDF_DFAN_ADDFDS: Optionally, add a file description.

HDF_DFAN_ADDFID: Optionally, add a file annotation.

Adding Data to an HDF File

The routines used to add data to an HDF file vary based on the interface model being used.

To add an 8-bit image (with or without a palette), use HDF_DFR8_ADDIMAGE or DFR8_PUTIMAGE.

To add a palette, use HDF_DFP_ADDPAL or HDF_DFP_PUTPAL.

To add a 24-bit image, use HDF_DF24_ADDIMAGE or HDF_DF24_PUTIMAGE.

To add a Scientific Dataset, use the following commands:

HDF_DFSD_SETINFO to insert information about the data (optional). HDF_DFSD_DIMSET to set dimension information.
HDF_DFSD_ADDDATA to insert the data.

To add a Multi-File Scientific Dataset, use the following commands:

HDF_SD_CREATE or HDF_SD_SELECT to create an SDS or select an existing one.
HDF_SD_DIMSET to set dimension information.
HDF_SD_ATTRSET to set attribute information.
HDF_SD_SETINFO to insert optional information about the data.
HDF_SD_ADDDATA to insert the data.
HDF_SD_SETEXTFILE to move the data to an external file (optional).
HDF_SD_ENDACCESS to end access to the SDS.

To add a Vdata, use the following commands:

HDF_VD_ATTACH to get a Vdata identifier.
HDF_VD_SETINFO to write information about the Vdata (optional). HDF_VD_FDEFINE to prepare non-trivial fields (optional).
HDF_VD_WRITE to write the Vdata.

To add a Vdata to a Vgroup, use the following commands:

HDF_VG_ATTACH to get a Vgroup identifier.
HDF_VG_SETINFO to set the Vgroup name and class (optional).
HDF_VG_INSERT to add the Vdata to a Vgroup.
HDF_VG_DETACH to close the Vgroup.
HDF_CLOSE to close the file.

HDF Examples

Two example files that demonstrate the use of the HDF routines can be found in the hdf_ncdf subdirectory of the examples subdirectory of the IDL distribution. The file prints a summary of basic information about an HDF file. The file creates a new HDF file and then reads the information back from that file.