BAS Main Index
  [Science]   [BAS home]   [Met home]   [WMC home] Antarctic Meteorology 


GRIB and GRID decoding

The origins of this are rather lost in the mist. I think I wanted to convert GRID into GRIB. OR vice versa. Anyway, the stuff of code to make them; blew hither; here they are.

My programs/code here are released under GPL.

Incidentally, the program "wgrib" is quite good.

What we have are two perl modules, which can be used to build code to decode/encode GRIB and GRID files. As an example, GRIB.pl and GRID.pl are wrapper scripts that do some simple things, and may even do all you need.

Note that, although these scripts *can* encode grib, they are more usually used to decode it. GRID.pl contains an example of writing out grid as grib; but creating a new grib message from data would be painful.

  1. GRIB.pm GRIB de/encoder, and a GRIB.pl driver script. [Note for naughty windoze users: care: don't confuse GRIB.pl and grib.pl. Also: if you have problems with long files, look for the "binmode" comment]
  2. GRID.pm GRID decoder, and a GRID.pl driver script.
  3. BlockGraph.pm Graphical interface. Needs Tk.pm.
Here is one way to use the wrapper scripts to decode a grib file. The same file and text output are given:
GRIB.pl MODE=textfull HEVA98.GRB > HEVA98.txt

or

GRIB.pl MODE=text mrf.grb > mrf.txt (also mrf.txt.d; also mrf.txt.wgrib (with -V))

Note that mrf.grb seems to have a problem (?) with decoding the scale factor which is wrong by a factor of ten. Odd.

Once upon a time were some other (non-module-type) scripts. Who knows, you may want these. Poke around, see if there is anything you like...

  1. grib.pl - basic. perhaps.
  2. wmc_grib1.pl - for ECMWF grib, including spectral.
  3. More info on reading ECMWF-type GRIB from here.
  4. A GRIB manual is at http://www-lehre.inf.uos.de/~fbstark/diplom/docs/data/GRIB/ - how useful!

Thanks: to Alexander D Ryan for testing and correcting the GRIB stuff, and for finding bytes 27-8 in the PDB, and for finding the GRIB manual.

Past last modified: 7/6/2004

wmc@bas.ac.uk     © Copyright Natural Environment Research Council - British Antarctic Survey 2001