Menu

[r2807]: / trunk / course / examples / scipy / example6.3  Maximize  Restore  History

Download this file

15 lines (13 with data), 542 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
>>> # Define function over sparse 20x20 grid
>>> x,y = mgrid[-1:1:20j,-1:1:20j]
>>> z = (x+y)*exp(-6.0*(x*x+y*y))
>>> xplt.surf(z,x,y,shade=1,palette='rainbow')
>>> xplt.title3("Sparsely sampled function.")
>>> xplt.eps("2d_func")
>>> # Interpolate function over new 70x70 grid
>>> xnew,ynew = mgrid[-1:1:70j,-1:1:70j]
>>> tck = interpolate.bisplrep(x,y,z,s=0)
>>> znew = interpolate.bisplev(xnew[:,0],ynew[0,:],tck)
>>> xplt.surf(znew,xnew,ynew,shade=1,palette='rainbow')
>>> xplt.title3("Interpolated function.")
>>> xplt.eps("2d_interp")
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.