wrf.interplevel

wrf.interplevel(field3d, vert, desiredlev, missing=<MagicMock name='mock().item()' id='140675643013392'>, squeeze=True, meta=True)

Return the three-dimensional field interpolated to a horizontal plane at the 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, 1D sequence, or numpy.ndarray) – The desired vertical level(s). This can be a single value (e.g. 500), a sequence of values (e.g. [1000, 850, 700, 500, 250]), or a multidimensional array where the right two dimensions (ny x nx) must match field3d, and any leftmost dimensions match field3d.shape[:-3] (e.g. planetary boundary layer). Must be in the same units as the vert parameter.
  • missing (float) – The fill value to use for the output. Default is wrf.default_fill(numpy.float64).
  • squeeze (bool, optional) – Set to False to prevent dimensions with a size of 1 from being automatically removed from the shape of the output. Default is True.
  • 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)

Interpolate Relative Humidity to Boundary Layer Heights

from netCDF4 import Dataset
from wrf import getvar, interplevel

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

rh = getvar(wrfin, "rh")
height = getvar(wrfin, "height_agl")
pblh = getvar(wrfin, "PBLH")

rh_pblh = interplevel(rh, height, pblh)