source: trunk/anuga_core/source/anuga/shallow_water/test_most2nc.py @ 7844

Last change on this file since 7844 was 7276, checked in by ole, 15 years ago

Merged numpy branch back into the trunk.

In ~/sandpit/anuga/anuga_core/source
svn merge -r 6246:HEAD ../../branches/numpy .

In ~/sandpit/anuga/anuga_validation
svn merge -r 6417:HEAD ../branches/numpy_anuga_validation .

In ~/sandpit/anuga/misc
svn merge -r 6809:HEAD ../branches/numpy_misc .

For all merges, I used numpy version where conflicts existed

The suites test_all.py (in source/anuga) and validate_all.py passed using Python2.5 with numpy on my Ubuntu Linux box.

File size: 1.1 KB
Line 
1import unittest
2import numpy as num
3from Scientific.IO.NetCDF import NetCDFFile
4import most2nc
5import os
6
7FN = 'small___.txt'
8
9class Test_most2nc(unittest.TestCase):
10    def setUp(self):
11        fid = open(FN, 'w')
12        fid.write("""4 4
13150.66667
14150.83334
15151.
16151.16667
17-34.
18-34.16667
19-34.33333
20-34.5
21-1. -2. -3. -4.
22-5. -6. -7. -8.
23-9. -10. -11. -12.
24-13. -14. -15. -16.
25""")
26        fid.close()
27                 
28    def tearDown(self):
29        os.remove(FN)
30
31    def test_small_nxn(self):
32        most2nc.most2nc(input_file=FN,output_file='test.nc'\
33                        ,inverted_bathymetry = False,verbose = False)
34
35        fid = NetCDFFile('test.nc')
36        elevation = fid.variables['ELEVATION'][:]
37        fid.close()
38
39        z=[[-13., -14., -15., -16.]\
40           ,[-9., -10., -11., -12.]\
41           ,[-5.,  -6.,  -7.,  -8.]\
42           ,[-1.,  -2.,  -3.,  -4.]]
43        z = num.asarray(z)
44
45        assert num.allclose(z,elevation)
46        import os
47        os.remove('test.nc')
48       
49if __name__ == "__main__":
50    suite = unittest.makeSuite(Test_most2nc,'test')
51    runner = unittest.TextTestRunner()
52    runner.run(suite)
Note: See TracBrowser for help on using the repository browser.