ZeroDivisionError
次のコードから取得しています:
#stacking the array into a complex array allows np.unique to choose
#truely unique points. We also keep a handle on the unique indices
#to allow us to index `self` in the same order.
unique_points,index = np.unique(xdata[mask]+1j*ydata[mask],
return_index=True)
#Now we break it into the data structure we need.
points = np.column_stack((unique_points.real,unique_points.imag))
xx1,xx2 = self.meta['rcm_xx1'],self.meta['rcm_xx2']
yy1 = self.meta['rcm_yy2']
gx = np.arange(xx1,xx2+dx,dx)
gy = np.arange(-yy1,yy1+dy,dy)
GX,GY = np.meshgrid(gx,gy)
xi = np.column_stack((GX.ravel(),GY.ravel()))
gdata = griddata(points,self[mask][index],xi,method='linear',
fill_value=np.nan)
ここで、xdata
、ydata
およびself
はすべてnumpy.ndarray
同じ形状の 2D (またはそのサブクラス) であり、 およびdtype=np.float32
です。 は同じ形状mask
の 2 次元であり、 と. ドキュメントを熟読したい人のためのリンクは次のとおりです。ndarray
dtype=bool
scipy.interpolate.griddata
もともと、xdata
とydata
は 4 ポイントのステンシルを持つ不均一な円柱状のグリッドから派生しています。同じポイントが複数回定義されているという事実からエラーが発生している可能性があると考えたため、入力ポイントのセットを次のように一意にしました。この質問で提案されています。残念ながら、それは役に立たなかったようです。完全なトレースバックは次のとおりです。
Traceback (most recent call last):
File "/xxxxxxx/rcm.py", line 428, in <module>
x[...,1].to_pz0()
File "/xxxxxxx/rcm.py", line 285, in to_pz0
fill_value=fill_value)
File "/usr/local/lib/python2.7/site-packages/scipy/interpolate/ndgriddata.py", line 183, in griddata
ip = LinearNDInterpolator(points, values, fill_value=fill_value)
File "interpnd.pyx", line 192, in scipy.interpolate.interpnd.LinearNDInterpolator.__init__ (scipy/interpolate/interpnd.c:2935)
File "qhull.pyx", line 996, in scipy.spatial.qhull.Delaunay.__init__ (scipy/spatial/qhull.c:6607)
File "qhull.pyx", line 183, in scipy.spatial.qhull._construct_delaunay (scipy/spatial/qhull.c:1919)
ZeroDivisionError: float division
価値があるのは、「最も近い」方法を使用すると、コードが「機能する」(例外なし)ことです。