CODA GRIB Mapping Description

CODA provides access to GRIB-1 and GRIB-2 formatted data by creating a view on the GRIB files using the CODA data types. Below we will describe how CODA maps the GRIB1/GRIB2 product structure to one that is based on the CODA data types. We assume you already have a decent understanding of the GRIB (edition 1 and 2) format and its details.

A file can contain one or more GRIB messages. CODA only supports files where GRIB messages are stored without any padding between the messages and where the file does not contain any non-GRIB header or footer information in the file. A file can contain a mix of messages with different GRIB edition numbers.

Since a file consists of a list of messages the root of the product is mapped to an array of union with each message being mapped to a union. The fields in the union reflect the edition number of the GRIB message and are called grib1 and grib2 (only one of the fields will be available, depending on the edition number of the GRIB message). The grib1 and grib2 fields contain record types for a GRIB1 and GRIB2 message respectively. The mapping for each is explained below.

CODA will try to provide as direct a mapping to the underlying data as possible. This means that code table indices will just be provided as indices and not be interpreted. You will have to consult the appropriate WMO code tables in order to interpret the data. The reason for this design choice was to eliminate as much as possible the dependency of CODA on the WMO tables. For certain structural information (such as the contents of the Grid Description Section or Product Definition Section) table information has been hard-coded in CODA.

There are a few exceptions to the 'direct mapping' approach. One is that CODA will already perform the decoding of the parameter values. The bit-packed data is already converted back to floating point values using the scale factors and reference value as described by the GRIB standard. The scale factors and reference values are still made accessible as fields in the GRIB message record, but they have the hidden property, since you should not need them to interpret the values that CODA will give back.

CODA will also perform the decoding of bitmap packed data (using the Bit Map Section). The data available in data/values[] will thus always contain the full grid, where missing grid points are given the 'referenceValue' as value.

In addition, for GRIB1, any IBM floating point values will be converted to IEEE754 floating point values.

CODA currently only supports to most common storage mechanism of GRIB which is the simple packing form. Data that is stored using complex packing or jpeg/png images is not supported. Also, CODA currently only supports grid definitions that use a lat/lon or Gaussian grid. Other grids, including Spherical Harmonic data, are currently not supported. If an unsupported feature is encountered, CODA will abort opening the product and return with an error.

GRIB1

A GRIB1 message consists of the following sections:

The contents of the PDS are mapped directly as fields in the message record, but for the GDS and BDS sections separate sub-records are used. The Indicator, BMS, and '7777' sections are not mapped.

For the naming of fields CODA tries to stay as close as possible to the naming scheme that is used by the ECMWF GRIB API software.

The following table gives the list of parameters that are available via CODA for a GRIB1 message:

path to variabletype classread typenotes
/[]/grib1/editionNumberintegeruint8
/[]/grib1/table2Versionintegeruint8
/[]/grib1/centreintegeruint8
/[]/grib1/generatingProcessIdentifierintegeruint8
/[]/grib1/gridDefinitionintegeruint8
/[]/grib1/indicatorOfParameterintegeruint8
/[]/grib1/indicatorOfTypeOfLevelintegeruint8
/[]/grib1/levelintegeruint16
/[]/grib1/yearOfCenturyintegeruint8
/[]/grib1/monthintegeruint8
/[]/grib1/dayintegeruint8
/[]/grib1/hourintegeruint8
/[]/grib1/minuteintegeruint8
/[]/grib1/unitOfTimeRangeintegeruint8
/[]/grib1/P1integeruint8
/[]/grib1/P2integeruint8
/[]/grib1/timeRangeIndicatorintegeruint8
/[]/grib1/numberIncludedInAverageintegeruint16
/[]/grib1/numberMissingFromAveragesOrAccumulationsintegeruint8
/[]/grib1/centuryOfReferenceTimeOfDataintegeruint8
/[]/grib1/decimalScaleFactorintegeruint8
/[]/grib1/subCentreintegerint16(hidden field)
/[]/grib1/localrawbytesoptional; the originating center specific data at the end of the PDS is made available as raw data via this field if it is available
/[]/grib1/grid/numberOfVerticalCoordinateValuesintegeruint8
/[]/grib1/grid/dataRepresentationTypeintegeruint8
/[]/grib1/grid/Niintegeruint16
/[]/grib1/grid/Njintegeruint16
/[]/grib1/grid/latitudeOfFirstGridPointintegerint32
/[]/grib1/grid/longitudeOfFirstGridPointintegerint32
/[]/grib1/grid/resolutionAndComponentFlagsintegeruint8
/[]/grib1/grid/latitudeOfLastGridPointintegerint32
/[]/grib1/grid/longitudeOfLastGridPointintegerint32
/[]/grib1/grid/iDirectionIncrementintegerint16
/[]/grib1/grid/jDirectionIncrementintegerint16optional
/[]/grib1/grid/Nintegerint16optional
/[]/grib1/grid/scanningModeintegeruint8
/[]/grib1/grid/coordinateValues[]realfloatoptional
/[]/grib1/grid/listOfNumbers[]integeruint16optional
/[]/grib1/data/bitsPerValueintegeruint8(hidden field)
/[]/grib1/data/binaryScaleFactorintegerint16(hidden field)
/[]/grib1/data/referenceValuerealfloat(hidden field)
/[]/grib1/data/values[]realfloat

GRIB2

A GRIB2 message consists of the following sections:

Within a message, sequences 3-7, 4-7, and/or 5-7 can be repeated several times.

The contents of the Identification Section are mapped directly as fields in the message record. For the Local Use, Grid Definition, and Data Sections special 'local', 'grid', and 'data' fields are available, with each being an array of the contents of each occurrence of the section. Each 'data' record will contain a 0-based index into the 'grid' array to reference the applicable grid for the parameter. Similary, for each 'grid' record a 0-based index into the 'local' array will be available. The visible content of the Product Definition and Data Representation Section are available in the 'data' record of the associated Data Section (Product Definition Section information can thus end up appearing replicated).

As for GRIB1, for the naming of fields, CODA tries to stay as close as possible to the naming scheme that is used by the ECMWF GRIB API software.

The following table gives the list of parameters that are available via CODA for a GRIB2 message:

path to variabletype classread typenotes
/[]/grib2/editionNumberintegeruint8
/[]/grib2/disciplineintegeruint8
/[]/grib2/centreintegeruint16
/[]/grib2/subCentreintegeruint16
/[]/grib2/masterTablesVersionintegeruint8
/[]/grib2/localTablesVersionintegeruint8
/[]/grib2/significanceOfReferenceTimeintegeruint8
/[]/grib2/yearintegeruint16
/[]/grib2/monthintegeruint8
/[]/grib2/dayintegeruint8
/[]/grib2/hourintegeruint8
/[]/grib2/minuteintegeruint8
/[]/grib2/secondintegeruint8
/[]/grib2/productionStatusOfProcessedDataintegeruint8
/[]/grib2/typeOfProcessedDataintegeruint8
/[]/grib2/local[]rawbytes
/[]/grib2/grid[]/localRecordIndexintegerint32index into /[]/local[] to find associated local use data. Will be -1 if no local use data is available
/[]/grib2/grid[]/sourceOfGridDefinitionintegeruint8
/[]/grib2/grid[]/numberOfDataPointsintegeruint32
/[]/grib2/grid[]/interpretationOfListOfNumbersintegeruint8
/[]/grib2/grid[]/gridDefinitionTemplateNumberintegeruint16
/[]/grib2/grid[]/shapeOfTheEarthintegeruint8
/[]/grib2/grid[]/scaleFactorOfRadiusOfSphericalEarthintegeruint8
/[]/grib2/grid[]/scaledValueOfRadiusOfSphericalEarthintegeruint32
/[]/grib2/grid[]/scaleFactorOfEarthMajorAxisintegeruint8
/[]/grib2/grid[]/scaledValueOfEarthMajorAxisintegeruint32
/[]/grib2/grid[]/scaleFactorOfEarthMinorAxisintegeruint8
/[]/grib2/grid[]/scaledValueOfEarthMinorAxisintegeruint32
/[]/grib2/grid[]/Niintegeruint32
/[]/grib2/grid[]/Njintegeruint32
/[]/grib2/grid[]/basicAngleOfTheInitialProductionDomainintegeruint32
/[]/grib2/grid[]/subdivisionsOfBasicAngleintegeruint32
/[]/grib2/grid[]/latitudeOfFirstGridPointintegerint32
/[]/grib2/grid[]/longitudeOfFirstGridPointintegerint32
/[]/grib2/grid[]/resolutionAndComponentFlagsintegeruint8
/[]/grib2/grid[]/latitudeOfLastGridPointintegerint32
/[]/grib2/grid[]/longitudeOfLastGridPointintegerint32
/[]/grib2/grid[]/iDirectionIncrementintegeruint32
/[]/grib2/grid[]/jDirectionIncrementintegeruint32optional
/[]/grib2/grid[]/Nintegeruint32optional
/[]/grib2/grid[]/scanningModeintegeruint8
/[]/grib2/grid[]/listOfNumbersintegeruint32optional
/[]/grib2/data[]/gridRecordIndexintegeruint32index into /[]/grid[] to find associated grid definition data
/[]/grib2/data[]/parameterCategoryintegeruint8
/[]/grib2/data[]/parameterNumberintegeruint8
/[]/grib2/data[]/constituentTypeintegeruint16optional
/[]/grib2/data[]/typeOfGeneratingProcessintegeruint8
/[]/grib2/data[]/backgroundProcessintegeruint8
/[]/grib2/data[]/generatingProcessIdentifierintegeruint8
/[]/grib2/data[]/hoursAfterDataCutoffintegeruint16
/[]/grib2/data[]/minutesAfterDataCutoffintegeruint8
/[]/grib2/data[]/indicatorOfUnitOfTimeRangeintegeruint8
/[]/grib2/data[]/forecastTimeintegeruint32
/[]/grib2/data[]/typeOfFirstFixedSurfaceintegeruint8
/[]/grib2/data[]/firstFixedSurfacerealdouble
/[]/grib2/data[]/typeOfSecondFixedSurfaceintegeruint8
/[]/grib2/data[]/secondFixedSurfacerealdouble
/[]/grib2/data[]/coordinateValues[]realfloatoptional
/[]/grib2/data[]/bitsPerValueintegeruint8(hidden field)
/[]/grib2/data[]/decimalScaleFactorintegerint16(hidden field)
/[]/grib2/data[]/binaryScaleFactorintegerint16(hidden field)
/[]/grib2/data[]/referenceValuerealfloat(hidden field)
/[]/grib2/data[]/values[]realfloat