I have three two dimesional arrays which have shape of (100,100). Each array looks like:
x =
[[-104.09417725 -104.08866882 -104.0831604 ..., -103.8795166 -103.87399292
-103.86849976]
...,
[-104.11058044 -104.10507202 -104.09954834 ..., -103.89535522
-103.88983154 -103.88430786]
[-104.11141968 -104.10591125 -104.10038757 ..., -103.89614868 -103.890625
-103.88513184]]
y =
[[ 40.81712341 40.81744385 40.81776428 ..., 40.82929611 40.82960129
40.82990646]
...,
[ 40.98789597 40.9882164 40.98854065 ..., 41.00011063 41.00041199
41.00072479]]
z =
[[ 1605.58544922 1615.62341309 1624.33911133 ..., 1479.11254883
1478.328125 1476.13378906]
...,
[ 1596.03857422 1600.5690918 1606.30712891 ..., 1598.56982422
1594.90454102 1594.07763672]]
Also I have two 1 d arrays of x1 and y1. These x1 and y1 are in the range of x and y respectively such as:
x1 = [ 104.07794 104.03169 104.03352 104.03584 104.03835 104.04085
104.04334 104.07315 104.07133 104.07635 104.07916 104.0321
104.03481 104.03741 104.04002 104.04366 104.04572 104.04787
...................................................................
103.92937 103.89825 103.90027 103.90253 103.90352 103.90375
103.89922 103.89931 103.90145 103.90482 103.90885 103.91058
103.91243 103.91525 103.91785 103.92078 103.97814]
y1 = [ 40.9542 40.96922 40.96733 40.96557 40.96377 40.96218 40.96043
40.95446 40.95686 40.95296 40.95184 40.94984 40.94834 40.9469
40.94538 40.94287 40.94154 40.94008 40.93824 40.93705 40.93579
.........................................................................
40.89675 40.9015 40.90044 40.89948 40.89766 40.89513 40.88374
40.88118 40.87915 40.87933 40.87917 40.878 40.87675 40.87598
40.87515 40.87421 40.91258]
x1 and y1 correspond as (x1,y1) each other following indices such as (104.07794,40.9542), (104.03169,40.96922) and so on. Here what I would like to get is z1 corresponding to (x1,y1) interpolated by x,y,z. For this purpose, I made a code like below:
x1,y1 = np.meshgrid(x1,y1)
f = interpolate.interp2d(x,y,z,kind='linear')
or
f = interpolate.Rbf(x,y,z,function='linear')
z1 = f(x1,y1)
However, I don't want to convert x1, y1 to 2 d meshgrid because this function fill the grid points which I don't like to fill in. So, I would like to interpolate x1, y1 without convert to 2 d meshgrid, but these 2d interpolation methods seem to require that x,y and x1,y1 have same dimesion. Is there any way to interpolate without making dimension of x1,y1 and x,y same? Thank you, Isaac
Rbfanswer I wrote earlier, the inputs (bothxandx1) are 1d arrays. In your case you probably need toflattenyour 2d arrays. stackoverflow.com/a/29979983/901925