'Assign values from irregular grid points to standard grid points using interpolation
I have (a lot of) data like below
y = [1, 3, 4, 5]
which corresponds to the grid points
x = [1, 2, 3, 4]
On the other hand, I have a standard grid
X = [1, 3]
What I need is to assign the value of y
at x[1] = 2
and x[3] = 4
, which are not in X
, to the grid points in X
using linear interpolation. For example, y[1] = 3
at x[1] = 2
will be allocated equally to the grid points X[0]
= 1 and X[1] = 3
.
The final result is expected to be
Y = [2.5, 10.5]
I have to handle millions of y
and the grid points x
could be different, so efficiency is important.
Any insights are appreciated.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|