Ejemplo n.º 1
0
r = 3

from vcmq import P, savefigs, code_file_name, N, auto_scale, add_grid
from vacumm.misc.grid.kriging import gridded_gauss3, random_gauss3, random_points, krig

# Generate random gridded field
xi, yi, zzi = gridded_gauss3(nx=nxi, ny=nyi)
xxi, yyi = N.meshgrid(xi, yi)

# Refined grid
xo = N.linspace(xi[0], xi[-1], (nxi - 1) * r + 1)
yo = N.linspace(yi[0], yi[-1], (nyi - 1) * r + 1)
xxo, yyo = N.meshgrid(xo, yo)

# Interpolate
zzo = krig(xxi.ravel(), yyi.ravel(), zzi.ravel(), xxo.ravel(), yyo.ravel())
zzo.shape = xxo.shape

# Section
P.figure(figsize=(8, 4))
iyis = [3, 4]
for iyi in iyis:
    label = iyi == iyis[0]
    P.plot(xi,
           zzi[iyi],
           'ob-',
           markersize=8,
           label='Original' if label else None)
    P.plot(xo,
           zzo[iyi * r],
           'or-',
Ejemplo n.º 2
0
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))
axis = [xxrb.min(), xxrb.max(), yyrb.min(), yyrb.max()]
#
P.subplot(332)
P.pcolormesh(xxrb, yyrb, zzr, **vminmax)
P.scatter(xi, yi, c='k')
P.title('Original')
P.axis(axis)
#
Ejemplo n.º 3
0
"""Test function :func:`~vacumm.misc.grid.kriging.krig`"""

npi = 500
npo = 200

from vcmq import P, savefigs, code_file_name
from vacumm.misc.grid.kriging import gridded_gauss3, random_gauss3, random_points, krig

# Generate random field
xg, yg, zzg = gridded_gauss3()
xi, yi, zi = random_gauss3(np=npi)

# Interpolate to random points
xo, yo = random_points(np=npo)
zo = krig(xi, yi, zi, xo, yo)

# Plot
# - source data
axis = [xg.min(), xg.max(), yg.min(), yg.max()]
kw = dict(vmin=zzg.min(), vmax=zzg.max())
kwim = dict(extent=axis,
            interpolation='bilinear',
            origin='lower',
            alpha=.2,
            **kw)
kwsc = dict(lw=0.2, **kw)
P.figure(figsize=(6, 3.5))
P.subplot(121)
P.title('Source field')
P.imshow(zzg, **kwim)
P.scatter(xi, yi, c=zi, **kwsc)
Ejemplo n.º 4
0
r = 3

from vcmq import P, savefigs, code_file_name, N, auto_scale, add_grid
from vacumm.misc.grid.kriging import gridded_gauss3, random_gauss3, random_points, krig

# Generate random gridded field
xi, yi, zzi = gridded_gauss3(nx=nxi, ny=nyi)
xxi, yyi = N.meshgrid(xi, yi)

# Refined grid
xo = N.linspace(xi[0], xi[-1], (nxi-1)*r+1)
yo = N.linspace(yi[0], yi[-1], (nyi-1)*r+1)
xxo, yyo = N.meshgrid(xo, yo)

# Interpolate
zzo = krig(xxi.ravel(), yyi.ravel(), zzi.ravel(), xxo.ravel(), yyo.ravel())
zzo.shape = xxo.shape

# Section
P.figure(figsize=(8, 4))
iyis = [3, 4]
for iyi in iyis:
    label = iyi==iyis[0]
    P.plot(xi, zzi[iyi], 'ob-', markersize=8, label='Original' if label else None)
    P.plot(xo, zzo[iyi*r], 'or-', markersize=5, lw=.8, label='Interpolated' if label else None)
    P.legend(loc='best', framealpha=0.5)
P.grid()
P.title('Section')
P.tight_layout()
savefigs(code_file_name(ext='_0.png'), verbose=False, pdf=True)
Ejemplo n.º 5
0
"""Test function :func:`~vacumm.misc.grid.kriging.krig`"""

npi = 500
npo = 200

from vcmq import P, savefigs, code_file_name
from vacumm.misc.grid.kriging import gridded_gauss3, random_gauss3, random_points, krig

# Generate random field
xg, yg, zzg = gridded_gauss3()
xi, yi, zi = random_gauss3(np=npi)

# Interpolate to random points
xo, yo = random_points(np=npo)
zo = krig(xi, yi, zi, xo, yo)

# Plot
# - source data
axis = [xg.min(), xg.max(), yg.min(), yg.max()]
kw = dict(vmin=zzg.min(), vmax=zzg.max())
kwim = dict(extent=axis, interpolation='bilinear', origin='lower', alpha=.2, **kw)
kwsc = dict(lw=0.2, **kw)
P.figure(figsize=(6, 3.5))
P.subplot(121)
P.title('Source field')
P.imshow(zzg, **kwim)
P.scatter(xi, yi, c=zi, **kwsc)
P.axis(axis)
# - interpolated data
P.subplot(122)
P.title('Interpolated points')