當前位置: 首頁>>代碼示例>>Python>>正文


Python Cdo.setrtomiss方法代碼示例

本文整理匯總了Python中cdo.Cdo.setrtomiss方法的典型用法代碼示例。如果您正苦於以下問題:Python Cdo.setrtomiss方法的具體用法?Python Cdo.setrtomiss怎麽用?Python Cdo.setrtomiss使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cdo.Cdo的用法示例。


在下文中一共展示了Cdo.setrtomiss方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_returnXArray

# 需要導入模塊: from cdo import Cdo [as 別名]
# 或者: from cdo.Cdo import setrtomiss [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])
開發者ID:Try2Code,項目名稱:cdo-bindings,代碼行數:35,代碼來源:test_cdo.py

示例2: test_returnMaArray

# 需要導入模塊: from cdo import Cdo [as 別名]
# 或者: from cdo.Cdo import setrtomiss [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])
開發者ID:Try2Code,項目名稱:cdo-bindings,代碼行數:31,代碼來源:test_cdo.py

示例3: test_fillmiss

# 需要導入模塊: from cdo import Cdo [as 別名]
# 或者: from cdo.Cdo import setrtomiss [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")
開發者ID:Try2Code,項目名稱:cdo-bindings,代碼行數:36,代碼來源:test_cdo.py

示例4: test_showMaArray

# 需要導入模塊: from cdo import Cdo [as 別名]
# 或者: from cdo.Cdo import setrtomiss [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')
開發者ID:Try2Code,項目名稱:cdo-bindings,代碼行數:20,代碼來源:test_cdo.py


注:本文中的cdo.Cdo.setrtomiss方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。