CEDA GRIB Documentation
A brief introduction to the GRIB 1data format.
This page gives a brief introduction to GRIB (GRIdded Binary) data with particular emphasis on the GRIB files held at CEDA. The aim is to give an indication of what to expect when faced with a GRIB file. More detailed documentation is available, for example at NCAR and the ECMWF.
GRIB is a WMO (World Meteorological Organisation) standard format for archiving and exchanging gridded data. GRIB is a binary format, and the data is packed to increase storage efficiency. GRIB data is also self-describing, meaning that the information needed to read the file is present within the file. This page outlines how the data and information needed to interpret the data is stored in a GRIB file.
Each GRIB file is composed of a series of GRIB records. One GRIB record holds the gridded data for one parameter at one time and at one level. Each GRIB record is composed of 6 GRIB sections. Section 4 contains the data itself. The other sections give the information required to read the GRIB record, and information on the meteorological parameter contained in the record, the level the record refers to and the type of grid the parameter is on. The sections are as follows:
Section 0: Indicator Section.
Section 1: Product Definition Section.
Section 2: Grid Description Section - Optional.
Section 3: Bit Map Section - Optional.
Section 4: Binary Data Section.
Section 5: '7777' - ASCII Characters indicating end of GRID record.
Section 1, known as the Product Definition Section (PDS), and section 2, known as the Grid Definition Section (GDS), are the information sections most frequently referred to by users of GRIB data. The PDS (section 1) contains information about the parameter, level type, level and date of the record. The GDS (section 2) contains information on the grid type (such as whether the grid is regular or gaussian), and the resolution of the grid.
Some of the information in the GRIB record information sections are represented by integer codes. For instance, the name of the parameter in the GRIB record is indicated using an integer known as the GRIB parameter code, or parameter identifier. Code tables, which are not part of the GRIB file but are held separately for each dataset using data in GRIB format.
Being coded binary files, GRIB files are not readable without the use of suitable software. There are utilities which can be used to decode GRIB files. An example is the XCONV/CONVSH package that can be obtained from NCAS-CMS.
The NCAR Command Language readily reads all GRIB-1 and GRIB-2 files.
Other freely available software packages that can read GRIB via the GrADS/GRIB interface are:
If you would prefer to write your own routines for reading GRIB data, a complete description of the format is given in the Guide to GRIB.
ExampleUsing grib2brief on one of the ECMWF 2.5° gridded data files held at the BADC will produce an output similar to that displayed below. The [emphasised] text at the line ends has been added here to highlight the most useful pieces of information in the GRIB information sections. It is worth noting that in the Grid definition section latitudes and longitudes are given in millidegrees.
Section 0 - Indicator Section. ------------------------------------- Length of GRIB message (octets). 21132 GRIB Edition Number. 1 Section 1 - Product Definition Section. --------------------------------------- Code Table 2 Version Number. 128 Originating centre identifier. 98 [98=ECMWF] Model identification. 190 Grid definition. 255 Flag. 10000000 Parameter identifier . 129 [129=geopotential] Type of level. 100 [100=pressure levels] Value 1 of level. 1000 [Data on 1000 hPa] Value 2 of level. 0 [used for layer mean data] Year of reference time of data. 1999 [Date information] Month of reference time of data. 1 [Date information] Day of reference time of data. 1 [Date information] Hour of reference time of data. 0 [Date information] Minute of reference time of data. 0 [Date information] Time unit. 1 [Time unit used for Time ranges] Time range one. 0 [Data is at hour specified above] Time range two. 0 [used for time average or accumulated fields] Time range indicator. 0 Number averaged. 0 Number missing from average. 0 Century of reference time of data. 20 Sub-centre identifier. 0 Units decimal scaling factor. 0 ECMWF local usage identifier. 1 (Mars labelling or ensemble forecast) Class. 1 Type. 2 Stream. 1025 Version number or Experiment identifier. 1000 Forecast number. 0 Total number of forecasts. 0 Section 2 - Grid Description Section. ------------------------------------- (Southern latitudes and Western longitudes are negative.) Data represent type = lat/long 0 [0=lat/lon grid] Number of points along a parallel. 144 Number of points along a meridian. 73 Latitude of first grid point. 90000 [in milli degrees] Longitude of first grid point. 0 [in milli degrees] Resolution and components flag. 10000000 Latitude of last grid point. -90000 [in milli degrees] Longitude of last grid point. 357500 [in milli degrees] i direction (East-West) increment. 2500 [in milli degrees] j direction (North-South) increment. 2500 [in milli degrees] Scanning mode flags 00000000 Number of vertical coordinate parameters. 0 Section 4 - Binary Data Section. ------------------------------------- Number of data values coded/decoded. 10512 Number of bits per data value. 16 Type of data (0=grid pt, 128=spectral). 0 Type of packing (0=simple, 64=complex). 0 Type of data (0=float, 32=integer). 0 Additional flags (0=none, 16=present). 0 Reserved. 0 Number of values (0=single, 64=matrix). 0 Secondary bit-maps (0=none, 32=present). 0 Values width (0=constant, 16=variable). 0 First 20 data values. [for scanning mode 00000000 longitudes 924.8220 vary most rapidly and scan from West to East 924.8220 latitudes vary least rapidly and scan from 924.8220 North to South. So the data opposite is 924.8220 the first 20 longitudes for the north pole] 924.8220 924.8220 924.8220 924.8220 924.8220 924.8220 924.8220 924.8220 924.8220 924.8220 924.8220 924.8220 924.8220 924.8220 924.8220 924.8220
ECMWF provides access and support for the GRIB-API, an API that is accessible from C, FORTRAN and Python for both GRIB edition 1 and 2 formatted data.
Another commonly used GRIB decoder, that also runs on PCs, is wgrib. A copy of wgrib and related documentation is available for users of ECMWF data held in the CEDA archives (in the software directory - registered users only).