wrf.interplevel

wrf.interplevel(field3d, vert, desiredlev, missing=9.969209968386869e+36, meta=True)

Return the three-dimensional field horizontally interpolated to a specified vertical level.

Parameters:
  • field3d (xarray.DataArray or numpy.ndarray) – A three-dimensional field to interpolate, with the rightmost dimensions of nz x ny x nx.
  • vert (xarray.DataArray or numpy.ndarray) – A three-dimensional array for the vertical coordinate, typically pressure or height. This array must have the same dimensionality as field3d.
  • desiredlev (float) – The desired vertical level. Must be in the same units as the vert parameter.
  • missing (float) – The fill value to use for the output. Default is wrf.Constants.DEFAULT_FILL.
  • meta (bool) – Set to False to disable metadata and return numpy.ndarray instead of xarray.DataArray. Default is True.
Returns:

The interpolated variable. If xarray is enabled and the meta parameter is True, then the result will be an xarray.DataArray object. Otherwise, the result will be a numpy.ndarray object with no metadata.

Return type:

xarray.DataArray or numpy.ndarray

Example

Interpolate Geopotential Height to 500 hPa

from netCDF4 import Dataset
from wrf import getvar, interplevel

wrfin = Dataset("wrfout_d02_2010-06-13_21:00:00")

p = getvar(wrfin, "pressure")
ht = getvar(wrfin, "z", units="dm")

ht_500 = interplevel(ht, p, 500.0)