python - linear interpolation with interp2d or scipy.interpolate.RectBivariateSpline -



python - linear interpolation with interp2d or scipy.interpolate.RectBivariateSpline -

i'm quite new python , want interpolate in regular grid. first, tried interp2d. worked cases, cases (the difference values) there warning , result not expected. code:

img=sys.argv[1] latitude=np.loadtxt(img+'/'+'geolayer.lat.txt') longitude=np.loadtxt(img+'/'+'geolayer.lon.txt') n=int(sys.argv[2]) rows=int(sys.argv[3]) cols=int(sys.argv[4]) m=len(latitude)/n #latitude column=latitude[:,0].reshape((m,n)) row=latitude[:,1].reshape((m,n)) val=latitude[:,2].reshape((m,n)) # create interpolation object interp=interp2d(column,row,val) # interpolate values lattmp=interp(np.arange(cols),np.arange(rows)) lat=np.degrees(np.arctan(1.0067395*np.tan(np.radians(lattmp))))

this warning occasionally:

warning: no more knots can added because number of b-spline coefficients exceeds number of info points m. causes: either s or m small. (fp>s) kx,ky=1,1 nx,ny=14,14 m=143 fp=0.000000 s=0.000000

this how input looks like:

in [174]: shape(column) out[174]: (13, 11) in [175]: shape(row) out[175]: (13, 11) in [176]: shape(val) out[176]: (13, 11)

the difference between warning , no warning values in val. after reading in several threads, tried scipy.interpolate.rectbivariatespline:

ttt=scipy.interpolate.rectbivariatespline(rr,cc,val,bbox=[0,4199, 0,4099],kx=1,ky=1) lattmp=ttt(np.arange(cols),np.arange(rows)) in [181]: shape(cc) out[181]: (11,) in [182]: shape(rr) out[182]: (13,) in [183]: shape(val) out[183]: (13, 11)

but this:

in [170]: lattmp out[170]: array([[ nan, nan, nan, ..., nan, nan, nan], [ nan, inf, inf, ..., inf, inf, inf], [ nan, inf, inf, ..., inf, inf, inf], ..., [ nan, inf, inf, ..., inf, inf, inf], [ nan, inf, inf, ..., inf, inf, inf], [ nan, inf, inf, ..., inf, inf, inf]])

could tell me, can do?

best regards , give thanks you, mathias

python numpy scipy linear-interpolation

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -