/[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 1153 - (show annotations)
Thu May 17 06:33:54 2007 UTC (13 years, 1 month ago) by jongui
File MIME type: text/x-python
File size: 2138 byte(s)
Made some minor modifications and fixed minor bugs. Most tests appear to pass on the Altix although there are two tests which occasionally throw an error related to memory corruption.
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 FIRST_FILE_NAME = "phi_talus_lava.0099.vtu"
15
16 IMAGE_NAME = "seriesofreads"
17 JPG_RENDERER = Renderer.ONLINE_JPG
18
19 # Create a Scene.
20 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
21 y_size = Y_SIZE)
22
23 # Create a DataCollector reading from a XML file. An initial file must always
24 # be assigned when the DataCollector is created, although the same file is
25 # read again in the for-loop.
26 dc1 = DataCollector(source = Source.XML)
27 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
28 FIRST_FILE_NAME))
29 dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_1)
30
31 # Create a Contour.
32 mosc1 = Contour(scene = s, data_collector = dc1,
33 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
34 outline = True)
35 mosc1.generateContours(0)
36
37 # Create a second DataCollector reading from the same XML file.
38 dc2 = DataCollector(source = Source.XML)
39 dc2.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
40 FIRST_FILE_NAME))
41 dc2.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_2)
42
43 # Create a second Contour.
44 mosc2 = Contour(scene = s, data_collector = dc2,
45 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = False,
46 outline = True)
47 mosc2.generateContours(0)
48
49 # Create a Camera.
50 cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
51
52 # Read in one file one after another and render the object.
53 for i in range(99, 104):
54 dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
55 FILE_2D + "%04d.vtu") % i)
56 dc2.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \
57 FILE_2D + "%04d.vtu") % i)
58
59 s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \
60 IMAGE_NAME + "%04d.jpg") % i)

  ViewVC Help
Powered by ViewVC 1.1.26