wrf.interp1d

wrf.interp1d(field, z_in, z_out, missing=<MagicMock name='mock().item()' id='140499233145616'>, meta=True)

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.

Parameters:

Warning

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

Returns:

An array with the same dimensionality as z_out containing the interpolated values. 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 850 hPa and 500 hPa values at location x,y = (100,200)

import numpy as np
from wrf import getvar, interp1d
from netCDF4 import Dataset

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

# Get a 1D vertical column for pressure at location x,y = 100,200
p_1d = wrf.getvar(wrfnc, "pres", units="hPa")[:,200,100]

# Get a 1D vertical column for height at location 100,200
ht_1d = wrf.getvar(wrfnc, "z", units="dm")[:,200,100]

# Want the heights (in decameters) at 850, 500 hPa
levels = np.asarray([850., 500.])

# Get the 850 hPa and 500 hPa values at location 100,200.
interp_vals = interp1d(p_1d, ht_1d, levels)