[SciPy-User] griddata interpolation methods
Gökhan Sever
gokhansever@gmail....
Thu Apr 25 11:13:27 CDT 2013
Hello,
I am using scipy.interpolate.griddata to interpolate a value from a table
of values. Below is the code, also attached in this e-mail:
# griddata interpolation method test
#
import itertools
import numpy as np
from scipy.interpolate import griddata
#
r_1_ry = np.array([ 0., 2., 3., 4., 6., 8., 10., 15., 20.,
25.])
r_2_ry = np.array([ 10., 20., 30., 40., 50., 60., 80., 100., 150.,
200., 300., 400., 500., 600.,1000.,1400.,1800.,2400.,3000.])
eff_ry = np.zeros((len(r_2_ry), len(r_1_ry)))
eff_ry[:,0] = [ .00, .00, .00, .00, .00, .00, .00, .00, .00, .00,
.00, .00, .00, .00, .00, .00, .00, .00, .00]
eff_ry[:,1] = [ .02, .00, .00, .00, .00, .00, .00, .00, .02, .04,
.10, .10, .10, .17, .15, .11, .08, .04, .02]
eff_ry[:,2] = [ .03, .02, .00, .00, .00, .01, .08, .14, .25, .30,
.33, .36, .36, .40, .37, .34, .29, .22, .16]
eff_ry[:,3] = [ .04, .03, .02, .02, .03, .13, .23, .32, .43, .46,
.51, .51, .52, .54, .52, .49, .45, .39, .33]
eff_ry[:,4] = [ .05, .06, .13, .23, .30, .38, .52, .60, .66, .69,
.72, .73, .74, .72, .74, .71, .68, .62, .55]
eff_ry[:,5] = [ .05, .12, .28, .40, .40, .57, .68, .73, .78, .81,
.82, .83, .83, .83, .82, .83, .80, .75, .71]
eff_ry[:,6] = [ .00, .17, .37, .55, .58, .68, .76, .81, .83, .87,
.87, .88, .88, .88, .88, .88, .86, .83, .81]
eff_ry[:,7] = [ .00, .17, .54, .70, .73, .80, .86, .90, .92, .93,
.93, .93, .93, .94, .94, .94, .96, .92, .90]
eff_ry[:,8] = [ .00, .00, .55, .75, .75, .86, .92, .94, .95, .95,
.96, .96, .96, .98, .98, .95, .94, .96, .94]
eff_ry[:,9] = [ .00, .00, .47, .75, .79, .91, .95, .96, .96, .96,
.97, .97, .97, 1.00, 1.00, 1.00, 1.00, 1.00, 1.00]
# Creating data point coordinates for use in griddata function
coords = list(itertools.product(*(r_2_ry, r_1_ry)))
interp1 = griddata(coords, eff_ry.flatten(), (50., 10.), method='linear')
interp2 = griddata(coords, eff_ry.flatten(), (50., 10.), method='nearest')
interp3 = griddata(coords, eff_ry.flatten(), (50., 10.), method='cubic')
print interp1
print interp2
print interp3
Running this code, I get the following results:
:!python Desktop/griddata_test.py
nan
0.58
nan
Why it produces nan for 'linear' and 'cubic' methods? I remember running
this code in an older scipy version with 'linear' switch and it was working
fine. Though, I can't remember the version of scipy that tested it before.
Was a there change in griddata since past?
Currently, I have:
np.__version__
'1.8.0.dev-82c0bb8'
scipy.__version__
'0.12.0.dev-2f17ff2'
--
Gökhan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20130425/f1843699/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: griddata_test.py
Type: application/octet-stream
Size: 2106 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/scipy-user/attachments/20130425/f1843699/attachment.obj
More information about the SciPy-User
mailing list