Skip to content

Commit 9280d85

Browse files
authored
Merge pull request #12 from UV-CDAT/test_migration
Tests!
2 parents b887c7d + b39a098 commit 9280d85

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+3112
-77
lines changed

Test/basetest.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import unittest
2+
import shutil
3+
import numpy
4+
import tempfile
5+
import cdms2
6+
import os
7+
8+
9+
class CDMSBaseTest(unittest.TestCase):
10+
def getFile(self, path, mode="r"):
11+
f = cdms2.open(path, mode)
12+
self.files.append(f)
13+
return f
14+
15+
def getDataFile(self, name):
16+
pth = os.path.dirname(os.path.abspath(__file__))
17+
return self.getFile(os.path.join(pth, "data", name))
18+
19+
def getTempFile(self, path, mode="r"):
20+
return self.getFile(os.path.join(self.tempdir, path), mode)
21+
22+
def setUp(self):
23+
global cdms2
24+
cdms2 = reload(cdms2)
25+
self.orig_cwd = os.getcwd()
26+
self.files = []
27+
self.NTIME = 3
28+
self.NLAT = 16
29+
self.NLON = 32
30+
self.test_arr = numpy.ma.arange(float(2 * self.NTIME * self.NLAT * self.NLON))
31+
self.test_arr.shape = (2, self.NTIME, self.NLAT, self.NLON)
32+
self.tempdir = tempfile.mkdtemp()
33+
34+
def tearDown(self):
35+
for f in self.files:
36+
f.close()
37+
os.chdir(self.orig_cwd)
38+
shutil.rmtree(self.tempdir)
39+
40+
def run():
41+
unittest.main()

Test/cdtest.py

Lines changed: 0 additions & 13 deletions
This file was deleted.

Test/data/cdtest13.xml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?xml version="1.0"?>
2+
<!DOCTYPE dataset SYSTEM "http://www-pcmdi.llnl.gov/software/cdms/cdml.dtd">
3+
<dataset
4+
cdms_filemap ="[[[bounds_lat,bounds_lon,lat,lon,sample],[[-,-,-,-,sampleCurveGrid4.nc]]]]"
5+
institution ="Program for Climate Model Diagnosis and Intercomparison (PCMDI)"
6+
directory =""
7+
Conventions ="CF-1.0"
8+
id ="none"
9+
history ="[2003-9-9 14:55:26] genSampleCgrid4.py
10+
[2003-9-10 21:31:3] /idoru/cdat/dev/bin/cdscan -x cdtest13.xml sampleCurveGrid4.nc"
11+
>
12+
<attr datatype="String" name="source">Analytic data</attr>
13+
<attr datatype="String" name="title">Sample data on a curvilinear grid</attr>
14+
<axis
15+
datatype ="Float"
16+
units =""
17+
length ="4"
18+
id ="nvert"
19+
>
20+
[ 0. 1. 2. 3.]
21+
</axis>
22+
<axis
23+
datatype ="Float"
24+
units =""
25+
length ="48"
26+
id ="x"
27+
>
28+
[ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14.
29+
15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28.
30+
29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42.
31+
43. 44. 45. 46. 47.]
32+
</axis>
33+
<axis
34+
datatype ="Float"
35+
units =""
36+
length ="32"
37+
id ="y"
38+
>
39+
[ 0. 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14.
40+
15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28.
41+
29. 30. 31.]
42+
</axis>
43+
<variable
44+
datatype ="Double"
45+
id ="bounds_lat"
46+
>
47+
<domain
48+
>
49+
<domElem start="0" length="32" name="y"/>
50+
<domElem start="0" length="48" name="x"/>
51+
<domElem start="0" length="4" name="nvert"/>
52+
</domain>
53+
</variable>
54+
<variable
55+
datatype ="Double"
56+
id ="bounds_lon"
57+
>
58+
<domain
59+
>
60+
<domElem start="0" length="32" name="y"/>
61+
<domElem start="0" length="48" name="x"/>
62+
<domElem start="0" length="4" name="nvert"/>
63+
</domain>
64+
</variable>
65+
<variable
66+
datatype ="Double"
67+
units ="degrees_north"
68+
id ="lat"
69+
long_name ="latitude"
70+
>
71+
<attr datatype="String" name="bounds">bounds_lat</attr>
72+
<domain
73+
>
74+
<domElem start="0" length="32" name="y"/>
75+
<domElem start="0" length="48" name="x"/>
76+
</domain>
77+
</variable>
78+
<variable
79+
datatype ="Double"
80+
units ="degrees_east"
81+
id ="lon"
82+
long_name ="longitude"
83+
>
84+
<attr datatype="String" name="bounds">bounds_lon</attr>
85+
<domain
86+
>
87+
<domElem start="0" length="32" name="y"/>
88+
<domElem start="0" length="48" name="x"/>
89+
</domain>
90+
</variable>
91+
<variable
92+
datatype ="Double"
93+
units ="m/s"
94+
id ="sample"
95+
long_name ="Sample variable"
96+
>
97+
<attr datatype="String" name="coordinates">lon lat</attr>
98+
<domain
99+
>
100+
<domElem start="0" length="32" name="y"/>
101+
<domElem start="0" length="48" name="x"/>
102+
</domain>
103+
</variable>
104+
</dataset>

Test/data/cdtest14.xml

Lines changed: 725 additions & 0 deletions
Large diffs are not rendered by default.

Test/data/dvtest1.dat

280 KB
Binary file not shown.

Test/data/dvtest1.dic

8.21 KB
Binary file not shown.

Test/data/ps.wrap.test.0E.nc

16.2 KB
Binary file not shown.

Test/data/readonly.nc

22.4 KB
Binary file not shown.

Test/data/sampleCurveGrid4.nc

133 KB
Binary file not shown.

0 commit comments

Comments
 (0)