[Top] [Prev] [Next]

15.4 Converting Floating-Point Data to SDS or RIS8: fp2hdf

15.4.1 General Description

The fp2hdf utility converts 32-bit floating-point arrays from either text files or 32-bit HDF floating-point scientific data sets to either 8-bit HDF raster image sets or 32-bit floating-point HDF scientific data sets, or both, and stores the results in an HDF file. (See Figure 15a.) The images can be scaled on a user-specified mean value.

The term scale is used to refer to the area between points on the axes. If these gaps are of equal size, a uniform scale is specified - for example, "1.0, 2.0, 3.0, . . . ". In an HDF file, scales may be omitted, but in a text file (as in the text file shown below) they must be included.

FIGURE 15a - The fp2hdf Utility

15.4.2 Command-Line Syntax

The syntax of fp2hdf is as follows.

fp2hdf input-filename [-o output-filename] [-r] [-f] [-e | -i] horizontal-resolution vertical-resolution [-p palette-filename] [-m mean] 
The input-filename parameter is the name of the file containing the unconverted data set in HDF format. If the format is text, see the discussion on the following page about how it must be organized.

The output-filename parameter is the name of the file containing the converted data set in HDF format. Depending on the output options output-filename contains a scientific data set and/or raster image set for each of the data sets in the input files.

-e Expand

Expands floating-point data using pixel replication (Default if -i option is specified)

-r Raster

Stores the data as a raster image set in the output file.

-f Float

Stores the data as a scientific data set in the output file. (Default if the "-r" option is not specified)

-i Interpolation

Applies bilinear interpolation when expanding floating-point data. The horizontal-resolution and vertical-resolution parameters are, respectively, the horizontal and vertical resolution of the image

-p Palette

Store the palette with the image. The palette-filename parameter is the file name of the file containing the palette data.

-m Mean

Cause the data to be scaled around the specified mean (supplied by the mean parameter) when generating the image, according to the following formulae:

newmax = mean + 0.5*max(abs(max-mean), abs(mean-min)

newmin = mean + 0.5*max(abs(max-mean), abs(mean-min))

The -e and the -i flags cannot be used simultaneously. Either pixel interpolation or bilinear interpolation can be chosen for image expansion, but not both.

If the -i option is chosen, the expanded image must have dimensions that are greater than or equal to the dimensions of the original data set.

An optional palette can accompany the image by loading it from an HDF file that contains a palette.

Data from several input files (with one set per input file) are stored as several data sets and/or images in one output file. A shell script can be used as another option in calling fp2hdf repeatedly to convert data from multiple input files to their corresponding output HDF files.

If an HDF file is used for input, it must contain an SDS. The SDS need only contain a dimension record and the data, but if it also contains maximum and minimum values and/or scales for the horizontal and vertical axes, these will be used as well.

If a text file is used for input, it must adhere to the following format.

number of rows number of columns
maximum value minimum value
scale for the vertical axis in an array
scale for the horizontal axis in an array
data-element-1 data-element-2 data-element-3
...
The arrays that contain the scale for the vertical and horizontal axes must have a size equal to the values specified in the number-of-rows and number-of-columns positions, respectively. The data elements are floating-point data and are assumed to be ordered by rows, left-to-right and top-to-bottom.

15.4.3 Examples

This is the fp2hdf command-line syntax used to convert floating-point data in the file named "infile1.txt" to the SDS format, and to store it as an SDS in the HDF output file "outfile1".

fp2hdf infile1.txt -o outfile1 
This fp2hdf command is used to convert floating-point data in the file named "infile2.txt" to an 8-bit raster image and store it in RIS8 format in the HDF output file named "outfile2".

fp2hdf infile2 -o outfile2 -r 
This fp2hdf command is used to convert floating-point data in the file named "infile3.txt" to the RIS8 and SDS formats and store both converted data groups in the HDF output file "outfile3".

fp2hdf infile3.txt -o outfile3 -r -f
This fp2hdf command is used to convert floating-point data in the file named "infile4.txt" to a 500 x 600 raster image, storing the RIS8 in the HDF file "outfile4". This also stores the palette data read from the file name "palfile" with the image data.

fp2hdf input4.txt -o outfile4 -r -e 500 600 -p palfile
This fp2hdf command is used to convert floating-point data in all files whose names begin with the letter "f" to 500 x 600 RIS8 images and store them in the output file "output5".

fp2hdf f* -o outfile5 -r -i 500 600


[Top] [Prev] [Next]

hdfhelp@ncsa.uiuc.edu
HDF User's Guide - 07/21/98, NCSA HDF Development Group.