Return the three-dimensional field interpolated to a horizontal plane at the specified vertical level. Args: field3d (:class:`xarray.DataArray` or :class:`numpy.ndarray`): A three-dimensional field to interpolate, with the rightmost dimensions of nz x ny x n
(field3d, vert, desiredlev, missing=default_fill(np.float64),
squeeze=True, meta=True)
| 21 | # Note: Extension decorator is good enough to handle left dims |
| 22 | @set_interp_metadata("horiz") |
| 23 | def interplevel(field3d, vert, desiredlev, missing=default_fill(np.float64), |
| 24 | squeeze=True, meta=True): |
| 25 | """Return the three-dimensional field interpolated to a horizontal plane |
| 26 | at the specified vertical level. |
| 27 | |
| 28 | Args: |
| 29 | |
| 30 | field3d (:class:`xarray.DataArray` or :class:`numpy.ndarray`): A |
| 31 | three-dimensional field to interpolate, with the rightmost |
| 32 | dimensions of nz x ny x nx. |
| 33 | |
| 34 | vert (:class:`xarray.DataArray` or :class:`numpy.ndarray`): A |
| 35 | three-dimensional array for the vertical coordinate, typically |
| 36 | pressure or height. This array must have the same dimensionality |
| 37 | as *field3d*. |
| 38 | |
| 39 | desiredlev (:obj:`float`, 1D sequence, or :class:`numpy.ndarray`): The |
| 40 | desired vertical level(s). This can be a single value (e.g. 500), |
| 41 | a sequence of values (e.g. [1000, 850, 700, 500, 250]), or a |
| 42 | multidimensional array where the right two dimensions (ny x nx) |
| 43 | must match *field3d*, and any leftmost dimensions match |
| 44 | field3d.shape[:-3] (e.g. planetary boundary layer). |
| 45 | Must be in the same units as the *vert* parameter. |
| 46 | |
| 47 | missing (:obj:`float`): The fill value to use for the output. |
| 48 | Default is :data:`wrf.default_fill(numpy.float64)`. |
| 49 | |
| 50 | squeeze (:obj:`bool`, optional): Set to False to prevent dimensions |
| 51 | with a size of 1 from being automatically removed from the shape |
| 52 | of the output. Default is True. |
| 53 | |
| 54 | meta (:obj:`bool`): Set to False to disable metadata and return |
| 55 | :class:`numpy.ndarray` instead of |
| 56 | :class:`xarray.DataArray`. Default is True. |
| 57 | |
| 58 | Returns: |
| 59 | |
| 60 | :class:`xarray.DataArray` or :class:`numpy.ndarray`: The |
| 61 | interpolated variable. If xarray is enabled and |
| 62 | the *meta* parameter is True, then the result will be an |
| 63 | :class:`xarray.DataArray` object. Otherwise, the result will |
| 64 | be a :class:`numpy.ndarray` object with no metadata. |
| 65 | |
| 66 | Example: |
| 67 | |
| 68 | Interpolate Geopotential Height to 500 hPa |
| 69 | |
| 70 | .. code-block:: python |
| 71 | |
| 72 | from netCDF4 import Dataset |
| 73 | from wrf import getvar, interplevel |
| 74 | |
| 75 | wrfin = Dataset("wrfout_d02_2010-06-13_21:00:00") |
| 76 | |
| 77 | p = getvar(wrfin, "pressure") |
| 78 | ht = getvar(wrfin, "z", units="dm") |
| 79 | |
| 80 | ht_500 = interplevel(ht, p, 500.0) |