Ejemplo n.º 1
0
    def plot_u(u, x, xv, y, yv, t, n):
        """User action function for plotting."""
        if t[n] == 0:
            time.sleep(2)
        if plot_method == 1:
            # Works well with Gnuplot backend, not with Matplotlib
            st.mesh(x, y, u, title='t=%g' % t[n], zlim=[-1,1],
                    caxis=[-1,1])
        elif plot_method == 2:
            # Works well with Gnuplot backend, not with Matplotlib
            st.surfc(xv, yv, u, title='t=%g' % t[n], zlim=[-1, 1],
                  colorbar=True, colormap=st.hot(), caxis=[-1,1],
                  shading='flat')
        elif plot_method == 3:
            print 'Experimental 3D matplotlib...under development...'
            # Probably too slow
            #plt.clf()
            ax = fig.add_subplot(111, projection='3d')
            u_surf = ax.plot_surface(xv, yv, u, alpha=0.3)
            #ax.contourf(xv, yv, u, zdir='z', offset=-100, cmap=cm.coolwarm)
            #ax.set_zlim(-1, 1)
            # Remove old surface before drawing
            if u_surf is not None:
                ax.collections.remove(u_surf)
            plt.draw()
            time.sleep(1)
        elif plot_method == 4:
	    # Mayavi visualization
            mlab.clf()
            extent1 = (0, 20, 0, 20,-2, 2)
            s = mlab.surf(x , y, u,
                          colormap='Blues',
                          warp_scale=5,extent=extent1)
            mlab.axes(s, color=(.7, .7, .7), extent=extent1,
                      ranges=(0, 10, 0, 10, -1, 1),
                      xlabel='', ylabel='', zlabel='',
                      x_axis_visibility=False,
                      z_axis_visibility=False)
            mlab.outline(s, color=(0.7, .7, .7), extent=extent1)
            mlab.text(6, -2.5, '', z=-4, width=0.14)
            mlab.colorbar(object=None, title=None,
                          orientation='horizontal',
                          nb_labels=None, nb_colors=None,
                          label_fmt=None)
            mlab.title('Gaussian t=%g' % t[n])
            mlab.view(142, -72, 50)
            f = mlab.gcf()
            camera = f.scene.camera
            camera.yaw(0)

        if plot_method > 0:
            time.sleep(0) # pause between frames
            if save_plot:
                filename = 'tmp_%04d.png' % n
		if plot_method == 4:
                    mlab.savefig(filename)  # time consuming!
		elif plot_method in (1,2):
                    st.savefig(filename)  # time consuming!
Ejemplo n.º 2
0
        def plot_u(u, x, xv, y, yv, t, n):

            #surf(xv, yv, u, show=True, zlim=[-2.4, 2.4])
            #surf(xv, yv, u, zlim=[-50.0, 300.0])
            #axis([0.0,400.0,0.0,430.0,-500.0,300.0])
            #show()
            st.surf(xv, yv, u, zlim=[zmin, zmax])
            #hold('on')

            #print 'xvshape = ',xv.shape[0],',yvshape = ', yv.shape[1]
            b_a = zeros((xv.shape[0], yv.shape[1]))
            b_a[:, :] = bottom(xv, yv)
            #print 'b_a.shape=',b_a.shape
            #surf(xv, yv, b_a)
            st.mesh(xv, yv, b_a, zlim=[zmin, zmax])
            #axis([0.0,400.0,0.0,430.0,-500.0,300.0])
            #show()
            #time.sleep(1.0)
            filename = 'tmp_gaussian2%04d.png' % n
            st.savefig(filename)
Ejemplo n.º 3
0
     def plot_u(u, x, xv, y, yv, t, n):
 
         #surf(xv, yv, u, show=True, zlim=[-2.4, 2.4])
         #surf(xv, yv, u, zlim=[-50.0, 300.0])
         #axis([0.0,400.0,0.0,430.0,-500.0,300.0])
         #show()
         st.surf(xv, yv, u, zlim=[zmin, zmax])
         #hold('on')
         
         #print 'xvshape = ',xv.shape[0],',yvshape = ', yv.shape[1]
         b_a = zeros((xv.shape[0],yv.shape[1]))
         b_a[:,:] = bottom(xv, yv)
         #print 'b_a.shape=',b_a.shape 
         #surf(xv, yv, b_a)
         st.mesh(xv, yv, b_a, zlim=[zmin, zmax])
         #axis([0.0,400.0,0.0,430.0,-500.0,300.0])
         #show()
         #time.sleep(1.0)
         filename = 'tmp_gaussian2%04d.png' % n
         st.savefig(filename)
Ejemplo n.º 4
0
        def plot_u(u, x, xv, y, yv, t, n):

            #surf(xv, yv, u, show=True, zlim=[-2.4, 2.4])
            #surf(xv, yv, u, zlim=[-50.0, 300.0])
            #axis([0.0,400.0,0.0,430.0,-500.0,300.0])
            #show()
            st.surf(xv, yv, u, zlim=[zmin, zmax])
            #show()
            #hold('on')
            #1 + 1
            #print 'xvshape = ',xv.shape[0],',yvshape = ', yv.shape[1]

            b_a = zeros((xv.shape[0], yv.shape[1]))
            #print 'xv=',xv,',yv=',yv
            b_a[:, :] = bottom(xv, yv)
            #print 'b_a=',b_a
            #print 'shape(b_a)=',shape(b_a)
            #print 'b_a.shape=',b_a.shape
            #surf(xv, yv, b_a)
            #mesh(xv, yv, b_a)
            st.mesh(xv, yv, b_a, zlim=[zmin, zmax])
Ejemplo n.º 5
0
 def plot_u(u, x, xv, y, yv, t, n):
     
     #surf(xv, yv, u, show=True, zlim=[-2.4, 2.4])
     #surf(xv, yv, u, zlim=[-50.0, 300.0])
     #axis([0.0,400.0,0.0,430.0,-500.0,300.0])
     #show()
     st.surf(xv, yv, u, zlim=[zmin, zmax])
     #show()
     #hold('on')
     #1 + 1 
     #print 'xvshape = ',xv.shape[0],',yvshape = ', yv.shape[1]
     
     b_a = zeros((xv.shape[0],yv.shape[1]))
     #print 'xv=',xv,',yv=',yv
     b_a[:,:] = bottom(xv, yv)
     #print 'b_a=',b_a
     #print 'shape(b_a)=',shape(b_a)
     #print 'b_a.shape=',b_a.shape 
     #surf(xv, yv, b_a)
     #mesh(xv, yv, b_a)
     st.mesh(xv, yv, b_a, zlim=[zmin, zmax])
Ejemplo n.º 6
0
    def plot_u(u, x, xv, y, yv, t, n):
        """User action function for plotting."""
        if t[n] == 0:
            time.sleep(2)
        if plot_method == 1:
            # Works well with Gnuplot backend, not with Matplotlib
            st.mesh(x, y, u, title='t=%g' % t[n], zlim=[-1, 1], caxis=[-1, 1])
        elif plot_method == 2:
            # Works well with Gnuplot backend, not with Matplotlib
            st.surfc(xv,
                     yv,
                     u,
                     title='t=%g' % t[n],
                     zlim=[-1, 1],
                     colorbar=True,
                     colormap=st.hot(),
                     caxis=[-1, 1],
                     shading='flat')
        elif plot_method == 3:
            print 'Experimental 3D matplotlib...under development...'
            # Probably too slow
            #plt.clf()
            ax = fig.add_subplot(111, projection='3d')
            u_surf = ax.plot_surface(xv, yv, u, alpha=0.3)
            #ax.contourf(xv, yv, u, zdir='z', offset=-100, cmap=cm.coolwarm)
            #ax.set_zlim(-1, 1)
            # Remove old surface before drawing
            if u_surf is not None:
                ax.collections.remove(u_surf)
            plt.draw()
            time.sleep(1)
        elif plot_method == 4:
            # Mayavi visualization
            mlab.clf()
            extent1 = (0, 20, 0, 20, -2, 2)
            s = mlab.surf(x,
                          y,
                          u,
                          colormap='Blues',
                          warp_scale=5,
                          extent=extent1)
            mlab.axes(s,
                      color=(.7, .7, .7),
                      extent=extent1,
                      ranges=(0, 10, 0, 10, -1, 1),
                      xlabel='',
                      ylabel='',
                      zlabel='',
                      x_axis_visibility=False,
                      z_axis_visibility=False)
            mlab.outline(s, color=(0.7, .7, .7), extent=extent1)
            mlab.text(6, -2.5, '', z=-4, width=0.14)
            mlab.colorbar(object=None,
                          title=None,
                          orientation='horizontal',
                          nb_labels=None,
                          nb_colors=None,
                          label_fmt=None)
            mlab.title('Gaussian t=%g' % t[n])
            mlab.view(142, -72, 50)
            f = mlab.gcf()
            camera = f.scene.camera
            camera.yaw(0)

        if plot_method > 0:
            time.sleep(0)  # pause between frames
            if save_plot:
                filename = 'tmp_%04d.png' % n
                if plot_method == 4:
                    mlab.savefig(filename)  # time consuming!
                elif plot_method in (1, 2):
                    st.savefig(filename)  # time consuming!