Python scipy插值的实现困难
我试图使用显示的类来插值一些数据 我很难让这个班上课。一个最简单的例子是:Python scipy插值的实现困难,python,numpy,scipy,interpolation,scientific-computing,Python,Numpy,Scipy,Interpolation,Scientific Computing,我试图使用显示的类来插值一些数据 我很难让这个班上课。一个最简单的例子是: #!/usr/bin/env python import sys from mayavi.mlab import * from mayavi import mlab from numpy import * import numpy as np from mayavi.scripts import mayavi2 from mayavi.sources.vtk_file_reader import VTKFileRead
#!/usr/bin/env python
import sys
from mayavi.mlab import *
from mayavi import mlab
from numpy import *
import numpy as np
from mayavi.scripts import mayavi2
from mayavi.sources.vtk_file_reader import VTKFileReader
from mayavi.modules.outline import Outline
from mayavi.modules.grid_plane import GridPlane
from mayavi.modules.contour_grid_plane import ContourGridPlane
from mayavi.modules.iso_surface import IsoSurface
from mayavi.modules.scalar_cut_plane import ScalarCutPlane
import scipy
from scipy import interpolate
from scipy.interpolate import griddata
#from scipy.interpolate import RegularGridInterpolator
print 'Argument List:', str(sys.argv)
if (len(sys.argv)==5):
NX = int(sys.argv[1])
NY = int(sys.argv[2])
NZ = int(sys.argv[3])
fname = sys.argv[4]
else:
print "Error in parsing the command line arguments"
print "Command line arguments are: N_X N_Y N_Z filename "
sys.exit()
clf()
figure(bgcolor=(1, 1, 1))
len(sys.argv)
data = genfromtxt(fname)
x,y,z = mgrid[ 0:NX:1, 0:NY:1, 0:NZ:1 ]
#print(x)
index = 0
V=0*x
for k in range(NZ):
for j in range(NY):
for i in range(NX):
V[i][j][k] = 1000*data[index,5]
scipy.interpolate.RegularGridInterpolator(V, V, method='linear', bounds_error=True, fill_value=nan) #ERROR
我当前的问题真正感兴趣的是最后一行和开头的所有导入命令
我的错误是:
Traceback (most recent call last):
File "contour-3d.py", line 70, in <module>
scipy.interpolate.RegularGridInterpolator(W, W, method='linear', bounds_error=True, fill_value=nan)
AttributeError: 'module' object has no attribute 'RegularGridInterpolator'
回溯(最近一次呼叫最后一次):
文件“contour-3d.py”,第70行,中
scipy.interpolate.RegularGridInterpolator(W,W,method='linear',bounds\u error=True,fill\u value=nan)
AttributeError:“模块”对象没有属性“RegularGridInterpolator”
我对python不太熟悉,因此这可能是一个非常基本的错误。来自文档:
版本0.14中的新功能
您可能有以前版本的SciPy。如果您正在使用Ubuntu,请尝试运行pip
:
pip install --user --upgrade scipy
您可能需要一些其他依赖项:
sudo apt-get install gcc gfortran python-dev libblas-dev liblapack-dev cython
有关更多信息,请参阅和文档中的:
版本0.14中的新功能
您可能有以前版本的SciPy。如果您正在使用Ubuntu,请尝试运行pip
:
pip install --user --upgrade scipy
您可能需要一些其他依赖项:
sudo apt-get install gcc gfortran python-dev libblas-dev liblapack-dev cython
有关更多信息,请参阅和文档中的:
版本0.14中的新功能
您可能有以前版本的SciPy。如果您正在使用Ubuntu,请尝试运行pip
:
pip install --user --upgrade scipy
您可能需要一些其他依赖项:
sudo apt-get install gcc gfortran python-dev libblas-dev liblapack-dev cython
有关更多信息,请参阅和文档中的:
版本0.14中的新功能
您可能有以前版本的SciPy。如果您正在使用Ubuntu,请尝试运行pip
:
pip install --user --upgrade scipy
您可能需要一些其他依赖项:
sudo apt-get install gcc gfortran python-dev libblas-dev liblapack-dev cython
有关更多信息,请参见和
scipy.interpolate.RegularGridInterpolator
是scipy
0.14.x
中的一个新函数。您可能正在使用旧版本。更新scipy
应该可以解决这个问题。scipy.interpolate.RegularGridInterpolator
是scipy
0.14.x
中的一个新函数。您可能正在使用旧版本。更新scipy
应该可以解决这个问题。scipy.interpolate.RegularGridInterpolator
是scipy
0.14.x
中的一个新函数。您可能正在使用旧版本。更新scipy
应该可以解决这个问题。scipy.interpolate.RegularGridInterpolator
是scipy
0.14.x
中的一个新函数。您可能正在使用旧版本。更新scipy
应该可以解决这个问题