Commit c9eb47ad authored by Ralf Mueller's avatar Ralf Mueller
Browse files

Add Cdo.readCDF operator with Tests

parent be5c0009
......@@ -175,6 +175,14 @@ class Cdo(object):
return delta_levels
def readCdf(self,iFile):
if not self.returnArray:
self.loadCdf()
return self.cdf(iFile)
# Helper module for easy temp file handling
class MyTempfile(object):
def __init__(self):
......
......@@ -2,7 +2,7 @@
from setuptools import setup
setup (name = 'cdo',
version = '1.0.4',
version = '1.0.5rc1',
author = "Ralf Mueller",
author_email= "stark.dreamdetective@gmail.com",
license = "GPLv2",
......
......@@ -137,6 +137,12 @@ class CdoTest(unittest.TestCase):
thicknesses = cdo.thicknessOfLevels(input = ifile)
self.assertEqual(targetThicknesses,thicknesses)
def test_readCdf(self):
input= "-settunits,days -setyear,2000 -for,1,4"
cdfFile = cdo.copy(options="-f nc",input=input)
cdf = cdo.readCdf(cdfFile)
self.assertEqual(['lat','lon','for','time'],cdf.variables().keys())
if __name__ == '__main__':
unittest.main()
......
......@@ -2,7 +2,7 @@ require 'rubygems'
spec = Gem::Specification.new do |s|
s.name = "cdo"
s.version = '1.0.4'
s.version = '1.0.5rc1'
s.platform = Gem::Platform::RUBY
s.files = ["lib/cdo.rb"] + ["gemspec","COPYING","README.rdoc","ChangeLog"]
s.test_file = "test/test_cdo.rb"
......
......@@ -175,6 +175,11 @@ module Cdo
}
delta_levels
end
def Cdo.readCdf(iFile)
Cdo.loadCdf unless State[:returnArray]
return NetCDF.open(iFile)
end
end
# Helper module for easy temp file handling
......
......@@ -147,6 +147,12 @@ class TestCdo < Test::Unit::TestCase
thicknesses = Cdo.thicknessOfLevels(:in => ifile)
assert_equal(targetThicknesses,thicknesses)
end
def test_readCdf
input = "-settunits,days -setyear,2000 -for,1,4"
cdfFile = Cdo.copy(:options =>"-f nc",:in=>input)
cdf = Cdo.readCdf(cdfFile)
assert_equal(['lon','lat','time','for'],cdf.var_names)
end
end
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment