Next: Variations
Up: Simple Recipes
Previous: Running a network
Importing Gridded Data
It is usually possible to input a file written by some other program
into DX. The procedure is simply to create a file which describes the
contents of the data file to DX. This description file is called a
`header file' and is simply a text file created with an editor.
As an example this recipe shows how to import a formatted text file
containing two data cubes. One data cube is a simple Gaussian field,
the other is a Gaussian superimposed on a sloping background. Note that
though the values are calculated using Fortran double precision
variables they are written out as floating point numbers. DX interprets the
ensuing file as containing single precision values. Each data cube is
represented as a single DX field (see Section
).
The program to generate the data file is listed in Figure
.
- The DX header file for this data file is shown in
Figure
. These header files have file type
`.general'. Thus the present example is called ` field.general'.
Figure:
Header file for gridded data.
 |
- Each line of the header file consists of a keyword followed by
one or more values. The purpose of the various keywords are as
follows.
- file
- is the name of the data file. If the file name is not
preceded by a directory specification then it is assumed to be in
the same directory as the header file.
- format
- is the format of the file; the current example is
a formatted file rather than a binary file.
- grid
- is the size of the grid of data. In the present case
both data cubes comprise grids with fifty elements in each side.
- majority
- specifies the organisation of multi-dimensional
arrays. `Column' majority means that the first dimension varies
fastest (as in Fortran); `row' majority means that the last
dimension varies fastest (as in C).
- interleaving
- specifies how the data for the two fields are
interleaved within the file. DX permits various possibilities.
For example, all the values for the first field could occur
first, followed by all the values for the second field. In the
present case the data for the two fields are more closely
intertwined. Each record in the file contains a value for a
position in the first field and a value for the corresponding
position in the second field (see Figures
and
). `interleaving=field' specifies this
sort of interleaving.
Figure:
The first few records of file field.lis (written by program field.f,
Figure
). The first column is values for the simple
Gaussian data cube, the second column values for the Gaussian
superimposed on a sloping background.
 |
- field
- specifies names for the fields in the file. Here
they are called `Gaussian' (the simple Gaussian data cube) and
`Sloping' (the Gaussian superimposed on a sloping background).
Note the use of a comma to separate the two names.
- structure
- specifies the structure of the two fields in the
file. In the current example both the fields are simple scalars.
- type
- specifies the data types of the two fields. In the
current example both fields are single precision real numbers.
- dependency
- denotes whether the data are position or
connection dependent. See Section
for an
explanation of these two cases. Here both fields are position
dependent (which is probably the more common case in astronomy).
A full description of all the possible keywords is given in
Section 4.3 Header File Syntax: Keyword Statements of the
IBM QuickStart Guide[1].
- Once a suitable description file has been been created the data
can be imported into DX by including the `Import' module in your
network. Note that it is the name of the description file, not
the name of the data file which must be supplied to `Import'.
Subsections
Next: Variations
Up: Simple Recipes
Previous: Running a network
The DX Cookbook
Starlink Cookbook 2
A.C. Davenhall
1st October 1997
E-mail:ussc@star.rl.ac.uk
Copyright © 2009 Science and Technology Facilities Council