Apply the rules defined in rules_file to each grib message in the grib files provided as arguments.
grib_filter [options] rules_file grib_file grib_file ...
Force. Force the execution not to fail on error.
Output grib is written to output_grib_file. If an output grib file is required and -o is not used, the output grib is written to filtered.out
Multi-field support off. Turn off support for multiple fields in single grib message.
Version.
Copy GTS header.
GRIBEX compatibility mode.
Message type. T->GTS, B->BUFR, A->Any (Experimental). The input file is interpreted according to the message type.
Does not fail when the message has wrong length
Verbose.
The grib_filter processes sequentially all grib messages contained in the input files and applies the rules to each one of them. Input messages can be written to the output by using the "write" statement. The write statement can be parameterised so that output is sent to multiple files depending on key values used in the output file name. If we write a rules_file containing the only statement:
write "../data/split/[centre]_[date]_[dataType]_[levelType].grib[editionNumber]"; |
> grib_filter rules_file ../data/tigge_pf_ecmwf.grib2 > ls ../data/split ecmf_20060619_pf_sfc.grib2 ecmf_20060630_pf_sfc.grib2 ecmf_20070122_pf_pl.grib2 ecmf_20070122_pf_pt.grib2 ecmf_20070122_pf_pv.grib2 ecmf_20070122_pf_sfc.grib2 |
The key values in the file name can also be obtained in a different format by indicating explicitly the type required after a colon.
write "../data/split/[centre:l]_[date]_[dataType:l]_[levelType].grib[editionNumber]"; |
> grib_filter rules_file ../data/tigge_pf_ecmwf.grib2 > ls ../data/split 98_20060619_4_sfc.grib2 98_20060630_4_sfc.grib2 98_20070122_4_pl.grib2 98_20070122_4_pt.grib2 98_20070122_4_pv.grib2 98_20070122_4_sfc.grib2 |
Other statements are allowed in the grib_filter syntax:
# Temperature if ( level == 850 && indicatorOfParameter == 11 ) { print "found indicatorOfParameter=[indicatorOfParameter] level=[level] date=[date]"; transient oldtype = type ; set identificationOfOriginatingGeneratingSubCentre=98; set gribTablesVersionNo = 128; set indicatorOfParameter = 130; set localDefinitionNumber=1; set marsClass="od"; set marsStream="kwbc"; # Negatively/Positively Perturbed Forecast if ( oldtype == 2 || oldtype == 3 ) { set marsType="pf"; set experimentVersionNumber="4001"; } # Control Forecast if ( oldtype == 1 ) { set marsType="cf"; set experimentVersionNumber="0001"; } set numberOfForecastsInEnsemble=11; write; print "indicatorOfParameter=[indicatorOfParameter] level=[level] date=[date]"; print; } |
The switch statement is an enhanced version of the if statement. Its syntax is the following:
switch (key1,key2,...,keyn) { case val11,val12,...,val1n: # block of rules; case val21,val22,...,val2n: # block of rules; default: # [ block of rules ] } |
processing paramId=[paramId] [shortName] [stepType] switch (shortName,indicatorOfParameter) { case tp: set stepType=accum; case ~,2 : set typeOfLevel=surface; default: } |