, , .
, interp1d , 1d-, .. F(x), x 2d- F. , , : (lat,lon). F_(lat,lon)(x).
, , , F(x) , , ( [lat,lon] , ). , , . , , .
. , , , , . , 3D- 2-, , 2d- . , , , . , , , .
, , :
import numpy as np
from scipy.interpolate import interp1d
arr = np.random.randint(0, 9, size=(3, 4, 5))
x = np.linspace(0, 10, 3)
x_new = np.random.rand(6,4,5)*10
interp_func = interp1d(x, arr, axis=0)
res = np.empty((6, 4, 5))
for lat in range(res.shape[1]):
for lon in range(res.shape[2]):
temp = interp_func(x_new[:,lat,lon])
res[:,lat,lon] = temp[:,lat,lon]
arr2 = arr.reshape(arr.shape[0],-1)
interp_func2 = interp1d(x,arr2,axis=0)
x_new2 = x_new.reshape(x_new.shape[0],-1)
temp = interp_func2(x_new2)
s = x_new2.shape[1]
res2 = temp[:,range(s),range(s)].reshape(res.shape)
res res2 , , , . , , (nx,nlat,nlon) (nx,nlat*nlon,nlat*nlon), , , .
, , - : nlat*nlon . , , , , .
, ( interpolate.interpnd interpolate.griddata). , , , . , , , .
, , , , . , ( C), " 1- ". -
arr = arr.transpose(1,2,0)
interp_func = interp1d(x, arr, axis=-1)
...
for lat ...:
for lon ...:
res[lat,lon,:] = temp[lat,lon,:]
, , , res.transpose(2,0,1).