The linear_1d class in scipy.interpolate is a convenient method to create a function based on fixed data points which can be evaluated anywhere within the domain defined by the given data using linear interpolation. An instance of this class is created by passing the 1-d vectors comprising the data. The instance of this class defines a __call__ method and can therefore by treated like a function which interpolates between known data values to obtain unknown values (it even has a docstring for help). Behavior at the boundary can be specified at instantiation time. The following example demonstrates it's use.
>>> x = arange(0,10) >>> y = exp(-x/3.0) >>> f = interpolate.linear_1d(x,y) >>> help(f) Instance of class: linear_1d <name>(x_new) Find linearly interpolated y_new = <name>(x_new). Inputs: x_new -- New independent variables. Outputs: y_new -- Linearly interpolated values corresponding to x_new. >>> xnew = arange(0,9,0.1) >>> xplt.plot(x,y,'x',xnew,f(xnew),'.')Figure shows the result: