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


Python MA.filled方法代碼示例

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


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

示例1: xrange

# 需要導入模塊: import MA [as 別名]
# 或者: from MA import filled [as 別名]
nhlat    = fice.shape[1]
nhlon    = fice.shape[2]

nmo    = 0
month  = nmo+1

icemon = MA.zeros((nhlat,nhlon),MA.Float0)
for i in xrange(fice_masked.shape[0]):
  for j in xrange(fice_masked.shape[1]):
    icemon[i,j] = MA.average(fice_masked[i,j,0:ntime:12])

#
#  Fill the places where icemon is zero with the fill value.
#
icemon = MA.masked_values(icemon,0.,rtol=0.,atol=1.e-15)
icemon = MA.filled(icemon,value=fill_value)

                       # Calculate the January (nmo=0) average.


nsub = 16 # Subscript location of northernmost hlat to be plotted.

cmap = Numeric.array([                                         \
         [1.00,1.00,1.00], [0.00,0.00,0.00], [1.00,1.00,0.50], \
         [0.00,0.00,0.50], [0.50,1.00,1.00], [0.50,0.00,0.00], \
         [1.00,0.00,1.00], [0.00,1.00,1.00], [1.00,1.00,0.00], \
         [0.00,0.00,1.00], [0.00,1.00,0.00], [1.00,0.00,0.00], \
         [0.50,0.00,1.00], [1.00,0.50,0.00], [0.00,0.50,1.00], \
         [0.50,1.00,0.00], [0.50,0.00,0.50], [0.50,1.00,0.50], \
         [1.00,0.50,1.00], [0.00,0.50,0.00], [0.50,0.50,1.00], \
         [1.00,0.00,0.50], [0.50,0.50,0.00], [0.00,0.50,0.50], \
開發者ID:akrherz,項目名稱:me,代碼行數:33,代碼來源:ngl09p.py

示例2: rgrd

# 需要導入模塊: import MA [as 別名]
# 或者: from MA import filled [as 別名]
    def rgrd(self, dataIn = None):

        """    --------------------------------------------------------------------------------------------------------
         
             ROUTINE: rgrd 
         
             PURPOSE:  To perform one of the following two possible computations in 3-space: 
                           To interpolate random data in 3-space using a modified Shepard's algorithm 
                           To find the nearest neighbor to a user specified point 
         
             USAGE:    To interpolate use
         
                           dataOut = r.rgrd(dataIn) where
                               
                               r       -- an instance of Shgrid
                               dataIn  -- input data 
                               dataOut -- output data 
         
                       To locate the nearest point use
         
                           np = r.rgrd(numberPoints) where
                               
                               r       -- an instance of Shgrid
                               np      -- the array with numberPoints indices into the input grid idenifying the nearest points
    --------------------------------------------------------------------------------------------------------""" 

        if self.callGridded == 'yes':                           # Interpolation in 3-space
            if usefilled == 'yes':
                dataIn = MA.filled(dataIn)

            if debug == 1:
                print 'calling shgrid' 

            iwk = numpy.zeros((2*self.ni,),'i')
            rwk = numpy.zeros((11*self.ni+6,),'f')
            dataOut, ier = shgridmodule.shgrid(self.xi, self.yi, self.zi,
                                               dataIn,
                                               self.xo, self.yo, self.zo,
                                               iwk,rwk)
            dataOut = numpy.transpose(dataOut)

            if debug == 1:
                print '*****************   returning from shgrid with  ier = ', ier

            if ier != 0:
                msg = 'Error in return from shgrid call with -- ' + Shgrid.errorTable(self)[ier]
                raise ValueError, msg

            # is a reverse the order in the returned arrays necessary?

            if (self.xreverse == 'yes') or (self.yreverse == 'yes') or (self.zreverse == 'yes'):
                needReverse = 'yes'
            else:
                needReverse = 'no'
            if needReverse == 'yes':
                dataOut = Shgrid.reverseData(self, dataOut)

            return dataOut 

    #---------------------------------------------------------------------------------

        else:                                                       # Computation of nearest neighbors
            if debug == 1:
                print 'calling shgetnp' 

            numberPoints = dataIn
            np = numpy.zeros((numberPoints,),numpy.int32)

            n = self.ni
            iwk = numpy.zeros((2*n,),numpy.int32)
            rwk = numpy.zeros((11*n + 6,), numpy.float32)

            iflag = 0
            np[0], ier = shgridmodule.shgetnp(self.xo, self.yo, self.zo,
                                              self.xi, self.yi, self.zi,
                                              iflag,
                                              iwk, rwk)

            if debug == 1:
                print '*****************   returning from shgrid with  ier = ', ier
            if ier != 0:
                msg = 'Error in return from shgetnp call with -- ' + Shgrid.errorTable(self)[ier]
                raise ValueError, msg

            iflag = 1
            for i in range(1, numberPoints):
                np[i], ier = shgridmodule.shgetnp(self.xo, self.yo, self.zo,
                                                  self.xi, self.yi, self.zi,
                                                  iflag,
                                                  iwk, rwk)

                if debug == 1:
                    print '*****************   returning from shgrid with  ier = ', ier
                if ier != 0:
                    msg = 'Error in return from shgetnp call with -- ' + Shgrid.errorTable(self)[ier]
                    raise ValueError, msg
            return np
開發者ID:NCPP,項目名稱:uvcdat-devel,代碼行數:99,代碼來源:sh.py


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