Wednesday 21 March 2012

Working on 2d interpolation in SciPy

For a project I'm working on (in SciPy), I need 2D interpolation routine.  I started playing around with interp2d, but soon found out that there is probably an issue with it. Below, the proof: interp2d output against griddata (yet another 2D interpolation method, which seems to be working correctly).

Both seem to be looking okey, but compare also the results at the edges. Furthermore, quite often the results are like these:

Please check and compare the colorbar alongside the imshow plots. These results are obtained without any warning from the interp2d, which happens too from time to time:

Warning: No more knots can be added because the number of B-spline coefficients
already exceeds the number of data points m. Probably causes: either
s or m too small. (fp>s)
kx,ky=3,3 nx,ny=22,19 m=256 fp=2019.239753 s=0.000000


I started googling the net, so here are some relevant links:
http://stackoverflow.com/questions/3526514/problem-with-2d-interpolation-in-scipy-non-rectangular-grid
http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data