예제 #1
0
def mcrtmv(frames, dt, Lx, Ly, Nx, Ny, savemovie=False, mvname='test'):
    x = np.linspace(0, Lx, Nx)
    y = np.linspace(0, Lx, Nx)
    X, Y = np.meshgrid(x, y)
    size = 500, 500

    fig = ml.figure(size=size, bgcolor=(1., 1., 1.))

    #fig.scene.anti_aliasing_frames=07

    #extent = [0,Nx-1,0,Ny-1,-30,30]

    ml.clf(figure=fig)
    u = np.loadtxt('data/solution_%06d.txt' % 1)

    fname = 'data/_tmp%07d.png' % 1
    s = ml.surf(x, y, u, figure=fig, vmin=-1, vmax=1)
    ml.axes(extent=[0, Lx, 0, Ly, -2, 2])
    ml.colorbar()
    ml.xlabel('x position')
    ml.ylabel('y position')
    ml.zlabel('wave amplitude')
    if savemovie == True:
        pl.ion()
        arr = ml.screenshot()
        img = pl.imshow(arr)
        pl.axis('off')

    for i in range(2, frames):

        u = np.loadtxt('data/solution_%06d.txt' % i)
        s.mlab_source.scalars = u
        fname = 'data/_tmp%07d.png' % i
        if savemovie == True:
            arr = ml.screenshot()
            img.set_array(arr)
            pl.savefig(filename=fname)  #,figure=fig)
            print 'Saving frame', fname
            pl.draw()

    fig.scene.disable_render = False
    os.system(
        "mencoder 'mf://data/_tmp*.png' -mf type=png:fps=20 -ovc lavc -lavcopts vcodec=wmv2 -oac copy -o %s.mpg"
        % mvname)
예제 #2
0
def mcrtmv(frames, dt,Lx,Ly,Nx,Ny,savemovie=False, mvname='test'):
	x = np.linspace(0,Lx,Nx);
	y = np.linspace(0,Lx,Nx);
	X,Y = np.meshgrid(x,y);
	size = 500,500
	
	fig = ml.figure(size= size, bgcolor=(1.,1.,1.));

	#fig.scene.anti_aliasing_frames=07

	#extent = [0,Nx-1,0,Ny-1,-30,30]
	
	ml.clf(figure=fig)
	u = np.loadtxt('data/solution_%06d.txt'%1);
	
	fname = 'data/_tmp%07d.png' % 1
	s = ml.surf(x,y,u,figure=fig,vmin=-1,vmax=1)
	ml.axes(extent=[0,Lx,0,Ly,-2,2])
	ml.colorbar()
	ml.xlabel('x position')
	ml.ylabel('y position')
	ml.zlabel('wave amplitude')
	if savemovie == True:
		pl.ion()
		arr = ml.screenshot()
		img = pl.imshow(arr)
		pl.axis('off')
	
	for i in range(2,frames):

		u = np.loadtxt('data/solution_%06d.txt'%i);
		s.mlab_source.scalars = u
		fname = 'data/_tmp%07d.png' % i
		if savemovie == True:
			arr = ml.screenshot()
			img.set_array(arr)
			pl.savefig(filename=fname)#,figure=fig)
			print 'Saving frame', fname
			pl.draw()

	fig.scene.disable_render = False
	os.system("mencoder 'mf://data/_tmp*.png' -mf type=png:fps=20 -ovc lavc -lavcopts vcodec=wmv2 -oac copy -o %s.mpg" % mvname);
예제 #3
0
            apply_transform_to_points(hmgns_world_coords, comb_trans_mat)

    # to get normalized view coordinates, we divide through by the fourth
    # element
    norm_view_coords = view_coords / (view_coords[:, 3].reshape(-1, 1))
    
    # the last step is to transform from normalized view coordinates to
    # display coordinates.
    view_to_disp_mat = get_view_to_display_matrix(f.scene)
    disp_coords = apply_transform_to_points(norm_view_coords, view_to_disp_mat)

    # at this point disp_coords is an Nx4 array of homogenous coordinates
    # where X and Y are the pixel coordinates of the X and Y 3D world
    # coordinates, so lets take a screenshot of mlab view and open it
    # with matplotlib so we can check the accuracy
    img = mlab.screenshot()
    pl.imshow(img)

    for i in range(N):
        print  'Point %d:  (x, y) ' % i, disp_coords[:, 0:2][i]
        pl.plot([disp_coords[:, 0][i]], [disp_coords[:, 1][i]], 'ro')
     
    pl.show()

    # you should check that the printed coordinates correspond to the
    # proper points on the screen 

    mlab.show()

#EOF