/[escript]/trunk/pyvisi/test/python/run_velocity.py
ViewVC logotype

Contents of /trunk/pyvisi/test/python/run_velocity.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1069 - (show annotations)
Thu Mar 29 04:16:38 2007 UTC (13 years, 4 months ago) by jongui
File MIME type: text/x-python
File size: 2747 byte(s)
Perform some cleanup.
1 from esys.pyvisi import DataCollector, Scene, Velocity
2 from esys.pyvisi.constant import *
3 import unittest, os
4 from stat import ST_SIZE
5
6 PYVISI_TEST_MESHES_PATH = "data_meshes/"
7 PYVISI_TEST_VELOCITY_IMAGES_PATH = "data_sample_images/velocity/"
8 MIN_IMAGE_SIZE = 100
9 FILE_2D = "interior_2D.xml"
10 FILE_3D = "interior_3D.xml"
11
12 X_SIZE = 400
13 Y_SIZE = 400
14
15 JPG_RENDERER = Renderer.OFFLINE_JPG
16
17 class TestVelocity:
18 def tearDown(self):
19 self.scene
20 self.data_collector
21 self.velocity
22
23 def render(self, file):
24 self.scene.render(image_name = \
25 PYVISI_TEST_VELOCITY_IMAGES_PATH + file)
26
27 self.failUnless(os.stat(PYVISI_TEST_VELOCITY_IMAGES_PATH + \
28 file)[ST_SIZE] > MIN_IMAGE_SIZE)
29
30 class TestVelocity2DArrowVectorColor(unittest.TestCase, TestVelocity):
31 def setUp(self):
32 self.scene = \
33 Scene(renderer = JPG_RENDERER, num_viewport = 1,
34 x_size = X_SIZE, y_size = Y_SIZE)
35
36 self.data_collector = DataCollector(source = Source.XML)
37 self.data_collector.setFileName(file_name = \
38 PYVISI_TEST_MESHES_PATH + FILE_2D)
39
40 self.velocity = Velocity(scene = self.scene,
41 data_collector = self.data_collector,
42 viewport = Viewport.SOUTH_WEST, arrow = Arrow.THREE_D,
43 color_mode = ColorMode.VECTOR, lut = Lut.COLOR,
44 cell_to_point = False, outline = True)
45
46 def testVelocityVectorScale(self):
47 self.velocity.setScaleModeByVector()
48 self.velocity.setScaleFactor(0.5)
49 self.render("TestVelocity2DArrowVectorColor_testVelocityVectorScale.jpg")
50
51 class TestVelocity2DArrowScalarColor(unittest.TestCase, TestVelocity):
52 def setUp(self):
53 self.scene = \
54 Scene(renderer = JPG_RENDERER, num_viewport = 1,
55 x_size = X_SIZE, y_size = Y_SIZE)
56
57 self.data_collector = DataCollector(source = Source.XML)
58 self.data_collector.setFileName(file_name = \
59 PYVISI_TEST_MESHES_PATH + FILE_2D)
60
61 self.velocity = Velocity(scene = self.scene,
62 data_collector = self.data_collector,
63 viewport = Viewport.SOUTH_WEST, arrow = Arrow.TWO_D,
64 color_mode = ColorMode.SCALAR, lut = Lut.COLOR,
65 cell_to_point = False, outline = True)
66
67 def testVelocityScalarScale(self):
68 self.velocity.setScaleModeByScalar()
69 self.velocity.setScaleFactor(1.5)
70 self.render("TestVelocity2DArrowScalarColor_testVelocityScalarScale.jpg")
71
72 def testMask(self):
73 self.velocity.setRatio(2)
74 self.velocity.randomOn()
75 self.render("TestVelocity2DArrowScalarColor_testMask.jpg")
76
77 ###############################################################################
78
79
80 if __name__ == '__main__':
81 suite = unittest.TestSuite()
82 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVelocity2DArrowVectorColor))
83 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVelocity2DArrowScalarColor))
84 unittest.TextTestRunner(verbosity=2).run(suite)

  ViewVC Help
Powered by ViewVC 1.1.26