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


Python MA.array方法代码示例

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


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

示例1: _calcValue

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import array [as 别名]
    def _calcValue(self):

        Nfaces = self.mesh.numberOfFaces
        M = self.mesh._maxFacesPerCell
        dim = self.mesh.dim
        cellFaceIDs = self.mesh.cellFaceIDs

        faceNormalAreas = self.distanceVar._levelSetNormals * self.mesh._faceAreas

        cellFaceNormalAreas = numerix.array(MA.filled(numerix.take(faceNormalAreas, cellFaceIDs, axis=-1), 0))
        norms = numerix.array(MA.filled(MA.array(self.mesh._cellNormals), 0))

        alpha = numerix.dot(cellFaceNormalAreas, norms)
        alpha = numerix.where(alpha > 0, alpha, 0)

        alphasum = numerix.sum(alpha, axis=0)
        alphasum += (alphasum < 1e-100) * 1.0
        alpha = alpha / alphasum

        phi = numerix.repeat(self.distanceVar[numerix.newaxis, ...], M, axis=0)
        alpha = numerix.where(phi > 0., 0, alpha)

        volumes = numerix.array(self.mesh.cellVolumes)
        alpha = alpha * volumes * norms

        value = numerix.zeros((dim, Nfaces), 'd')

        vector._putAdd(value, cellFaceIDs, alpha, mask=MA.getmask(MA.array(cellFaceIDs)))

##         value = numerix.reshape(value, (dim, Nfaces, dim))

        return -value / self.mesh._faceAreas
开发者ID:usnistgov,项目名称:fipy,代码行数:34,代码来源:surfactantConvectionVariable.py

示例2: _cellFaceIDs

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import array [as 别名]
 def _cellFaceIDs(self):
     return MA.array(_Grid3DBuilder.createCells(self.nx,
                                                self.ny,
                                                self.nz,
                                                self.numberOfXYFaces,
                                                self.numberOfXZFaces,
                                                self.numberOfYZFaces))
开发者ID:usnistgov,项目名称:fipy,代码行数:9,代码来源:uniformGrid3D.py

示例3: _getCellToCellIDs

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import array [as 别名]
 def _getCellToCellIDs(self):
     c1 = numerix.arange(self.numberOfCells)
     ids = MA.array((c1 - 1, c1 + 1))
     if self.numberOfCells > 0:
         ids[0, 0] = MA.masked
         ids[1, -1] = MA.masked
     return ids
开发者ID:huahbo,项目名称:FiPy-2.1.3,代码行数:9,代码来源:uniformGrid1D.py

示例4: _numberOfFacesPerCell

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import array [as 别名]
 def _numberOfFacesPerCell(self):
     cellFaceIDs = self.cellFaceIDs
     if isinstance(cellFaceIDs, type(MA.array(0))):
         ## bug in count returns float values when there is no mask
         return numerix.array(cellFaceIDs.count(axis=0), 'l')
     else:
         return self._maxFacesPerCell * numerix.ones(cellFaceIDs.shape[-1], 'l')
开发者ID:usnistgov,项目名称:fipy,代码行数:9,代码来源:abstractMesh.py

示例5: _getNumberOfFacesPerCell

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import array [as 别名]
 def _getNumberOfFacesPerCell(self):
     cellFaceIDs = self._getCellFaceIDs()
     if type(cellFaceIDs) is type(MA.array(0)):
         ## bug in count returns float values when there is no mask
         return numerix.array(cellFaceIDs.count(axis=0), 'l')
     else:
         return self._getMaxFacesPerCell() * numerix.ones(cellFaceIDs.shape[-1], 'l')
开发者ID:regmi,项目名称:fipy,代码行数:9,代码来源:mesh.py

示例6: getFaceCellIDs

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import array [as 别名]
 def getFaceCellIDs(self):
     c1 = numerix.arange(self.numberOfFaces)
     ids = MA.array((c1 - 1, c1))
     if self.numberOfFaces > 0:
         ids[0, 0] = ids[1, 0]
         ids[1, 0] = MA.masked
         ids[1, -1] = MA.masked
     return ids
开发者ID:huahbo,项目名称:FiPy-2.1.3,代码行数:10,代码来源:uniformGrid1D.py

示例7: _calcFaceCellIDs

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import array [as 别名]
    def _calcFaceCellIDs(self):
        array = MA.array(MA.indices(self.cellFaceIDs.shape, 'l')[1], 
                         mask=MA.getmask(self.cellFaceIDs))
        self.faceCellIDs = MA.zeros((2, self.numberOfFaces), 'l')

        ## Nasty bug: MA.put(arr, ids, values) fills its ids and
        ## values arguments when masked!  This was not the behavior
        ## that was assumed when used below.  It was only working
        ## because the old fill value was 0 and the first element of
        ## the array needed to be 0 since the cell's face was
        ## 0. numerix.put() has been changed to deal with this
        ## properly.

##         MA.put(firstRow, cellFaceIDsFlat[::-1], array[::-1])
##         MA.put(secondRow, cellFaceIDsFlat, array)
        firstRow = self.faceCellIDs[0]
        secondRow = self.faceCellIDs[1]
        numerix.put(firstRow, self.cellFaceIDs[::-1,::-1], array[::-1,::-1])
        numerix.put(secondRow, self.cellFaceIDs, array)
        
        mask = ((False,) * self.numberOfFaces, (firstRow == secondRow))
        self.faceCellIDs = MA.sort(MA.array(self.faceCellIDs, mask = mask),
                                   axis=0)
开发者ID:regmi,项目名称:fipy,代码行数:25,代码来源:mesh.py

示例8: _calcFaceCenters

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import array [as 别名]
    def _calcFaceCenters(self):
        maskedFaceVertexIDs = MA.filled(self.faceVertexIDs, 0)

        faceVertexCoords = numerix.take(self.vertexCoords, maskedFaceVertexIDs, axis=1)

        if MA.getmask(self.faceVertexIDs) is False:
            faceVertexCoordsMask = numerix.zeros(numerix.shape(faceVertexCoords), 'l')
        else:
            faceVertexCoordsMask = \
              numerix.repeat(MA.getmaskarray(self.faceVertexIDs)[numerix.newaxis,...], 
                             self.dim, axis=0)
            
        faceVertexCoords = MA.array(data=faceVertexCoords, mask=faceVertexCoordsMask)

        return MA.filled(MA.average(faceVertexCoords, axis=1))
开发者ID:LWhitson2,项目名称:fipy,代码行数:17,代码来源:mesh.py

示例9: _getAddedMeshValues

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import array [as 别名]
    def _getAddedMeshValues(self, other, smallNumber):
        """
        Returns a `dictionary` with 3 elements: the new mesh vertexCoords, faceVertexIDs, and cellFaceIDs.
        """

        other = other._getConcatenableMesh()

        selfNumFaces = self.faceVertexIDs.shape[-1]
        selfNumVertices = self.vertexCoords.shape[-1]
        otherNumFaces = other.faceVertexIDs.shape[-1]
        otherNumVertices = other.vertexCoords.shape[-1]
        ## check dimensions
        if(self.vertexCoords.shape[0] != other.vertexCoords.shape[0]):
            raise MeshAdditionError, "Dimensions do not match"
        ## compute vertex correlates
        vertexCorrelates = {}
        for i in range(selfNumVertices):
            for j in range(otherNumVertices):
                diff = self.vertexCoords[...,i] - other.vertexCoords[...,j]
                diff = numerix.array(diff)
                if (sum(diff ** 2) < smallNumber):
                    vertexCorrelates[j] = i
        if (self._getNumberOfVertices() > 0 and other._getNumberOfVertices() > 0 and vertexCorrelates == {}):
            raise MeshAdditionError, "Vertices are not aligned"

        
         
        ## compute face correlates
        faceCorrelates = {}
        for i in range(otherNumFaces):
##          Seems to be overwriting other.faceVertexIDs with new numpy
##            currFace = other.faceVertexIDs[i]
##            currFace = other.faceVertexIDs[...,i].copy()
##          Changed this again as numpy 1.0.4 seems to have no copy method for
##          masked arrays.
            try:
                currFace = other.faceVertexIDs[...,i].copy()
            except:
                currFace = MA.array(other.faceVertexIDs[...,i], mask=MA.getmask(other.faceVertexIDs[...,i]))

            keepGoing = 1
            currIndex = 0 
            for item in currFace:
                if(vertexCorrelates.has_key(item)):
                    currFace[currIndex] = vertexCorrelates[item]
                    currIndex = currIndex + 1
                else:
                    keepGoing = 0
            if(keepGoing == 1):
                for j in range(selfNumFaces):
                    if (self._equalExceptOrder(currFace, self.faceVertexIDs[...,j])):
                        faceCorrelates[i] = j
        if (self._getNumberOfFaces() > 0 and other._getNumberOfFaces() > 0 and faceCorrelates == {}):
            raise MeshAdditionError, "Faces are not aligned"
        
        faceIndicesToAdd = ()
        for i in range(otherNumFaces):
            if(not faceCorrelates.has_key(i)):
                faceIndicesToAdd = faceIndicesToAdd + (i,)
        vertexIndicesToAdd = ()
        for i in range(otherNumVertices):
            if(not vertexCorrelates.has_key(i)):
                vertexIndicesToAdd = vertexIndicesToAdd + (i,)

        ##compute the full face and vertex correlation list
        a = selfNumFaces
        for i in faceIndicesToAdd:
            faceCorrelates[i] = a
            a = a + 1
        b = selfNumVertices
        for i in vertexIndicesToAdd:
            vertexCorrelates[i] = b
            b = b + 1

        ## compute what the cells are that we need to add
        cellsToAdd = numerix.ones((self.cellFaceIDs.shape[0], other.cellFaceIDs.shape[-1]))
        cellsToAdd = -1 * cellsToAdd

        for j in range(other.cellFaceIDs.shape[-1]):
            for i in range(other.cellFaceIDs.shape[0]):
                cellsToAdd[i, j] = faceCorrelates[other.cellFaceIDs[i, j]]

        cellsToAdd = MA.masked_values(cellsToAdd, -1)


        ## compute what the faces are that we need to add
        facesToAdd = numerix.take(other.faceVertexIDs, faceIndicesToAdd, axis=1)

        for j in range(facesToAdd.shape[-1]):
            for i in range(facesToAdd.shape[0]):
                facesToAdd[i, j] = vertexCorrelates[facesToAdd[i, j]]

        ## compute what the vertices are that we need to add
        verticesToAdd = numerix.take(other.vertexCoords, vertexIndicesToAdd, axis=1)

        return {
            'vertexCoords': numerix.concatenate((self.vertexCoords, verticesToAdd), axis=1), 
            'faceVertexIDs': numerix.concatenate((self.faceVertexIDs, facesToAdd), axis=1), 
            'cellFaceIDs': MA.concatenate((self.cellFaceIDs, cellsToAdd), axis=1)
            }
开发者ID:regmi,项目名称:fipy,代码行数:102,代码来源:mesh.py

示例10: _getCellAreaProjections

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import array [as 别名]
 def _getCellAreaProjections(self):
     return MA.array(self._getCellNormals())
开发者ID:huahbo,项目名称:FiPy-2.1.3,代码行数:4,代码来源:uniformGrid1D.py

示例11: _getCellFaceIDs

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import array [as 别名]
 def _getCellFaceIDs(self):
     return MA.array(self._createCells())
开发者ID:huahbo,项目名称:FiPy-2.1.3,代码行数:4,代码来源:uniformGrid1D.py

示例12: _cellAreaProjections

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import array [as 别名]
 def _cellAreaProjections(self):
     return MA.array(self.cellNormals) * self.cellAreas
开发者ID:usnistgov,项目名称:fipy,代码行数:4,代码来源:cylindricalUniformGrid1D.py

示例13: _cellFaceIDs

# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import array [as 别名]
 def _cellFaceIDs(self):
     return MA.array(_Grid1DBuilder.createCells(self.nx))
开发者ID:usnistgov,项目名称:fipy,代码行数:4,代码来源:uniformGrid1D.py


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