Converting GRIB2 to NetCDF

Conversion of GRIB2 to NetCDF

There are a number of utilities that can perform this conversion so I'll list a few of those I've found.

Tested solution

The simplest solution, and the one I have tested, is the Climate Data Operators (CDO) from the Max Planck Institute. It is available for IBM AIX, CRAY, NEC, Linux, MacOS, FreeBSD & Windows (32bit). I tested the CDO using example Global Sea Surface Temperature and North Atlantic and Europe SST taken from the EUMETSAT site. The conversion command is simple and quick, for examplecdo -f nc copy M02-MARINE-OSSTGLB-0.0-1.1-20111016120000.000000000Z-1016602.grb \ M02-MARINE-OSSTGLB-0.0-1.1-20111016120000.000000000Z-1016602.ncThis seemed to produce sensible NetCDFs that claim to comply with the CF-1.4 convention.

CDO build notes for Linux

If compiling from scratch, to get GRIB2 support the GRIB_API from the ECMWF is also needed which in turn may needJasper to handle jpeg200 files.I built Jasper with the standard ./configure, make, make install chain and it installed to /usr/local . I built the GRIB API with/configure --prefix=/usr/local/app/grib_api --with-jasper=/usr/localthen the usual make, make install.

To compile CDO on our systems run./configure --with-netcdf=/usr/lib64 --with-hdf5=/usr/lib64 --with-proj=/usr/lib64 \ --with-grib_api=/usr/local/app/grib_api --with-jasper=/usr/localthen make, make install.

Other possibilities

NCAR's command language (NCL) provides the explicit command ncl_convert2nc to do the conversion. NCL requires registration to download, runs on UNIX and Mac natively and under Cygwin on windows. It can be built from source but this is not recommended.

The Norwegian Service Centre for Climate Modelling has a variation on NCL that requires either an existing NetCDF file to add to or provides utilities to create auxiliary CDL files or translation tables to tweak the NetCDF file format. This may be of use to some, but I'm guessing this facility is to cope with GRIB's use of descriptor files. See here.

Freely available full visualisation applications that can also be used to read and write both GRIB and NetCDF are PCMDI's Climate Data Analysis Tool (CDAT) or COLA's (GrADS).

Java users can use the NetCDF Java Library (version 2.2 and later) from here which provides a uniform interface for reading a large number of different data file types.

There is also degrib which is available for UNIX/Linux and Windows, but registration is required for downloads and it doesn't handle all forms of GRIB file.

The EAMNet project was partially funded by the European Commission Framework 7 Programme under Space Call SPA.2009.3.2.01 International Cooperation
Framework 7 logoThe EU stars logo