/[escript]/trunk-mpi-branch/doc/examples/pyvisi/movie.py
ViewVC logotype

Contents of /trunk-mpi-branch/doc/examples/pyvisi/movie.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1295 - (show annotations)
Mon Sep 10 06:07:09 2007 UTC (11 years, 7 months ago) by ksteube
File MIME type: text/x-python
File size: 1845 byte(s)
Have now merged latest trunk features into MPI branch in preparation for
ending the MPI branch.
Compiles but has run time problems in bandwith reduction.

1 """
2 Author: John Ngui, john.ngui@uq.edu.au
3 """
4
5 # Import the necessary modules.
6 from esys.pyvisi import Scene, DataCollector, Map, Camera, Velocity, Legend
7 from esys.pyvisi import Movie, LocalPosition
8 from esys.pyvisi.constant import *
9 import os
10
11 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
12 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
13 X_SIZE = 800
14 Y_SIZE = 800
15
16 SCALAR_FIELD_POINT_DATA = "temp"
17 FILE_2D = "tempvel-"
18 IMAGE_NAME = "movie"
19 JPG_RENDERER = Renderer.ONLINE_JPG
20
21 # Create a Scene.
22 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
23 y_size = Y_SIZE)
24
25 # Create a DataCollector reading from a XML file.
26 dc1 = DataCollector(source = Source.XML)
27 dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
28
29 # Create a Map.
30 m1 = Map(scene = s, data_collector = dc1,
31 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
32 outline = True)
33
34 # Create a Camera.
35 cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
36
37 # Create a movie.
38 mov = Movie()
39 #lst = []
40
41 # Read in one file one after another and render the object.
42 for i in range(938, 949):
43 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
44 FILE_2D + "%06d.vtu") % i)
45
46 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
47 IMAGE_NAME + "%06d.jpg") % i)
48
49 #lst.append(IMAGE_NAME + "%06d.jpg" % i)
50
51 # Images (first and last inclusive) from which the movie is to be generated.
52 mov.imageRange(input_directory = PYVISI_EXAMPLE_IMAGES_PATH,
53 first_image = IMAGE_NAME + "000938.jpg",
54 last_image = IMAGE_NAME + "000948.jpg")
55
56 # Alternatively, a list of images can be specified.
57 #mov.imageList(input_directory = PYVISI_EXAMPLE_IMAGES_PATH, image_list = lst)
58
59 # Generate the movie.
60 mov.makeMovie(os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))
61

  ViewVC Help
Powered by ViewVC 1.1.26