简体   繁体   English

使用SciPy 2D插补器时出错

[英]Error using SciPy 2D interpolator

I have the following piece of code for 2D interpolation: 我有以下2D插值代码:

myInterpolator = NearestNDInterpolator(XY_product, grid_data)

When I run this interpolator for a new data point: 当我为新数据点运行此插值器时:

new_grid_data = myInterpolator(new_XY)

I get the following error: 我收到以下错误:

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

How do I fix this? 我该如何解决?

Here is the description of xi = self._check_call_shape(xi) which illuminates where the error is coming from: 以下是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

This basically means that xi.shape[-1] should be equal to self.points.shape[1] . 这基本上意味着xi.shape[-1]应该等于self.points.shape[1]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM