| spline | index spline.py |
Spline module for smooth interpolation in one and two dimensions
class: FloatSpline - 1D cubic spline
Constructor
FloatSpline( listOfXYPairs , isPeriodic=False)
where listOfXYPairs is a sequence of sequences containing two
floating point elements listing (x,y) datapoints. The x values do
not have to lie on a regular grid.
If isPeriodic is set to True, an additional point is added to
listOfXYPairs at (x,y), where
x = 2 listOfXYPairs[N-1][0] - listOfXYPairs[N-1][0]
y = listOfXYPairs[0][1]
also, in this case the slope at the first and final points are set to
match.
Use:
interpolated y values are obtained using the __call__() method. For example,
spline = FloatSpline( [(0,1), (1,2), (2,3)] )
spline(0.5)
will return the value 1.5
class: FloatSpline2D - 2D bicubic interpolation
Constructor
FloatSpline2D(xList,yList,zList, periodic=PERIODIC_NOT)
xList and yList contain x and y values of gridpoints. These values
should be monotonically increasing, but do not need to be equally
spaced. zList is a row-major list of data on this grid.
The optional periodic argument is a bit field specifying whether the x-
or y- dimensions contain periodic data. Valid values are PERIODIC_NOT,
PERIODIC_X and PERIODIC_Y. If a dimension is marked as periodic, the
corresponding dimension in zList should be one less: the final row of
z values is taken from the first.
If, for instance PERIODIC_X is set, zList should have one less row than
xList has values. The values in the final row are set to those in the
first. First derivatives at the top and the bottom of zList are also
matched.
Note that, unlike the 1D case, the spline coefficients are not taken
from a global fit. This is possible, but not yet implemented.
Methods:
__call__(x,y) - return the interpolated value at (x,y).
derivs(x,y) - return derivatives wrt x and y at (x,y) in a tuple (dx,dy).
The Python implementation needs to be completed.
Use:
interpolated z values are obtained using the __call__() method. For example,
x=[1,2,3]
y=[4,7]
z=[7,9,
1,3,
3,6]
spline2d=spline.FloatSpline2D(x,y,z)
spline2d(1.4,5.1)
will return the value 4.93173
| Classes | ||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||
| Functions | ||
| ||
| Data | ||
| PERIODIC_NOT = 0 PERIODIC_X = 1 PERIODIC_Y = 2 | ||