## GRIB section 4, the binary data section

An INTEGER array of at least 42 elements.

Element | Contents | GRIB API keys |
---|---|---|

1 | Number 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 |

2 | Number of bits used for each encoded value. | decimalPrecision bitsPerValue |

3 | Type of data: | |

4 | Type of 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: | |

6 | Additional flags indicator: | |

7 | Reserved. Set to 0. | |

8 | Number of values indicator: | |

9 | Secondary bitmaps indicator: | |

10 | Values width indicator: | |

11 | Number of bits for second order values when these have constant width. | |

12-15 | Reserved for WMO reserved flag fields. Set to 0. | |

16 | For complex packing, a pointer to the start of packed data values (ie the octet number). Otherwise set to 0. | |

17 | For complex packing, the scaling factor P, stored as the INTEGER value P*1000 (in the range -10000 to +10000). Otherwise set to 0. | |

18 | For 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. | |

19 | For 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. | |

20 | For 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. | |

21 | The 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-33 | Reserved. Set to 0. | |

34 | An 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.

Element | Contents |
---|---|

34 | Number of points to be decoded (maximum 4). |

35 | Number of the latitude row of the first value. |

36 | Number of the longitude point of the first value. |

37 | Number of the latitude row of the second value. |

38 | Number of the longitude point of the second value. |

39 | Number of the latitude row of the third value. |

40 | Number of the longitude point of the third value. |

41 | Number of the latitude row of the fourth value. |

42 | Number 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:

Element | Contents |
---|---|

50 | First dimension of each matrix (the number of rows). |

51 | Second dimension of each matrix (the number of columns). |

52 | First dimension coordinate values definition. |

53 | Number of coefficients or values used to specify the first dimension coordinate function, NC1. |

54 | Second dimension coordinate values definition. |

55 | Number of coefficients or values used to specify the second dimension coordinate function, NC2. |

56 | First dimension physical significance. |

57 | Second dimension physical significanc. |

58 - 59 | Reserved. 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.

Elements | Contents |
---|---|

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 |