本文整理汇总了Python中fipy.tools.numerix.MA.masked_where方法的典型用法代码示例。如果您正苦于以下问题:Python MA.masked_where方法的具体用法?Python MA.masked_where怎么用?Python MA.masked_where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类fipy.tools.numerix.MA
的用法示例。
在下文中一共展示了MA.masked_where方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _cellVertexIDs
# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import masked_where [as 别名]
def _cellVertexIDs(self):
## Get all the vertices from all the faces for each cell
cellFaceVertices = numerix.take(self.faceVertexIDs, self.cellFaceIDs, axis=1)
## get a sorted list of vertices for each cell
cellVertexIDs = numerix.reshape(cellFaceVertices, (-1, self.numberOfCells))
cellVertexIDs = MA.sort(cellVertexIDs, axis=0, fill_value=-1)
cellVertexIDs = MA.sort(MA.concatenate((cellVertexIDs[-1, numerix.newaxis],
MA.masked_where(cellVertexIDs[:-1]
== cellVertexIDs[1:],
cellVertexIDs[:-1]))),
axis=0, fill_value=-1)
## resize the array to remove extra masked values
if cellVertexIDs.shape[-1] == 0:
length = 0
else:
length = min(numerix.sum(MA.getmaskarray(cellVertexIDs), axis=0))
return cellVertexIDs[length:][::-1]
示例2: faceCellIDs
# 需要导入模块: from fipy.tools.numerix import MA [as 别名]
# 或者: from fipy.tools.numerix.MA import masked_where [as 别名]
def faceCellIDs(self):
faceCellIDs = numerix.zeros((2, self.numberOfFaces), 'l')
mask = numerix.zeros((2, self.numberOfFaces), 'l')
inline._runInline("""
int ID = j * ni + i;
int rowlength = ni * nj + Nhor + nj;
faceCellIDs[ID + 0 * rowlength] = ID - ni;
faceCellIDs[ID + 1 * rowlength] = ID;
faceCellIDs[ID + Nhor + j + 0 * rowlength] = ID - 1;
faceCellIDs[ID + Nhor + j + 1 * rowlength] = ID;
if (j == 0) {
faceCellIDs[ID + 0 * rowlength] = ID;
mask[ID + 1 * rowlength] = 1;
}
if (j == nj - 1) {
faceCellIDs[ID + ni + 0 * rowlength] = ID;
mask[ID + ni + 1 * rowlength] = 1;
}
if (i == 0) {
faceCellIDs[ID + Nhor + j + 0 * rowlength] = ID;
mask[ID + Nhor + j + 1 * rowlength] = 1;
}
if ( i == ni - 1 ) {
faceCellIDs[ID + Nhor + j + 1 + 0 * rowlength] = ID;
mask[ID + Nhor + j + 1 + 1 * rowlength] = 1;
}
""",
Nhor=self.numberOfHorizontalFaces,
mask=mask,
faceCellIDs=faceCellIDs,
ni=self.nx,
nj=self.ny)
return MA.masked_where(mask, faceCellIDs)