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, anumpy.ma.MaskedArrayis not created and this routine should be considered as low-level access to the underlying Fortran routine.See also
Parameters: - field3d (
xarray.DataArrayornumpy.ndarray) – The array to interpolate with at least three dimensions, whose rightmost dimensions are nz x ny x nx. - xy (
xarray.DataArrayornumpy.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 returnnumpy.ndarrayinstead ofxarray.DataArray. Default is True.
Warning
The input arrays must not contain any missing/fill values or
numpy.nanvalues.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.DataArrayobject. Otherwise, the result will be anumpy.ndarrayobject with no metadata.Return type: xarray.DataArrayornumpy.ndarrayExamples
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)
- field3d (