interp

metpy.calc.interp(x, xp, *args, **kwargs)[source]

Interpolates data with any shape over a specified axis.

Interpolation over a specified axis for arrays of any shape.

Parameters
  • x (array-like) – 1-D array of desired interpolated values.

  • xp (array-like) – The x-coordinates of the data points.

  • args (array-like) – The data to be interpolated. Can be multiple arguments, all must be the same shape as xp.

  • axis (int, optional) – The axis to interpolate over. Defaults to 0.

  • fill_value (float, optional) – Specify handling of interpolation points out of data bounds. If None, will return ValueError if points are out of bounds. Defaults to nan.

  • return_list_always (bool, optional) – Whether to always return a list of interpolated arrays, even when only a single array is passed to args. Defaults to False.

Returns

array-like – Interpolated values for each point with coordinates sorted in ascending order.

Examples

>>> x = np.array([1., 2., 3., 4.])
>>> y = np.array([1., 2., 3., 4.])
>>> x_interp = np.array([2.5, 3.5])
>>> metpy.interpolate.interpolate_1d(x_interp, x, y)
array([2.5, 3.5])

Notes

xp and args must be the same shape.

Deprecated since version 0.9.0: Function has been renamed interpolate_1d and moved to metpy.interpolate, and will be removed from MetPy in 0.12.0.