Пример #1
0
#    Axes
#     Graphics

app = vv.use()
#vv.clf() 

#
# Superficie como gráfica de una función
#
f = lambda x, y: x*y

xs = np.linspace(-2.0,2.0,21)
ys = np.linspace(-2.0,2.0,21)
zs = [ [ f(x,y) for x in xs ] for y in ys ]

graph_surf = vv.grid(xs, ys, zs, axesAdjust=True)
#graph_surf = vv.surf(xs, ys, zs, axesAdjust=True)
graph_surf.colormap = vv.CM_JET


#
# Superficie paramétrica
#
def paramSurf(u,v):
	x = 2.0 * cos(u) * sin(v)
	y = 1.5 * sin(u) * sin(v)
	z = 2.2 * cos(v)
	return np.array( (x, y, z) )

NU = 21
NV = 11
#Plot in 3D with matplotlib

from mpl_toolkits.mplot3d.axes3d import *
import matplotlib.pyplot as plt
from matplotlib import cm
fig = plt.figure()
ax = Axes3D(fig)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.jet,linewidth=1, antialiased=True)
plt.show()

#Plot in 3D with visvis

import visvis
f = visvis.gca()
m = visvis.grid(xi,yi,Z) 
f.daspect = 1,1,10 # z x 10
# draped colors
m = visvis.surf(xi,yi,Z)
m.colormap = visvis.CM_JET

#Save to GeoTiff file

nrows,ncols = np.shape(Z) 
xres = (xmax-xmin)/ncols
yres = (ymax-ymin)/nrows
geotransform=(xmin,xres,0,ymin,0, yres) 
driver = gdal.GetDriverByName("GTiff")
ds = driver.Create('output.tif', nrows,ncols, 1, gdal.GDT_Float32)
ds.SetGeoTransform(geotransform)
#Establish its coordinate
#'inverse': 1.0/sqrt((r/self.epsilon)**2 + 1)

#x2 = np.linspace(min(x2), max(x2))
#y2 = np.linspace(min(y2), max(y2))
#X2, Y2 = np.meshgrid(x2, y2)

# interpolación
Z = spline(X, Y)
Z1 = spline1(X, Y)
#Visualización con visvis
f = visvis.gca()
m = visvis.plot(x, y, z, lc='k', ls='', mc='g', mw=10, lw=10, ms='.')
f.daspect = 1, 1, 10  # z x 10
#m = visvis.surf(xi,yi,Z)
m = visvis.surf(xi, yi, Z)
m = visvis.grid(xi, yi, Z1)

m.colormap = visvis.CM_JET
f.axis.visible = True

#m = visvis.surf(x2,y2,Z2)
#m.colormap = visvis.CM_JET

#Volumen en cada interpolación con respecto a los puntos:
#volume = Convexhull(xyz).volume

# Necesario para que la vista no se cierre
app = visvis.use()

#Movimiento cámara en 3 dimensiones (FPS)
a = visvis.gca()
Пример #4
0
    Keyword arguments
    -----------------
    axesAdjust : bool
        If True, this function will call axes.SetLimits(), and set
        the camera type to 3D. If daspectAuto has not been set yet, 
        it is set to False.
    axes : Axes instance
        Display the bars in the given axes, or the current axes if not given.
    
    Notes
    -----
      * This function should not be confused with the axis grid, see the 
        Axis.showGrid property.
      * This function is know in Matlab as mesh(), but to avoid confusion
        with the vv.Mesh class, it is called grid() in visvis.
    
    Also see surf() and the solid*() methods.
    
    """
    
    m = vv.surf(*args, **kwargs)
    m.faceShading = None
    m.edgeShading = 'smooth'
    m.edgeColor = 'w'
    return m

if __name__ == '__main__':
    vv.figure()
    m = vv.grid(vv.peaks())
    m.colormap = vv.CM_HOT    
Пример #5
0
    -----------------
    axesAdjust : bool
        If True, this function will call axes.SetLimits(), and set
        the camera type to 3D. If daspectAuto has not been set yet,
        it is set to False.
    axes : Axes instance
        Display the bars in the given axes, or the current axes if not given.
    
    Notes
    -----
      * This function should not be confused with the axis grid, see the
        Axis.showGrid property.
      * This function is know in Matlab as mesh(), but to avoid confusion
        with the vv.Mesh class, it is called grid() in visvis.
    
    Also see surf() and the solid*() methods.
    
    """

    m = vv.surf(*args, **kwargs)
    m.faceShading = None
    m.edgeShading = 'smooth'
    m.edgeColor = 'w'
    return m


if __name__ == '__main__':
    vv.figure()
    m = vv.grid(vv.peaks())
    m.colormap = vv.CM_HOT