Defines classes for extrapolating variables:
Bases: object
Extrapolates the 1-D function of given interpolator.
The Extrapolator1d acts as a wrapper around a given Colour or scipy interpolator class instance with compatible signature. Two extrapolation methods are available:
Specifying the left and right arguments takes precedence on the chosen extrapolation method and will assign the respective left and right values to the given points.
Parameters: |
|
---|
Notes
The interpolator must define x and y attributes.
References
[1] | sastanin. (n.d.). How to make scipy.interpolate give an extrapolated result beyond the input range? Retrieved August 08, 2014, from http://stackoverflow.com/a/2745496/931625 |
Examples
Extrapolating a single numeric variable:
>>> from colour.algebra import LinearInterpolator1d
>>> x = np.array([3, 4, 5])
>>> y = np.array([1, 2, 3])
>>> interpolator = LinearInterpolator1d(x, y)
>>> extrapolator = Extrapolator1d(interpolator)
>>> extrapolator(1)
-1.0
Extrapolating an array_like variable:
>>> extrapolator(np.array([6, 7 , 8]))
array([ 4., 5., 6.])
Using the Constant extrapolation method:
>>> x = np.array([3, 4, 5])
>>> y = np.array([1, 2, 3])
>>> interpolator = LinearInterpolator1d(x, y)
>>> extrapolator = Extrapolator1d(interpolator, method='Constant')
>>> extrapolator(np.array([0.1, 0.2, 8, 9]))
array([ 1., 1., 3., 3.])
Using defined left boundary and Constant extrapolation method:
>>> x = np.array([3, 4, 5])
>>> y = np.array([1, 2, 3])
>>> interpolator = LinearInterpolator1d(x, y)
>>> extrapolator = Extrapolator1d(interpolator, method='Constant', left=0)
>>> extrapolator(np.array([0.1, 0.2, 8, 9]))
array([ 0., 0., 3., 3.])
Evaluates the Extrapolator1d at given point(s).
Parameters: | x (numeric or array_like) – Point(s) to evaluate the Extrapolator1d at. |
---|---|
Returns: | Extrapolated points value(s). |
Return type: | float or ndarray |
Property for self.__interpolator private attribute.
Returns: | self.__interpolator |
---|---|
Return type: | object |