Im having trouble using scipy.interpolate.RegularGridInterpolant.More precisely, i cant make extrapolations with the interpolating function of the output. In the documentation says that if 'fill value' is None, the values out of the grid are extrapolated, but its seems not working. I want to interpolate linearly, I see other functions that extrapolate but with other methods (nearest neighbor, or a predefined value).
Here is an example with dummy data (not the arrays that im working but the case is the same)
import numpy as np
from scipy.interpolate import RegularGridInterpolator
x = np.array([11,22,33,44,55,66,77])
y = np.array([101,102,103,104,105,106,107])
z = np.random.rand(7,7)
x_new = np.array([1,12,23,34,45,56,67])
y_new = np.array([101,102,103,104,105,106,107])
interpolant_function = RegularGridInterpolator((x,y),z, fill_value = None)
result = interpolant_function((x_new,y_new))
This code raises the following error
raise ValueError("One of the requested xi is out of bounds "
ValueError: One of the requested xi is out of bounds in dimension 0
Im stucked since few days, also if anyone knows another function to do the same and works well im glad to hear it
I think you need to add “bounds_error=False”.
interpolant_function = RegularGridInterpolator((x,y),z, bounds_error=False, fill_value = None)
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