interp

Contents

interp#

class saiunit.math.interp(x, xp, fp, left=None, right=None, period=None, **kwargs)#

One-dimensional linear interpolation.

Parameters:
  • x (Union[saiunit.Quantity, Array, ndarray, number, bool]) – The x-coordinates at which to evaluate the interpolated values.

  • xp (Union[saiunit.Quantity, Array, ndarray, number, bool]) – The x-coordinates of the data points, must be increasing.

  • fp (Union[saiunit.Quantity, Array, ndarray, number, bool]) – The y-coordinates of the data points.

  • left (Union[Array, ndarray, number, bool, saiunit.Quantity, None]) – Value to return for x < xp[0].

  • right (Union[Array, ndarray, number, bool, saiunit.Quantity, None]) – Value to return for x > xp[-1].

  • period (Union[Array, ndarray, number, bool, saiunit.Quantity, None]) – A period for the x-coordinates.

Returns:

out – Quantity if fp is a Quantity, else an array.

Return type:

Union[saiunit.Quantity, Array]

Examples

>>> import saiunit as u
>>> x = [1, 2, 3] * u.second
>>> xp = [0, 1, 2, 3, 4] * u.second
>>> fp = [0, 1, 2, 3, 4] * u.meter
>>> u.math.interp(x, xp, fp)