Package Scientific :: Package Functions :: Module Interpolation :: Class InterpolatingFunction
[frames] | no frames]

Class InterpolatingFunction

Known Subclasses:

Function defined by values on a grid using interpolation

An interpolating function of n variables with m-dimensional values is defined by an (n+m)-dimensional array of values and n one-dimensional arrays that define the variables values corresponding to the grid points. The grid does not have to be equidistant.

An InterpolatingFunction object has attributes real and imag like a complex function (even if its values are real).

Instance Methods
 
__abs__(self)
number
__call__(self, *points)
Returns: the function value obtained by linear interpolation
 
__getattr__(self, attr)
InterpolatingFunction or number
__getitem__(self, i)
Returns: an InterpolatingFunction whose number of variables is reduced, or a number if no variable is left
InterpolatingFunction or number
__getslice__(self, i, j)
Returns: an InterpolatingFunction whose number of variables is reduced by one, or a number if no variable is left
 
__init__(self, axes, values, default=None, period=None)
int
__len__(self)
Returns: number of variables
 
arccos(self)
 
arcsin(self)
 
arctan(self)
 
cos(self)
 
cosh(self)
InterpolatingFunction or number
definiteIntegral(self, variable=0)
Returns: a new InterpolatingFunction containing the numerical integral.
InterpolatingFunction
derivative(self, variable=0)
Returns: a new InterpolatingFunction containing the numerical derivative
 
exp(self)
Scientific.Functions.Polynomial
fitPolynomial(self, order)
Returns: a polynomial whose coefficients have been obtained by a least-squares fit to the grid values
InterpolatingFunction
integral(self, variable=0)
Returns: a new InterpolatingFunction containing the numerical integral.
 
log(self)
InterpolatingFunction
selectInterval(self, first, last, variable=0)
Returns: a new InterpolatingFunction whose grid is restricted
 
sin(self)
 
sinh(self)
 
sqrt(self)
 
tan(self)
 
tanh(self)
Method Details

__call__(self, *points)
(Call operator)

 
Returns: number
the function value obtained by linear interpolation
Raises:
  • TypeError - if the number of arguments (len(points)) does not match the number of variables of the function
  • ValueError - if the evaluation point is outside of the domain of definition and no default value is defined

__getitem__(self, i)
(Indexing operator)

 
Parameters:
  • i (indexing expression) - any indexing expression possible for N.array that does not use N.NewAxis
Returns: InterpolatingFunction or number
an InterpolatingFunction whose number of variables is reduced, or a number if no variable is left
Raises:
  • TypeError - if i is not an allowed index expression

__getslice__(self, i, j)
(Slicling operator)

 
Parameters:
  • i (int) - lower slice index
  • j (int) - upper slice index
Returns: InterpolatingFunction or number
an InterpolatingFunction whose number of variables is reduced by one, or a number if no variable is left

__init__(self, axes, values, default=None, period=None)
(Constructor)

 
Parameters:
  • axes (sequence of N.array) - a sequence of one-dimensional arrays, one for each variable, specifying the values of the variables at the grid points
  • values (N.array) - the function values on the grid
  • default (number or None) - the value of the function outside the grid. A value of None means that the function is undefined outside the grid and that any attempt to evaluate it there raises an exception.
  • period (sequence of numbers or None) - the period for each of the variables, or None for variables in which the function is not periodic.

__len__(self)
(Length operator)

 
Returns: int
number of variables

definiteIntegral(self, variable=0)

 
Parameters:
  • variable (int) - the index of the variable of the function with respect to which the integration is performed
Returns: InterpolatingFunction or number
a new InterpolatingFunction containing the numerical integral. The integration constant is defined such that the integral at the first grid point is zero. If the original function has only one free variable, the definite integral is a number

derivative(self, variable=0)

 
Parameters:
  • variable (int) - the index of the variable of the function with respect to which the derivative is taken
Returns: InterpolatingFunction
a new InterpolatingFunction containing the numerical derivative

fitPolynomial(self, order)

 
Parameters:
  • order (int) - the order of the polynomial to be fitted
Returns: Scientific.Functions.Polynomial
a polynomial whose coefficients have been obtained by a least-squares fit to the grid values

integral(self, variable=0)

 
Parameters:
  • variable (int) - the index of the variable of the function with respect to which the integration is performed
Returns: InterpolatingFunction
a new InterpolatingFunction containing the numerical integral. The integration constant is defined such that the integral at the first grid point is zero.

selectInterval(self, first, last, variable=0)

 
Parameters:
  • first (float) - lower limit of an axis interval
  • last (float) - upper limit of an axis interval
  • variable (int) - the index of the variable of the function along which the interval restriction is applied
Returns: InterpolatingFunction
a new InterpolatingFunction whose grid is restricted