I have the following piece of code for 2D interpolation:
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:
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].
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With