Skip to content
David R. Pugh edited this page Jul 2, 2013 · 36 revisions

Much/all of the Fortran code used in the routines below is available from John Burkardt. The Python wrappers are constructed entirely using f2Py as described below. I plan to develop a more "Pythonic" interface for the module in the near future.

Need to discuss NumPy and SciPy interpolation routines!

Lagrange interpolation:

1D, 2D and ND routines for Lagrange polynomial interpolation on a regular grid. I constructed the Python wrappers using f2Py as follows. First, I built the signature file:

$ f2py -m lagrange_interp -h lagrange_interp.pyf lagrange_interp_1d.f90 lagrange_interp_2d.f90 lagrange_interp_nd.f90

which, after some light editing to declare inputs and outputs, can be compiled into a Python extension module using:

$ f2py -c lagrange_interp.pyf lagrange_interp_1d.f90 lagrange_interp_2d.f90 lagrange_interp_nd.f90 r8lib.f90

Note the rblib.f90 dependency. Still not compiling correctly!!!

Piece-wise linear interpolation:

1D, 2D, and 3D routines for basic linear, bi-linear, and tri-linear interpolation on a regular grid. I constructed the Python wrappers using f2Py as follows. First, I built the signature file:

f2py -m pwl_interp -h pwl_interp.pyf pwl_interp_1d.f90 pwl_interp_2d.f90 pwl_interp_3d.f90

Then, after lightly editing the signature file to denote inputs and outputs, I compiled the source code...

f2py -c pwl_interp.pyf pwl_interp_1d.f90 pwl_interp_2d.f90 pwl_interp_3d.f90 r8lib.f90

Note the rblib.f90 dependency.

1D test case:

Routine will also extrapolate!

2D test case:

###Transfinite (Blend) interpolation:

2-dimensional interpolation schemes:

3-dimensional interpolation schemes: