next up previous contents
Next: Example 3. Tensor (Wind Up: Dimensional Levels Previous: Example 1. Scalar (Temperature)   Contents


Example 2. Vector (Wind)

Consider a data object consisting of a wind vector measured over a longitude-latitude grid and standard atmospheric pressure levels, as in the previous example. The winds are averages over ten years for each day in January. Each wind measurement is a vector having three components ($u$, $v$, $w$), one along each of the dimensions of longitude, latitude, and pressure.

Thus the data have one Level 0 dimension with three elements. Longitude and latitude are Level 1 dimensions as in the previous example, but this time we make pressure a Level 1 dimension, too, instead of Level 2.

We choose to write the data out as a $6 \times 3 \times 91 \times 72 \times 31$ array (i.e., pressure, wind component, latitude, longitude, day of month).

If our indices start numbering at 0, then we have the following record fields:

OBJDESC.
NDIM0 = 1
NDIM1 = 3
NDIM2 = 1
NDIM3 = 1
DIMSPEC0.
INDEX = 1
GPTNUM = 3
DIMSPEC1.
INDEX = (3, 2, 0)
DESNUM = (1, 1, 1)
DIMSPEC2.
INDEX = 4
GPTNUM = 31
DIMSPEC3.
DESNUM = 1
DESCRIP0.
DATFMT = (single precision floating-point, single precision floating-point, single precision floating-point)
VARTYPE = ($u$, $v$, $w$)
UNITS = (m/s, m/s, cm/s)
DESCRIP1.
DEXSORT = 1
NDEX = 1
RECSORT = 0
START = 0
END = -1
GPTNUM = 91
DUPNUM = 0
DESSUP = 0
DESFMT = long integer
DESTYPE = latitude
UNITS = degree
STORG = 2
DESCVAL.
DLEVEL = 1
LEVEL = 1
DINDEX = 0
DEXSORT = 1
NDEX = 1
RECSORT = 0
AVALS = (-90, 90)
DESCRIP1.
DEXSORT = 0
NDEX = 0
RECSORT = 0
START = 0
END = -1
GPTNUM = 72
DUPNUM = 0
DESSUP = 0
DESFMT = long integer
DESTYPE = longitude
UNITS = degree
STORG = 1
DESCVAL.
DLEVEL = 1
LEVEL = 1
DINDEX = 0
DEXSORT = 0
NDEX = 0
RECSORT = 0
AVALS = (0, 5)
DESCRIP1.
DEXSORT = 2
NDEX = 2
RECSORT = 0
START = 0
END = -1
GPTNUM = 6
DUPNUM = 0
DESSUP = 0
DESFMT = single precision floating-point
DESTYPE = pressure
UNITS = mb
STORG = 0
DESCVAL.
DLEVEL = 1
LEVEL = 1
DINDEX = 0
DEXSORT = 2
NDEX = 2
RECSORT = 0
AVALS = (1000., 850., 700., 500., 250., 100.)
DESCRIP2.
NDEX = 0
DUPNUM = 0
DESSUP = 0
DESFMT = long integer
DESTYPE = time
UNITS = day of month
STORG = 1
DESCVAL.
DLEVEL = 2
LEVEL = 2
DINDEX = 0
DEXSORT = 0
NDEX = 0
RECSORT = 0
AVALS = (1, 1)
DESCRIP3.
DEXSORT = 0
NDEX = 0
RECSORT = 0
START = (0, 0, 0, 0, 0)
END = (-1, -1, -1, -1, -1)
GPTNUM = 10
AVGCOD = 1
DUPNUM = 0
DESSUP = 0
DESFMT = long integer
DESTYPE = time
UNITS = year
STORG = 2
DESCVAL.
DLEVEL = 3
LEVEL = 3
DINDEX = 0
DEXSORT = 0
NDEX = 0
RECSORT = 0
AVALS = (1983, 1992)

In IDL, then, the code for specifying the dimensions would look something like this:

    ; set up the relevant elements in the OBJDESC record
    RECTYPE = long(1)
    NDIM0 = long(1)
    NDIM1 = long(3)
    NDIM2 = long(1)
    NDIM3 = long(1)
    .
    .
    .
    writeu,log_file_unit,   RECTYPE, vartype, reserved    $
    , NDIM0, NDIM1, NDIM2, NDIM3, reserved, isource       $
    , reserved, reserved, naudit, ninfo, ncomms, comcod   $
    , reserved, nbads, reserved, nprocs, reserved, npacks $
    , reserved, reserved, cmpnum, reserved, reserved      $
    , reserved

    .
    .
    .

    ; set up the DIMSPEC0 record
    RECTYPE = long(20)
    ;  The wind component index is second in the actual data 
    ;  array
    INDEX = long(1)
    ;  There are three components to the wind
    GPTNUM = long(3)

    writeu,log_file_unit,  RECTYPE, reserved, reserved $
    , INDEX, GPTNUM

    ; set up the DIMSPEC1 record
    RECTYPE = long(21)
    ; longitude, latitude, and pressure are the fourth, 
    ; third, and first dimensions of the data array read in.
    INDEX = long( [ 3, 2, 0 ] )
    ; we will specify only one DESCRIP1 record for each 
    ; dimension
    DESNUM = long( [ 1, 1, 1 ] )

    writeu,log_file_unit,  RECTYPE, reserved, reserved $
    , INDEX, DESNUM

    ; set up the DIMSPEC2 record
    RECTYPE = long(22)
    ; Time will be the fifth dimension of the data array read 
    ; in.
    INDEX = long( 4 )
    ; There will be 31 times, one for each day of January
    GPTNUM = long( 31 )

    writeu,log_file_unit,  RECTYPE, reserved, reserved $
    , INDEX, GPTNUM

    ; set up the DIMSPEC3 record
    RECTYPE = long(23)
    ; there will be only one DESCRIP3 record for the single 
    ; Level 3 dimension
    DESNUM = 1

    writeu,log_file_unit, RECTYPE, reserved, reserved, DESNUM

    ; set up the DESCRIP0 record
    RECTYPE = long(30)
    ; data are floating-point single precision numbers
    DATFMT = long(67108864, 67108864, 67108864)
    ; data are wind componenets (u, v, w)
    ; Note: in actual working code, one would call here a 
    ; function which would convert the strings 
    ; "measured u wind", "measured v wind", and
    ; "measured w wind" to the quantity codes:
    ; 18874368, 18878464, 18882560  
    VARTYPE = long(18874368, 18878464, 18882560)
    ; the wind components are in m/s, m/s, cm/s
    UNITS = long(1616347136, 1616347136, 1616347137)

    writeu,log_file_unit, RECTYPE, reserved, reserved $
    , DATFMT, VARTYPE, UNITS

    ; Now do the latitude DESCRIP1 and DESCVAL records
    writeu,log_file_unit, long(31), long(1), long(0)       $
    , long(-1), long(91), long(0), long(0), long(51445760) $
    , long(17838096), long(1745355010), long(2), reserved  $ 
    , reserved
    writeu,log_file_unit, long(35),long(1),long(1) $
    , long([ -90, 90 ])

    ; Now do the longitude DESCRIP1 and DESCVAL records
    writeu,log_file_unit, long(31), long(0), long(0)       $
    , long(-1), long(72), long(0), long(0), long(51445760) $
    , long(17838080), long(1745355010), long(1), reserved  $
    , reserved
    writeu,log_file_unit, long(35), long(1), long(0), $
    , long([ 0, 5 ])

    ; Do the pressure DESCRIP1 record
    RECTYPE = long(31)
    ; This describes the third Level 1 dimension
    NDEX = long(2)
    ; This covers the entire range of the single Level 2 
    ; dimension
    START = long(0)
    ENDIT = long(-1)
    ; Six pressure levels
    GPTNUM = 6
    ; No duplicate records
    DUPNUM = long(0)
    ; No supplemental information
    DESSUP = long(0)
    ; pressures are floating-point numbers
    DESFMT = long(67108864)
    ; the quantity id for pressure is 16781312
    DESTYPE = long(16781312)
    ; The units code for millibars is 1081593921
    UNITS = long(1081593921)
    ; We will store this as a an explicit array
    STORG = long(0)

    writeu,log_file_unit, RECTYPE, NDEX, START, ENDIT $
    , GPTNUM, DUPNUM, DESSUP, DESFMT, DESTYPE, UNITS  $
    , STORG, reserved, reserved

    ; set up the pressure DESCVAL record
    RECTYPE = long(35)
    ; This belongs to Level 1, dimension number 3
    LEVEL = long(1)
    NDEX = long(2)
    ; We list the pressure levels
    AVALS = float([1000., 850., 700., 500., 250., 100.] )

    writeu,log_file_unit, RECTYPE, LEVEL, NDEX, AVALS

    ; do the time dimension spec (DESCRIP2 and DESCVAL)
    writeu,log_file_unit, long(32), long(0), long(0)  $
    , long(0), long(50397184), long(131072)           $
    , long(1615331845), long(1), reserved, reserved
    writeu,log_file_unit, long(35), long(2), long(0) $
    , long(1, 1)

    ; set up the time averaging DESCRIP3 record
    RECTYPE = long(33)
    ; This describes the first Level 3 dimension
    NDEX = long(0)
    ; This covers the entire range of all Levels 0-2 
    ; dimension
    START = long( [ 0, 0, 0, 0, 0 ] )
    ENDIT = long( [ -1, -1, -1, -1, -1 ] )
    ; There are 10 years in the average
    GPTNUM = long(10)
    ; These are arithmetic means computed from discrete sums
    AVGCOD = 1
    ; No duplicate records
    DUPNUM = long(0)
    ; No supplemental information
    DESSUP = long(0)
    ; years are unsigned long integers
    DESFMT = long(50397184)
    ; the quantity id for time is 131072
    DESTYPE = long(131072)
    ; The units code for year is 1615331616
    UNITS = long(1615331616)
    ; We will store this as a an implicit 
    ; (low-value, high-value) pair
    STORG = long(2)

    writeu,log_file_unit, RECTYPE, NDEX, START, ENDIT $
    , GPTNUM, AVGCOD, DUPNUM, DESSUP, DESFMT, DESTYPE $
    , UNITS, STORG, reserved, reserved

    ; set up the 10-year average DESCVAL record
    RECTYPE = long(35)
    ; This belongs to Level 3, dimension number 1
    LEVEL = long(3)
    NDEX = long(0)
    ; We start at 1983 increase and end at 1992
    AVALS = long([ 1983, 1992 ] )

    writeu,log_file_unit, RECTYPE, LEVEL, NDEX, AVALS

Note that the specifications for the dimensions, the dimension descriptors, and even the data itself do not have to be stored in any prescribed order. This is explained in Section 2.3.2. These indices are used as pointers from the descriptors to the specifications to the data itself. The DESCVAL record associated with the DESCRIP3 record will contain the year index over which the data has been averaged. These values are not needed to access the data values but instead they aid in interpreting the meaning of the data.


next up previous contents
Next: Example 3. Tensor (Wind Up: Dimensional Levels Previous: Example 1. Scalar (Temperature)   Contents
Eric Nash 2003-09-25