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-set_metadata

wgrib2: -set_metadata


Whenever -set_metadata option is "executed", one line of the data file is read, the metadata is then applied to the current (sub-)message. For example, your grib file has 3 messages and you want to alter the metadata. Here is a metadata file that could be used to alter the grib file.

0:0:d=2009010100:HGT:500 mb:anl:scale=0,0:
0:0:d=2009010100:TMP:2 m above ground:anl
0:0:d=2009010106:HGT:500 mb:12 hour forecast:scale=0,0

The format of the metadata file resembles the wgrib2 inventory by design. The first and second fields are ignored by by -set_metadata. In practice, the first first is the record number and the second field is the byte location of the template to be used. (A template file could be a collection of templates.) The third through sixth fields are the date code, variable name, level and ftime. Finally the remaining fields are optional and order independent.

		Optional fields

    scale=I,J			set decimal scaling (I) and binary scaling (J)
    packing=S                   set compression/packing to S
                                S=simple,complex1,complex2,complex3,jpeg (long form)
                                S=s,c1,c2,c3,j (short form)
    N%d level                   set percentile
    prob ...                    set probability
    ENS=...                     set ensemble member info
                                ENS=hi-res, low-res, +N, or -N
    N ens members               set number of ensemble members
                                ex. 22 ens members
    code table X.Y=Z            set code table, equivalent -set table_X.Y Z   requires wgrib2 v2.0.5+
    flag table X.Y=Z            set flag table, equivalent -set table_X.Y Z   requires wgrib2 v2.0.5+
                                note: not X.Y have been implemented

             Following options follows -set VAR VAL and do not follow the wgrib2 inventory format
    center=                     set center
    subcenter=                  set sub-center
    table_M.N=                  only for selected M.N

To change the metadata, you can do

wgrib2 in.grb -set_metadata  meta -grib_out out.grb

The -set_metadata option is used for creating grib2 files. Note that both -set_metadata and the various -import options will change the output precision. Consequently the -import option should preceed the -set_metadatda option.

Note: only a subset of levels and ftime parameters is currently implemented. The -set_metadatda option does not support all metadata.

To format of the levels and ftime are the same was used by wgrib2 inventories.

See also: -set_ave, -set_date, -set_ftime, -set_lev, -set_metadata_str, -set_scale, set_var,

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: April 4, 2016.
Disclaimer Privacy Policy