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) # -> Tester la methode "carg" # -> Testez parametre sub=... # -> Essayer avec GridData zov2 = xy2xy(xi, yi, zi, xo, yo) # Krigeage from vacumm.misc.grid.kriging import krig zzok = krig(xi, yi, zi, xxr.ravel(), yyr.ravel(), nproc=1).reshape(zzr.shape) # -> Tester nproc et npmax # Plots from vcmq import meshbounds, P xxrb, yyrb = meshbounds(xr, yr) P.figure(figsize=(10, 8))
yr = N.arange(10.) xxr, yyr = N.meshgrid(xr, yr) xrb, yrb = meshbounds(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()) # On construit un echantillon irregulier a partir du regulier ij = N.unique((N.random.rand(50)*zzr.size).astype('i')) xi, yi, zi = xxr.flat[ij], yyr.flat[ij], zzr.flat[ij] # Interpolation sur la grille reguliere # - natgrid from vacumm.misc.grid.regridding import griddata zirn = griddata(xi, yi, zi, (xr, yr), method='nat', ext=True, sub=6) # - krigeage zirk = griddata(xi, yi, zi, (xr, yr), method='carg') # Plot de verif import pylab as P from vacumm.misc.plot import savefigs P.figure(1, figsize=(6, 8)) P.subplots_adjust(hspace=.3, bottom=.05, top=.95, left=.06) # - regulier P.subplot(311) P.pcolor(xrb, yrb, zzr, **vminmax) P.xlim(xrb.min(), xrb.max()) ; P.ylim(yrb.min(), yrb.max()) P.title('Original') stdref = zzr.std() # - irregulier via natgrid
yr = N.arange(10.) xxr, yyr = N.meshgrid(xr, yr) xrb, yrb = meshbounds(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()) # On construit un echantillon irregulier a partir du regulier ij = N.unique((N.random.rand(50) * zzr.size).astype('i')) xi, yi, zi = xxr.flat[ij], yyr.flat[ij], zzr.flat[ij] # Interpolation sur la grille reguliere # - natgrid from vacumm.misc.grid.regridding import griddata zirn = griddata(xi, yi, zi, (xr, yr), method='nat', ext=True, sub=6) # - krigeage zirk = griddata(xi, yi, zi, (xr, yr), method='carg') # Plot de verif import pylab as P from vacumm.misc.plot import savefigs P.figure(1, figsize=(6, 8)) P.subplots_adjust(hspace=.3, bottom=.05, top=.95, left=.06) # - regulier P.subplot(311) P.pcolor(xrb, yrb, zzr, **vminmax) P.xlim(xrb.min(), xrb.max()) P.ylim(yrb.min(), yrb.max()) P.title('Original') stdref = zzr.std()