NCL Home > Documentation > Functions > WRF, Interpolation

wrf_interp_1d

Linearly interpolates a one-dimensional variable in the vertical.

Prototype

	function wrf_interp_1d (
		v_in   : numeric,  
		z_in   : numeric,  
		z_out  : numeric   
	)

	return_val [dimsizes(z_out)] :  float or double

Arguments

v_in

One-dimensional array to interpolate in the vertical. This array's rightmost dimension is nz.

z_in

One-dimensional array representing the vertical structure (height/pressure) of the v_in array. This array has the same dimensionality as v_in.

z_out

An array with constant height to interpolate to. Must be of the same type (height/pressure) as z_in.

Return value

The return array will be the same dimensionality as z_out. The return type will be double of any of the input is double, and float otherwise.

Description

Linear interpolation in the vertical. Vertical indices can increase or decrease with height.

If v_in has attributes "description" or "units", they will be returned with the output variable. The "description" attribute will be set to " " if v_in doesn't contain this attribute.

As of version 5.1.0, the return variable will contain the same named dimensions (if any) of Qv. Otherwise, the rightmost two dimensions will be named "south_north" and "west_east".

See Also

wrf_interp_2d_xy, wrf_interp_3d_z, wrf_user_intrp3d, wrf_user_getvar

See the full list of WRF functions.

Examples

Example 1

    a = addfile("wrfout_d01_2000-01-24_12:00:00.nc","r")
    time = 0
    
    tk  = wrf_user_getvar(a,"tk",time)      ; temperature in Kelvin
    z   = wrf_user_getvar(a,"height",time)  ; On half (mass) levels
    lat = wrf_user_getvar(a,"lat",time)     ; latitude
    lon = wrf_user_getvar(a,"lon",time)     ; latitude
   
  ; Radiosonde observation
    radiosonde = asciiread("raob_OUN.txt",(/2,39/),"float")
    z_raob = radiosonde(0,:)    ; height in radiosonde
    z_raob@_FillValue = -999.99 ; missing value
    
  ; Station information (OUN - Norman, OK)
    olat = 35.2
    olon = -97.4
    
  ; Find the closest point to the radiosonde site in WRF grids
    obsij = wrf_user_ll_to_ij(lat,lon,olat,olon)
    obsi = obsij(0)
    obsj = obsij(1)
    
    tin = tk(:,obsi,obsj)
    zin = z(:,obsi,obsj)
  
  ; Interpolation
    t_wrf = wrf_interp_1d (tin,zin,z_raob)
    t_wrf@_FillValue = -999.99
    print(t_wrf)