# [SciPy-User] Problems with 2D interpolation of data on polar grid

denis denis-bz-gg@t-online...
Fri Aug 27 11:03:01 CDT 2010

```Kyle, folks,

for nonuniform 2d interpolation I'd recommend
matplotlib.mlab.griddata,
which does a Delaunay triangulation then Natural-neighbor;
see http://scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data
and http://en.wikipedia.org/wiki/Natural_neighbor .

To interpolate to arbitrary points with Delaunay,
use the little class Triinterpolate in the scipy-user thread
"Interpolation in 3D with interp2d " Aug 17.

griddata returns a masked array, masked outside the convex hull of the
input x y --
if that's a problem, you can extrapolate to the corners.

I've found fitpack BivariateSpline to be *very* sensitive to s=
(which is a sum of squares -- print sqrt( fit.get_residual() / N ),
also print once fit.get_knots() ).
What you really want to specify for BivariateSpline is the number of
knots --
but you can't, afaik.

cheers
-- denis

On Aug 20, 5:52 pm, Kyle Parfrey <kparf...@gmail.com> wrote:
> Hi all,
>
> I've been having some trouble doing 2D interpolation with both
> interp2d and bisplrep/bisplev. My data is on a spherical polar (r,
> theta) grid, and I'm trying to interpolate functions similar to the
> vector components of a dipole field. The output looks very wrong, and
> I keep getting warnings like (from interp2d):
```