Hi all,
I would like to interpolate 3D scatter data. I have some 3D points, each point has an associated value, I would like to interpolate these point to calculate the value of a random point. This example may help to understand: from math import cos, sin As you can see here we have some points over a cylinder, each point has associate a value (color), which in this case is the z-coordinate. scipy.interpolate.Rbf should answer my problem, to better understsand how it works I gave it some points [[0,0,0],[0,0,1]], but the result of rbfi(xi, yi, zi) is [-1.04833984 -0.10205078]. I expected that a point along the axis, aligned with some point should return the z-coordinate of this point [0, 1] but got some negative number. Any ideas? Do you have any alternative that I can use to have a linear interpolation or by the nearest? Thanks _______________________________________________ SciPy-User mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/scipy-user |
Hi Vasco, That code is pretty old now and I don't have any small test data sets for it, so just take a look and see if it helps,Sorry for not replying sooner. I thought I had a self-contained example of using the scipy.ndimage.map_coordinates() function to do this. I can't find it though. It may help to look at how I used map_coordinates() to interpolate a vector field to map the vector onto a sphere: https://gist.github.com/gazzar/369ed55f15045bb99cae On 16 February 2016 at 06:48, Vasco Gervasi <[hidden email]> wrote:
_______________________________________________ SciPy-User mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/scipy-user |
Sorry but I am not able to understand how map_coordinates works. Let's say that I am in 2D and I have the points [x=0, y=0] and [x=1, y=1], and each point has associated a value [x=0, y=0, v=0] and [x=1, y=1, v=2]. My input for map_coordinates should be: in_data = np.array([[0.,0.,0.], I would like to interpolate in the middle point [x=0.5, y=0.5] so the coordinates should be; lookpoints = np.array([[0.5, 0.5]]).T So: s = map_coordinates(in_data, lookpoints, order=1) But i get s=0.5 not 1. What am I doing wrong? Thanks _______________________________________________ SciPy-User mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/scipy-user |
Hi Vasco, The input to map_coordinates should be a regularly-sampled array, like an image. In your case, you've provided an input image of shape (2, 3). In the format you're thinking, (x, y, val) tuples, the input you have provided would be expressed as: [[0, 0, 0], [0, 1, 0], [0, 2, 0], [1, 0, 1], [1, 1, 1], [1, 2, 2]] As you can see, using linear interpolation at (0.5, 0.5) in that image interpolates between the values 0, 0, 1, 1, thus resulting in 0.5. Juan. On Mon, Feb 22, 2016 at 1:48 AM, Vasco Gervasi <[hidden email]> wrote:
_______________________________________________ SciPy-User mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/scipy-user |
So how can do if the input is not a regularly-sampled array? Like some scattered data? Thank you very much _______________________________________________ SciPy-User mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/scipy-user |
Have a look at the functions in scipy.interpolate. `griddata` looks like what you need but is not defined for only two points in 2D: you need to define values for enough points to form a convex hull. (ie at a minimum, ndim + 1 points.) hth! Juan. On Mon, Feb 22, 2016 at 6:58 PM, Vasco Gervasi <[hidden email]> wrote:
_______________________________________________ SciPy-User mailing list [hidden email] https://mail.scipy.org/mailman/listinfo/scipy-user |
Free forum by Nabble | Edit this page |