NCL Website header
NCL Home > Documentation > Functions > WRF, Interpolation


Vertically interpolates ARW WRF variables given the type of surface and a set of new levels.

Available in version 6.3.0 and later.


load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"      ; These two libraries are automatically
load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRFUserARW.ncl"    ; loaded from NCL V6.4.0 onward.
                                                              ; No need for user to explicitly load.

	function wrf_user_vert_interp (
		file_handle         : file or list,  
		field               : numeric,       
		vert_coordinate [1] : string,        
		interp_levels   [*] : numeric,       
		opts            [1] : logical        

	return_val  :  numeric



Reference to an input netCDF file opened with addfile, or list of NetCDF files opened with addfiles.


The field variable to be interpolated. This must be a 3D array dimensioned bottom_top x south_north x west_east, or a 4D array dimensioned time x bottom_top x south_north x west_east.


A scalar string indicating the type of surface to interpolate to. Valid strings are:

  • "pressure", "pres" - pressure [hPa]
  • "ght_msl" - grid point height msl [km]
  • "ght_agl" - grid point height agl [km]
  • "theta" - potential temperature [K]
  • "theta-e" - equivalent potential temperature [K]


A 1D array of vertical levels to interpolate to.


A scalar logical that can be set to True to indicate additional options attached as attributes. Valid attributes are:

  • opts@extrapolate (logical) - whether to extrapolate values below ground (default=False)

  • opts@field_type (string) - the type of field; valid values are:

    • "ght"
    • "pressure", "pres", "p"
    • "t"
    • "z"
    • "none"

  • opts@logP (logical) - use the log of the pressure for interpolation instead of just pressure (default=False)

  • opts@time (logical) - the time index used to extract the variables for interpolation, which should be set to the same time index that was used to extract the field that is being interpolated (default=-1)
    (Available in version 6.4.0 and later.)

Return value

The return variable will be the same dimensionality as field, except with the level dimension replaced by the number of new levels. An attribute called "vert_interp_type" will be added to indicate the type of interpolation done.

Bug fixed in version 6.4.0: The coordinate variable interp_levels is no longer reversed in the returned variable.


This function does a vertical interpolation of ARW WRF variables to several possible surfaces: Pressure, Height, AGL, Height MSL, Potential Temperature and Equivalent Potential Temperature. It also does an extrapolation below ground level and above the model surfaces.

wrf_user_vert_interp is part of a library of functions and procedures in WRFUserARW.ncl written to help users plot ARW WRF model data.

Questions on this function should be sent to

See Also

See the full list of WRF functions.


Example 1

  filename = "wrfout_d01_1991-01-01_00:00:00"
  fin      = addfile(filename+".nc","r")

  fld = wrf_user_getvar(fin,"tk",-1)     ; The variable to interpolate

  vert_coord       = "theta"
  interp_levels    = ispan(200,1000,50)
  opts             = True
  opts@extrapolate = True 
  opts@field_type  = "T"
  opts@logP        = True 
  fld_intrp = wrf_user_vert_interp(fin,fld,vert_coord,interp_levels,opts)

The output will be:

Variable: fld_intrp
Type: float
Total Size: 7493940 bytes
            1873485 values
Number of Dimensions: 4
Dimensions and sizes:[Time | 1] x [interp_levels | 17] x [south_north | 279] x [west_east | 395]
            interp_levels: [200..1000]
Number Of Attributes: 8
_FillValue :9.96921e+36
description :Temperature
FieldType :104
MemoryOrder :XYZ
units :K
stagger :
coordinates :XLONG XLAT
vert_interp_type :theta

Example 2

  in_files = (/"wrfout_d02_2005-08-28_00:00:00", \
                wrfout_d02_2005-08-28_12:00:00", \
  input_list = addfiles(in_files, "r")
  timeidx = 6
  fld1 = wrf_user_getvar(input_list, "tk", timeidx)
  vert_coord       = "theta"
  interp_levels    = (/200,300,500,1000/)
  opts             = True
  opts@extrapolate = True 
  opts@field_type  = "T"
  opts@logP        = True
  opts@time        = timeidx  
  fld1_intrp = wrf_user_vert_interp(input_list,fld1,vert_coord,interp_levels,opts)

The output will be:

Variable: fld1_intrp
Type: float
Total Size: 147456 bytes
            36864 values
Number of Dimensions: 3
Dimensions and sizes:   [interp_levels | 4] x [south_north | 96] x [west_east | 96]
            interp_levels: [200..1000]
Number Of Attributes: 8
  _FillValue :  9.96921e+36
  description : Temperature
  coordinates : XLONG XLAT XTIME
  stagger : 
  units :   K
  MemoryOrder : XYZ
  FieldType :   104
  vert_interp_type :    theta