I cannot find in the documentation how SciPy’s RegularGridInterpolator handles duplicate values within the grid.
For instance, if my points are a regular grid np.meshgrid of x and y values and my values for interpolating to the grid are a multidimensional dataset containing (x, y, z, temp).
What happens if I have a subsection of values that looks like:
[[4, 10, 100, 71]
[5, 10, 100, 70]
[5, 10, 90, 71]
[6, 10, 110, 69]]
where I have 2 different pairs of z and temp data for the (5,10) XY coordinate.
Does RegularGridInterpolator take the first occurance or average them? Do I have any control over how RegularGridInterpolator handles this?
The way that RegularGridInterpolator expects values to be passed means that you can’t pass it duplicate values.
RegularGridInterpolator expects (at least) two arguments, points
and values
. The values
array is an N dimensional array, where N is the number of dimensions you’re interpolating across. The points
tuple is a tuple of one dimensional arrays of labels of each axis.
In order to have duplicate values for the same point, you would either need to pass the same value in points
twice for some axis, which would create the error ValueError: The points in dimension 0 must be strictly ascending or descending
, or you would need to assign two different numbers to the same position in a NumPy array, which is impossible.
In the process of converting your data into the format RegularGridInterpolator expects, you will need to make some decision on how to handle duplicate values.