Interpolator¶
- class photonforge.Interpolator(x, y, method='linear', coords='real_imag', extrapolation='extrapolate', parameter_names=None)¶
Interpolator object.
- Parameters:
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.
Methods
copy()Create a copy of this layer specification.
Attributes
Interpolation coordinate system for complex values (read-only).
Extrapolation strategy for out-of-range query points (read-only).
Interpolation method (read-only).
Names for each parameter in x.
Object properties.
Independent variable values (read-only).
Dependent variable values (read-only).
- coords¶
Interpolation coordinate system for complex values (read-only).
- Type:
str
- copy()¶
Create a copy of this layer specification.
- Returns:
New copy.
- Return type:
- extrapolation¶
Extrapolation strategy for out-of-range query points (read-only).
- Type:
str
- method¶
Interpolation method (read-only).
- Type:
str
- parameter_names¶
Names for each parameter in x.
- Type:
tuple[str, …] | None
- properties¶
Object properties.
- Type:
- x¶
Independent variable values (read-only).
- Type:
ndarray
- y¶
Dependent variable values (read-only).
- Type:
ndarray | list[ndarray]