Skip Navigation Links www.nws.noaa.gov 
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-new_grid
 

wgrib2: -new_grid

Introduction

The -new_grid option interpolates the fields into a new grid. The default interpolation is bilinear but that can be changed using the -new_grid_interpolation option. This option uses scalar and vector interpolation as appropriate. In order for the vector interpolation to work, the vector quantities must be in a (U,V) order. For example: Z200, U200, V200, Z500, U500, V500 is good. If the vector quanties are not in (U,V) order, the vector quantites will not be interpolated.

The option is not part of the default configuration. The interpolation code is written in fortran and combining fortran and C code requires some work. For example, on my linux box with gcc and g95, I had to add the g95 libraries to the makefile. On NCEP's AIX, I had figure out the needed libraries. Using gfortran was easy but I had to search for the required libraries and add it to my makefile. Getting the C and Fortran code to cooperate requires some system-specific knowledge and may not be possible in all cases. Consequently you are on your own in getting the -new_grid option installed.

Installing -new_grid: unsupported

Did I make myself clear? To make Fortran and C code work together requires knowledge of the specific computer system. Consult your local expert. Don't ask me to read the documentation specific to your computer system. Don't make me guess which libraries are needed and where they hid the required libraries.

Limitations

  • only limited number of input grids are supported (can be expanded)
  • only limited number of output grids are supported (can be expanded)
  • only limited number of NCEP grids described (can be expanded)
  • interpolation library only uses degrees to the nearest milli-degree
  • Lambert conformal: LatD must follow grib1 conventions
  • Polar Stereographic: LatD must be 60 latitude

Installation

1) set USE_IPOLATES to 1 in the makefile
2) environment variable $FC must be set to the fortran-90 compiler, ex. export FC=gfortran
3) If $FC is not gfortran, openf95, xlf_r, or then
      modify the makefile for the new fortran compiler
      modify New_grid.c for the new fortran compiler
4) now you are ready to make

Usage

-new_grid_winds W -new_grid A B C outfile
    W = earth or grid
        earth means that the U wind goes eastward
        grid means that U wind goes from grid (i,j) to (i+1,j)
          which is not eastward in a Lambert-conformal or polar stereographic grids
    A, B, C are the output grid description
    outfile is an output file.  The grib-2 interpolated records are written in outfile

Examples

  wgrib2 IN.grb -new_grid_winds earth -new_grid latlon 100:10:1  30:20:1 OUT.grb
    Interpolates from IN.grb to OUT.grb
    Makes a 10x20, 1x1 degree lat-lon grid, lower left corner: 100E 30N


  wgrib2 IN.grb -new_grid_winds earth -new_grid ncep grid 221 OUT.grb
    Interpolates from IN.grb to OUT.grb
    Interpolates to NCEP grid 221.

Grid description format

-new_grid ncep grid I outfile                                   	I = 2,3,98,128,173,221,230,249  (ncep grid defintions)

-new_grid latlon lon0:nlon:dlon lat0:nlat:dlat outfile			lat-lon grid

									lat0, lon0 = degrees of lat/lon for 1st grid point 
									nlon = number of longitudes
									nlat = number of latitudes
									dlon = grid length, degrees of longitude
									dlat = grid length, degrees of latitude

-new_grid lambert:lov:latin1:latin2:lad lon0:nx:dx lat0:ny:dy outfile	lambert conic conformal
-new_grid lambert:lov:latin1:latin2 lon0:nx:dx lat0:ny:dy outfile       lad = latin2
-new_grid lambert:lov:latin1 lon0:nx:dx lat0:ny:dy outfile              latin2 = latini lad = latin1

									lov = longitude (degrees) where y axis is parallel to meridian
									latin1 = first latitude from pole which cuts the secant cone
									latin2 = second latitude from pole which cuts the secant cone
									lad = latitude (degrees) where dx and dy are specified
									lat0, lon0 = degrees of lat/lon for 1st grid point 
									nx = number of grid points in X direction
									ny = number of grid points in Y direction
									dx = grid length, meters in x direction at lad
									dy = grid length, meters in y direction at lad
                                                                        note: if latin2 >= 0, the north pole is on proj plane
                                                                              if latin2 < 0, the south pole is on proj plane


-new_grid nps:lov:lad lon0:nx:dx lat0:ny:dy outfile                     north polar stereographic
-new_grid sps:lov:lad lon0:nx:dx lat0:ny:dy outfile			south polar stereographic

									lov = longitude (degrees) where y axis is parallel to meridian
									lad = latitude (degrees) where dx and dy are specified
									lat0, lon0 = degrees of lat/lon for 1st grid point 
									nx = number of grid points in X direction
									ny = number of grid points in Y direction
									dx = grid length, meters in x direction at lad
									dy = grid length, meters in y direction at lad


-new_grid gaussian lon0:nx:dlon lat0:ny                                 global Gaussian grids
                                                                        lat0, lon0 = degrees of lat/lon for 1st grid point
                                                                        note: lon1 = -lon0, lat1 = lat0 + (nx-1)*dlon;
									nx = number of grid points in X direction
									ny = number of grid points in Y direction
                                                                             ny must be even
                                                                        dlon = grid length, degrees of longitude

-new_grid ncep grid NCEP_GRID_NO                                        some of my favorite NCEP grids
                                                                        NCEP_GRID_NO=2, 3, 98, 126, 128, 173, 221, 230, 249,
                                                                            and non-standard t62, t126, t382
                                                                        Want more ncep grids?  Modify ncep_grids.c


(v1.9.7)
-new_grid mercator:lad lon0:nx:dx:lonn lat0:ny:dy:latn outfile          lad = latitude (degrees) where dx and dy are specified

                                                                        lat0, lon0 = degrees of lat/lon for 1st grid point
                                                                        latn, lonn = degrees of lat/lon for last grid point
                                                                        nx = number of grid points in X direction
                                                                        ny = number of grid points in Y direction
                                                                        dx = grid length, meters in x direction at lad
                                                                        dy = grid length, meters in y direction at lad

                                                                        note: the mercator grid description is over specified
                                                                        User must make sure (nx,dy) is consistent with lonn
                                                                        as well as (ny,dy) is consistent with latn


lambert, nps, sps, mercator only support we:sn ordering
latlon, gaussian only support we:sn and we:ns ordering

Type of Interpolation

The IPOLATES library supports a number of interpolation schemes including bilinear (default), bicubic, neighbor and budget. The wgrib2 was tested with the spectral interpolation but that option was removed because it greatly increased the code size for a minor option. The interpolation can be selected by using the -new_grid_interpolation option before the -new_grid option. Some of the interpolation options need numeric parameters which are set by the -new_grid_ipopt option. IPOPT is an IPOLATES grid.

You can use different interpolations for different variables. For example, a bilinear interpolation of soil or vegetation type is meaningless.

    wgrib2 IN.grb -new_grid_winds earth \
      -new_grid_interpolation bilinear \
      -if ":(VGTYP|SOTYP):" -new_grid_interpolation neighbor -fi \
      -new_grid latlon 0:360:1 90:1811:-1 OUT.grb

   line 2: set default interpolation to bilinear
   line 3: if VGTYP or SOTYP then set the interpolatin nearest neighbor
   line 4: do the interpolation

Winds

Before you do an interpolation, you need to define the wind directions. Most people want the the V winds to be in the direction of the North Pole. With a verbose wgrib2 inventory, you will seee winds(N/S). Some meteorologists want the V winds to go from grid point (i,j) to (i,j+1). The corresponding wgrib2 notation is "winds(grid)". See the -new_grid_winds option for more details.

Quilting tiles - Merging files

Yes, it can be done using -new_grid, -bin, -import_bin -rpn, and the -grib_out options. No, I haven't done it.

Limitations

The IPOLATES library is used in operations at NCEP but has its limitations. Grids used by NCEP get supported and others don't. The library has a grib-1 interface, so new features of grib2 are not supported and the precision of the grid parameters are limited to the grib-1 values. For example, latitude and longitude values are limited to milli-degrees.
  1. only not all grids supported by IPOLATES
  2. only common grids are supported by the wgrib2 "wrapper" for IPOLATES
  3. latitude, longitude values are in milli-degrees (affects interpolation)
  4. only grib1 scan order are supported (i.e., WE:SN and WE:NS)
  5. NDFD/Glahn scan order are not supported (i.e., WE|EW:SN)

NDFD work arounds

NDFD files are written in an order which is not supported by the IPOLATES library. The NDFD files come in (WE|EW):SN order. Which means the odd rows are in WE order and the even rows are EW order. The rows go from south to north. The solution is to convert the grid to WE:SN order is

  1. for data in input=WE|EW:SN scan order (wgrib2 IN -scan)
  2. read data, change order scan order of data, change flag table 3.4, save data
  3. wgrib2 IN.grb -rpn alt_x_scan -set table_3.4 64 -grib_out OUT.grb

A variation of the previous trick can be used to put data in to (WE|EW):SN packing. See also: -new_grid_interpolation, -new_grid_winds, -lola, -bin, -import_bin, -rpn, -grib_out,


NOAA/ National Weather Service
National Centers for Environmental Prediction
Climate Prediction Center
5200 Auth Road
Camp Springs, Maryland 20746
Climate Prediction Center Web Team
Page last modified: Oct 28, 2011
Disclaimer Privacy Policy