[SciPy-Dev] Problem with N-dimensional interpolation using a new griddata function for N>=3
Adam Machnik
amachnik@gmail....
Tue Sep 21 06:54:45 CDT 2010
Hello ,
I have downloaded from SVN the latest `griddata` implementation for
working in N-D
with irregular grids (scipy v0.9.0dev6812).
It works great for 2D problems. However for 3D (and more) I have a problem:
the NaN values appears always in the same position, and it does not
depend on the scalar field being interpolated.
Here is a small example of simple 3x3x3 regular grid and a constant
scalar field of 1.0 values, that is interpolated at the input data
points.
Example:
******************************
from numpy import *
from scipy.interpolate import *
grid_x, grid_y, grid_z = mgrid[0:1:3j, 0:1:3j, 0:1:3j]
pts = [[ 0.0 , 0.0 , 0.0 ],
[ 0.0 , 0.0 , 0.5 ],
[ 0.0 , 0.0 , 1.0 ],
[ 0.0 , 0.5 , 0.0 ],
[ 0.0 , 0.5 , 0.5 ],
[ 0.0 , 0.5 , 1.0 ],
[ 0.0 , 1.0 , 0.0 ],
[ 0.0 , 1.0 , 0.5 ],
[ 0.0 , 1.0 , 1.0 ],
[ 0.5 , 0.0 , 0.0 ],
[ 0.5 , 0.0 , 0.5 ],
[ 0.5 , 0.0 , 1.0 ],
[ 0.5 , 0.5 , 0.0 ],
[ 0.5 , 0.5 , 0.5 ],
[ 0.5 , 0.5 , 1.0 ],
[ 0.5 , 1.0 , 0.0 ],
[ 0.5 , 1.0 , 0.5 ],
[ 0.5 , 1.0 , 1.0 ],
[ 1.0 , 0.0 , 0.0 ],
[ 1.0 , 0.0 , 0.5 ],
[ 1.0 , 0.0 , 1.0 ],
[ 1.0 , 0.5 , 0.0 ],
[ 1.0 , 0.5 , 0.5 ],
[ 1.0 , 0.5 , 1.0 ],
[ 1.0 , 1.0 , 0.0 ],
[ 1.0 , 1.0 , 0.5 ],
[ 1.0 , 1.0 , 1.0 ]]
vls = ones(27)
points = array(pts).astype('float64')
values = array(vls).astype('float64')
grid_z1 = griddata(points, values, (grid_x, grid_y, grid_z),
method='linear', fill_value=0)
print 'grid_z1=', grid_z1
***********************
I obtain the following result:
grid_z1= [[[ 1. 1. 1.]
[ 1. 1. 1.]
[ 1. 1. 1.]]
[[ 1. 1. 1.]
[ 1. 1. 1.]
[ 1. 1. 1.]]
[[ 1. 1. 1.]
[ 1. 1. nan]
[ 1. 1. 1.]]]
Thanks,
Adam
More information about the SciPy-Dev
mailing list