NCL Home > Documentation > Functions > WRF, Interpolation


Interpolates two-dimensional WRF-ARW field along a line.

Available in version 6.6.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_interp_line (
		var2d      : numeric,  
		loc_param  : numeric,  ; up to four values
		opt    [1] : logical   

	return_val  :  numeric



Data that will be interpolated. The rightmost dimensions of this array are ny x nx.


An array of four values representing the start point and end point for the cross section (start_x, start_y, end_x, end_y) OR a single point when opt@use_pivot is True representing the pivot point.

The values can be in grid coordinates or lat/lon coordinates (start_x = start_lon, start_y = start_lat, ...). If using lat/lon coordinates, then opt@latlon must be True.


A logical scalar that can optionally contain attributes. See description below.

Return value

Data interpolated to a specified line on the model domain.


This function interpolates two-dimensional WRF-ARW model data onto a specified line.

The interpolation can be further customized by attaching attributes to the opt argument:

  • use_pivot - set to True to indicate that loc_param and opt@angle are used. Otherwise, loc_param must be set to four values to indicate a start and end point.

    Default: False

  • angle - an angle for vertical plots - 90 represents a WE cross section; ignored if opt@use_pivot is either not set or is set to False.

    Default: 0.0

  • latlon - set to True if the values in loc_param are latitude and longitude values rather than grid values

    Default: False

  • file_handle - must be set to a file handle when opt@latlon is True or opt@linecoords is True, otherwise this is ignored.

  • timeidx - the time index to use for moving nests when latlon is True. Use 0 if the nest is not moving.

    Default: 0

  • linecoords - set to True to include the latitude and longitude coordinates for the cross section line in the output attributes.

    Default: False

See Also

wrf_user_interp_level, wrf_user_vert_cross


  a = addfile("","r")

;---Retrieve T2 for all time periods
  t2 = wrf_user_getvar(a,"T2",-1)        

  dims = dimsizes(t2)

  loc_param = (/ dims(2)/2, dims(1)/2 /)
  opts = True
  opt@use_pivot = True
  opt@angle     = 90.                          ; plot from west to east

  X_plane = wrf_user_interp_line(t2,loc_param,opts)