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

Annotation of /trunk/doc/examples/pyvisi/movie.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1191 - (hide annotations)
Tue Jun 12 05:54:41 2007 UTC (13 years, 7 months ago) by jongui
File MIME type: text/x-python
File size: 2245 byte(s)
A movie can now be generated within the python script itself by creating an instace of 'Movie'. The 'Movie' instance will in turn execute the 'ppmtompeg' command. The corresponding tests and examples have also been added.
1 jongui 1191 # Import the necessary modules.
2     from esys.pyvisi import Scene, DataCollector, Map, Camera, Velocity, Legend
3     from esys.pyvisi import Movie, LocalPosition
4     from esys.pyvisi.constant import *
5     import os
6    
7     PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
8     PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
9     X_SIZE = 800
10     Y_SIZE = 800
11    
12     SCALAR_FIELD_POINT_DATA = "temp"
13     FILE_2D = "tempvel-"
14     IMAGE_NAME = "movie"
15     JPG_RENDERER = Renderer.ONLINE_JPG
16    
17     # Create a Scene.
18     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
19     y_size = Y_SIZE)
20    
21     # Create a DataCollector reading from a XML file.
22     dc1 = DataCollector(source = Source.XML)
23     dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
24    
25     # Create a Map.
26     m1 = Map(scene = s, data_collector = dc1,
27     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
28     outline = True)
29    
30     # Create a Velocity.
31     vopc1 = Velocity(scene = s, data_collector = dc1,
32     viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.VECTOR,
33     arrow = Arrow.TWO_D, lut = Lut.COLOR, cell_to_point = False,
34     outline = True)
35     vopc1.setScaleFactor(scale_factor = 0.07)
36     vopc1.setRatio(ratio = 8)
37     vopc1.setColor(color = Color.BLACK)
38    
39     # Create a scalar Legend.
40     sb = Legend(scene = s, data_collector= dc1, viewport = Viewport.SOUTH_WEST,
41     lut = Lut.COLOR, legend = LegendType.SCALAR)
42     sb.setOrientationToHorizontal()
43     sb.setPosition(LocalPosition(85,5))
44     sb.setScalarRange(0, 1)
45     sb.setLabelColor(color = Color.BLACK)
46     sb.setTitleColor(Color.BLACK)
47     sb.setTitle("Temperature")
48    
49     # Create a Camera.
50     cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
51    
52     # Create a movie.
53     mov = Movie()
54    
55     # Read in one file one after another and render the object.
56     for i in range(938, 949):
57     dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
58     FILE_2D + "%06d.vtu") % i)
59    
60     s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
61     IMAGE_NAME + "%06d.jpg") % i)
62    
63     # Generate the movie from the rendered images.
64     mov.makeMovie(input_directory = PYVISI_EXAMPLE_IMAGES_PATH,
65     first_image = IMAGE_NAME + "000938.jpg",
66     last_image = IMAGE_NAME + "000949.jpg",
67     movie = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, "movie.mpg"))
68    

  ViewVC Help
Powered by ViewVC 1.1.26