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

Return the field interpolated to a specified pressure or height level.

This function is roughly equivalent to interplevel(), but does not handle multi-product diagnostics (uvmet, cape_3d, etc) that contain an additional leftmost dimension for the product type. Also, a numpy.ma.MaskedArray is not created and this routine should be considered as low-level access to the underlying Fortran routine.

  • 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.default_fill(numpy.float64).
  • meta (bool) – Set to False to disable metadata and return numpy.ndarray instead of xarray.DataArray. Default is True.


The input arrays must not contain any missing/fill values or numpy.nan values.

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 1: Interpolate Geopotential Height to 500 hPa

from netCDF4 import Dataset
from wrf import getvar, interpz3d

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

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

ht_500 = interpz3d(ht, p, 500.0)