Floatstohdf

Name

floatstohdf - convert stream of floats to HDF SDS format

Synopsis


floatstohdf [-llabel] [-uunits] [-fformat] [-ccoordsys] 
      [-b[Fortran|C]] [-shdrbytes] [-Mmax] [-mmin] [-oofile] nx ny nz 

Description

floatstohdf reads a stream of floating point numbers from the standard input, and saves the values as an HDF Scientific Dataset representing a single 3D grid. The X, Y, and Z dimensions of the grid are given by nx, ny, and nz. By default, the input stream is assumed to be floats in ascii format; new lines are ignored. The -b switch (see below) can be used to specify a binary input stream.

The program finds and stores minimum and maximum values for the data. These values may then be used by other programs (for example VFleet). The -M and -m switches can be used to specify these values.

The following options exist:

-llabel
Attach the given string to the data as a label. For example, "density" might be a typical label string.
-uunits
Attach the given string to specify the units of the data. For example, "kg/m^3" might be a typical units string.
-fformat
Attach the given string to specify the Fortran format to be used in printing the data. For example, "f10.4" might be a typical format string.
-ccoordsys
Attach the given string to specify the coordinate system in which the data is defined. For example, "cartesian" might be a typical coordinate system string.
-b[Fortran|C]
Rather than the default ascii input stream, expect a binary input stream. If Fortran (or at least F) is specified, the program will make a valiant attempt to compensate for Fortran binary file record structure and read raw data written from Fortran. If C is specified (the default), the program will expect binary floating point numbers as written from the C language.
-shdrbytes
If in binary C mode, skip hdrbytes bytes at the beginning of the file.
-Mmax
Use the given value as the maximum of the dataset.
-mmin
Use the given value as the minimum of the dataset.
-oofile
Specify an ascii string giving the filename of the output file. If not specified, the file produced is named floats.hdf.

Note that in HDF Datasets, the Z index varies fastest. This means that successive planes of data (defined by adjacent blocks in the input file) represent slices in planes of constant X. The X dimension is thus the number of slices present, rather than the (perhaps more intuitive) Z dimension.

Note that this program expects data in C language array order, that is, with the last array dimension varying fastest. If the input datastream was written from a Fortran language array, in which the first index varies fastest, the translation process will change the coordinate system of the data from right handed to left handed (or vice versa).

Examples

floatstohdf -ooutfile xdim ydim zdim < infile
will read xdim*ydim*zdim floats from the filename specified as infile and output an HDF file of the given name outfile containing the data. The input file is assumed to consist of ascii representations of floats with arbitrary line breaks.

A dataset consisting of 100 planes of data, each plane being 200 by 300 voxels, would be arranged in the input file as a series of 100 blocks of data, each block representing a plane. Each block in turn would consist of 200 rows of data, each 300 data elements long. The appropriate floatstohdf command to convert such a dataset to HDF format would be:

floatstohdf -ooutfile.hdf 100 200 300 < infile.ascii

If the input file was a Fortran raw binary file with the same data order rather than an ascii format file, the appropriate command would be:

floatstohdf -bF -ooutfile.hdf 100 200 300 < infile.raw

The Fortran program which generated the binary file might have saved the data in Fortran array order, however. If so, the data would need to be read as follows:

floatstohdf -bF -ooutfile.hdf 300 200 100 < infile.raw
This array order ambiguity is often best resolved by experiment.
J. Welling
Last modified: Mon Jul 15 16:38:58 EDT