当前位置: 首页>>代码示例>>Python>>正文


Python Cdo.stdatm方法代码示例

本文整理汇总了Python中cdo.Cdo.stdatm方法的典型用法代码示例。如果您正苦于以下问题:Python Cdo.stdatm方法的具体用法?Python Cdo.stdatm怎么用?Python Cdo.stdatm使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cdo.Cdo的用法示例。


在下文中一共展示了Cdo.stdatm方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_cdf

# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import stdatm [as 别名]
 def test_cdf(self):
     cdo = Cdo()
     self.assertTrue(hasattr(cdo, "cdf"))# not in cdo.__dict__)
     if cdo.hasNetcdf:
       sum = cdo.fldsum(input = cdo.stdatm("0",options="-f nc"),returnCdf=True)
       self.assertEqual(1013.25,sum.variables["P"][:])
     else:
       self.assertRaises(ImportError,cdo.fldsum,input = cdo.stdatm("0",options="-f nc"),returnCdf=True)
开发者ID:Try2Code,项目名称:cdo-bindings,代码行数:10,代码来源:test_cdo.py

示例2: test_simple

# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import stdatm [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,])
开发者ID:Try2Code,项目名称:cdo-bindings,代码行数:12,代码来源:test_cdo.py

示例3: test_cdiMeta

# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import stdatm [as 别名]
 def test_cdiMeta(self):
   cdo = Cdo()
   if cdo.hasNetcdf:
     ofile = cdo.stdatm("0", returnCdf = True)
     if DEBUG:
       print(ofile)
   if cdo.hasXarray:
     ofile = cdo.stdatm("0", returnXArray = 'T')
     if DEBUG:
       print(ofile)
       print(ofile.attrs)
     ofile = cdo.stdatm("0", returnXDataset=True)
     if DEBUG:
       print(ofile)
       print(ofile.attrs)
开发者ID:Try2Code,项目名称:cdo-bindings,代码行数:17,代码来源:test_cdo.py

示例4: test_verticalLevels

# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import stdatm [as 别名]
 def test_verticalLevels(self):
     cdo = Cdo()
     # 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]
     sourceLevels = "25 100 250 500 875 1400 2100 3000 4000 5000".split()
     thicknesses = cdo.thicknessOfLevels(input = "-selname,T " + cdo.stdatm(','.join(sourceLevels),options = "-f nc"))
     self.assertEqual(targetThicknesses,thicknesses)
开发者ID:Try2Code,项目名称:cdo-bindings,代码行数:9,代码来源:test_cdo.py

示例5: test_returnCdf

# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import stdatm [as 别名]
 def test_returnCdf(self):
     cdo = Cdo()
     ofile = tempfile.NamedTemporaryFile(delete=True,prefix='cdoPy').name
     press = cdo.stdatm("0",output=ofile,options="-f nc")
     self.assertEqual(ofile,press)
     if cdo.hasNetcdf:
       variables = cdo.stdatm("0",returnCdf=True).variables
       print(variables)
       cdf = cdo.stdatm("0",returnCdf=True)
       press = cdf.variables['P'][:]
       self.assertEqual(1013.25,press.min())
       press = cdo.stdatm("0",output=ofile,options="-f nc")
       self.assertEqual(ofile,press)
     else:
       self.assertRaises(ImportError,cdo.stdatm,0,returnCdf=True)
     rm([ofile,])
开发者ID:Try2Code,项目名称:cdo-bindings,代码行数:18,代码来源:test_cdo.py

示例6: test_bndLevels

# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import stdatm [as 别名]
 def test_bndLevels(self):
     cdo = Cdo()
     ofile = cdo.stdatm(25,100,250,500,875,1400,2100,3000,4000,5000,options = "-f nc")
     self.assertEqual([0, 50.0, 150.0, 350.0, 650.0, 1100.0, 1700.0, 2500.0, 3500.0, 4500.0, 5500.0],
                 cdo.boundaryLevels(input = "-selname,T " + ofile))
     self.assertEqual([50.0, 100.0, 200.0, 300.0, 450.0, 600.0, 800.0, 1000.0, 1000.0, 1000.0],
                  cdo.thicknessOfLevels(input = ofile))
开发者ID:Try2Code,项目名称:cdo-bindings,代码行数:9,代码来源:test_cdo.py

示例7: test_returnXDataset

# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import stdatm [as 别名]
 def test_returnXDataset(self):
     cdo = Cdo()
     if cdo.hasXarray:
       sum = cdo.fldsum(input = cdo.stdatm("0",options="-f nc"),returnXDataset=True)
       self.assertEqual(1013.25,sum.variables["P"][:])
     else:
       self.assertRaises(ImportError,
           cdo.fldsum,
           input = '-topo',returnXDataset=True)
开发者ID:Try2Code,项目名称:cdo-bindings,代码行数:11,代码来源:test_cdo.py

示例8: test_errorException

# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import stdatm [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'))
开发者ID:Try2Code,项目名称:cdo-bindings,代码行数:21,代码来源:test_cdo.py

示例9: test_returnArray

# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import stdatm [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')
开发者ID:Try2Code,项目名称:cdo-bindings,代码行数:14,代码来源:test_cdo.py

示例10: test_inputArray

# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import stdatm [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])
开发者ID:Try2Code,项目名称:cdo-bindings,代码行数:16,代码来源:test_cdo.py

示例11: test_forceOutput

# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import stdatm [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 = []
开发者ID:Try2Code,项目名称:cdo-bindings,代码行数:47,代码来源:test_cdo.py

示例12: test_env

# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import stdatm [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')
开发者ID:Try2Code,项目名称:cdo-bindings,代码行数:44,代码来源:test_cdo.py

示例13: test_showlevels

# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import stdatm [as 别名]
 def test_showlevels(self):
     cdo = Cdo()
     sourceLevels = "25 100 250 500 875 1400 2100 3000 4000 5000".split()
     self.assertEqual(' '.join(sourceLevels),
                     cdo.showlevel(input = "-selname,T " + cdo.stdatm(','.join(sourceLevels),options = "-f nc"))[0])
开发者ID:Try2Code,项目名称:cdo-bindings,代码行数:7,代码来源:test_cdo.py

示例14: test_combine

# 需要导入模块: from cdo import Cdo [as 别名]
# 或者: from cdo.Cdo import stdatm [as 别名]
 def test_combine(self):
     cdo = Cdo()
     cdo.debug = DEBUG
     stdatm  = cdo.stdatm("0",options = "-f nc")
     stdatm_ = cdo.stdatm("0",options = "-f nc")
开发者ID:Try2Code,项目名称:cdo-bindings,代码行数:7,代码来源:test_cdo.py


注:本文中的cdo.Cdo.stdatm方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。