当前位置: 首页>>代码示例>>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;未经允许,请勿转载。