wgrib2: -ave, -fcst_ave
Introduction
The -ave
and -fcst_ave options are very similar;
they both make temporal averages.
The -fcst_ave option uses the verification time
and the -ave option uses the reference time
for the temporal average.
You would use -fcst_ave to temporally average
a single forecast run. For example, you have a 3 week forecast with
output every 6 hours. You could use -fcst_ave
to find the forecast for the second week.
You would use -ave to temporally average
the results of different analyses. Suppose you have
analyses every 6 hours and you want to find the analysis for the month.
The input grib file has to be processed in a special order. Don't worry,
a grib file can be ordered very easily with the sort command. wgrib2 reads the data
sequentially and when ever it encounters a new variable/level/chemical-type,
it starts the averaging process. The length of the averaging depends on
how many records it finds to average. For example, to make a daily
average, a file has to be in the following order.
U500 2000-01-02 00Z start ave
U500 2000-01-02 06Z
U500 2000-01-02 12Z
U500 2000-01-02 18Z end ave
V500 2000-01-02 00Z start ave
V500 2000-01-02 06Z
V500 2000-01-02 12Z
V500 2000-01-02 18Z end ave
Z500 2000-01-02 00Z start ave
Z500 2000-01-02 06Z
Z500 2000-01-02 12Z
Z500 2000-01-02 18Z end ave
To make a daily average of the above file, you need to specify the
output file and the time interval between samples. The time
units are the same as used by GrADS (hr, dy, mo, yr).
$ wgrib2 input.grb -ave 6hr out.grb
If the file is not sorted, you can use the unix sort by,
$ wgrib2 input.grb | sort -t: -k4,4 -k5,5 -k6,6 -k3,3 | \
wgrib2 -i input.grb -set_grib_type c3 -ave 6hr output.grb
If you want to make daily means from 4x daily monthly files
and assuming that more than one variable/level is in the monthly file.
$ wgrib2 input.grb | sed 's/\(:d=........\)/\1:/' | \
sort -t: -k3,3 -k5,5 -k6,6 -k7,7 -k4,4 | \
wgrib2 input.grb -i -set_grib_type c3 -ave 6hr daily.ave.grb
Using -fcst_ave is like using
-ave except you use the verification
time instead of the reference time. To make an inventory that
use the verification time instead of the reference time, you type,
$ wgrib2 input.grb -vt -var -lev -misc
1:0:vt=2011040101:PRATE:surface:
2:592224:vt=2011040102:PRATE:surface:
3:1233694:vt=2011040103:PRATE:surface:
4:1909322:vt=2011040104:PRATE:surface:
5:2612620:vt=2011040105:PRATE:surface:
The sed command will be alterered very slightly when making the
sort (:d=) -> (:st=).
Usage
-ave (time interval) (output grib file)
-fcst_ave (time interval) (output grib file)
only works with PDT=4.0, 4.1 and 4.8
See also:
|