yr = N.arange(10.) xxr, yyr = N.meshgrid(xr, yr) zzr = (N.sin(xxr*N.pi/6)*N.sin(yyr*N.pi/6) + \ N.exp(-((xxr-7.)**2+(yyr-7.)**2)/4.**2))*100. zzr -= zzr.min() vminmax = dict(vmin=zzr.min(), vmax=zzr.max()) ij = N.unique((N.random.rand(50) * zzr.size).astype('i')) xi, yi, zi = xxr.flat[ij], yyr.flat[ij], zzr.flat[ij] ij2 = N.unique((N.random.rand(50) * zzr.size).astype('i')) xo2, yo2 = xxr.flat[ij2], yyr.flat[ij2] # CDAT natgrid from nat import Natgrid I = Natgrid(xi, yi, xr, yr) I.ext = 1 I.igr = 1 zzoc = I.rgrd(zi).T # Matplotlib / R. Kern from matplotlib.delaunay import Triangulation tri = Triangulation(xi, yi) I = tri.nn_extrapolator(zi) zzok = I(xxr, yyr) # Plot from matplotlib import pyplot as P P.figure(figsize=(4, 11))
yr = N.arange(10.) xxr, yyr = N.meshgrid(xr, yr) zzr = (N.sin(xxr*N.pi/6)*N.sin(yyr*N.pi/6) + \ N.exp(-((xxr-7.)**2+(yyr-7.)**2)/4.**2))*100. zzr -= zzr.min() vminmax = dict(vmin=zzr.min(), vmax=zzr.max()) ij = N.unique((N.random.rand(50)*zzr.size).astype('i')) xi, yi, zi = xxr.flat[ij], yyr.flat[ij], zzr.flat[ij] ij2 = N.unique((N.random.rand(50)*zzr.size).astype('i')) xo2, yo2 = xxr.flat[ij2], yyr.flat[ij2] # CDAT natgrid from nat import Natgrid I = Natgrid(xi, yi, xr, yr) I.ext = 1 I.igr = 1 zzoc = I.rgrd(zi).T # Matplotlib / R. Kern from matplotlib.delaunay import Triangulation tri = Triangulation(xi,yi) I = tri.nn_extrapolator(zi) zzok = I(xxr,yyr) # Plot from matplotlib import pyplot as P P.figure(figsize=(4, 11)) P.subplot(311)
N.exp(-((xxr-7.)**2+(yyr-7.)**2)/4.**2))*100. zzr -= zzr.min() vminmax = dict(vmin=zzr.min(), vmax=zzr.max()) # - un jeu alatoire (input) ij = N.unique((N.random.rand(50)*zzr.size).astype('i')) xi, yi, zi = xxr.flat[ij], yyr.flat[ij], zzr.flat[ij] # - un autre jeu aleatoire (output) ij2 = N.unique((N.random.rand(100)*zzr.size).astype('i')) xo, yo = xxr.flat[ij2], yyr.flat[ij2] # Sans VACUMM # - CDAT natgrid from nat import Natgrid I = Natgrid(xi, yi, xr, yr) I.ext = 1 # Changer I.igr = 1 # les parametres zzoc = I.rgrd(zi).T # - Matplotlib / R. Kern from matplotlib.delaunay import Triangulation tri = Triangulation(xi,yi) I = tri.nn_extrapolator(zi) # Tester les autres methodes zzork = I(xxr,yyr) # vers grille zork = I(xo,yo) # vers points # Avec VACUMM from vacumm.misc.grid.regridding import GridData, griddata, xy2xy zzov = griddata(xi, yi, zi, (xr, yr), method='nat', ext=True, sub=10)