本文整理汇总了Python中cdo.Cdo.topo方法的典型用法代码示例。如果您正苦于以下问题:Python Cdo.topo方法的具体用法?Python Cdo.topo怎么用?Python Cdo.topo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cdo.Cdo
的用法示例。
在下文中一共展示了Cdo.topo方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_returnXArray
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import topo [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])
示例2: test_returnMaArray
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import topo [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 topo [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_showMaArray
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import topo [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')
示例5: test_xdataset_output
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import topo [as 别名]
def test_xdataset_output(self):
cdo = Cdo()
try:
import xarray
except:
print("no xarray installation available!")
return
tDataset = cdo.topo('global_10.0',returnXDataset = True)
if DEBUG:
print(tDataset)
示例6: test_xarray_output
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import topo [as 别名]
def test_xarray_output(self):
cdo = Cdo()
try:
import xarray
except:
print("no xarray installation available!")
return
tArray = cdo.topo('global_10.0',returnXArray = 'topo')
if DEBUG:
print(tArray)
示例7: test_log
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import topo [as 别名]
def test_log(self):
cmd = '-fldmean -mul -random,r20x20 -topo,r20x20'
if DEBUG:
print('# logging with a real file')
cdo = Cdo(logging = True,logFile='foo.log')
cdo.topo()
cdo.temp()
cdo.sinfov(input=cmd)
if DEBUG:
cdo.showLog()
cmd = '-fldmean -mul -random,r20x20 -topo,r20x20'
if DEBUG:
print('# logging with a real file, passed as unicode string')
cdo = Cdo(logging=True, logFile=u'foo.log')
cdo.topo()
cdo.temp()
cdo.sinfov(input=cmd)
if DEBUG:
cdo.showLog()
if DEBUG:
print('# logging with in-memory stringio')
cdo = Cdo(logging = True)
cdo.topo()
cdo.temp()
cdo.sinfov(input=cmd)
if DEBUG:
cdo.showLog()
示例8: testTempdir
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import topo [as 别名]
def testTempdir(self):
# manual set path
tempPath = os.path.abspath('.')+'/tempPy_{0}'.format( random.randrange(1,100000))
cdo = Cdo(tempdir=tempPath)
cdo.topo('r10x10',options = '-f nc')
self.assertEqual(1,len(os.listdir(tempPath)))
cdo.topo('r10x10',options = '-f nc')
cdo.topo('r10x10',options = '-f nc')
self.assertEqual(3,len(os.listdir(tempPath)))
cdo.topo('r10x10',options = '-f nc')
cdo.topo('r10x10',options = '-f nc')
self.assertEqual(5,len(os.listdir(tempPath)))
cdo.cleanTempDir()
self.assertEqual(0,len(os.listdir(tempPath)))
示例9: test_xarray_input
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import topo [as 别名]
def test_xarray_input(self):
cdo = Cdo()
if not (cdo.hasNetcdf and cdo.hasXarray):
print("xarray or netcdf not available! no tests run")
return
try:
import xarray
except:
print("no xarray installation available!")
return
dataSet = xarray.open_dataset(cdo.topo('global_0.1',options = '-f nc'))
dataSet['topo'] = 1.0 + np.abs(dataSet['topo'])
#check the changes withing xarray
self.assertEqual(1.0,np.min(dataSet['topo']))
# tfGen = CdoTempfileStore(dir=tempfile.gettempdir())
xarrayFile = tempfile.NamedTemporaryFile(delete=True,
prefix='test_xarray_input_',
dir=tempfile.gettempdir())
# xarrayFile = tfGen.newFile()
dataSet.to_netcdf(xarrayFile.name)
#check change via cdo
minByCdo = cdo.fldmin(input=xarrayFile.name,returnArray='topo').min()
self.assertEqual(1.0,minByCdo)
#do the same without explicit tempfile
self.assertEqual(1.0,cdo.fldmin(input=dataSet,returnArray='topo').min())
xarrayFile.close()
示例10: test_system_tempdir
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import topo [as 别名]
def test_system_tempdir(self):
# automatic path
tempPath = tempfile.gettempdir()
cdo = Cdo()
cdo.topo('r10x10',options = '-f nc')
self.assertEqual(1,len([ f for f in os.listdir(tempPath) if 'cdoPy' in f]))
cdo.topo('r10x10',options = '-f nc')
cdo.topo('r10x10',options = '-f nc')
self.assertEqual(3,len([ f for f in os.listdir(tempPath) if 'cdoPy' in f]))
cdo.topo('r10x10',options = '-f nc')
cdo.topo('r10x10',options = '-f nc')
cdo.topo('r10x10',options = '-f nc')
cdo.topo('r10x10',options = '-f nc')
cdo.topo('r10x10',options = '-f nc')
cdo.topo('r10x10',options = '-f nc')
cdo.topo('r10x10',options = '-f nc')
cdo.topo('r10x10',options = '-f nc')
cdo.topo('r10x10',options = '-f nc')
self.assertEqual(12,len([ f for f in os.listdir(tempPath) if 'cdoPy' in f]))
cdo.cleanTempDir()
self.assertEqual(0,len([ f for f in os.listdir(tempPath) if 'cdoPy' in f]))
示例11: test_output_set_to_none
# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import topo [as 别名]
def test_output_set_to_none(self):
cdo = Cdo()
self.assertEqual(str,type(cdo.topo(output = None)))
self.assertEqual("GRIB",cdo.sinfov(input = "-topo", output = None)[0].split(' ')[-1])