Regridding

Regridding griggs Thu, 04/25/2019 - 16:23

Regrid-Data-Plane

Regrid-Data-Plane griggs Thu, 04/25/2019 - 16:25

The MET grid-to-grid tools (i.e. Grid-Stat, MODE, Wavelet-Stat, Ensemble-Stat, Series-Analysis, and so on) require that their input data be placed on a common grid prior to processing. Users may either interpolate to a common grid prior to calling the tools or utilize the automated regridding feature within the MET tools. The latter is controlled by the regrid section of the MET configuration files. In this section we discuss options for regridding prior to calling the MET grid-to-grid tools using the Regrid-Data-Plane tool, copygb for GRIB1 data, or wgrib2 for GRIB2 data.

Regrid-Data-Plane Functionality

The Regrid-Data-Plane tool reads one or more fields from any gridded data file that MET supports. It defines the output grid as a named grid, the path to a gridded data file, or an explicit grid specification string. It regrids the input data to the output grid applying the user-specified interpolation options. It writes regridded data to an output NetCDF file. Regrid-Data-Plane calls exactly the same library code that is used during the automated regridding step in the MET grid-to-grid tools. It is just a stand-alone regridding utility.

Regrid-Data-Plane Usage

View the usage statement for Regrid-Data-Plane by simply typing the following:

regrid_data_plane

At a minimum, the input_filename, output_filename, output to_grid grid specification, and at least one -field of data must be defined. You may use -field multiple times to process multiple fields of data, but there is no way to process ALL data. The -method and -width options define the regridding method to be applied.

Run

Run griggs Thu, 04/25/2019 - 16:26

Run the following commands to regrid 2-meter temperature data several different ways:

regrid_data_plane \
$MET_TUTORIAL_DATA/input/sample_fcst/2005080700/wrfprs_ruc13_12.tm00_G212 \
G130 \
$MET_TUTORIAL_DATA/output/regrid_data_plane/tmp_z2_G130.nc \
-field 'name="TMP"; level="Z2";'
  • The default interpolation method is nearest neighbor. Rerun this command using the mean within a 10x10 interpolation box, which applies a large amount of smoothing:
regrid_data_plane \
$MET_TUTORIAL_DATA/input/sample_fcst/2005080700/wrfprs_ruc13_12.tm00_G212 \
G130 \
$MET_TUTORIAL_DATA/output/regrid_data_plane/tmp_z2_smooth.nc \
-field 'name="TMP"; level="Z2";' \
-method UW_MEAN -width 10
  • Next, define the output grid using the path to another gridded data file over the Pacific Northwest of the United States using bilinear interpolation:
regrid_data_plane \
$MET_TUTORIAL_DATA/input/sample_fcst/2005080700/wrfprs_ruc13_12.tm00_G212 \
$MET_TUTORIAL_DATA/input/sample_fcst/2009123112/arw-fer-gep1/d01_2009123112_02400.grib \
$MET_TUTORIAL_DATA/output/regrid_data_plane/tmp_z2_bilin.nc \
-field 'name="TMP"; level="Z2";' \
-method BILIN -width 2
  • Lastly, manually define a LatLon output domain (latlon Nx Ny lat_ll lon_ll delta_lat delta_lon) using the default nearest neighbor interpolation method:
regrid_data_plane \
$MET_TUTORIAL_DATA/input/sample_fcst/2005080700/wrfprs_ruc13_12.tm00_G212 \
'latlon 100 50 25 -100 0.25 0.25' \
$MET_TUTORIAL_DATA/output/regrid_data_plane/tmp_z2_latlon.nc \
-field 'name="TMP"; level="Z2";'

Output

Output griggs Thu, 04/25/2019 - 16:26

Run Plot-Data-Plane to visualize the output we generated on the previous page. Use the -plot_range option to keep the color scale fixed across all plots.

  • Plot the input data:
plot_data_plane \
$MET_TUTORIAL_DATA/input/sample_fcst/2005080700/wrfprs_ruc13_12.tm00_G212 \
$MET_TUTORIAL_DATA/output/regrid_data_plane/tmp_z2_input.ps \
'name="TMP"; level="Z2";' \
-plot_range 275 305
  • Plot the nearest neighbor G130 output:
plot_data_plane \
$MET_TUTORIAL_DATA/output/regrid_data_plane/tmp_z2_G130.nc \
$MET_TUTORIAL_DATA/output/regrid_data_plane/tmp_z2_G130.ps \
'name="TMP_Z2"; level="(*,*)";' \
-plot_range 275 305
  • Plot the smoothed G130 output:
plot_data_plane \
$MET_TUTORIAL_DATA/output/regrid_data_plane/tmp_z2_smooth.nc \
$MET_TUTORIAL_DATA/output/regrid_data_plane/tmp_z2_smooth.ps \
'name="TMP_Z2"; level="(*,*)";' \
-plot_range 275 305
  • Plot the bilinear Pacific Northwest output:
plot_data_plane \
$MET_TUTORIAL_DATA/output/regrid_data_plane/tmp_z2_bilin.nc \
$MET_TUTORIAL_DATA/output/regrid_data_plane/tmp_z2_bilin.ps \
'name="TMP_Z2"; level="(*,*)";' \
-plot_range 275 305
  • Plot the custom lat/lon grid output:
plot_data_plane \
$MET_TUTORIAL_DATA/output/regrid_data_plane/tmp_z2_latlon.nc \
$MET_TUTORIAL_DATA/output/regrid_data_plane/tmp_z2_latlon.ps \
'name="TMP_Z2"; level="(*,*)";' \
-plot_range 275 305

Open each of these PostScript images and compare them to the input ($MET_TUTORIAL_DATA/output/regrid_data_plane/tmp_z2_input.ps).

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

WGRIB2 (GRIB2)

WGRIB2 (GRIB2) griggs Thu, 04/25/2019 - 16:35

WGRIB2 Functionality

While COPYGB is recommended for regridding entire GRIB1 files, WGRIB2 is recommended for regridding GRIB2 files. We will not cover the details of WGRIB2 here but will refer you to the National Weather Service, Climate Predicition Center and in particular the explanation of the -new_grid option for regridding examples.