Return the linear interpolation of a one-dimensional variable. This function is typically used to interpolate a variable in a vertical column, but the coordinate system need not be a vertical coordinate system. Multiple interpolation points may be specified in the *z_out* parameter
(field, z_in, z_out, missing=default_fill(np.float64),
meta=True)
| 105 | |
| 106 | @set_interp_metadata("1d") |
| 107 | def interp1d(field, z_in, z_out, missing=default_fill(np.float64), |
| 108 | meta=True): |
| 109 | """Return the linear interpolation of a one-dimensional variable. |
| 110 | |
| 111 | This function is typically used to interpolate a variable in a vertical |
| 112 | column, but the coordinate system need not be a vertical coordinate |
| 113 | system. Multiple interpolation points may be specified in the *z_out* |
| 114 | parameter. |
| 115 | |
| 116 | Args: |
| 117 | |
| 118 | field (:class:`xarray.DataArray` or :class:`numpy.ndarray`): A |
| 119 | one-dimensional field. Metadata for *field* is only copied |
| 120 | to the output if *field* is a :class:`xarray.DataArray` object. |
| 121 | |
| 122 | z_in (:class:`xarray.DataArray` or :class:`numpy.ndarray`): The |
| 123 | one-dimensional coordinates associated with *field* (usually the |
| 124 | vertical coordinates, either height or pressure). |
| 125 | |
| 126 | z_out (:class:`xarray.DataArray`, :class:`numpy.ndarray`): A |
| 127 | one-dimensional array of *z_in* coordinate points to interpolate |
| 128 | to. Must be the same type as *z_in*. |
| 129 | |
| 130 | missing (:obj:`float`, optional): The fill value to use for the |
| 131 | output. Default is :data:`wrf.default_fill(np.float64)`. |
| 132 | |
| 133 | meta (:obj:`bool`, optional): Set to False to disable metadata and |
| 134 | return :class:`numpy.ndarray` instead of |
| 135 | :class:`xarray.DataArray`. Default is True. |
| 136 | |
| 137 | Warning: |
| 138 | |
| 139 | The input arrays must not contain any missing/fill values or |
| 140 | :data:`numpy.nan` values. |
| 141 | |
| 142 | Returns: |
| 143 | |
| 144 | :class:`xarray.DataArray` or :class:`numpy.ndarray`: An array with the |
| 145 | same dimensionality as *z_out* containing the interpolated values. |
| 146 | If xarray is enabled and the *meta* parameter is True, then the result |
| 147 | will be a :class:`xarray.DataArray` object. Otherwise, the result will |
| 148 | be a :class:`numpy.ndarray` object with no metadata. |
| 149 | |
| 150 | |
| 151 | Examples: |
| 152 | |
| 153 | Example 1: Calculate the 850 hPa and 500 hPa values at location \ |
| 154 | x,y = (100,200) |
| 155 | |
| 156 | .. code-block:: python |
| 157 | |
| 158 | import numpy as np |
| 159 | from wrf import getvar, interp1d |
| 160 | from netCDF4 import Dataset |
| 161 | |
| 162 | wrfnc = Dataset("wrfout_d02_2010-06-13_21:00:00") |
| 163 | |
| 164 | # Get a 1D vertical column for pressure at location x,y = 100,200 |
nothing calls this directly
no test coverage detected