本文整理汇总了Python中cdo.Cdo.__print__方法的典型用法代码示例。如果您正苦于以下问题:Python Cdo.__print__方法的具体用法?Python Cdo.__print__怎么用?Python Cdo.__print__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cdo.Cdo
的用法示例。
在下文中一共展示了Cdo.__print__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_splitOps
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import __print__ [as 别名]
def test_splitOps(self):
cdo = Cdo()
cdo.debug = DEBUG
pattern = 'stdAtm_{0}'.format( random.randrange(1,100000))
cdo.__print__('test_splitOps')
resultsFiles = cdo.splitname(input = '-stdatm,0',output = pattern)
self.assertTrue(2 <= len(resultsFiles))
if DEBUG:
print(resultsFiles)
for var in ['T','P']:
print(pattern+var+'.grb')
self.assertTrue(pattern+var+'.grb' in resultsFiles)
rm(resultsFiles)
pattern = 'sel_{0}'.format( random.randrange(1,100000))
resultsFiles = cdo.splitsel(1,input = '-for,0,9',output = pattern)
if DEBUG:
print(resultsFiles)
self.assertTrue(10 <= len(resultsFiles))
rm(resultsFiles)
for var in range(0,10):
self.assertTrue(pattern+'00000'+str(var)+'.grb' in resultsFiles)
rm(resultsFiles)
pattern = 'lev_{0}'.format( random.randrange(1,100000))
resultsFiles = cdo.splitlevel(input = '-stdatm,100,2000,5000',output = pattern)
self.assertTrue(3 <= len(resultsFiles))
if DEBUG:
print(resultsFiles)
rm(resultsFiles)
for var in ['0100','2000','5000']:
self.assertTrue(pattern+'00'+str(var)+'.grb' in resultsFiles)
rm(resultsFiles)
示例2: test_errorException
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import __print__ [as 别名]
def test_errorException(self):
cdo = Cdo()
cdo.__print__('test_errorException')
self.assertFalse(hasattr(cdo, 'nonExistingMethod'))
self.assertFalse(not 'max' in cdo.operators)
self.failUnlessRaises(CDOException, cdo.max)
try:
cdo.max()
except CDOException as e:
self.assertTrue(e.returncode != 0)
self.assertTrue(len(e.stderr) > 1)
self.assertTrue(hasattr(e, 'stdout'))
try:
cdo.stdatm(0,10,input="",output="")
except CDOException as e:
self.assertTrue(e.returncode != 0)
self.assertTrue(len(e.stderr) > 1)
self.assertTrue(hasattr(e, 'stdout'))
示例3: test_env
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import __print__ [as 别名]
def test_env(self):
# clean up
tag = 'test___env_test_{0}'.format( random.randrange(1,100000))
files = glob.glob(tag+'*')
rm(files)
files = glob.glob(tag+'*')
self.assertEqual([],files)
# setup
cdo = Cdo()
cdo.debug = DEBUG
self.assertEqual(os.environ,cdo.env)
cdo.__print__('test_env')
# cdf default
ifile = cdo.stdatm(10,20,50,100,options='-f nc')
cdo.splitname(input=ifile,output=tag)
files = glob.glob(tag+'*')
files.sort()
self.assertEqual(['%sP.nc'%(tag), '%sT.nc'%(tag)],files)
rm(files)
# manual setup to nc2 via operator call
cdo.splitname(input=ifile,output=tag,env={"CDO_FILE_SUFFIX": ".foo"})
cdo.env = {}
files = glob.glob(tag+'*')
files.sort()
self.assertEqual(['%sP.foo'%(tag), '%sT.foo'%(tag)],files)
rm(files)
# manual setup to nc2 via object setup
cdo.__print__('test_env:VOR BLA')
cdo.env = {"CDO_FILE_SUFFIX": ".bla"}
cdo.splitname(input=ifile,output=tag)
cdo.splitname(input=ifile,output='bla')
cdo.__print__('test_env:NACH BLA')
cdo.env = {}
files = glob.glob(tag+'*')
files.sort()
self.assertEqual(['%sP.bla'%(tag), '%sT.bla'%(tag)],files)
rm(files)
cdo.__print__('test_env:ENDE')