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

Contents of /trunk/doc/examples/pyvisi/seriesofreads.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1191 - (show annotations)
Tue Jun 12 05:54:41 2007 UTC (12 years, 6 months ago) by jongui
File MIME type: text/x-python
File size: 1764 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 # Import the necessary modules.
2 from esys.pyvisi import Scene, DataCollector, Contour, Camera
3 from esys.pyvisi.constant import *
4 import os
5
6 PYVISI_EXAMPLE_MESHES_PATH = "data_meshes"
7 PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images"
8 X_SIZE = 400
9 Y_SIZE = 300
10
11 SCALAR_FIELD_POINT_DATA_1 = "lava"
12 SCALAR_FIELD_POINT_DATA_2 = "talus"
13 FILE_2D = "phi_talus_lava."
14
15 IMAGE_NAME = "seriesofreads"
16 JPG_RENDERER = Renderer.ONLINE_JPG
17
18 # Create a Scene.
19 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
20 y_size = Y_SIZE)
21
22 # Create a DataCollector reading from a XML file.
23 dc1 = DataCollector(source = Source.XML)
24 dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_1)
25
26 # Create a Contour.
27 mosc1 = Contour(scene = s, data_collector = dc1,
28 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
29 outline = True)
30 mosc1.generateContours(0)
31
32 # Create a second DataCollector reading from the same XML file.
33 dc2 = DataCollector(source = Source.XML)
34 dc2.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_2)
35
36 # Create a second Contour.
37 mosc2 = Contour(scene = s, data_collector = dc2,
38 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
39 outline = True)
40 mosc2.generateContours(0)
41
42 # Create a Camera.
43 cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
44
45 # Read in one file one after another and render the object.
46 for i in range(99, 104):
47 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
48 FILE_2D + "%04d.vtu") % i)
49 dc2.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
50 FILE_2D + "%04d.vtu") % i)
51
52 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
53 IMAGE_NAME + "%04d.jpg") % i)

  ViewVC Help
Powered by ViewVC 1.1.26