GRIB Tables
The following assumes that you want generic software like the netCDF-Java library to be able to correctly read the GRIB files that you write, or need to read.
Writing Grib-1
Encoding the center (octet 5) and subcenter id (octet 26)
You must encode a center and subcenter id, in order for software to correctly match the tables used. If there is no subcenter in use, use id =0 ("no subcenter:), although 255 ("missing") is acceptable but ambiguous.
Encoding the version number (octet 4)
If you are only using WMO standard tables (all parameter ids < 128) then you should use version number = 1, 2, or 3, corresponding to the WMO standard table version. The Current WMO GRIB-1 table version is 3. Using only parameters from the standard tables is best practice for the international exchange of GRIB messages.
If you are using non-standard (aka local) parameters, then you should use a version number in the range 128-254.
Using local tables
If you use local parameters, you must do the following:
- You must own the center id, or own a subcenter id within the center, so that you can version your tables.
- You must correctly version your local table number. If your local table changes in a way that is not backwards compatible, you must change the version number.
- You must publish your local tables at some authoritative place, in a machine readable format. You must mantain these indefinitely.
- You must put the correct center, subcenter and version number into each GRIB message.
Best practice for local table use includes the following:
- Use a version number between 128-254.
- Do not override any entries in the WMO standard tables, ie, with parameter numbers less than 128.
- There are no standards for publishing your tables, but any fixed column ASCII, CSV, or XML format is ok. Follow the NCAR DSS format if you like. Do not use HTML, PDF, MS Word etc, since these are not machine readable formats.
- We need to be able to find your tables. Add enough metadata so that a google search on "<your center name> GRIB tables" finds you within the first 2 pages. Send a link to netcdf-java@unidata.ucar.edu and we will link to you.
Reading Grib-1 files with the CDM library version 4.3
Standard table mapping
- See resources/grib1/grib1Tables.txt in grib-version.jar or grib/src/main/resources/resources/grib1/grib1Tables.txt from the source tree.
- You can view the standard tables in ToolsUI, using the iosp/GRIBold/GRIB1-TABLES tab.
- The table that matches the center-subcenter-version is used.
- Use a "-1" for the subcenter or version in order to match any. The order of the entries in the grib1Tables.txt file is therefore important.
- If a table is not matched, the file will fail to open. You can change that in the RunTime configuration file by adding
<grib1Table strict="false"/>
In this case, the default WMO table will be used, but there's no way of knowing if the parameters are correctly named.
Adding to the standard table mapping
- You can add your own table within your application, or to applications that support the RunTime configuration file.
- Tables that are user-added take precedence over the standard tables.
- Parameters that are not present in your table are taken from the default WMO table, if they exist.
- Missing parameters are marked "unknown" in the variable name and units.
Table Registry
In principle, if everything is done right, the reader ends up using the table that the writer used. In practice, there are many ways for that to fail. In order to increase the reliability of table-based file formats, I have proposed a web registry of tables, which would create a unique id for each registered table. The writer would then embed the id into the GRIB or BUFR message (possibly in the "local use" section of GRIB-2, or GRIB-1 octets > 41 in PDS), and the reader could use the id to unambiguously retrieve the table from the web registry. Stay tuned for further details and a trial implementation.
This document is maintained by John Caron and was last updated August 2011