/[escript]/trunk/downunder/test/python/run_datasources.py
ViewVC logotype

Diff of /trunk/downunder/test/python/run_datasources.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4014 by caltinay, Thu Oct 4 03:28:35 2012 UTC revision 4016 by caltinay, Tue Oct 9 03:50:27 2012 UTC
# Line 25  import numpy as np Line 25  import numpy as np
25  import os  import os
26  import sys  import sys
27  import unittest  import unittest
28  from esys.escript import inf,sup,saveDataCSV  from esys.escript import inf,sup,saveDataCSV,getMPISizeWorld
29  from esys.downunder.datasources import *  from esys.downunder.datasources import *
30    
31  # this is mainly to avoid warning messages  # this is mainly to avoid warning messages
# Line 38  logger.addHandler(handler) Line 38  logger.addHandler(handler)
38  try:  try:
39      TEST_DATA_ROOT=os.environ['DOWNUNDER_TEST_DATA_ROOT']      TEST_DATA_ROOT=os.environ['DOWNUNDER_TEST_DATA_ROOT']
40  except KeyError:  except KeyError:
41      TEST_DATA_ROOT='.'      TEST_DATA_ROOT='ref_data'
42    
43  try:  try:
44      WORKDIR=os.environ['DOWNUNDER_WORKDIR']      WORKDIR=os.environ['DOWNUNDER_WORKDIR']
# Line 55  NC_DATA = os.path.join(TEST_DATA_ROOT, ' Line 55  NC_DATA = os.path.join(TEST_DATA_ROOT, '
55  NC_REF = os.path.join(TEST_DATA_ROOT, 'netcdf_test.csv')  NC_REF = os.path.join(TEST_DATA_ROOT, 'netcdf_test.csv')
56  NC_NULL = 0.  NC_NULL = 0.
57  NC_SIZE = [20,15]  NC_SIZE = [20,15]
58  NC_ORIGIN = [309097.0, 6319002.0]  NC_ORIGIN = [403320.91466610413, 6414860.942530109]
59  VMIN=-10000.  VMIN=-10000.
60  VMAX=10000  VMAX=10000
61  NE_V=15  NE_V=15
62  ALT=0.  ALT=0.
63  PAD_X=7  PAD_X=3
64  PAD_Y=9  PAD_Y=2
65    
66  class TestERSDataSource(unittest.TestCase):  class TestERSDataSource(unittest.TestCase):
67      def test_ers_with_padding(self):      def test_ers_with_padding(self):
# Line 130  class TestNetCDFDataSource(unittest.Test Line 130  class TestNetCDFDataSource(unittest.Test
130          # check metadata          # check metadata
131          self.assertEqual(NP, NC_SIZE, msg="Wrong number of data points")          self.assertEqual(NP, NC_SIZE, msg="Wrong number of data points")
132          # this only works if gdal is available          # this only works if gdal is available
133          #self.assertAlmostEqual(X0, NC_ORIGIN, msg="Data origin wrong")          try:
134                import osgeo.osr
135                for i in xrange(len(NC_ORIGIN)):
136                    self.assertAlmostEqual(X0[i], NC_ORIGIN[i], msg="Data origin wrong")
137            except ImportError:
138                print("Skipping test of data origin since gdal is not installed.")
139    
140          # check data          # check data
141          nx=NP[0]+2*PAD_X          nx=NP[0]+2*PAD_X
# Line 163  class TestNetCDFDataSource(unittest.Test Line 168  class TestNetCDFDataSource(unittest.Test
168    
169  if __name__ == "__main__":  if __name__ == "__main__":
170      suite = unittest.TestSuite()      suite = unittest.TestSuite()
171      suite.addTest(unittest.makeSuite(TestERSDataSource))      if getMPISizeWorld()==1:
172      if 'NetCDFDataSource' in dir():          suite.addTest(unittest.makeSuite(TestERSDataSource))
173          suite.addTest(unittest.makeSuite(TestNetCDFDataSource))          if 'NetCDFDataSource' in dir():
174                suite.addTest(unittest.makeSuite(TestNetCDFDataSource))
175            else:
176                print("Skipping netCDF data source test since netCDF is not installed")
177      else:      else:
178          print("Skipping netCDF data source test since netCDF is not installed")          print("Skipping data source tests since MPI size > 1")
179      s=unittest.TextTestRunner(verbosity=2).run(suite)      s=unittest.TextTestRunner(verbosity=2).run(suite)
180      if not s.wasSuccessful(): sys.exit(1)      if not s.wasSuccessful(): sys.exit(1)
181    

Legend:
Removed from v.4014  
changed lines
  Added in v.4016

  ViewVC Help
Powered by ViewVC 1.1.26