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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2344 - (show annotations)
Mon Mar 30 02:13:58 2009 UTC (10 years, 5 months ago) by jfenwick
File MIME type: text/x-python
File size: 2810 byte(s)
Change __url__ to launchpad site

1
2 ########################################################
3 #
4 # Copyright (c) 2003-2008 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # http://www.opensource.org/licenses/osl-3.0.php
11 #
12 ########################################################
13
14 __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15 Earth Systems Science Computational Center (ESSCC)
16 http://www.uq.edu.au/esscc
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="https://launchpad.net/escript-finley"
21
22 from esys.pyvisi import DataCollector, Scene, Contour
23 from esys.pyvisi.constant import *
24 from esys.escript import getMPISizeWorld
25 import unittest, os, sys
26 from stat import ST_SIZE
27
28 try:
29 PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
30 except KeyError:
31 PYVISI_WORKDIR='.'
32 try:
33 PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
34 except KeyError:
35 PYVISI_TEST_DATA_ROOT='.'
36
37 PYVISI_TEST_MESHES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, "data_meshes")
38 PYVISI_TEST_CONTOUR_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
39 "data_sample_images", "contour")
40
41 MIN_IMAGE_SIZE = 100
42 FILE_2D = "interior_2D.xml"
43 X_SIZE = 400
44 Y_SIZE = 400
45 JPG_RENDERER = Renderer.OFFLINE_JPG
46
47 class TestContour(unittest.TestCase):
48 def setUp(self):
49 self.scene = \
50 Scene(renderer = JPG_RENDERER, num_viewport = 1,
51 x_size = X_SIZE, y_size = Y_SIZE)
52
53 self.data_collector = DataCollector(source = Source.XML)
54 self.data_collector.setFileName(file_name = \
55 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_2D))
56
57 self.contour = Contour(scene = self.scene,
58 data_collector = self.data_collector,
59 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
60 cell_to_point = False, outline = True)
61
62 def tearDown(self):
63 del self.scene
64 del self.data_collector
65 del self.contour
66
67 def render(self, file):
68 self.scene.render(image_name = \
69 os.path.join(PYVISI_TEST_CONTOUR_IMAGES_PATH, file))
70
71 self.failUnless(os.stat(os.path.join(PYVISI_TEST_CONTOUR_IMAGES_PATH, \
72 file))[ST_SIZE] > MIN_IMAGE_SIZE)
73
74 def testGenerateContours(self):
75 self.contour.generateContours(5)
76 self.render("TestContour_testGenerateContours.jpg")
77
78
79 ##############################################################################
80
81
82 if __name__ == '__main__':
83 if getMPISizeWorld() == 1:
84 suite = unittest.TestSuite()
85 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestContour))
86 s=unittest.TextTestRunner(verbosity=2).run(suite)
87 if not s.wasSuccessful(): sys.exit(1)
88 else:
89 print "run_contour.py is not executed as more than one processor is used."

  ViewVC Help
Powered by ViewVC 1.1.26