Defines classes for interpolating variables.
Bases: object
Linearly interpolates a 1-D function.
Parameters: |
|
---|
Notes
This class is a wrapper around numpy.interp definition.
See also
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 = LinearInterpolator(x, y)
>>> # Doctests ellipsis for Python 2.x compatibility.
>>> f(0.5)
7.64...
Interpolating an array_like variable:
>>> f([0.25, 0.75])
array([ 6.7825, 8.5075])
Evaluates the interpolating polynomial at given point(s).
Parameters: | x (numeric or array_like) – Point(s) to evaluate the interpolant at. |
---|---|
Returns: | Interpolated value(s). |
Return type: | float or ndarray |
Bases: object
Constructs a fifth-order polynomial that passes through \(y\) dependent variable.
Sprague (1880) method is recommended by the CIE for interpolating functions having a uniformly spaced independent variable.
Parameters: |
|
---|
See also
Notes
The minimum number \(k\) of data points required along the interpolation axis is \(k=6\).
References
[1] | CIE TC 1-38. (2005). 9.2.4 Method of interpolation for uniformly spaced independent variable. In CIE 167:2005 Recommended Practice for Tabulating Spectral Data for Use in Colour Computations (pp. 1–27). ISBN:978-3-901-90641-1 |
[2] | Westland, S., Ripamonti, C., & Cheung, V. (2012). Interpolation Methods. In Computational Colour Science Using MATLAB (2nd ed., pp. 29–37). ISBN:978-0-470-66569-5 |
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 array_like variable:
>>> f([0.25, 0.75])
array([ 6.7295161..., 7.8140625...])
Defines the coefficients used to generate extra points for boundaries interpolation.
SPRAGUE_C_COEFFICIENTS : array_like, (4, 6)
References
[3] | CIE TC 1-38. (2005). Table V. Values of the c-coefficients of Equ.s 6 and 7. In CIE 167:2005 Recommended Practice for Tabulating Spectral Data for Use in Colour Computations (p. 19). ISBN:978-3-901-90641-1 |
Evaluates the interpolating polynomial at given point(s).
Parameters: | x (numeric or array_like) – Point(s) to evaluate the interpolant at. |
---|---|
Returns: | Interpolated value(s). |
Return type: | numeric or ndarray |
Bases: scipy.interpolate.interpolate.interp1d
Interpolates a 1-D function using cubic spline interpolation.
Notes
This class is a wrapper around scipy.interpolate.interp1d class.
Bases: object
PCHIP 1-d monotonic cubic interpolation
x and y are arrays of values used to approximate some function f, with y = f(x). The interpolant uses monotonic cubic splines to find the value of new points. (PCHIP stands for Piecewise Cubic Hermite Interpolating Polynomial).
Parameters: |
|
---|
Notes
The first derivatives are guaranteed to be continuous, but the second derivatives may jump at x_k.
Preserves monotonicity in the interpolation data and does not overshoot if the data is not smooth.
Determines the derivatives at the points x_k, d_k, by using PCHIP algorithm:
Let m_k be the slope of the kth segment (between k and k+1) If m_k=0 or m_{k-1}=0 or sgn(m_k) != sgn(m_{k-1}) then d_k == 0 else use weighted harmonic mean:
w_1 = 2h_k + h_{k-1}, w_2 = h_k + 2h_{k-1} 1/d_k = 1/(w_1 + w_2)*(w_1 / m_k + w_2 / m_{k-1})
where h_k is the spacing between x_k and x_{k+1}.
Evaluate the PCHIP interpolant or its derivative.
Parameters: |
|
---|---|
Returns: | y – Interpolated values. Shape is determined by replacing the interpolation axis in the original array with the shape of x. |
Return type: | array-like |
Construct a piecewise polynomial representing the derivative.
Parameters: | der (int, optional) – Order of derivative to evaluate. (Default: 1) If negative, the antiderivative is returned. |
---|---|
Returns: |
|
Return the roots of the interpolated function.