使用 SciPy 二维插值器时出错
Error using SciPy 2D interpolator
我有以下 2D
插值代码:
myInterpolator = NearestNDInterpolator(XY_product, grid_data)
当我运行这个新数据点的插值器时:
new_grid_data = myInterpolator(new_XY)
我收到以下错误:
xi = self._check_call_shape(xi)
File "interpnd.pyx", line 133, in
scipy.interpolate.interpnd.NDInterpolatorBase._check_call_shape
(scipy/interpolate/interpnd.c:3261)
ValueError: number of dimensions in xi does not match x
我该如何解决这个问题?
这里是 xi = self._check_call_shape(xi)
的描述,说明了错误的来源:
def _check_call_shape(self, xi):
xi = np.asanyarray(xi)
if xi.shape[-1] != self.points.shape[1]:
raise ValueError("number of dimensions in xi does not match x")
return xi
这基本上意味着 xi.shape[-1]
应该等于 self.points.shape[1]
。
我有以下 2D
插值代码:
myInterpolator = NearestNDInterpolator(XY_product, grid_data)
当我运行这个新数据点的插值器时:
new_grid_data = myInterpolator(new_XY)
我收到以下错误:
xi = self._check_call_shape(xi)
File "interpnd.pyx", line 133, in
scipy.interpolate.interpnd.NDInterpolatorBase._check_call_shape
(scipy/interpolate/interpnd.c:3261)
ValueError: number of dimensions in xi does not match x
我该如何解决这个问题?
这里是 xi = self._check_call_shape(xi)
的描述,说明了错误的来源:
def _check_call_shape(self, xi):
xi = np.asanyarray(xi)
if xi.shape[-1] != self.points.shape[1]:
raise ValueError("number of dimensions in xi does not match x")
return xi
这基本上意味着 xi.shape[-1]
应该等于 self.points.shape[1]
。