[SciPy-user] 2D interpolation containing missing values
Wed Feb 27 16:27:51 CST 2008
Hi SciPy users,
I would like to interpolate data from a 2D irregular grid to a limited
number of points. The input data is defined by: a 2D longitude array,
a 2D latitude array and a 2D array containing the data values. The
data array is a numpy masked array (numpy.ma) and may contain masked
out values. It can for example represent an ocean temperature field
which is masked out at land points. If a land point is included in the
interpolation to one of the output points I would like the result to
be nan or something else identifiable so that I can mask it out.
I have tried to do the interpolation using the delaunay package.
Unfortunately it does not seem to be able to handle masked arrays. I
have therefore ended up with a solution in which I only keep the
non-masked values of the data in the interpolation. The result of this
is that land values are interpolated from the nearest ocean values. I
can of course mask out these values afterwards by finding the nearest
point in my input data array and check if it is masked. But that is
probably not very effective and I was wondering if anyone has a better
solution? Are some of the other interpolation routines better suited
for such a problem?
More information about the SciPy-user