Obtaining Information on Existing HDF Files


As mentioned previously, a single HDF file may contain more than one scientific data set (or images, tables, etc.). Within the SD interface (and other interfaces for the various data types), there are routines that can be called within short programs, C or FORTRAN, which, among other operations, help the user do the following:


Previous Main Topic

Next Main Topic

Return to Main Topics


Determine the contents of an HDF file

Before reading an HDF file, it might be necessary for the user to determine the number of data sets within the file, and the attributes of the file itself.

After initializing and accessing the Application interface (in this case, the SD and GR interfaces for, respectively, scientific data sets and images (with associated palettes), this can be done using the following statements:

	SDfileinfo(sd_id, n_datasets, n_file_attr); (C)
GRfileinfo(gr_id,n_images,nfile_attr)
and
sffinfo(sd_id, n_datasets, n_file_attr) (FORTRAN)
mgfinfo(gr_id,n_images,n_file_attr)

where

	sd_id= file id number
gr_id= GR interface identifier
n_datasets= Number of data sets within the file n_file_attr= number of file attribute
n_images= number of images within the file

Return to top

Obtain information on individual data sets

Before reading a particular data set or image from an HDF file, the user may need to know the rank, dimension sizes, data type, and number of attributes of the data array.

After the user has initiated and accessed the interface (for example, the GR interface for images and the SD interface for data arrays) and selected the data set by using the sfselect/SDselect (data set) or mgselct/GRselect (image) in a short FORTRAN (C) program, this information can be retrieved using the following calls:

	SDgetinfo (sds_id, name, rank, dim_sizes, num_type, attributes); 	(C)
GRgetinfo(ri_id,name,n_comps,data_type,interlace_mode,dim_sizes,n_attrs)
and
sfginfo (sds_id, name, rank, dim_sizes, num_type, attributes) (FORTRAN)
mgginf(ri_id,name,n_comps,data_type,interlace_mode,dim_sizes,n_attrs)

where

	sds_id = data set id number
ri_id = raster image id number
name = name of corresponding data set
rank = rank of corresponding data set
dim_sizes = dimensions of corresponding data set
num_type = data type of corresponding data set
data_type = data type of corresponding image
attributes = number of attributes of corresponding data set
n_comps = number of components
interlace_mode = interlacing mode of data
n_attrs = number of sttributes

Return to top