wrf.interp2dxy

wrf.interp2dxy(field3d, xy, meta=True)

Return a cross section for a three-dimensional field.

The returned array will hold the vertical cross section data along the line described by xy.

This method differs from wrf.vertcross() in that it will return all vertical levels found in field3d. wrf.vertcross() includes an additional interpolation to set the output to a fixed number of vertical levels. Also, a numpy.ma.MaskedArray is not created and this routine should be considered as low-level access to the underlying Fortran routine.

Parameters:
  • field3d (xarray.DataArray or numpy.ndarray) – The array to interpolate with at least three dimensions, whose rightmost dimensions are nz x ny x nx.
  • xy (xarray.DataArray or numpy.ndarray) – An array of one less dimension than field3d, whose rightmost dimensions are nxy x 2. This array holds the x,y pairs of a line across the model domain. The requested vertical cross section will be extracted from field3d along this line.
  • meta (bool, optional) – Set to False to disable metadata and return numpy.ndarray instead of xarray.DataArray. Default is True.

Warning

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

Returns:An array containing the vertical cross section along the line xy. The returned dimensions will be the same as xy, but with the rightmost dimensions being nz x nxy. If xarray is enabled and the meta parameter is True, then the result will be a xarray.DataArray object. Otherwise, the result will be a numpy.ndarray object with no metadata.
Return type:xarray.DataArray or numpy.ndarray

Examples

Example 1: Calculate the vertical cross section for RH for a diagonal line from the lower left to the upper right of the domain.

from wrf import getvar, xy, interp2dxy
from netCDF4 import Dataset

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

rh = getvar(wrfnc, "rh")
start = (0, 0)
end = (-1, -1)
xy_line = xy(rh, start_point=start, end_point=end)

vert_cross = interp2dxy(rh, xy_line)