Skip to content

Interpolator

Interpolator(
x,
y,
method='linear',
coords='real_imag',
extrapolation='extrapolate',
parameter_names=None,
)

Interpolator object.

Args

  • x (Sequence[float] | Sequence[Sequence[float]]): Independent variable (parameter) values.
  • y (Sequence[float | complex] | Sequence[Sequence[float | complex]]): Dependent variable values. Multiple variables sharing the same parameter values can be interpolated simultaneously by setting to a sequence of vectors.
  • method (str): Interpolation method. See table below for options.
  • coords (Literal[“mag_phase”, “real_imag”]): Coordinate system used for interpolation of complex values.
  • extrapolation (Literal[“extrapolate”, “constant”]): Extrapolation strategy for query points outside the sampled interval (1D only). "extrapolate" continues the interpolant; "constant" clamps query points to the sample boundaries.
  • parameter_names (Sequence[str] | None): Optional names for each parameter.

===================== ================================================ Interpolation method Description ===================== ================================================ "linear" Linear interpolation between neighboring points "barycentric" Barycentric Lagrange interpolation "cubicspline" Cubic spline interpolation "pchip" Piecewise cubic Hermite interpolating polynomial "akima" Akima interpolation "makima" Modified Akima interpolation ===================== ================================================

Examples

>>> interp = pf.Interpolator([0, 1, 2], [-1, 1, 1])
>>> interp([0, 1.5])
array([-1., 1.])
>>> interp = pf.Interpolator([0, 1, 2], [[-1, 1, 1], [0, -1, -2]])
>>> interp([0.5, 1, 3])
array([[ 0. , 1. , 1. ],
[-0.5, -1. , -3. ]])
>>> # 2D interpolation (2 parameters, 1 value, 3 sample points)
>>> interp = pf.Interpolator(
... [[0, 0], [1, -1], [2, 0]],
... [10, 20, 30],
... parameter_names=("param1", "param2"),
... )
>>> interp([0.5, -0.5])
15.0
>>> interp([[0, 0], [1.5, 0]])
array([10., 25.])

Note

Single-dimensional interpolation (single parameter) perform phase unwrapping when interpolating complex values in magnitude and phase. That is not supported for multi-dimensional interpolation.

MethodDescription
copyCreate a copy of this layer specification.

copy(self)

Create a copy of this layer specification.

Returns

Interpolator: New copy.

AttributeDescription
coordsstr: Interpolation coordinate system for complex values (read-only).
extrapolationstr: Extrapolation strategy for out-of-range query points (read-only).
methodstr: Interpolation method (read-only).
parameter_namestuple[str, …] | None: Names for each parameter in x.
propertiesProperties: Object properties.
xndarray: Independent variable values (read-only).
yndarray | list[ndarray]: Dependent variable values (read-only).

str: Interpolation coordinate system for complex values (read-only).

str: Extrapolation strategy for out-of-range query points (read-only).

str: Interpolation method (read-only).

tuple[str, …] | None: Names for each parameter in x.

Properties: Object properties.

ndarray: Independent variable values (read-only).

ndarray | list[ndarray]: Dependent variable values (read-only).