colour.SpragueInterpolator#

class colour.SpragueInterpolator(x: ArrayLike, y: ArrayLike, dtype: Type[DTypeReal] | None = None, *args: Any, **kwargs: Any)[source]#

Bases: object

Perform fifth-order polynomial interpolation using the Sprague (1880) method for uniformly spaced data.

Implement the Sprague (1880) interpolation method recommended by the CIE for interpolating functions with uniformly spaced independent variables. This interpolator constructs a fifth-order polynomial that passes through specified dependent variable values, providing smooth interpolation suitable for spectral data and other colour science applications.

Parameters:
  • x (ArrayLike) – Independent \(x\) variable values corresponding with \(y\) variable.

  • y (ArrayLike) – Dependent and already known \(y\) variable values to interpolate.

  • dtype (Type[DTypeReal] | None) – Data type used for internal conversions.

  • args (Any)

  • kwargs (Any)

Attributes

Methods

Notes

  • The minimum number \(k\) of data points required along the interpolation axis is \(k=6\).

References

[CIET13805b], [WRC12c]

Examples

Interpolating a single numeric variable:

>>> y = np.array([5.9200, 9.3700, 10.8135, 4.5100, 69.5900, 27.8007, 86.0500])
>>> x = np.arange(len(y))
>>> f = SpragueInterpolator(x, y)
>>> f(0.5)
7.2185025...

Interpolating an ArrayLike variable:

>>> f([0.25, 0.75])
array([ 6.7295161...,  7.8140625...])
SPRAGUE_C_COEFFICIENTS = array([[  884, -1960,  3033, -2648,  1080,  -180],        [  508,  -540,   488,  -367,   144,   -24],        [  -24,   144,  -367,   488,  -540,   508],        [ -180,  1080, -2648,  3033, -1960,   884]])#

Defines the coefficients used to generate extra points for boundaries interpolation.

SPRAGUE_C_COEFFICIENTS, (4, 6)

References

[CIET13805c]

__init__(x: ArrayLike, y: ArrayLike, dtype: Type[DTypeReal] | None = None, *args: Any, **kwargs: Any) None[source]#
Parameters:
Return type:

None

property x: NDArrayFloat#

Getter and setter for the independent \(x\) variable.

Parameters:

value – Value to set the independent \(x\) variable with.

Returns:

Independent \(x\) variable.

Return type:

numpy.ndarray

Raises:

AssertionError – If the provided value has not exactly one dimension.

property y: NDArrayFloat#

Getter and setter for the dependent and already known \(y\) variable.

Parameters:

value – Value to set the dependent and already known \(y\) variable with.

Returns:

Dependent and already known \(y\) variable.

Return type:

numpy.ndarray

Raises:

AssertionError – If the provided value has not exactly one dimension and its value count is less than 6.

__call__(x: ArrayLike) NDArrayFloat[source]#

Evaluate the interpolating polynomial at specified point(s).

Parameters:

x (ArrayLike) – Point(s) to evaluate the interpolant at.

Returns:

Interpolated value(s).

Return type:

numpy.ndarray

__weakref__#

list of weak references to the object