The class LinearInterpolationNOGrid supports linear, bilinear and trilinear interpolation for data on an even grid in 1D, 2D or 3D, with orthogonal or non-orthogonal lattice vectors. Please see the code reference for documentation.
The class takes a function on a uniform, rectangular grid (with orthogonal or non-orthogonal lattice vectors) and calculates the function at any point using linear interpolation. It can be a 1D, 2D or 3D grid.
See http://en.wikipedia.org/wiki/Trilinear_interpolation for the math.
Usage:
func=[[0,1],[2,3]]
start=[0,0]
latticevecs=[[1e-3,0],[0,1e-3]]
interp=LinearInterpolationNOGrid(func,latticevecs)
f=interp(0.3,0.6)
Note: the gridpoints on the upper boundary in each direction are not accessible by the interpolation function. TODO: fix that.
Also note: Pay attention to the ordering of the func array.
http://www.packtpub.com/article/advanced-matplotlib-part1
fig1 = pyplot.figure()
fig2 = pyplot.figure()
ax1 = fig1.add_subplot(2,1,1)
ax2 = fig1.add_subplot(2,1,2)
l, = ax2.plot(x, y)
m, = ax1.plot(x, y)
w, = ax1.plot(x, y+3)
t = ax2.set_title('random numbers')
l.set_color('red')
m.set_color('blue')
ax3=fig2.add_subplot(1,1,1)
n, = ax3.plot(x, y)
w.set_color('red')
fig1.legend([m,w], ["line 2", "line 1"])
ax2.legend([l],["line 3"])
i.e. they are applied to the current axes.
The standard procedure would be:
This is not a utility class, but it’s the best place to put this information.
(Work on this!)