Trouble gridding irregularly spaced data

Hi,

I'm trying to grid irregularly spaced data, such that the convex hull
of the data is not rectangular. Specifically, all my data lies in an
equilateral triangle inside the unit circle. I found:

     http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data

and tried the suggested technique. For my grid, I made a square of
the min and max of my data. However, it had problems:

...
  File "/home/guest/.local/lib/python2.6/site-packages/matplotlib/delaunay/triangulate.py",
line 125, in _compute_convex_hull
    hull.append(edges.pop(hull[-1]))
KeyError: 0

Should I expect matplotlib.mlab.griddata to work with a dataset like
this? I know that I can use hexbin, but it'd be really nice to see
contours explicitly.

It's not a problem with your points lying inside a triangle. There is some other problem with the construction of the Delaunay triangulation. Sometimes the algorithm fails. This is one way that it fails.

···

On 2010-02-16 00:40 AM, T J wrote:

Hi,

I'm trying to grid irregularly spaced data, such that the convex hull
of the data is not rectangular. Specifically, all my data lies in an
equilateral triangle inside the unit circle. I found:

      http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data

and tried the suggested technique. For my grid, I made a square of
the min and max of my data. However, it had problems:

...
   File "/home/guest/.local/lib/python2.6/site-packages/matplotlib/delaunay/triangulate.py",
line 125, in _compute_convex_hull
     hull.append(edges.pop(hull[-1]))
KeyError: 0

Should I expect matplotlib.mlab.griddata to work with a dataset like
this? I know that I can use hexbin, but it'd be really nice to see
contours explicitly.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
  that is made terrible by our own mad attempt to interpret it as though it had
  an underlying truth."
   -- Umberto Eco

T J wrote:

Hi,

I'm trying to grid irregularly spaced data, such that the convex hull
of the data is not rectangular. Specifically, all my data lies in an
equilateral triangle inside the unit circle. I found:

     http://www.scipy.org/Cookbook/Matplotlib/Gridding_irregularly_spaced_data

and tried the suggested technique. For my grid, I made a square of
the min and max of my data. However, it had problems:

...
  File "/home/guest/.local/lib/python2.6/site-packages/matplotlib/delaunay/triangulate.py",
line 125, in _compute_convex_hull
    hull.append(edges.pop(hull[-1]))
KeyError: 0

Should I expect matplotlib.mlab.griddata to work with a dataset like
this? I know that I can use hexbin, but it'd be really nice to see
contours explicitly.
  
We have the natgrid toolkit for just this reason - it's slower than the default, and has a more restrictive license, but it often succeeds when the default algorithm fails. This is discussed at the end of that wiki page. Let us know if the natgrid toolkit also fails.

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-113
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg