Ejemplo n.º 1
0
def show_convection3(new_fig=True):
    x, y, z = np.mgrid[0:1:20j, 0:1:20j, 0:1:20j]
    u, v, w = convection_cell(x, y, z)

    if new_fig:
        mlab.figure(fgcolor=(0., 0., 0.), bgcolor=(0.5, 0.5, 0.5),
                    size=(600,600))
    src = mlab.pipeline.vector_field(u, v, w)
    magnitude = mlab.pipeline.extract_vector_norm(src)
    mlab.outline()

    # We apply the following modules on the magnitude object, in order to
    # be able to display the norm of the vectors, eg as the color.
    iso = mlab.pipeline.iso_surface(magnitude, contours=[1.9, ], 
                                    opacity=0.3)

    vec = mlab.pipeline.vectors(magnitude, 
                                mask_points=40,
                                line_width=1,
                                color=(1, 1, 1),
                                scale_factor=4.)

    flow = mlab.pipeline.streamline(magnitude, 
                                    seedtype='plane',
                                    seed_visible=True,
                                    seed_scale=0.5,
                                    seed_resolution=1,
                                    linetype='ribbon',)

    vcp = mlab.pipeline.vector_cut_plane(magnitude, mask_points=2,
                                         scale_factor=4,
                                         colormap='jet',
                                         plane_orientation='x_axes')
Ejemplo n.º 2
0
    def _plot_max_Value( self ):
        X = self.X_hf[:, 0]
        Y = self.Y_hf[:, 0]
        Z = self.Z_hf[:, 0]


        plot_col = getattr( self, self.plot_column )[:, 0]
        scale = 1 / max( plot_col )
#        if self.plot_column == 'n_tex':
#            plot_col = where( plot_col < 0, 0, plot_col )

        mlab.figure( figure = "SFB532Demo",
                     bgcolor = ( 1.0, 1.0, 1.0 ),
                     fgcolor = ( 0.0, 0.0, 0.0 ) )

        mlab.points3d( X, Y, ( -1.0 ) * Z, plot_col,
#                       colormap = "gist_rainbow",
#                       colormap = "Reds",
                       colormap = "copper",
                       mode = "cube",
                       scale_factor = scale )
        mlab.outline()

        mlab.scalarbar( title = self.plot_column, orientation = 'vertical' )

        mlab.show
Ejemplo n.º 3
0
def show_convection1(new_fig=True):
    x, y, z = np.mgrid[0:1:20j, 0:1:20j, 0:1:20j]
    u, v, w = convection_cell(x, y, z)
    if new_fig:
        mlab.figure(size=(600, 600))

    mlab.quiver3d(u, v, w)
    mlab.outline()
Ejemplo n.º 4
0
def show_convection1(new_fig=True):
    x, y, z = np.mgrid[0:1:20j, 0:1:20j, 0:1:20j]
    u, v, w = convection_cell(x, y, z)
    if new_fig:
        mlab.figure(size=(600,600))

    mlab.quiver3d(u, v, w)
    mlab.outline()
Ejemplo n.º 5
0
def show_convection2(new_fig=True):
    x, y, z = np.mgrid[0:1:20j, 0:1:20j, 0:1:20j]
    u, v, w = convection_cell(x, y, z)
    if new_fig:
        mlab.figure(size=(600, 600))

    src = mlab.pipeline.vector_field(u, v, w)
    mlab.pipeline.vectors(src, mask_points=20, scale_factor=3.)
    mlab.outline()
Ejemplo n.º 6
0
def show_convection2(new_fig=True):
    x, y, z = np.mgrid[0:1:20j, 0:1:20j, 0:1:20j]
    u, v, w = convection_cell(x, y, z)
    if new_fig:
        mlab.figure(size=(600,600))

    src = mlab.pipeline.vector_field(u, v, w)
    mlab.pipeline.vectors(src, mask_points=20, scale_factor=3.)
    mlab.outline()
Ejemplo n.º 7
0
def Show_Phase(phase_numpy):
    dims=phase_numpy.shape
    
    fig=mlab.figure()
    src = mlab.pipeline.scalar_field(phase_numpy)
    mlab.outline()
    mlab.orientation_axes()
    #v= mlab.pipeline.vector_field(velx_numpy,vely_numpy,velz_numpy)
    #vx=mlab.pipeline.scalar_field(velx_numpy)
    #vy=mlab.pipeline.scalar_field(vely_numpy)
    #vz=mlab.pipeline.scalar_field(velz_numpy)
    extract=mlab.pipeline.extract_grid(src)
    extract.set(x_min=1,x_max=dims[0]-2,y_min=1,y_max=dims[1]-2)
    surf = mlab.pipeline.contour_surface(extract)
	def _plotbutton1_fired(self):
		mlab.clf()
		self.loaddata()
		field=mlab.pipeline.scalar_field(self.sregion)     # Generate a scalar field
		mlab.pipeline.volume(field,vmax=self.datamax,vmin=self.datamin) # Render the field with dots

		mlab.outline()
		mlab.xlabel('RA(J2000)')
		mlab.ylabel('DEC(J2000)')
		mlab.zlabel('Velocity')
		mlab.view(azimuth=0, elevation=0)
		mlab.show()
		
		self.field   = field
Ejemplo n.º 9
0
    def save(self,it):

        msh = self.__msh
        w = (self.__eqn).get(self.__var)()

        mlab.clf()
        mlab.points3d(msh.x[:,0], msh.x[:,1], zeros(w.shape), w,
                      scale_factor=self.__scale, scale_mode=self.__mode)
        mlab.outline(extent=[msh.BB[0,0],msh.BB[1,0],msh.BB[0,1],msh.BB[1,1],
                     0,0])
        mlab.view(0,0,self.__zoom,self.__xView)
        mlab.colorbar()
        fSol =  ''.join([self.__figDir,'/',self.__name,'%04d.png'% it])
        #print fSol
        mlab.savefig(fSol)
Ejemplo n.º 10
0
def test_den():
    P = np.random.random((10,10))
    #P=np.load(r'c:\maxdenP.np.npy')
    #myfilestr=r'c:\structfactors_density.dat'
    #x,y,z=np.loadtxt(myfilestr).T
    #P=z.reshape((101,101))
    #print P.shape
    fig=mlab.figure()    
    x,y,z=gen_as()   
    #view along z-axis
    pts_as=mlab.points3d(x,y,z-.125,color=(1,0,0),colormap='gist_rainbow',figure=fig,scale_factor=.1)
    x,y,z=gen_fe()  
    print 'x',x
    print 'y',y
    print 'z',z
    pts_fe=mlab.points3d(x,y,z-.125,color=(0,1,0),colormap='gist_rainbow',figure=fig,scale_factor=.02)
    x,y,z=gen_sr()  
    pts_sr=mlab.points3d(x,y,z-.125,color=(0,0,1),colormap='gist_rainbow',figure=fig)
    outline=mlab.outline(figure=fig,extent=[0,1,0,1,-1,0])
    mlab.orientation_axes(figure=fig,xlabel='a',ylabel='b',zlabel='c')
    print 'shape',P.shape
    P = P[:,:, np.newaxis]
    print 'after',P.shape
    src = mlab.pipeline.scalar_field(P)
    #src = mlab.pipeline.array2d_source(P)
    surf = mlab.pipeline.surface(src,figure=fig,extent=[0,1,0,1,-1,0],name='surf2',opacity=0.4)
    #surf.transform.GetTransform().RotateX(90)
    print 'done'
	def _plotbutton2_fired(self):
		mlab.clf()
		self.loaddata()
		field=mlab.contour3d(self.sregion,colormap='gist_ncar')     # Generate a scalar field
		field.contour.maximum_contour = self.datamax
		field.contour.minimum_contour = self.datamin
		field.actor.property.opacity = self.opacity

		mlab.outline()
		mlab.xlabel('RA(J2000)')
		mlab.ylabel('DEC(J2000)')
		mlab.zlabel('Velocity')
		mlab.view(azimuth=0, elevation=0)
		mlab.show()

		self.field   = field
Ejemplo n.º 12
0
def draw_struct():
    fig = mlab.figure()
    r = gen_fe()
    s = gen_spins()
    #view along z-axis
    x = r[:, 0]
    y = r[:, 1]
    z = r[:, 2]
    u = s[:, 0]
    v = s[:, 1]
    w = s[:, 2]

    #print x.shape
    #print y.shape
    #print z.shape
    pts_as = mlab.points3d(x,
                           y,
                           z,
                           color=(0, 0, 1),
                           colormap='gist_rainbow',
                           figure=fig,
                           scale_factor=.1)
    mlab.quiver3d(x, y, z, u, v, w, line_width=3, scale_factor=.3, figure=fig)
    outline = mlab.outline(figure=fig, extent=[0, 1, 0, 1, 0, 1])
    mlab.orientation_axes(figure=fig, xlabel='a', ylabel='b', zlabel='c')
    print 'done'
Ejemplo n.º 13
0
def add_cell(at,
             pts,
             origin=[0., 0., 0.],
             shift=[.5, .5, .5],
             supercell=[1, 1, 1]):
    if not at.is_orthorhombic:
        raise ValueError('Cannot draw cell outline for non-orthorhombic cells')

    na, nb, nc = supercell
    extent = np.array(
        [0., at.lattice[1, 1], 0., at.lattice[2, 2], 0., at.lattice[3, 3]])
    shift = np.dot(np.array(at.lattice), shift)
    shift = np.array(
        [shift[0], shift[0], shift[1], shift[1], shift[2], shift[2]])
    origin = np.array(origin)
    origin = np.array(
        [origin[0], origin[0], origin[1], origin[1], origin[2], origin[2]])

    print 'origin', origin
    print 'shift', shift

    for i in range(na):
        for j in range(nb):
            for k in range(nc):
                disp = np.array([
                    i * at.lattice[1, 1], i * at.lattice[1, 1],
                    j * at.lattice[2, 2], j * at.lattice[2, 2],
                    k * at.lattice[3, 3], k * at.lattice[3, 3]
                ])
                return mlab.outline(pts,
                                    extent=origin + disp + extent - shift,
                                    name='outline_%d_%d_%d' % (i, j, k))
Ejemplo n.º 14
0
def test_den():
    #P = np.random.random((10,10))
    #P=np.load(r'c:\maxdenP.np.npy')
    #myfilestr=r'c:\structfactors_density.dat'
    #x,y,z=np.loadtxt(myfilestr).T
    #P=z.reshape((101,101))
    #print P.shape
    fig = mlab.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1))
    x, y, z = np.array([[1, 0, 1], [0, -1, 1], [-1, 0, -1], [0, 1, -1],
                        [1, 1, 0], [-1, -1, 0]], 'float64').T
    #view along z-axis
    pts_as = mlab.points3d(x,
                           y,
                           z,
                           color=(1, 0, 0),
                           colormap='gist_rainbow',
                           figure=fig,
                           scale_factor=.3)
    #x,y,z=gen_fe()
    print 'x', x, x.shape
    print 'y', y, y.shape
    print 'z', z, z.shape
    x, y, z = np.array([
        [0, 1, 1],
        [0, -1, -1],
    ], 'float64').T
    pts_FE = mlab.points3d(x,
                           y,
                           z,
                           color=(0, 1, 0),
                           colormap='gist_rainbow',
                           figure=fig,
                           scale_factor=.3)
    mlab.text3d(0, 1, 1, '011', scale=.2, color=(1, 1, 0))
    mlab.text3d(1, 1, 0, '110', scale=.2)
    mlab.text3d(-1, -1, 0, '-1-10', scale=.2)
    mlab.text3d(1, 0, 1, '101', scale=.2)
    mlab.text3d(0, -1, 1, '0-11', scale=.2)
    mlab.text3d(-1, 0, -1, '-10-1', scale=.2)
    mlab.text3d(0, 1, -1, '01-1', scale=.2)

    #pts_fe=mlab.points3d(x,y,z-.125,color=(0,1,0),colormap='gist_rainbow',figure=fig,scale_factor=.02)
    #x,y,z=gen_sr()
    #print 'x',x,x.shape
    #pts_sr=mlab.points3d(x,y,z-.125,color=(0,0,1),colormap='gist_rainbow',figure=fig)
    #outline=mlab.outline(figure=fig,extent=[0,1,0,1,-1,0])
    outline = mlab.outline(figure=fig)
    mlab.orientation_axes(figure=fig, xlabel='a', ylabel='b', zlabel='c')
    #print 'shape',P.shape
    #P = P[:,:, np.newaxis]
    #print 'after',P.shape
    #src = mlab.pipeline.scalar_field(P)
    #src = mlab.pipeline.array2d_source(P)
    #surf = mlab.pipeline.surface(src,figure=fig,extent=[0,1,0,1,-1,0],name='surf2',opacity=0.4)
    #surf.transform.GetTransform().RotateX(90)
    print 'done'
Ejemplo n.º 15
0
def cutPlanes(volume, colormap='gist_ncar'):
    '''Display a 3D volume of scalars with two cut planes.

    volume: a three dimensional array of scalars
    '''

    scalarField = mlab.pipeline.scalar_field(volume)

    mlab.pipeline.image_plane_widget(scalarField,
                                     plane_orientation='z_axes',
                                     slice_index=10,
                                     colormap=colormap)
    mlab.pipeline.image_plane_widget(scalarField,
                                     plane_orientation='y_axes',
                                     slice_index=10,
                                     colormap=colormap)
    mlab.outline()
    mlab.axes()
    mlab.colorbar(orientation='vertical')
Ejemplo n.º 16
0
 def _flow_default(self):
     x, y, z = self.points
     u, v, w = self.get_uvw()
     f = self.scene.mlab.flow(x, y, z, u, v, w)
     f.stream_tracer.integration_direction = 'both'
     f.stream_tracer.maximum_propagation = 200
     src = f.mlab_source.m_data
     o = mlab.outline()
     mlab.view(120, 60, 150)
     return f
Ejemplo n.º 17
0
def Show_Phase(phase_numpy):
    dims = phase_numpy.shape

    fig = mlab.figure()
    src = mlab.pipeline.scalar_field(phase_numpy)

    mlab.outline()
    mlab.orientation_axes()
    #v= mlab.pipeline.vector_field(velx_numpy,vely_numpy,velz_numpy)
    #vx=mlab.pipeline.scalar_field(velx_numpy)
    #vy=mlab.pipeline.scalar_field(vely_numpy)
    #vz=mlab.pipeline.scalar_field(velz_numpy)
    extract = mlab.pipeline.extract_grid(src)
    extract.set(x_min=1, x_max=dims[0] - 2, y_min=1, y_max=dims[1] - 2)
    surf = mlab.pipeline.contour_surface(extract)

    #mlab.pipeline.image_plane_widget(vx, plane_orientation='x_axes', slice_index=250)
    #mlab.pipeline.vectors(v, mask_points=20, scale_factor=3.)
    #mlab.pipeline.vector_cut_plane(v, mask_points=2, scale_factor=3)
    mlab.show()
Ejemplo n.º 18
0
    def main(self):
        from enthought.mayavi import mlab

        self._iter = 1
        self.density = mlab.pipeline.scalar_field(self.sim.rho.transpose())
        self.vx = mlab.pipeline.scalar_field((self.sim.vx**2 + self.sim.vy**2 + self.sim.vz**2).transpose())
        self.velocity = mlab.pipeline.vector_field(self.sim.vx.transpose(), self.sim.vy.transpose(), self.sim.vz.transpose())
        self.trc = mlab.points3d(self.sim.tracer_x, self.sim.tracer_y, self.sim.tracer_z, scale_factor=0.75)

        mlab.pipeline.image_plane_widget(self.vx, plane_orientation='x_axes', slice_index=10)
        mlab.pipeline.image_plane_widget(self.vx, plane_orientation='y_axes', slice_index=10)
        mlab.pipeline.image_plane_widget(self.vx, plane_orientation='z_axes', slice_index=10)
        mlab.axes()

#       mlab.pipeline.vector_cut_plane(self.velocity, mask_points=2, scale_factor=3, plane_orientation='y_axes')
#       mlab.pipeline.vectors(self.velocity, mask_points=20, scale_factor=3.)
        mlab.outline()

        while 1:
            self.visualize()
Ejemplo n.º 19
0
def cutPlanes( volume, colormap='gist_ncar' ):
    '''Display a 3D volume of scalars with two cut planes.

    volume: a three dimensional array of scalars
    '''
    
    scalarField = mlab.pipeline.scalar_field( volume )
    
    mlab.pipeline.image_plane_widget(scalarField,
                            plane_orientation='z_axes',
                            slice_index=10,
                            colormap = colormap
                                     )
    mlab.pipeline.image_plane_widget(scalarField,
                            plane_orientation='y_axes',
                            slice_index=10,
                            colormap = colormap
                                     )
    mlab.outline()
    mlab.axes()
    mlab.colorbar(orientation='vertical')
Ejemplo n.º 20
0
def show_convection3(new_fig=True):
    x, y, z = np.mgrid[0:1:20j, 0:1:20j, 0:1:20j]
    u, v, w = convection_cell(x, y, z)

    if new_fig:
        mlab.figure(fgcolor=(0., 0., 0.),
                    bgcolor=(0.5, 0.5, 0.5),
                    size=(600, 600))
    src = mlab.pipeline.vector_field(u, v, w)
    magnitude = mlab.pipeline.extract_vector_norm(src)
    mlab.outline()

    # We apply the following modules on the magnitude object, in order to
    # be able to display the norm of the vectors, eg as the color.
    iso = mlab.pipeline.iso_surface(magnitude, contours=[
        1.9,
    ], opacity=0.3)

    vec = mlab.pipeline.vectors(magnitude,
                                mask_points=40,
                                line_width=1,
                                color=(1, 1, 1),
                                scale_factor=4.)

    flow = mlab.pipeline.streamline(
        magnitude,
        seedtype='plane',
        seed_visible=True,
        seed_scale=0.5,
        seed_resolution=1,
        linetype='ribbon',
    )

    vcp = mlab.pipeline.vector_cut_plane(magnitude,
                                         mask_points=2,
                                         scale_factor=4,
                                         colormap='jet',
                                         plane_orientation='x_axes')
Ejemplo n.º 21
0
def test_den():
    #P = np.random.random((10,10))
    #P=np.load(r'c:\maxdenP.np.npy')
    #myfilestr=r'c:\structfactors_density.dat'
    #x,y,z=np.loadtxt(myfilestr).T
    #P=z.reshape((101,101))
    #print P.shape
    fig=mlab.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1))
    x,y,z=np.array([[1,0,1],
                    [0,-1,1],
                    [-1,0,-1],
                    [0,1,-1],
                    [1,1,0],
                    [-1,-1,0]
                    ],'float64').T
    #view along z-axis
    pts_as=mlab.points3d(x,y,z,color=(1,0,0),colormap='gist_rainbow',figure=fig,scale_factor=.3)
    #x,y,z=gen_fe()
    print 'x',x,x.shape
    print 'y',y,y.shape
    print 'z',z,z.shape
    x,y,z=np.array([[0,1,1],
                    [0,-1,-1],
                    ],'float64').T
    pts_FE=mlab.points3d(x,y,z,color=(0,1,0),colormap='gist_rainbow',figure=fig,scale_factor=.3)
    mlab.text3d(0, 1, 1,'011',scale=.2,color=(1,1,0))
    mlab.text3d(1, 1, 0,'110',scale=.2)
    mlab.text3d(-1, -1, 0,'-1-10',scale=.2)
    mlab.text3d(1, 0, 1,'101',scale=.2)
    mlab.text3d(0, -1, 1,'0-11',scale=.2)
    mlab.text3d(-1, 0, -1,'-10-1',scale=.2)
    mlab.text3d(0, 1, -1,'01-1',scale=.2)


    #pts_fe=mlab.points3d(x,y,z-.125,color=(0,1,0),colormap='gist_rainbow',figure=fig,scale_factor=.02)
    #x,y,z=gen_sr()
    #print 'x',x,x.shape
    #pts_sr=mlab.points3d(x,y,z-.125,color=(0,0,1),colormap='gist_rainbow',figure=fig)
    #outline=mlab.outline(figure=fig,extent=[0,1,0,1,-1,0])
    outline=mlab.outline(figure=fig)
    mlab.orientation_axes(figure=fig,xlabel='a',ylabel='b',zlabel='c')
    #print 'shape',P.shape
    #P = P[:,:, np.newaxis]
    #print 'after',P.shape
    #src = mlab.pipeline.scalar_field(P)
    #src = mlab.pipeline.array2d_source(P)
    #surf = mlab.pipeline.surface(src,figure=fig,extent=[0,1,0,1,-1,0],name='surf2',opacity=0.4)
    #surf.transform.GetTransform().RotateX(90)
    print 'done'
Ejemplo n.º 22
0
    def show(self):
        """show Vm in a graph. Works for 1D projects only"""
        if self.Vm.ndim == 2:
            pylab.imshow(self.Vm,aspect='auto',cmap=cm.jet)
            pylab.show()
        elif self.Vm.ndim == 3:
            s = mlab.surf(self.Vm[...,0])
            raw_input("Press Enter to lauch the simulation...")
            for i in range(self.Vm.shape[-1]):
                s.mlab_source.scalars = self.Vm[...,i]
        elif self.Vm.ndim == 4:
            p = mlab.pipeline.scalar_field(self.Vm[...,0])
            s = mlab.pipeline.image_plane_widget( p,
                                        plane_orientation='x_axes',
                                        slice_index=self.mdl.stimCoord[0],
                                        vmin = self.Vm.min(),
                                        vmax = self.Vm.max()
                                    )

            s2 = mlab.pipeline.image_plane_widget(p,
                                        plane_orientation='y_axes',
                                        slice_index=self.mdl.stimCoord[2],
                                        vmin = self.Vm.min(),
                                        vmax = self.Vm.max()
                                    )
            s3 = mlab.pipeline.image_plane_widget( p,
                                        plane_orientation='z_axes',
                                        slice_index=self.mdl.stimCoord[4],
                                        vmin = self.Vm.min(),
                                        vmax = self.Vm.max()
                                    )
            mlab.scalarbar(s,orientation='vertical',nb_labels=4,label_fmt='%.3f')
            mlab.outline(color=(1,1,1))
            raw_input("Press Enter to lauch the simulation...")
            for i in range(self.Vm.shape[-1]):
                p.mlab_source.scalars = self.Vm[...,i]
Ejemplo n.º 23
0
    def plot(self):
        "绘制场景"
        

        # ball.up.x = 5
        # ball.up.y = 6
        # ball.up.z = 7

        # ball.up.x = -4
        # ball.up.y = -3
        # ball.up.z = -2
        x = [[-1,1,1,-1,-1],
            [-1,1,1,-1,-1]]

        y = [[-1,-1,-1,-1,-1],
            [1,1,1,1, 1]]

        z = [[1,1,-1,-1,1],
            [1,1,-1,-1,1]]
       # s = mlab.mesh(x, y, z, representation="wireframe", line_width=1.0 )
       # mlab.show()
        pl = mlab.surf(x,y,z,warp_scale="auto")
        mlab.axes(xlabel = 'x',ylabel= 'y',zlabel= 'z')
        mlab.outline(pl)
Ejemplo n.º 24
0
def test_quiver3d():
    fig = mlab.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1))
    x, y, z = numpy.mgrid[-2:3, -2:3, -2:3]
    print 'almost'
    #mlab.quiver3d(x, y, z,f, line_width=3, scale_factor=1,figure=fig)

    d = 0.2
    x = d * numpy.arange(0, 25)
    y = -d * numpy.arange(0, 25)
    z = numpy.zeros(len(x))
    if 0:
        func = spiral
    if 1:
        func = amplitude
    mlab.quiver3d(x, y, z, func, line_width=3, scale_factor=1, figure=fig)
    outline = mlab.outline(figure=fig, extent=[-1, 1, -1, 1, -1, 1])
    mlab.orientation_axes(figure=fig, xlabel='a', ylabel='b', zlabel='c')
    print 'done'
Ejemplo n.º 25
0
def test_quiver3d():
    fig=mlab.figure(fgcolor=(0, 0, 0), bgcolor=(1, 1, 1))
    x, y, z = numpy.mgrid[-2:3, -2:3, -2:3]
    print 'almost'
    #mlab.quiver3d(x, y, z,f, line_width=3, scale_factor=1,figure=fig)

    d=0.2
    x=d*numpy.arange(0,25)
    y=-d*numpy.arange(0,25)
    z=numpy.zeros(len(x))
    if 0:
        func=spiral
    if 1:
        func=amplitude
    mlab.quiver3d(x, y, z,func, line_width=3, scale_factor=1,figure=fig)
    outline=mlab.outline(figure=fig,extent=[-1,1,-1,1,-1,1])
    mlab.orientation_axes(figure=fig,xlabel='a',ylabel='b',zlabel='c')
    print 'done'
Ejemplo n.º 26
0
def draw_struct():
    fig=mlab.figure()
    r=gen_fe()
    s=gen_spins()
    #view along z-axis
    x=r[:,0]
    y=r[:,1]
    z=r[:,2]
    u=s[:,0]
    v=s[:,1]
    w=s[:,2]

    #print x.shape
    #print y.shape
    #print z.shape
    pts_as=mlab.points3d(x,y,z,color=(0,0,1),colormap='gist_rainbow',figure=fig,scale_factor=.1)
    mlab.quiver3d(x, y, z,u,v,w, line_width=3, scale_factor=.3,figure=fig)
    outline=mlab.outline(figure=fig,extent=[0,1,0,1,0,1])
    mlab.orientation_axes(figure=fig,xlabel='a',ylabel='b',zlabel='c')
    print 'done'
Ejemplo n.º 27
0
    mlab.contour3d(ras,
                   decs,
                   vs,
                   HI_cube * cm_tweak,
                   contours=[level * cm_tweak],
                   opacity=op,
                   vmin=color_scale[1] * cm_tweak,
                   vmax=color_scale[0] * cm_tweak,
                   name='I: ' + np.str(level),
                   colormap='Set1')

# Draw a box around the cube to aid in the visualization
mlab.outline(extent=[
    np.min(ras),
    np.max(ras),
    np.min(decs),
    np.max(decs), c_v[slice_min, 1], c_v[slice_max, 1]
],
             color=(0, 0, 0),
             line_width=2.0)  # Draw a box around it

# Now, add some axes
ax = mlab.axes(extent=[
    np.min(ras),
    np.max(ras),
    np.min(decs),
    np.max(decs), c_v[slice_min, 1], c_v[slice_max, 1]
],
               nb_labels=3,
               color=(0, 0, 0))

# Fine tune the look of the axis
Ejemplo n.º 28
0
        temperature[i,j,k] = (f[:,i,j,k]* v[2:-2]**2).sum() / f.sum(axis=0)[i,j,k]


  return temperature


for frame in range(len(fileh.root.Time[:])):
  # 3D Movie
  frame = 4*frame
  mlab.clf(figure=fig3d)
  scene = mlab.contour3d(Temperature(fileh.root.Phasespace[:,:,:,:,frame], fileh.root.Phasespace.attrs.v), contours=50)
  # Density profile
  #scene = mlab.contour3d(fileh.root.Phasespace[:,:,:,:,frame].sum(axis=0), contours=50)
  #source = mlab.pipeline.scalar_field(Temperature(fileh.root.Phasespace[:,:,:,:,frame], fileh.root.Phasespace.attrs.v))
  #vol = mlab.pipeline.volume(source)
  angle = 50.
  mlab.view(azimuth=angle%360, distance=72.0)
  #mlab.axes(color=(0.0,0.0,0.),extent=ext,xlabel='X',ylabel='Y',zlabel='Z')
  #a = array(gradient(fileh.root.Phi[:,:,:,frame]))**2
  #mlab.quiver3d(a[0],a[1],a[2])
  mlab.colorbar(orientation='vertical')#, label_fmt="%.2f", nb_labels=3)
  mlab.outline()
  mlab.savefig("Rho_" + string.zfill(frame, 4) + ".jpg")#, size=(600,600))
  print "[", string.zfill(frame, 4),"/", len(fileh.root.Time[:]), "]"





#mencoder "mf://*.jpg" -mf fps=10 -ovc lavc -o mymovie.av
Ejemplo n.º 29
0
# -*- coding: utf-8 -*-
from enthought.mayavi import mlab

x = [[-1, 1, 1, -1, -1], [-1, 1, 1, -1, -1]]

y = [[-1, -1, -1, -1, -1], [1, 1, 1, 1, 1]]

z = [[1, 1, -1, -1, 1], [1, 1, -1, -1, 1]]

box = mlab.mesh(x, y, z, representation="surface")
mlab.axes(xlabel='x', ylabel='y', zlabel='z')
mlab.outline(box)
mlab.show()
Ejemplo n.º 30
0
fig.scene.background = (1, 1, 1)

p = vis.plot_prism_mesh(mesh.vfilter(res, 900, 2001),
                        style='surface',
                        opacity=1)
mlab.get_engine().scenes[0].children[-1].children[0].children[0].children[
    0].scalar_lut_manager.data_range = [0, 2000]

#a = mlab.axes(p, nb_labels=0, extent=extent, color=(0,0,0))
#a.label_text_property.color = (0,0,0)
#a.title_text_property.color = (0,0,0)
#a.axes.label_format = ""
#a.axes.x_label, a.axes.y_label, a.axes.z_label = "", "", ""
#a.property.line_width = 1

mlab.outline(p, extent=extent, color=(0, 0, 0))

pos = 1000
field = 'gz'
scale = 200
Y, X, Z = utils.extract_matrices(data[field])
p = mlab.contour_surf(X, Y, Z, contours=10, colormap='jet')
p.contour.filled_contours = True
p.actor.actor.position = (0, 0, pos)
p.actor.actor.scale = (1, 1, scale)

a = mlab.axes(p,
              nb_labels=0,
              extent=[0, 3000, 0, 3000, pos, pos + scale * Z.max()],
              color=(0, 0, 0))
a.label_text_property.color = (0, 0, 0)
Ejemplo n.º 31
0
#!/usr/bin/env python

import numpy as np
from enthought.mayavi import mlab
x,y=np.ogrid [-2:2:160j,-2:2:160j]
z=abs(x)*np.exp(-x**2-(y/.75)**2)
pl=mlab.surf(x,y,z,warp_scale=2)
mlab.axes(xlabel='x',ylabel='y',zlabel='z')
mlab.outline(pl)
mlab.show()

            
            
        
        
        
        
        
        
        
    
    
    
    
    
    
    
    
    
    
Ejemplo n.º 32
0
            self.filter.extent = (self.x_min, self.x_max,
                                  self.y_min, self.y_max,
                                  self.z_min, self.z_max)

    view = View('x_min', 'x_max', 'y_min', 'y_max', 'z_min', 'z_max',
                title='Edit extent', resizable=True)


################################################################################
# Now build the visualization using mlab
from enthought.mayavi import mlab
fig = mlab.figure(1, bgcolor=(1, 1, 1))

# Create unconnected points
pts = mlab.pipeline.scalar_scatter(x, y, z, s)
mlab.outline(pts)

# Use a geometry_filter to filter with a bounding box
geometry_filter = mlab.pipeline.user_defined(pts,
                                   filter='GeometryFilter')
geometry_filter.filter.extent_clipping = True
# Connect our dialog to the filter
extent_dialog = ExtentDialog(
            data_x_min=0, data_x_max=1,
            data_y_min=0, data_y_max=1,
            data_z_min=0, data_z_max=1,
            filter=geometry_filter.filter)
# We need to use 'edit_traits' and not 'configure_traits()' as we do
# not want to start the GUI event loop (the call to mlab.show())
# at the end of the script will do it.
extent_dialog.edit_traits()
Ejemplo n.º 33
0
     
    # Plot the said contour - and flip the colorscheme for aesthetic purposes.     
    cm_tweak = -1.0      
    mlab.contour3d(ras,decs,vs,
                   HI_cube*cm_tweak,
                   contours = [level*cm_tweak],
                   opacity =op,
                   vmin =color_scale[1]*cm_tweak, vmax = color_scale[0]*cm_tweak,
                   name = 'I: '+np.str(level),
                   colormap = 'Set1')     
                   
                   
# Draw a box around the cube to aid in the visualization
mlab.outline(extent=[  np.min(ras),np.max(ras),
                       np.min(decs), np.max(decs),
                       c_v[slice_min,1],
                       c_v[slice_max,1]],
                       color=(0,0,0),
                       line_width = 2.0) # Draw a box around it


# Now, add some axes
ax = mlab.axes(extent=[np.min(ras),np.max(ras),
                       np.min(decs), np.max(decs),
                       c_v[slice_min,1],
                       c_v[slice_max,1]],
                       nb_labels=3, color = (0,0,0))

# Fine tune the look of the axis               
ax.axes.fly_mode = 'outer_edges'
ax.title_text_property.font_size = 10
ax.title_text_property.font_family = 'courier'
Ejemplo n.º 34
0
scale_error = 1000.0


def S(k, b):
    "计算直线y=k*x+b和原始数据X、Y的误差的平方和"
    error = np.zeros(k.shape)
    for x, y in zip(X, Y):
        error += (y - (k * x + b))**2
    return error


ks, bs = np.mgrid[k - scale_k:k + scale_k:40j, b - scale_b:b + scale_b:40j]

error = S(ks, bs) / scale_error

from enthought.mayavi import mlab
surf = mlab.surf(ks, bs / scale_b, error)
mlab.axes(xlabel="k",
          ylabel="b",
          zlabel="error",
          ranges=[
              k - scale_k, k + scale_k, b - scale_b, b + scale_b,
              np.min(error) * scale_error,
              np.max(error) * scale_error
          ])
mlab.outline(surf)
mlab.points3d([k], [b / scale_b], [S(k, b) / scale_error],
              scale_factor=0.1,
              color=(1, 1, 1))
mlab.show()
Ejemplo n.º 35
0
# -*- coding: utf-8 -*-
import numpy as np
from enthought.mayavi import mlab

x, y = np.ogrid[-2:2:20j, -2:2:20j]
z = x * np.exp(-x**2 - y**2)

face = mlab.surf(x, y, z, warp_scale=2)
mlab.axes(xlabel='x', ylabel='y', zlabel='z')
mlab.outline(face)

from enthought.tvtk.pipeline.browser import PipelineBrowser
b = PipelineBrowser()
b.root_object = [mlab.gcf().scene.render_window]
b.show()
mlab.show()
mscene = mlab.gcf()
tscene = mscene.scene
rw = tscene.render_window
a1 = rw.renderers[0].view_props[0]
Ejemplo n.º 36
0
new_fig = NewFig()

options = dict(scale_factor=0.9, mode='cube', scale_mode='none',
                                 vmin=0, vmax=10, opacity=0.3)

################################################################################
# Broadcasting first figure
################################################################################
new_fig()

a = 0*np.ones((8, 5, 3), np.int)
a = np.atleast_3d(a)
x, y, z = -np.indices(a.shape)
z *= -1
mat1 = mlab.points3d(x, y, z, a, **options)
mlab.outline(mat1)

a = 10*np.ones((8, 1, 1), np.int)
a = np.atleast_3d(a)
x, y, z = -np.indices(a.shape)
y += 2
z *= -1
mat2 = mlab.points3d(x, y, z, a, **options)
o = mlab.outline(mat1)
mlab.pipeline.set_extent(o, mat2.actor.actor.bounds)

a = 5*np.ones((1, 5, 3), np.int)
a = np.atleast_3d(a)
x, y, z = -np.indices(a.shape)
x += 2
z *= -1
Ejemplo n.º 37
0
# -*- coding: utf-8 -*-
from enthought.mayavi import mlab

x = [[-1,1,1,-1,-1],
     [-1,1,1,-1,-1]]

y = [[-1,-1,-1,-1,-1],
     [ 1, 1, 1, 1, 1]]

z = [[1,1,-1,-1,1],
     [1,1,-1,-1,1]]

box = mlab.mesh(x, y, z, representation="surface")
mlab.axes(xlabel='x', ylabel='y', zlabel='z')
mlab.outline(box)
mlab.show()
    pl.gca().add_patch(rect)

pl.gca().set_aspect("equal")
pl.show()

####### 误差曲面 #######
scale_k = 1.0
scale_b = 10.0
scale_error = 1000.0

def S(k, b):
    "计算直线y=k*x+b和原始数据X、Y的误差的平方和"
    error = np.zeros(k.shape)
    for x, y in zip(X, Y):
        error += (y - (k*x + b))**2
    return error

ks, bs = np.mgrid[k-scale_k:k+scale_k:40j, b-scale_b:b+scale_b:40j]

error = S(ks, bs)/scale_error

from enthought.mayavi import mlab
surf = mlab.surf(ks, bs/scale_b, error)
mlab.axes(xlabel="k", ylabel="b", zlabel="error", 
    ranges=[k-scale_k,k+scale_k,
            b-scale_b,b+scale_b,
            np.min(error)*scale_error, np.max(error)*scale_error])
mlab.outline(surf)
mlab.points3d([k],[b/scale_b],[S(k,b)/scale_error],scale_factor=0.1, color=(1,1,1))
mlab.show()
Ejemplo n.º 39
0
import numpy
from enthought.mayavi import mlab
from fatiando import vis

f = open("mesh.pickle")
mesh = pickle.load(f)
f.close()

f = open("seeds.pickle")
seeds = pickle.load(f)
f.close()

f = open("model.pickle")
model = pickle.load(f)
f.close()

seed_mesh = numpy.array([seed['cell'] for seed in seeds])

fig = mlab.figure()
fig.scene.camera.yaw(230)
fig.scene.background = (1, 1, 1)
vis.plot_prism_mesh(model, style='wireframe', xy2ne=True)
plot = vis.plot_prism_mesh(mesh, xy2ne=True)
vis.plot_prism_mesh(seed_mesh, xy2ne=True)
axes = mlab.axes(plot, nb_labels=5, color=(0,0,0))
axes.label_text_property.color = (0,0,0)
axes.title_text_property.color = (0,0,0)
axes.axes.label_format = "%-#.0f"
mlab.outline(color=(0,0,0))

mlab.show()
Ejemplo n.º 40
0
right_ys = []

for line in data:
    cm = line.split()
    top_xs.append(float(cm[0]))
    left_zs.append(float(cm[2]))
    right_ys.append(float(cm[1]))

    dms.append(float(cm[9]))

# diameters
mlab.options.offscreen = True

mlab.figure(1, bgcolor=(1, 1, 1), size=(1280, 720))
dms = [x / 2.0 for x in dms]
q = mlab.quiver3d(top_xs, right_ys, left_zs, dms, dms, dms, mode='sphere', scale_factor=1)
mlab.orientation_axes()
mlab.outline(color=(0,0,0), line_width=1.0)
a = mlab.axes(color=(0.1,0.1,0.1), nb_labels=3, line_width=1.0)
a.axes.axis_label_text_property.color = (0,0,0)

q.scene.isometric_view()

count = 1
while count < 360:
    q.scene.camera.azimuth(1)
    mlab.draw()
    mlab.savefig('animate/' + stage + '-dms-animated-' + str(count).zfill(3) + '.png')
    count += 1
    print(count)
density *= pdf_z

a = x + y
b = 2 * y
c = a - b + z

norm = np.sqrt(a.var() + b.var())
a /= norm
b /= norm

mlab.figure(1, bgcolor=(1, 1, 1), fgcolor=(0, 0, 0))
mlab.clf()
pts = mlab.points3d(a, b, c, density, colormap='jet', mode='2dvertex')
mlab.outline(extent=[
    -3 * a.std(), 3 * a.std(), -3 * b.std(), 3 * b.std(), -3 * c.std(),
    3 * c.std()
],
             line_width=2)

Y = np.c_[a, b, c]
U, pca_score, V = np.linalg.svd(Y, full_matrices=False)
x_pca_axis, y_pca_axis, z_pca_axis = V.T * pca_score / pca_score.min()

mlab.view(-20.8, 83, 9, [0.18, 0.2, -0.24])
#mlab.savefig('pca_3d.jpg')
mlab.quiver3d(0.1 * x_pca_axis,
              0.1 * y_pca_axis,
              0.1 * z_pca_axis,
              2 * x_pca_axis,
              2 * y_pca_axis,
              2 * z_pca_axis,
Ejemplo n.º 42
0
scene.scene.background = (1, 1, 1)

p = vis.plot_prism_mesh(res, style='surface', xy2ne=True)
p.actor.property.line_width = 2
mlab.get_engine().scenes[0].children[-1].children[0].children[0].children[0].scalar_lut_manager.data_range = [0,1200]

p = vis.plot_prism_mesh(seeds, style='surface', xy2ne=True)
p.actor.property.line_width = 2
mlab.get_engine().scenes[0].children[-1].children[0].children[0].children[0].scalar_lut_manager.data_range = [0,1200]

p = vis.plot_prism_mesh(model, style='surface', xy2ne=True)
p.actor.property.line_width = 2

p = vis.plot_prism_mesh(mesh.vfilter(model,1100,1201), style='wireframe', xy2ne=True)
p.actor.property.color = (0,0,0)
p.actor.property.line_width = 3

mlab.outline(color=(0,0,0), extent=extent)

a = mlab.axes(p, nb_labels=5, extent=extent, ranges=ranges, color=(0,0,0))
a.label_text_property.color = (0,0,0)
a.title_text_property.color = (0,0,0)
a.property.line_width = 1
a.axes.label_format = "%-#.1f"
a.axes.x_label, a.axes.y_label, a.axes.z_label = "Y (km)", "X (km)", "Z (km)"

view.bbox(mlab)

view.set(scene)
mlab.show()
Ejemplo n.º 43
0
cat1 = cat(x, y, 1)
cat2 = cat(x, y, 2)
cat3 = cat(x, y, 3)

# The cats lie in a [0, 1] interval, with .5 being the assymptotique
# value. We want to reposition this value to 0, so as to put it in the
# center of our extents.
cat1 -= 0.5
cat2 -= 0.5
cat3 -= 0.5

cat1_extent = (-14,-6, -4,4, 0,5)
surf_cat1 = mlab.surf(x-10, y, cat1, colormap='Spectral', warp_scale=5, 
            extent=cat1_extent, vmin=-0.5, vmax=0.5)
mlab.outline(surf_cat1, color=(.7, .7, .7))
mlab.axes(surf_cat1, color=(.7, .7, .7), extent=cat1_extent, 
            ranges=(0,1, 0,1, 0,1), xlabel='', ylabel='',
            zlabel='Probability',
            x_axis_visibility=False, z_axis_visibility=False)

mlab.text(-18, -4, '1 photon', z=-4, width=0.13)

cat2_extent = (-4,4, -4,4, 0,5)
surf_cat2 = mlab.surf(x, y, cat2, colormap='Spectral', warp_scale=5, 
            extent=cat2_extent, vmin=-0.5, vmax=0.5)
mlab.outline(surf_cat2, color=(0.7, .7, .7), extent=cat2_extent)

mlab.text(-4, -3, '2 photons', z=-4, width=0.14)

cat3_extent = (6,14, -4,4, 0,5)
Ejemplo n.º 44
0
import numpy as np
from enthought.mayavi import mlab

x, y = np.ogrid[-2:2:20j, -2:2:20j]
z = x * np.exp(-x**2 - y**2)

pl = mlab.surf(x, y, z, warp_scale='auto')
mlab.axes(xlabel='x', ylabel='y', zlabel='z')
mlab.outline(pl)
Ejemplo n.º 45
0
s2 = mlab.pipeline.image_plane_widget(p,
                            plane_orientation='y_axes',
                            slice_index=ymax,
                            vmin = -60,
                            vmax = 10
                        )
s3 = mlab.pipeline.image_plane_widget( p,
                            plane_orientation='z_axes',
                            slice_index=zmax,
                            vmin = -60,
                            vmax = 10
                        )

mlab.scalarbar(s,orientation='vertical',nb_labels=4,label_fmt='%.3f')
mlab.outline(color=(1,1,1))

filename = str('png/2F_%04d' % i) + '.png'
mlab.savefig(filename)

for i in range(int(tstep/round(max(t)/len(t))),len(t),int(tstep/round(max(t)/len(t)))) :
    #
    # The next four lines are just like MATLAB.
    #
    p.mlab_source.scalars = Y[...,i]
    titl.text=str("Potential at time: %.0f ms."% t[i])
    filename = str('png/2F_%04d' % i) + '.png'
    mlab.savefig(filename)
    if showbar:
        pbar.update(i)
pdf_z = pdf(5*z)

density *= pdf_z

a = x+y
b = 2*y
c = a-b+z

norm = np.sqrt(a.var() + b.var())
a /= norm
b /= norm

mlab.figure(1, bgcolor=(1, 1, 1), fgcolor=(0, 0, 0))
mlab.clf()
pts = mlab.points3d(a, b, c, density, colormap='jet', mode='2dvertex')
mlab.outline(extent=[-3*a.std(), 3*a.std(), -3*b.std(), 3*b.std(),
                     -3*c.std(), 3*c.std()], line_width=2)

Y = np.c_[a, b, c]
U, pca_score, V = np.linalg.svd(Y, full_matrices=False)
x_pca_axis, y_pca_axis, z_pca_axis = V.T*pca_score/pca_score.min()

mlab.view(-20.8, 83, 9, [0.18, 0.2, -0.24])
#mlab.savefig('pca_3d.jpg')
mlab.quiver3d(0.1*x_pca_axis, 0.1*y_pca_axis, 0.1*z_pca_axis,
                2*x_pca_axis, 2*y_pca_axis, 2*z_pca_axis,
                color=(0.6, 0, 0), line_width=2)

x_pca_axis, y_pca_axis, z_pca_axis = 3*V.T
x_pca_plane = np.r_[x_pca_axis[:2], - x_pca_axis[1::-1]]
y_pca_plane = np.r_[y_pca_axis[:2], - y_pca_axis[1::-1]]
z_pca_plane = np.r_[z_pca_axis[:2], - z_pca_axis[1::-1]]
Ejemplo n.º 47
0
y1, y2 = 0, 3000
z1, z2 = 0, 3000
extent = [x1, x2, y1, y2, -z2, -z1]

# Plot the adjusted model plus the skeleton of the synthetic model
fig = mlab.figure(size=(600,730))
fig.scene.background = (1, 1, 1)

p = vis.plot_prism_mesh(mesh.vfilter(res,900,2001), style='surface', opacity=1)
mlab.get_engine().scenes[0].children[-1].children[0].children[0].children[0].scalar_lut_manager.data_range = [0,2000]

#a = mlab.axes(p, nb_labels=0, extent=extent, color=(0,0,0))
#a.label_text_property.color = (0,0,0)
#a.title_text_property.color = (0,0,0)
#a.axes.label_format = ""
#a.axes.x_label, a.axes.y_label, a.axes.z_label = "", "", ""
#a.property.line_width = 1

mlab.outline(p, extent=extent, color=(0,0,0))

scene = fig
scene.scene.camera.position = [5617.6246210610589, 9378.6744914189112, 1832.0425527256102]
scene.scene.camera.focal_point = [1435.8921050117997, 1598.1461572098237, -1715.9026272606379]
scene.scene.camera.view_angle = 30.0
scene.scene.camera.view_up = [-0.18883236854009863, -0.3216128720649955, 0.92785101019163696]
scene.scene.camera.clipping_range = [4531.9434654515926, 15755.396726380868]
scene.scene.camera.compute_view_plane_normal()
scene.scene.render()

mlab.show()
Ejemplo n.º 48
0
    scene = mlab.contour3d((fileh.root.Phi[2:-2, 2:-2, 2:-2, frame]**2),
                           contours=50,
                           extent=ext,
                           vmax=fmax,
                           vmin=fmin)  #, colormap='ylgn')

    # Cutplane
    #E  = gradient(fileh.root.Phi[:,:,:,frame])
    #mlab.quiver3d(E[0], E[1], E[2])
    #src = mlab.pipeline.vector_field(E[2], E[1], E[0])
    #mlab.pipeline.vectors(src, mask_points=20, scale_factor=3.)
    #mlab.pipeline.vector_cut_plane(src, mask_points=1, scale_factor=5)
    #src = mlab.pipeline.vector_field(E[0], E[1], E[2])
    #magnitude = mlab.pipeline.extract_vector_norm(src)
    #flow = mlab.pipeline.streamline(magnitude, seedtype='plane', seed_visible=False, seed_scale=1.0, seed_resolution=100, linetype='line',integration_direction='both')
    #$mlab.axes(color=(0.0,0.0,0.),extent=ext,xlabel='X',ylabel='Y',zlabel='Z')
    #source = mlab.pipeline.scalar_field(fileh.root.Phi[:,:,:,frame]**2)
    #vol = mlab.pipeline.volume(source)
    #a = array(gradient(fileh.root.Phi[:,:,:,frame]))**2
    #mlab.quiver3d(a[0],a[1],a[2])
    #  mlab.view(azimuth=angle%360, distance=128.0)
    mlab.view(azimuth=angle % 360, distance=10.0)
    angle += 1.0
    mlab.colorbar(orientation='vertical', label_fmt="%.2e", nb_labels=5)
    mlab.outline()
    mlab.savefig("Phi3D_" + filename + "_" + string.zfill(frame, 4) +
                 ".jpg")  #, size=(600,600))
    print "[", string.zfill(frame, 4), "/", len(fileh.root.Time[:]), "]"

#mencoder "mf://*.jpg" -mf fps=10 -ovc lavc -o mymovie.av
Ejemplo n.º 49
0
mlab.clf()
figure.scene.disable_render = True

# Creates two set of points using mlab.points3d: red point and
# white points
x1, y1, z1 = np.random.random((3, 10))
red_glyphs = mlab.points3d(x1, y1, z1, color=(1, 0, 0),
                resolution=20)

x2, y2, z2 = np.random.random((3, 10))
white_glyphs = mlab.points3d(x2, y2, z2, color=(0.9, 0.9, 0.9), 
                resolution=20)

# Add an outline to show the selected point and center it on the first
# data point.
outline = mlab.outline(line_width=3)
outline.outline_mode = 'cornered'
outline.bounds = (x1[0]-0.1, x1[0]+0.1, 
                  y1[0]-0.1, y1[0]+0.1, 
                  z1[0]-0.1, z1[0]+0.1)

# Every object has been created, we can reenable the rendering.
figure.scene.disable_render = False
################################################################################


# Here, we grab the points describing the individual glyph, to figure
# out how many points are in an individual glyph.
glyph_points = red_glyphs.glyph.glyph_source.glyph_source.output.points.to_array()