Dealing with GRIB2 data

We use python for our data analysis and plotting.

The wonderful xarray package ( has no problem with NetCDF, but doesn’t like GRIB2. GFS data are in GRIB2, however, so it would be nicve if we could convert them easily to NetCDF.

We can do this by using the great wgrib2 tool (

To install wgrib2 (on ORR2 or SONIC, for example), do the following:

  1. Make a directory for wgrib2 and move there:
    mkdir wgrib2
    cd wgrib2
  2. Get wgrib2 and unpack it:
    tar -xzf wgrib2.tgz
  3. Move into the directory, set environment variables and make wgrib2:
    cd grib2/
    export CC=gcc
    export FC=gfortran
  4. Now you can convert a GFS GRIB2 file to NetCDF!
    wgrib2/grib2/wgrib2/wgrib2 gec00.t12z.pgrb2f00 -netcdf

    It’d be a good idea to add the wgrib2 executable directory to your PATH, so you can call it from any directory.