### 6 Importing Particle Data

6.1 Variations

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 input a formatted text file containing particle (or catalogue) data. The positions of the particles trace out a three-dimensional cone. The data are represented as a single DX field (see Section 17). For simplicity the file contains only this single field. However, it is possible to have particle datasets containing several fields, similar to the gridded data in Section 5. The program to generate the data is listed in Figure 9.

(1)
The DX header file for this data file is shown in Figure 8. These header files have file type ‘.general’. Thus the present example is called ‘particle.general’.

file=particle.lis
points=10000
format=text
field=locations, Intensity
structure=3-vector, scalar
interleaving=field

Figure 8: Header file for particle data.

(2)
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.
points
is the number of particles (or points) in the data set.
format
is the format of the file; the current example is a formatted file rather than a binary file.
field
specifies names for the the individual fields (or columns) in the data file. In the present case the first three columns, containing the positions are collectively called ‘locations’ and the final column is called ‘Intensity’. Note the use of a comma to separate the two names.
structure
specifies the structure of each field in the file. In the present case the first three columns are grouped into a three-element vector containing the positions and the fourth column is treated as a scalar dependent variable.
interleaving
specifies how the various data items within the file are intertwined. In the present case each record in the file contains the position and data value for a single particle (see Figure 9). ‘interleaving=field’ specifies this sort of interleaving.

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].

(3)
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’.

#### 6.1 Variations

See the notes for variations of Importing Gridded Data, Section 5, above.

PROGRAM PARTICLE
IMPLICIT NONE
*    Generate a particle dataset, with the individual particles tracing
*    out positions on a cone.  The dependent variable varies
*    (indirectly) with the Z distance.
*    A C Davenhall (Edinburgh), 4/12/95.
REAL
:  DR,      ! Increment in radius.
:  DTHETA,  !     "     "  theta.
:  DZ,      !     "     "  z.
:  PI       ! Pi.
PARAMETER
: (DR = 1.0E-1,  DTHETA = 1.0E-2,
:  DZ = 1.0E-1,  PI = 3.1415927E0)
REAL
:  R,       ! Radius.
:  THETA,   ! Theta.
:  X,       ! X coordinate.
:  Y,       ! Y     "     .
:  Z,       ! Z     "     .
:  VALUE    ! Value of the point.
INTEGER
:  I, J, K  ! Loop indices.

OPEN(UNIT=10, FILE=’particle.lis’, STATUS=’NEW’)

DO I = 1, 10000
R = REAL(I) * DR
THETA = REAL(I) * DTHETA
THETA = MOD(THETA, 2*PI)
X = R * COS(THETA)
Y = R * SIN(THETA)
Z = REAL(I) * DZ

VALUE = SIN(MOD( REAL(I)/5.0E3, 2*PI) )

WRITE(10, ’(0PE12.4, 1X, 0PE12.4, 1X, 0PE12.4, 1X, 0PE12.4)’ )
:     X, Y, Z, VALUE
END DO

CLOSE(UNIT=10)

END

Figure 9: Program particle.f to write particle data.