GRIB2 file carpentry
Nov. 18, 2016
Posted by: RDA Team
Note: This page was originally sourced from our Blogger page: http://ncarrda.blogspot.com/2016/11/grib2-file-carpentry.htmlWe've learned from several users that the second WRF method in our post about How to work around operational changes to GFS/GDAS/FNL does not work.
Use the first method described.
First, you can work around the problem by removing the new vertical levels in the files after the GFS/GDAS change. Then all of your WPS input will be consistent. You can do this yourself with wgrib2, or our "Get a Subset" tool.Here's the detailed recipe for those of you not familiar with wgrib2 tool for manipulating grib2 files.
We're going to use tip #4 and #4a from Wesley's Tricks for wgrib2 page to extract a range of records from a grib2 file.
Start by making a short inventory to identify the records that you want to keep and to remove.
wgrib2 gdas1.fnl0p25.2016051106.f00.grib2 > gdas1.fnl0p25.2016051106.f00.inv
wgrib2 gdas1.fnl0p25.2016051112.f00.grib2 > gdas1.fnl0p25.2016051112.f00.inv
Note that gdas1.fnl0p25.2016051106.f00.inv has 322 lines and gdas1.fnl0p25.2016051112.f00.inv has 352 lines. The extra 30 lines/records are in records 5-34.
for file in gdas1*f00.grib2; do
wgrib2 $file -for 1:4 -grib temp1
wgrib2 $file -for 35:352 -grib temp2
cat temp1 temp2 > $file.27