[Top] [Prev] [Next]

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

15.4.1 General Description

The fp2hdf utility converts floating-point data from either text files, 32-bit or 64-bit native floating point data files, or HDF floating-point scientific data sets to either 8-bit HDF raster image datasets or HDF floating-point 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 refers to the spacing between points on the axes. If these spacing is uniform, i.e., the gaps are of equal size, a uniform scale is specified -- for example, 1.0, 2.0, 3.0, . . .. Scales may be omitted in an HDF file; they must be included in a text file.

FIGURE 15a - The fp2hdf Utility

15.4.2 Command-line Syntax

The syntax of fp2hdf is as follows.

fp2hdf input-filename [input-filename] -o output-filename 
[-r] [-f]
[-e|-i horizontal-resolution vertical-resolution depth]
[-p palette-filename]
[-m mean]
fp2hdf -h 
The input-filename parameter is the name of the file containing the unconverted data set. The file may contain a single two-dimensional or three-dimensional floating point array in ASCII text, native floating point, or HDF SDS format. 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 each axis, these will be used. If the format is ASCII text or native floating point, see the discussion at the end of this section regarding the required structure of the data.

The output-filename parameter is the name of the output 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.

The fp2hdf options and parameters are described in Table 15E.

TABLE 15E
-h

Help:

Prints a summary of usage, then exits.

-r

Raster:

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

-f

Float:

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

32-bit input data will be stored to a 32-bit SDS; 64-bit input data will be stored to a 64-bit SDS.

-e

Expand:

Expands the floating point data via pixel replication to produce the output image(s). (Default if -i option is specified.)

horizontal-resolution and vertical-resolution specify the horizontal and vertical resolutions of the image(s) to be produced. The optional parameter depth specifies the number of images or depth planes, and is used only with 3D input data.

Cannot be used with the -i option.

-i

Interpolation:

Applies bilinear or trilinear interpolation when expanding floating-point data.

The values of the horizontal-resolution , vertical-resolution, and depth parameters must be greater than or equal to the dimensions of the original dataset.

If max, maximum value, and min, minimum value, are supplied in the input file, this option clips values that are greater than max or less then min, setting them to the max and min, respectively.

Cannot be used with the -e option.

-p

Palette:

Stores the palette with the image. The palette-filename parameter names the file containing the palette data. This may be an HDF file containing a palette, or a file containing a raw palette.

-m

Mean:

Causes the data to be scaled around the specified mean (supplied by the mean parameter) when generating the image. The new maximum and minimum values, newmax and newmin, are specified by 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))

fp2hdf Options and Parameters

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.

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 the input file format is ASCII text or native floating point, the data must be presented in an ordered set of fields as listed in Table 15F.

TABLE 15F
format

Must conain exactly one format designator:
TEXT, FP32, or FP64.

number_of_planes

Dimension of the depth axis. Must contain the value 1 for two-dimensional input.

number_of_rows

Dimension of the vertical axis.

number_of_columns

Dimension of the horizontal axis.

maximum_value

Maximum data value.

minimum_value

Minimum data value.

[plane1 plane2 plane3 ...]

Scales for the depth axis.

row1 row2 row3 ...

Scales for the vertical axis.

col1 col2 col3 ...

Scales for the horizontal axis.

data1 data2 data3 ...

Floating-point data ordered by rows, left to right and top to bottom; then optionally by planes, front to back.

...

Data continues...

fp2hdf ASCII Text or Native Floating Point Input Fields

The arrays containing the scales 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.

For the FP32 and FP64 input formats, number_of_planes, number_of_rows, and number_of_columns are native integers; where format is the integer representation of the appropriate 4-character string (0x46503332 for FP32 and 0x46503634 for FP64). The remaining input fields are composed of native 32-bit floating point values for FP32 input format, or native 64-bit floating point values for FP64 input format.

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 - 05/19/99, NCSA HDF Development Group.