本文整理汇总了Python中cdo.Cdo.debug方法的典型用法代码示例。如果您正苦于以下问题:Python Cdo.debug方法的具体用法?Python Cdo.debug怎么用?Python Cdo.debug使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cdo.Cdo
的用法示例。
在下文中一共展示了Cdo.debug方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testDbg
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import debug [as 别名]
def testDbg(self):
if not 'DEBUG' in os.environ:
cdo = Cdo()
self.assertEqual(False,cdo.debug)
cdo.debug = True
self.assertEqual(True,cdo.debug)
cdo.debug = False
示例2: test_returnMaArray
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import debug [as 别名]
def test_returnMaArray(self):
cdo = Cdo()
cdo.debug = DEBUG
if not cdo.hasNetcdf:
print("no tests run for test_returnMaArray")
return
topo = cdo.topo(returnMaArray='topo')
self.assertEqual(-1890.0,round(topo.mean()))
self.assertEqual(259200,topo.count())
bathy = cdo.setrtomiss(0,10000, input = "-topo",returnMaArray='topo')
#print(bathy)
self.assertEqual(173565,bathy.count())
self.assertEqual(-3386.0,round(bathy.mean()))
oro = cdo.setrtomiss(-10000,0, input = "-topo",returnMaArray='topo')
self.assertEqual(1142.0,round(oro.mean()))
self.assertEqual(85567,oro.count())
bathy = cdo.remapnn('r2x2',input = "-topo", returnMaArray = 'topo')
self.assertEqual(-4298.0,bathy[0,0])
self.assertEqual(-2669.0,bathy[0,1])
ta = cdo.remapnn('r2x2',input = "-topo", options = '-f nc')
tb = cdo.subc(-2669.0,input = ta,options = '-f nc')
withMask = cdo.div(input=ta+" "+tb,returnMaArray='topo')
self.assertEqual('--',withMask[0,1].__str__())
self.assertEqual(False,withMask.mask[0,0])
self.assertEqual(False,withMask.mask[1,0])
self.assertEqual(False,withMask.mask[1,1])
self.assertEqual(True,withMask.mask[0,1])
示例3: test_CDO_options
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import debug [as 别名]
def test_CDO_options(self):
cdo = Cdo()
cdo.debug = DEBUG
names = cdo.showname(input = "-stdatm,0",options = "-f nc")
self.assertEqual(["P T"],names)
if cdo.hasLib("sz"):
ofile = cdo.topo(options = "-z szip")
示例4: test_splitOps
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import debug [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)
示例5: test_fillmiss
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import debug [as 别名]
def test_fillmiss(self):
cdo = Cdo()
if not SHOW:
return
if cdo.hasNetcdf:
if 'CDO' in os.environ:
cdo.setCdo(os.environ.get('CDO'))
cdo.debug = DEBUG
rand = cdo.setname('v',input = '-random,r25x25 ', options = ' -f nc')
missRange = '0.25,0.85'
withMissRange = tempfile.NamedTemporaryFile(delete=True,prefix='cdoPy').name
arOrg = cdo.copy(input = rand,returnMaArray = 'v')
arWmr = cdo.setrtomiss(missRange,input = rand,output = withMissRange,returnMaArray='v')
arFm = cdo.fillmiss( input = withMissRange,returnMaArray = 'v')
arFm1s= cdo.fillmiss2(2, input = withMissRange,returnMaArray = 'v')
if 'setmisstonn' in cdo.operators:
arM2NN= cdo.setmisstonn( input = withMissRange,returnMaArray = 'v')
pool = multiprocessing.Pool(8)
pool.apply_async(plot, (arOrg, ),{"title":'org' })#ofile='fmOrg')
pool.apply_async(plot, (arWmr, ),{"title":'missing' })#ofile='fmWmr')
pool.apply_async(plot, (arFm, ),{"title":'fillmiss' })#ofile= 'fmFm')
pool.apply_async(plot, (arFm1s,),{"title":'fillmiss2'})#ofile='fmFm2')
if 'setmisstonn' in cdo.operators:
pool.apply_async(plot, (arM2NN,), {"title":'setmisstonn'})#, ofile='fmsetMNN')
pool.close()
pool.join()
else:
print("test_fillmiss disables because of missing python-netCDF4")
示例6: test_returnXArray
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import debug [as 别名]
def test_returnXArray(self):
cdo = Cdo()
cdo.debug = DEBUG
if not cdo.hasXarray:
print("nothing testes for test_returnXArray because of missing xarray")
return
topo = cdo.topo(options='-f nc',returnXArray='topo')
self.assertEqual(-1889,int(topo.mean()))
self.assertEqual(259200,topo.count())
bathy = cdo.setrtomiss(0,10000, input = " -topo" ,returnXArray='topo')
self.assertEqual(-3385,int(bathy.mean()))
self.assertEqual(173565,bathy.count())
oro = cdo.setrtomiss(-10000,0,
input = cdo.topo(options='-f nc'),returnXArray='topo')
self.assertEqual(1142,int(oro.mean()))
self.assertEqual(85567,oro.count())
bathy = cdo.remapnn('r2x2',input = cdo.topo(options = '-f nc'), returnXArray = 'topo')
self.assertEqual(-4298.0,bathy[0,0])
self.assertEqual(-2669.0,bathy[0,1])
ta = cdo.remapnn('r2x2',input = cdo.topo(options = '-f nc'))
tb = cdo.subc(-2669.0,input = ta)
withMask = cdo.div(input=ta+" "+tb,returnXArray='topo')
from xarray import DataArray
self.assertEqual(False,DataArray.to_masked_array(withMask).mask[0,0])
self.assertEqual(False,DataArray.to_masked_array(withMask).mask[1,0])
self.assertEqual(False,DataArray.to_masked_array(withMask).mask[1,1])
self.assertEqual(True,DataArray.to_masked_array(withMask).mask[0,1])
示例7: test_smooth
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import debug [as 别名]
def test_smooth(self):
cdo = Cdo()
if (parse_version(cdo.version()) >= parse_version('1.7.2') and cdo.hasNetcdf):
ifile = "-select,level=0 " + DATA_DIR + '/icon/phc.nc'
cdo = Cdo()
cdo.debug = DEBUG
#cdo.merge(input='/home/ram/data/icon/input/phc3.0/PHC__3.0__TempO__1x1__annual.nc /home/ram/data/icon/input/phc3.0/PHC__3.0__SO__1x1__annual.nc',
# output=ifile,
# options='-O')
smooth = cdo.smooth(input=" -sellonlatbox,0,30,0,90 -chname,SO,s,TempO,t " + ifile, returnMaArray='s',options='-f nc')
plot(np.flipud(smooth[0,:,:]),ofile='smooth',title='smooth')
smooth2 = cdo.smooth('nsmooth=2',input="-sellonlatbox,0,30,0,90 -chname,SO,s,TempO,t " + ifile, returnMaArray='s',options='-f nc')
plot(np.flipud(smooth2[0,:,:]),ofile='smooth2',title='smooth,nsmooth=2')
smooth4 = cdo.smooth('nsmooth=4',input="-sellonlatbox,0,30,0,90 -chname,SO,s,TempO,t " + ifile, returnMaArray='s',options='-f nc')
plot(np.flipud(smooth4[0,:,:]),ofile='smooth4',title='smooth,nsmooth=4')
smooth9 = cdo.smooth9(input="-sellonlatbox,0,30,0,90 -chname,SO,s,TempO,t " + ifile, returnMaArray='s',options='-f nc')
plot(np.flipud(smooth9[0,:,:]),ofile='smooth9',title='smooth9')
smooth3deg = cdo.smooth('radius=6deg',input="-sellonlatbox,0,30,0,90 -chname,SO,s,TempO,t " + ifile, returnMaArray='s',options='-f nc')
plot(np.flipud(smooth3deg[0,:,:]),ofile='smooth3deg',title='smooth,radius=6deg')
smooth20 = cdo.smooth('nsmooth=20',input="-sellonlatbox,0,30,0,90 -chname,SO,s,TempO,t " + ifile, returnMaArray='s',options='-f nc')
plot(np.flipud(smooth20[0,:,:]),ofile='smooth20',title='smooth,nsmooth=20')
示例8: test_simple
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import debug [as 别名]
def test_simple(self):
cdo = Cdo()
cdo.debug = DEBUG
s = cdo.sinfov(input="-topo",options="-f nc")
s = cdo.sinfov(input="-remapnn,r36x18 -topo",options="-f nc")
f = tempfile.NamedTemporaryFile(delete=True,prefix='cdoPy').name
cdo.expr("'z=log(abs(topo)+1)*9.81'",input="-topo", output=f, options="-f nc")
s = cdo.infov(input=f)
cdo.stdatm("0",output=f,options="-f nc")
rm([f,])
示例9: test_libs
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import debug [as 别名]
def test_libs(self):
cdo = Cdo()
cdo.debug = DEBUG
if DEBUG:
print(cdo.libs)
self.assertTrue(cdo.hasLib("nc4"),"netcdf4 support missing")
self.assertTrue(cdo.hasLib("netcdf"),"netcdf support missing")
self.assertTrue(cdo.hasLib("udunits2"),"netcdf support missing")
self.assertFalse(cdo.hasLib("udunits"),'boost is not a CDO dependency')
self.assertFalse(cdo.hasLib("boost"),'boost is not a CDO dependency')
self.assertRaises(AttributeError, cdo.libsVersion,"foo")
示例10: test_returnArray
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import debug [as 别名]
def test_returnArray(self):
cdo = Cdo()
cdo.debug = DEBUG
if cdo.hasNetcdf:
self.assertRaises(LookupError, cdo.stdatm,0, returnArray = 'TT')
temperature = cdo.stdatm(0,returnArray = 'T')
self.assertEqual(288.0,temperature.flatten()[0])
#TODO pressure = cdo.stdatm("0,1000",options = '-f nc -b F64',returnArray = 'P')
#TODO self.assertEqual("[ 1013.25 898.54345604]",pressure.flatten().__str__())
else:
self.assertRaises(ImportError, cdo.stdatm,0, returnArray = 'TT')
self.assertRaises(ImportError, cdo.stdatm,0, returnArray = 'T')
示例11: test_inputArray
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import debug [as 别名]
def test_inputArray(self):
cdo = Cdo()
cdo.debug = DEBUG
# check for file input
fileA = cdo.stdatm(0,output='A_{0}'.format( random.randrange(1,100000)))
fileB = cdo.stdatm(0,output='B_{0}'.format( random.randrange(1,100000)))
files = [fileA,fileB]
self.assertEqual(cdo.diffv(input = ' '.join(files)), cdo.diffv(input = files))
self.assertEqual([],cdo.diffv(input = files))
# check for operator input
self.assertEqual([],cdo.diffv(input = ["-stdatm,0","-stdatm,0"]))
# check for operator input and files
self.assertEqual([],cdo.diffv(input = ["-stdatm,0",fileB]))
rm([fileA, fileB])
示例12: test_forceOutput
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import debug [as 别名]
def test_forceOutput(self):
cdo = Cdo()
cdo.debug = DEBUG
outs = []
# tempfiles
outs.append(cdo.stdatm("0,10,20"))
outs.append(cdo.stdatm("0,10,20"))
self.assertNotEqual(outs[0],outs[1])
outs = []
# deticated output, force = true (=defaut setting)
ofile = 'test_force_{0}'.format( random.randrange(1,100000))
outs.append(cdo.stdatm("0,10,20",output = ofile))
mtime0 = os.stat(ofile).st_mtime
#to make it compatible with systems providing no nanos.
time.sleep(1)
outs.append(cdo.stdatm("0,10,20",output = ofile))
mtime1 = os.stat(ofile).st_mtime
self.assertNotEqual(mtime0,mtime1)
self.assertEqual(outs[0],outs[1])
os.remove(ofile)
outs = []
# dedicated output, force = false
ofile = 'test_force_false_{0}'.format( random.randrange(1,100000))
outs.append(cdo.stdatm("0,10,20",output = ofile,force=False))
mtime0 = os.stat(outs[0]).st_mtime
outs.append(cdo.stdatm("0,10,20",output = ofile,force=False))
mtime1 = os.stat(outs[1]).st_mtime
self.assertEqual(mtime0,mtime1)
self.assertEqual(outs[0],outs[1])
os.remove(ofile)
outs = []
# dedicated output, global force setting
ofile = 'test_force_global_{0}'.format( random.randrange(1,100000))
cdo.forceOutput = False
outs.append(cdo.stdatm("0,10,20",output = ofile))
mtime0 = os.stat(outs[0]).st_mtime
outs.append(cdo.stdatm("0,10,20",output = ofile))
mtime1 = os.stat(outs[1]).st_mtime
self.assertEqual(mtime0,mtime1)
self.assertEqual(outs[0],outs[1])
os.remove(ofile)
outs = []
示例13: test_showMaArray
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import debug [as 别名]
def test_showMaArray(self):
cdo = Cdo()
cdo.debug = DEBUG
if DEBUG:
print(cdo)
if cdo.hasNetcdf:
bathy = cdo.setrtomiss(0,10000,
input = cdo.topo('r100x100'),returnMaArray='var1')
plot(bathy)
oro = cdo.setrtomiss(-10000,0,
input = cdo.topo(),returnMaArray='var1')
plot(oro)
random = cdo.setname('test_maArray',
input = "-setrtomiss,0.4,0.8 -random,r180x90 ",
returnMaArray='test_maArray')
plot(random)
else:
self.assertRaises(ImportError,cdo.setrtomiss,0,10000,input="-topo,r100x100",returnMaArray='var1')
示例14: test_env
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import debug [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')
示例15: test_phc
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import debug [as 别名]
def test_phc(self):
ifile = "-select,level=0 " + DATA_DIR + '/icon/phc.nc'
cdo = Cdo()
cdo.debug = DEBUG
if not cdo.hasNetcdf:
return
#cdo.merge(input='/home/ram/data/icon/input/phc3.0/PHC__3.0__TempO__1x1__annual.nc /home/ram/data/icon/input/phc3.0/PHC__3.0__SO__1x1__annual.nc',
# output=ifile,
# options='-O')
s = cdo.sellonlatbox(0,30,0,90, input="-chname,SO,s,TempO,t " + ifile,output='test_my_phc.nc',returnMaArray='s',options='-f nc')
plot(np.flipud(s[0,:,:]),ofile='org',title='original')
sfmo = cdo.sellonlatbox(0,30,0,90, input="-fillmiss -chname,SO,s,TempO,t " + ifile,returnMaArray='s',options='-f nc')
plot(np.flipud(sfmo[0,:,:]),ofile='fm',title='fillmiss')
sfm = cdo.sellonlatbox(0,30,0,90, input="-fillmiss2 -chname,SO,s,TempO,t " + ifile,returnMaArray='s',options='-f nc')
plot(np.flipud(sfm[0,:,:]),ofile='fm2',title='fillmiss2')
ssetmisstonn = cdo.sellonlatbox(0,30,0,90, input="-setmisstonn -chname,SO,s,TempO,t " + ifile,returnMaArray='s',options='-f nc')
plot(np.flipud(ssetmisstonn[0,:,:]),ofile='setmisstonn',title='setmisstonn')
if (parse_version(cdo.version()) >= parse_version('1.7.2')):
smooth = cdo.sellonlatbox(0,30,0,90, input="-smooth -chname,SO,s,TempO,t " + ifile,returnMaArray='s',options='-f nc')
plot(np.flipud(ssetmisstonn[0,:,:]),ofile='smooth',title='smooth')