GRIB section 4, the binary data section

An INTEGER array of at least 42 elements.


ElementContentsecCodes keys
1Number of data values in array PSEC4 to be encoded or which have been decoded. When the 'A' coding option is used, the count is the number of image bytes stored four to an integer. When the 'B' coding option is used, the count is the number of integers used to return image bytes, stored four to an integer.

When a bitmap is used, this number includes the total of both missing and present data values.

If this number is negative:

  • the number of field points is -KSEC4(1),
  • the entire field is missing,
  • all values in PSEC4 are 0,
  • the coded data has all the bits of its scale factor are set to 1
  • all the bits of the exponent and mantissa of its reference value are set to 1 (This is an ECMWF convention).

numberOfPoints

numberOfValues

numberOfCodedValues

numberOfMissing

2Number of bits used for each encoded value.

decimalPrecision

bitsPerValue

3
Type of data:
0 Grid point data.
128 Spherical harmonic coefficients
(Used only if Section 2 is not included when
coding data.)
4
Type of packing:
0 Simple packing.
64 Complex or second-order packing.
packingType = grid_simple | grid_ieee | spectral_complex | spectral_simple |
spectral_ieee | grid_simple_matrix | grid_second_order |
grid_second_order_different_width | grid_complex |
grid_complex_spatial_differencing | grid_jpeg | grid_png |
grid_simple_log_preprocessing
5
Data representation:
0 Floating point data.
32 Integer data.

6
Additional flags indicator:
0 No additional flags.
16 Additional flags.

7Reserved. Set to 0.
8
Number of values indicator:
0 Single datum at each grid point.
64 Matrix of values at each grid point.

9
Secondary bitmaps indicator:
0 No secondary bitmaps.
32 Secondary bitmaps present.

10
Values width indicator:
0 Second order values have constant width.
16 Second order values have different widths.

11Number of bits for second order values when these have constant width.
12-15Reserved for WMO reserved flag fields. Set to 0.
16For complex packing, a pointer to the start of packed data values (ie the octet number). Otherwise set to 0.
17For complex packing, the scaling factor P, stored as the INTEGER value P*1000 (in the range -10000 to +10000). Otherwise set to 0.
18For complex packing, the pentagonal resolution parameter J specifying the truncation of the subset of the data represented as 32-bit floating point numbers (ie not packed). Otherwise set to 0.
19For complex packing, the pentagonal resolution parameter K specifying the truncation of the subset of the data represented as 32-bit floating point numbers (ie not packed). Otherwise set to 0.
20For complex packing, the pentagonal resolution parameter M specifying the truncation of the subset of the data represented as 32-bit floating point numbers (ie not packed). Otherwise set to 0.
21The number of non-missing values in a field which uses a bitmap.

When the 'B' coding option is used, this count is the number of image bytes (versions of GRIBEX after 13.040).


22-33Reserved. Set to 0.
34An offset bit pointer to coded values in the GRIB record. (This is returned by the 'G', 'I' or 'J' decoding options).

Contents of KSEC4

X decoding option.

Elements 34 to 42 are used only for the 'X' option, which decodes up to 4 values. (See HOPER above). The scanning mode must be from West to East and from North to South.

ElementContents
34Number of points to be decoded (maximum 4).
35Number of the latitude row of the first value.
36Number of the longitude point of the first value.
37Number of the latitude row of the second value.
38Number of the longitude point of the second value.
39Number of the latitude row of the third value.
40Number of the longitude point of the third value.
41Number of the latitude row of the fourth value.
42Number of the longitude point of the fourth value.

KSEC4 - X decoding option

Grid point matrix packing.

For grid point packing, with a matrix of values at each grid point, elements 50 to (50+NC1+NC2) are used as follows:

ElementContents
50First dimension of each matrix (the number of rows).
51Second dimension of each matrix (the number of columns).
52First dimension coordinate values definition.
53Number of coefficients or values used to specify the first dimension coordinate function, NC1.
54Second dimension coordinate values definition.
55Number of coefficients or values used to specify the second dimension coordinate function, NC2.
56First dimension physical significance.
57Second dimension physical significanc.
58 - 59Reserved. Set to 0.

KSEC4 - grid matrix packing

ECMWF use of REALs.

In the WMO specification, the following fields are INTEGER values. ECMWF uses floating-point values for its wave models, so these fields contain REAL values in both input and output.

ElementsContents
60 - (59+NC1)Coefficients to define the first dimension coordinate values in functional form, or the explicit coordinate values.
(60+NC1)-(59+NC1+NC2)Coefficients to define the second dimension coordinate values in functional form, or the explicit coordinate values