Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

analogy to scipy.interpolate.griddata?

I want to interpolate a given 3D point cloud:

I had a look at scipy.interpolate.griddata and the result is exactly what I need, but as I understand, I need to input "griddata" which means something like x = [[0,0,0],[1,1,1],[2,2,2]].

But my given 3D point cloud don't has this grid-look - The x,y-values don't behave like a grid - anyway there is only a single z-value for each x,y-value.*

So is there an alternative to scipy.interpolate.griddata for my not-in-a-grid-point-cloud?

*edit: "no grid look" means my input looks like this:

x = [0,4,17]
y = [-7,25,116]
z = [50,112,47]
like image 899
Munchkin Avatar asked Aug 28 '13 19:08

Munchkin


People also ask

What does Scipy interpolate Griddata do?

interpolate. griddata() method is used to interpolate on a 2-Dimension grid.

What is Scipy interpolation?

The interp1d class in the scipy. interpolate is a convenient method to create a function based on fixed data points, which can be evaluated anywhere within the domain defined by the given data using linear interpolation. By using the above data, let us create a interpolate function and draw a new interpolated graph.


1 Answers

This is a function I use for this kind of stuff:

from numpy import linspace, meshgrid

def grid(x, y, z, resX=100, resY=100):
    "Convert 3 column data to matplotlib grid"
    xi = linspace(min(x), max(x), resX)
    yi = linspace(min(y), max(y), resY)
    Z = griddata(x, y, z, xi, yi)
    X, Y = meshgrid(xi, yi)
    return X, Y, Z

Then use it like this:

  X, Y, Z = grid(x, y, z)
like image 141
elyase Avatar answered Oct 10 '22 16:10

elyase