next up previous contents
Next: DESCRIP3, PROCSPEC, PROCDUP, AUXSPEC, Up: START and END Fields Previous: DESCRIP1 Case   Contents


BADVAL Case

The BADVAL START and END fields will specify which Level 1 and Level 2 dimensions a given BADVAL record will apply to. Again, there can be no overlap of the ranges specified by multiple BADVAL records; i.e., there can only be one bad-data flag per data value.

In the previous example, we changed the number of station identifiers in each record, depending on which stations had data available. Another option would be to make a single Level 1 definition for the array of station identifiers, giving it a fixed length of three. In this case, we would mark the data from Station 1003 on Day 2 with bad-data flag values. That is, we would set the missing station's temperature to some flag value and set the BADVAL.VALUE field to that same flag value. The START and END fields have two elements each (one for the Level 1 dimension and one for the Level 2 dimension); to make this BADVAL record apply over the entire dataset, both START elements would be 0, and both END elements would be -1. This is the most straightforward and common use of the BADVAL record type. The relevant record fields will be as follows (indices start at 0):

OBJDESC.
NDIM0 = 1
NDIM1 = 1
NDIM2 = 1
NDIM3 = 0
NBADS = 1
DIMSPEC0.
INDEX = -1
GPTNUM = 1
DIMSPEC1.
INDEX = 0
DESNUM = 1
DIMSPEC2.
INDEX = 1
GPTNUM = 3
DESCRIP0.
DATFMT = single precision floating-point
VARTYPE = temperature
UNITS = K
DESCRIP1.
DEXSORT = 0
NDEX = 0
RECSORT = 0
START = 0
END = -1 or 2
GPTNUM = 3
DUPNUM = 0
DESSUP = 0
DESFMT = long integer
DESTYPE = station identifier
UNITS = no units
STORG = 0
DESCVAL.
DLEVEL = 1
LEVEL = 1
DINDEX = 0
DEXSORT = 0
NDEX = 0
RECSORT = 0
AVALS = (1001, 1002, 1003)
DESCRIP2.
NDEX = 0
DUPNUM = 0
DESSUP = 0
DESFMT = long integer
DESTYPE = time
UNITS = day
STORG = 1
DESCVAL.
DLEVEL = 2
LEVEL = 2
DINDEX = 0
DEXSORT = 0
NDEX = 0
RECSORT = 0
AVALS = (1, 1)
BADVAL.
RECSORT = 0
START = (0, 0)
END = (-1, -1)
VALUE = bad-data flag

As another example, consider the case of the vector winds described above in Example 2 in Section 3.2.2. In this case, a different bad-data flag may be needed for each data component. The elements of the START and END array will correspond to the longitude, latitude, pressure, and day-of-year dimensions. The relevant record fields will be the same as in that example, with the addition of the BADVAL record type as follows (indices start at 0):

OBJDESC.
NBADS = 1
BADVAL.
RECSORT = 0
START = (0, 0, 0, 0)
END = (-1, -1, -1, -1)
VALUE = $u$ bad-data flag, $v$ bad-data flag, $w$ bad-data flag

The IDL code for writing such a record might look something like this:

    ; set up the BADVAL record
    RECTYPE = long(40)
    ; This is the first BADVAL record
    RECSORT = long(1)
    ; This BADVAL record is valid over the entire range of 
    ; Levels 1-3 dimensions
    START = long( [ 0, 0, 0, 0 ] )
    ENDIT = long( [ -1, -1, -1, -1 ])
    ; Remember, VALUE must have as many components as the data
    VALUE = float( [ -9999.0, -9999.0, -999.0 ] )

    writeu,log_file_unit,  RECTYPE,RECSORT, reserved $
    , reserved, START, ENDIT, VALUE

Now consider the possibility that after, say, nine days the bad-data flag is changed, so that each pressure altitude has its own bad-data flag value. This situation would need seven BADVAL records: the first would contain the single bad data value that applies to all of the pressure altitudes for the first nine days. Then a second BADVAL record would contain the flag that applies to the first pressure altitude for the rest of the days. The third through seventh records would give the flags that apply to the other pressure levels after the ninth day.

The relevant record fields would now be as follows (indices start at 0):

OBJDESC.
NBADS = 7
BADVAL.
RECSORT = 0
START = (0, 0, 0, 0)
END = (-1, -1, -1, 8)
VALUE= first bad data value
BADVAL.
RECSORT = 1
START = (0, 0, 0, 9)
END = (-1, -1, 0, -1)
VALUE= second bad data value at pressure level 0
BADVAL.
RECSORT = 2
START = (0, 0, 1, 9)
END = (-1, -1, 1, -1)
VALUE= second bad data value at pressure level 1
BADVAL.
RECSORT = 3
START = (0, 0, 2, 9)
END = (-1, -1, 2, -1)
VALUE= second bad data value at pressure level 2
BADVAL.
RECSORT = 4
START = (0, 0, 3, 9)
END = (-1, -1, 3, -1)
VALUE= second bad data value at pressure level 3
BADVAL.
RECSORT = 5
START = (0, 0, 4, 9)
END = (-1, -1, 4, -1)
VALUE = second bad data value at pressure level 4
BADVAL.
RECSORT = 6
START = (0, 0, 5, 9)
END = (-1, -1, 5, -1)
VALUE = second bad data value at pressure level 5


next up previous contents
Next: DESCRIP3, PROCSPEC, PROCDUP, AUXSPEC, Up: START and END Fields Previous: DESCRIP1 Case   Contents
Eric Nash 2003-09-25