NCL Website header
NCL Home> Application examples> Models || Data files for some examples

Example pages containing: tips | resources | functions/procedures

WRF

Plotting WRF-ARW on Lambert Conformal projection

This suite of examples uses various gsn_csm scripts to plot WRF-ARW data.

The examples below reference WRF output files that are defined on a Lambert Conformal map projection, but these scripts should work for WRF data on other map projections as well. You can identify what map projection your WRF output file is on by looking at the "MAP_PROJ" global attribute on the file:

  • MAP_PROJ = 0 --> "CylindricalEquidistant"
  • MAP_PROJ = 1 --> "LambertConformal"
  • MAP_PROJ = 2 --> "Stereographic"
  • MAP_PROJ = 3 --> "Mercator"
  • MAP_PROJ = 6 --> "Lat/Lon"

Newer WRF files have a "MAP_PROJ_CHAR" attribute that give you the projection as a string.

To plot WRF-ARW data with the gsn_csm scripts in the native map projection defined on the file, you must do three things:

  1. Call wrf_map_resources

    This sets the necessary NCL resources to define the native map projection.

  2. Set tfDoNDCOverlay = True

    By default, when data are placed onto a map, NCL performs a transformation to the specified projection. This transformation is not needed if you have defined the native grid that your data is on. Setting tfDoNDCOverlay = True turns off this transformation, and also results in faster graphic generation.

  3. Set gsnAddCyclic = False

    The gsm_csm_*map* suite of interfaces expect global data, and hence they may try to add a longitude cyclic point. If plotting regional data, it is necessary to set gsnAddCyclic = False to prevent the longitude cyclic point from being added.

For more examples using gsn_csm plotting functions to plot WRF-ARW data, see the WRF-GSN plotting page.

For a suite of examples using WRF plotting functions to plot WRF-ARW data, we recommend that you visit the WRF-ARW Online Tutorial.

WRF_lc_1.ncl: This script creates a basic black-and-white contour plot at a specified time and level, using the native Lambert Conformal map projection defined on the file.

The function wrf_map_resources queries the WRF output file to set the necessary map resources. You must also set tfDoNDCOverlay to False to indicate you are plotting over a native map projection, and gsnAddCyclic to False to indicate this data is regional and not global.

WRF_lc_2.ncl: This script is similar to the previous one, except color-filled contours are created.

cnFillOn = True turns on color contours while cnFillPalette = "BlAqGrYeOrReVi200" allows the user to change the color map to the BlAqGrYeOrReVi200 color map. The color map can be chosen from a set of available color tables or created using various other techniques such as specifying named colors or RGB triplets.

pmTickMarkDisplayMode = "Always" turns on "nice" map tickmarks. The top and right side lat/lon labels may be turned off by setting tmXTOn = False and tmYROn = False.

WRF_lc_3.ncl: This script panels three different variables at the same time step. Using the cnFillPalette resource, you can assign a color map to each variable you want to plot. This resource can be set to any one of NCL's maps predefined color maps or you can create your own color map in various ways. See the color fill page for some examples.

gsn_panel is the procedure that controls the placement of multiple plots on a page. It expects a different resource variable (e.g. res vs. panel_res) since there are several panel-only options. The panel example page demonstrates these options.

WRF_lc_4.ncl: Panel a specified variable at every 6 forecast hours. When panelling an individual variable, it is usually desirable to have one common label bar, so it's important to defined the same the contour levels for each plot so the colors represent the same values.

The nice_mnmxintvl function can be used to determine "nice" contour levels for the range of your data:

  mnmxint = nice_mnmxintvl( min(x), max(x), 14, False)
  res@cnLevelSelectionMode  = "ManualLevels"   
  res@cnMinLevelValF        = mnmxint(0)
  res@cnMaxLevelValF        = mnmxint(1)
  res@cnLevelSpacingF       = mnmxint(2)/2.    ; twice as many levels
WRF_lc_5.ncl: WRF-ARW netCDF files do not have a missing value attribute (e.g. _FillValue). The SMOIS (soil moisture) and SST (sea surface temperature) variables use 1.0 and 0.0, respectively, to indicate out-of-range or missing values. These were determined by examining the file. To treat these as missing values, the _FillValue for each variable must be set manually.

The orientation of the label bar can be changed from the default horizontal by setting lbOrientation = "vertical"

cnFillMode = "RasterFill", turns on color rasters, which creates blocky contours if you don't have very high-resolution data.

WRF_lc_6.ncl: Use the RAINC and RAINNC variables to calculate the total precipitation. Prior to calculating the total, the algebraic operator ">" is used to ensure that negative values are set to zero.

Named colors are used create a custom color map. Each color matches the unequally spaced contour levels specified by the user.

WRF_lc_7.ncl:Basic vectors and wind barbs.

The U and V components are on a staggered grid. The wrf_user_unstagger function is used to unstagger the grids so they are on what's known as the "mass" grid.

WRF_lc_8.ncl: Overlay winds at 10 meters (U10, V10) over the total precipitation. Meteorological wind barbs are used to indicate direction and speed.