bilingrb - A bilinear GRIB interpolator & subsampler
bilingrb is a program for extraction, interpolation, or
subsampling of geographic subdomains from GRIB 2D-fields in
lat-lon format. The records are interpolated using bilinear
interpolation, not the most subtle of techniques, but frequently close
enough for .gov work.
Comments are appreciated, future versions may appear.
Syntax
% bilingrb gribfile newgribfile westlon southlat dlon
dlat nlon nlat
where gribfile & newgribfile are the old and new GRIB files,westlon,southlat
are the coords of the SW corner in your new grid, dlon & dlat
define the east and north resolution in degrees, and nlon & nlat
define the grid size in the east and north direction, respectively.
Facts & caveats
- The grid must be in geographic coordinates (lat-lon). The
grid scan mode is arbitrary.
- Do not use bilingrb with directional data, it will
mess up your data seriously near the branch cut (where the wind
direction shifts from 0 to 359 degrees). Such GRIB records
must be weeded out in advance, for instance with wgrib, an
excellent piece of software available at www.cpc.ncep.noaa.gov/products/wesley.
- Vector components near the poles should be handled with care.
- Cyclic grids (periodic in longitude) are allowed, selecting a
subdomain that crosses the branch cut (0/360 or -180/180) is also
allowed.
- Subsampling is achieved by selecting the starting coordinates to
coincide with the grid points in the old grid and choosing dlon and dlat, the resolution, to be
multiples of the original resolution.
- Undefined points (e.g. land in an ocean grid) are tackled by bilingrb.The
new grid points become undefined if any of their neighbours in the old
grid are undefined (except when the new grid point coincides exactly
with a grid point in the old grid, this to avoid unnecessary swelling of
coastlines when subsampling).
- Specifying bounding coords that go beyond the original grid
domain is verboten and will cause bilingrb to quit, so
make sure you weed out unwanted records from your GRIB file in
advance.
- The interpolation is weighted with the cosine of the latitude.
Examples
1. If world.grb is a global file with resolution 1.5 x
1.5 deg, then
% bilingrb world.grb smallworld.grb -10.0 45.0 0.5 0.5 51
71
produces a 51x71 interpolated subdomain with bounding coordinates
(45N,10W) and (80N,15E) with resolution 0.5 x 0.5 deg.
2. If a subsampled version of world.grb
with resolution 3.0 x 3.0 deg is desired, then
% bilingrb world.grb sparseworld.grb 0.0 -90.0 3.0 3.0
121 61
yields a 121x61 subsampled grid of the whole domain, assuming the
original grid has a node at (90S,0E). Note that when subsampling it is
recommended that you select westlon, southlat to coincide with a grid
point in the old grid and dlon, dlat to be multiples of the old grid
resolution. This circumvents interpolation error and avoids bloated
coastlines if dealing with undef'd points (dry points in a wet dataset).
Installation
% tar -xvf gribw.tar
% cd gribw
% make -f gribwlib.make
% cd ../bilingrb
% make -f bilingrb.make
The gribw library (gribw.tar)
home page will
have links to the current version of gribw.tar.
See also
ggrib, a program for
extracting subdomains without interpolating.
wgrib, a program for
viewing and extracting records.
gribw, grib writing library
v1.1, 2004-01-22,
oyvind.breivik@met.no, 5/2006 revised links WNE
--
Øyvind Breivik, Norwegian Meteorological Institute,
www.met.no