Skip to content
Snippets Groups Projects
Commit 9e207ab8 authored by Ralf Mueller's avatar Ralf Mueller
Browse files

Add test on thickness checking

parent 998a386a
No related branches found
No related tags found
No related merge requests found
......@@ -96,10 +96,11 @@ class CdoTest(unittest.TestCase):
stdatm = cdo.stdatm("0",options = "-f nc",output=o)
self.assertEqual(o,stdatm)
o = MyTempfile().path()
o_ = MyTempfile().path()
sum = cdo.fldsum(input = stdatm,output = o)
sum = cdo.fldsum(input = stdatm)
sum = cdo.fldsum(input = cdo.stdatm("0",options="-f nc",output="F"),output="G")
sum = cdo.fldsum(input = cdo.stdatm("0",options="-f nc",output="F"),returnArray=True)
sum = cdo.fldsum(input = cdo.stdatm("0",options="-f nc"))
sum = cdo.fldsum(input = cdo.stdatm("0",options="-f nc"),returnArray=True)
self.assertEqual(288.0,sum.var("T").get().min())
def test_cdf(self):
......@@ -107,10 +108,20 @@ class CdoTest(unittest.TestCase):
cdo.setReturnArray()
self.assertIn("cdf",cdo.__dict__)
cdo.setReturnArray(False)
sum = cdo.fldsum(input = cdo.stdatm("0",options="-f nc",output="F"),output="G",returnArray=True)
sum = cdo.fldsum(input = cdo.stdatm("0",options="-f nc"),returnArray=True)
self.assertEqual(1013.25,sum.var("P").get().min())
cdo.unsetReturnArray()
def test_verticalLevels(self):
iconpath = "/home/ram/src/git/icon/grids"
# check, if a given input files has vertival layers of a given thickness array
targetThicknesses = [50.0, 100.0, 200.0, 300.0, 450.0, 600.0, 800.0, 1000.0, 1000.0, 1000.0]
ifile = '/'.join([iconpath,"ts_phc_annual-iconR2B04-L10_50-1000m.nc"])
self.assertEqual(["25 100 250 500 875 1400 2100 3000 4000 5000",
"25 100 250 500 875 1400 2100 3000 4000 5000"],cdo.showlevel(input = ifile))
thicknesses = cdo.thicknessOfLevels(input = ifile)
self.assertEqual(targetThicknesses,thicknesses)
if __name__ == '__main__':
unittest.main()
......
......@@ -124,6 +124,18 @@ class TestCdo < Test::Unit::TestCase
assert_equal(1013.25,sum.min)
test_returnArray
end
def test_verticalLevels
iconpath = "/home/ram/src/git/icon/grids"
# check, if a given input files has vertival layers of a given thickness array
targetThicknesses = [50.0, 100.0, 200.0, 300.0, 450.0, 600.0, 800.0, 1000.0, 1000.0, 1000.0]
ifile = [iconpath,"ts_phc_annual-iconR2B04-L10_50-1000m.nc"].join('/')
assert_equal(["25 100 250 500 875 1400 2100 3000 4000 5000",
"25 100 250 500 875 1400 2100 3000 4000 5000"],Cdo.showlevel(:in => ifile))
thicknesses = Cdo.thicknessOfLevels(:in => ifile)
assert_equal(targetThicknesses,thicknesses)
end
end
# # Calling simple operators
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment