COPYGB (GRIB1)

COPYGB (GRIB1) griggs Thu, 04/25/2019 - 16:28

COPYGB Functionality

The COPYGB tool was developed by the NOAA Environmental Modeling Center, is distributed by the National Weather Service, Climate Prediction Center, and is also distributed as part of the Unified PostProcessor (UPP). It may be run on GRIB files to horizontally interpolate the data from one grid to another. The MET tools which compare gridded forecasts to gridded observations (Grid-Stat, Wavelet-Stat, Ensemble-Stat and, MODE) require that the input forecast and observation data be on the same grid. Therefore the COPYGB tool is very useful in preparing your gridded data for use in MET.

The following copygb commands assume that copygb is installed on your system and has been added to your path.

COPYGB Usage

If you have copygb installed on your machine, view the usage statement by simply typing the following:

copygb.exe

 

Usage: copygb  
  [-g "grid [kgds]"] [-i "ip [ipopts]"] [-k "kpds"] [-v "uparms"]
  [-B mapgrib [-b mapindex] [-A "<> mapthreshold"] [-K "mapkpds"]]
  [-M "mask"/mergegrib [-m mergeindex]] [-X] [-a] [-N namelist]
  then either: grib1 index1 grib2
  or: -x grib1 grib2

COPYGB accepts many optional command line options which control its functionality. In this tutorial, we'll focus on the simplest types of horizontal interpolation using the default interpolation options. For a full description of these command line options, please see the copygb.doc COPYGB documentation file.

Run: Predefined

Run: Predefined griggs Thu, 04/25/2019 - 16:29

In this tutorial, we'll run COPYGB several times to do the following:

  1. Interpolate to a predefined NCEP grid.
  2. Interpolate to a user-defined Lat/Lon grid.
  3. Interpolate to a user-defined Lambert Conformal grid.
  4. Interpolate to a user-defined Polar Stereographic grid.

Predefined NCEP Grid

First, we'll run the wgrib tool to dump out information about a sample GRIB file:

wgrib -V $MET_TUTORIAL_DATA/input/sample_obs/ST2ml/ST2ml2005080712.Grb_G212

The -V argument for wgrib dumps out the definition of the grid on which the data resides. This data is on a Lambert Conformal grid with the grid definition parameters listed below:

Lambert Conf: Lat1 12.190000 Lon1 -133.459000 Lov -95.000000
Latin1 25.000000 Latin2 25.000000 LatSP 0.000000 LonSP 0.000000
North Pole (185 x 129) Dx 40.635000 Dy 40.635000 scan 64 mode 8

This data resides on NCEP Grid 212 (image), a 40-km Lambert Conformal grid over the contiguous United States. Now run COPYGB on this file to interpolate this data to NCEP Grid 202 (image), a 190-km Polar Stereographic grid:

mkdir -p $MET_TUTORIAL_DATA/output/copygb

copygb.exe \
-xg 202 \
$MET_TUTORIAL_DATA/input/sample_obs/ST2ml/ST2ml2005080712.Grb_G212 \
$MET_TUTORIAL_DATA/output/copygb/ST2ml2005080712.Grb_G202

In the command above the -x option indicates that we want the data to be extracted and the -g 202 option indicates that the data should be interpolated to NCEP Grid 202. Next, run wgrib on the output and note that the grid definition has changed:

wgrib -V $MET_TUTORIAL_DATA/output/copygb/ST2ml2005080712.Grb_G202

The resulting grid definition parameters are listed below:

polar stereo: Lat1 7.838000 Long1 -141.028000 Orient -105.000000
north pole (65 x 43) Dx 190500 Dy 190500 scan 64 mode 9

For a list of the predefined NCEP grids available, please see:
http://www.nco.ncep.noaa.gov/pmb/docs/on388/tableb.html

Run: Lat/Lon

Run: Lat/Lon griggs Thu, 04/25/2019 - 16:31

For most users of WRF and MET, using the predefined NCEP grids will not suffice. Instead, you will often want to interpolate to the domain on which your model data resides. This is easy to do with COPYGB but will require you to define the grid to be used on the command line. The grid definition arguments to COPYGB differ based on the type of projection used. Listed below are the arguments for user-defined Lat/Lon grids:

copygb -g"255 0 NX NY LAT0 LON0 128 LAT1 LON1 DX DY 64" -x in.grb out.grb

where  
  255 0 User-defined Lat/Lon grid
  NX Number of points on latitude circle
  NY Number of points on longitude meridian
  LAT0 Latitude of origin * 1000 (lat = -90 ... 90)
  LON0 Longitude of origin * 1000 (lon = -180 ... 180)
  128
  LAT1 Latitude of extreme (last) point * 1000
  LON1 Longitude of extreme (last) point * 1000
  DX Longitudinal increment in millidegrees
  DY Latitudinal increment in millidegrees
  64

Please note that all of the grid definition parameters must be integers. All latitude, longitude, and increments values are given in thousandths of a degree.

User-Defined Lat/Lon Grid

Let's define a Lat/Lon grid over the central United States as follows:

  • Latitude ranging from 35N to 45N
  • Longitude ranging from 105W to 90W
  • 0.5 degree grid spacing

Translate this definition to the COPYGB grid specification as follows:

  • NX = 30
  • NY = 20
  • LAT0 = 35000
  • LON0 = -105000
  • LAT1 = 45000
  • LON1 = -90000
  • DX = 500
  • DY = 500

Plug these numbers into the grid specification and run COPYGB as follows:

copygb.exe \
-xg"255 0 30 20 35000 -105000 128 45000 -90000 500 500 64" \
$MET_TUTORIAL_DATA/input/sample_obs/ST2ml/ST2ml2005080712.Grb_G212 \
$MET_TUTORIAL_DATA/output/copygb/ST2ml2005080712.Grb_latlon

Lastly, run wgrib on the COPYGB output and make sure the grid definition matches what you expected:

wgrib -V $MET_TUTORIAL_DATA/output/copygb/ST2ml2005080712.Grb_latlon

Run: Lambert conformal grid

Run: Lambert conformal grid griggs Thu, 04/25/2019 - 16:32

The COPYGB grid definition parameters for Lambert Conformal grids are listed below:

copygb -g"255 3 NX NY STARTLAT STARTLON 8 CENLON DX DY POLE 64 TRUELAT1 TRUELAT2" -x in.grb out.grb

where  
  255 3 User-defined Lambert Conformal grid
  NX Number of points on latitude circle
  NY Number of points on longitude meridian
  STARTLAT Southwest corner latitude * 1000 (lat = -90 ... 90)
  STARTLON Southwest corner longitude * 1000 (lon = -180 ... 180)
  8
  CENLON Center longitude * 1000
  DX Longitudinal increment in meters
  DY Latitudinal increment in meters
  POLE Northern (0) or southern (128) hemisphere
  64
  TRUELAT1 First true latitude * 1000
  TRUELAT2 Second true latitude * 1000

Please note that all of the grid definition parameters must be integers. All latitude and longitude values are given in thousandths of a degree. The grid increments are given in meters.

User-Defined Lambert Conformal Grid

Rather than defining a Lambert Conformal manually, we'll use the output of wgrib to define the grid we'd like to use. Let's look again at the wgrib output for NCEP grid 212:

wgrib -V $MET_TUTORIAL_DATA/input/sample_obs/ST2ml/ST2ml2005080712.Grb_G212

Here is the grid definition:

Lambert Conf: Lat1 12.190000 Lon1 -133.459000 Lov -95.000000
Latin1 25.000000 Latin2 25.000000 LatSP 0.000000 LonSP 0.000000
North Pole (185 x 129) Dx 40.635000 Dy 40.635000 scan 64 mode 8

Translate this definition to the COPYGB grid specification as follows:

  • NX = 185
  • NY = 129
  • STARTLAT = 12190
  • STARTLON = -133459
  • CENLON = -95000
  • DX = 40635
  • DY = 40635
  • TRUELAT1 = 25000
  • TRUELAT2 = 25000

Plug these numbers into the grid specification and run COPYGB follows:

copygb.exe \
-xg"255 3 185 129 12190 -133459 8 -95000 40635 40635 0 64 25000 25000" \
$MET_TUTORIAL_DATA/input/sample_fcst/2009123112/arw-fer-gep1/d01_2009123112_02400.grib \
$MET_TUTORIAL_DATA/output/copygb/d01_2009123112_02400.grib_lambert

Lastly, run wgrib on the COPYGB output and make sure the grid matches the one listed above:

wgrib -V $MET_TUTORIAL_DATA/output/copygb/d01_2009123112_02400.grib_lambert

Run: Polar Stereographic

Run: Polar Stereographic griggs Thu, 04/25/2019 - 16:33

The COPYGB grid definition parameters for Polar Stereographic grids are listed below:

copygb -g"255 5 NX NY STARTLAT STARTLON 8 CENLON DX DY POLE 64" -x in.grb out.grb

where  
  255 5 User-defined Polar Stereographic grid
  NX Number of points on latitude circle
  NY Number of points on longitude meridian
  STARTLAT Southwest corner latitude * 1000 (lat = -90 ... 90)
  STARTLON Southwest corner longitude * 1000 (lon = -180 ... 180)
  8
  CENLON Center longitude * 1000
  DX Longitudinal increment in meters
  DY Latitudinal increment in meters
  POLE Northern (0) or southern (128) hemisphere
  64

Please note that all of the grid definition parameters must be integers. All latitude and longitude values are given in thousandths of a degree. The grid increments are given in meters.

User-Defined Polar Stereographic Grid

Again, let's look at the wgrib output for a Polar Stereographic grid and use it to define the grid definition arguments for COPYGB. Run wgrib on a Polar Stereographic dataset:

wgrib -V $MET_TUTORIAL_DATA/output/copygb/ST2ml2005080712.Grb_G202

Here is the grid definition:

polar stereo: Lat1 7.838000 Long1 -141.028000 Orient -105.000000
north pole (65 x 43) Dx 190500 Dy 190500 scan 64 mode 9

Translate this definition to the COPYGB grid specification as follows:

  • NX = 65
  • NY = 43
  • STARTLAT = 7838
  • STARTLON = -141028
  • CENLON = -105000
  • DX = 190500
  • DY = 190500
  • POLE = 0

Plug these numbers into the grid specification and run COPYGB follows:

copygb.exe \
-xg"255 5 65 43 7838 -141028 8 -105000 190500 190500 0 64" \
$MET_TUTORIAL_DATA/input/sample_obs/ST2ml/ST2ml2005080712.Grb_G212 \
$MET_TUTORIAL_DATA/output/copygb/ST2ml2005080712.Grb_stereo

Lastly, run wgrib on the COPYGB output and make sure the grid matches the one listed above:

wgrib -V $MET_TUTORIAL_DATA/output/copygb/ST2ml2005080712.Grb_stereo