Skip Navigation Links 
NOAA logo - Click to go to the NOAA home page National Weather Service   NWS logo - Click to go to the NWS home page
Climate Prediction Center

About Us
   Our Mission
   Who We Are

Contact Us
   CPC Information
   CPC Web Team

HOME > Monitoring_and_Data > Oceanic and Atmospheric Data > Reanalysis: Atmospheric Data > wgrib2: new grib

wgrib2: new grib


When wgrib2 is processing a field, it has a copy of the grid point values and grib (sub-)message in memory. There are options that allow you to change the in-memory grid point values (ex. -rpn, -undefine). After changing the grid point values, you can write out new grib message using the updated in-memory grid point values using the -grib_out option. The packing/comprression using by -grib_out option is selected by the -set_grib_type option.

wgrib2 also has options for modifying the meta-data of the in-memory grib (sub-)message. Options like -set_var will set the variable name, -set_lev will change the level, -set_date will change the date code in the in-memory grib (sub-)message. Once you have modified the meta-data, you can write out a new grib message using the -grib_out or -grib options. The former will write out the message using the in-memory grid point values and the latter will use the in-memory grib message and original gridded values. The former is slower because it has to pack or compress the data.


Making grib-1 files was a pain because you had to specify much meta-data and had to worry about the packing. Making grib-2 files is even more painful because there is more meta-data to specify and more libraries are needed for packing/compression. One way to get around the meta-data problem is to use a template (a grib file with all the common metadata) and use some routines to modify the variable/level/date/etc codes. You still have to put the metadata into the template but you should be able to reuse the template.

The approach described in the first two paragraphs is a way to make new grib2 files using the template approach. For example, one may want to convert a data set into grib. After making a template, one could use the -import options.

NOAA/ National Weather Service
National Centers for Environmental Prediction
Climate Prediction Center
5830 University Research Court
College Park, Maryland 20740
Climate Prediction Center Web Team
Page last modified: May 15, 2005
Disclaimer Privacy Policy