def createPlateMod(xc, zc, dx, dz, rotAng, sigplate, sighalf):
# use matplotlib paths to find CC inside of polygon
plateCorners = getPlateCorners(xc,zc,dx,dz,rotAng)
verts = [
(plateCorners[0,:]), # left, top
(plateCorners[1,:]), # right, top
(plateCorners[3,:]), # right, bottom
(plateCorners[2,:]), # left, bottom
(plateCorners[0,:]), # left, top (closes polygon)
]
codes = [Path.MOVETO,
Path.LINETO,
Path.LINETO,
Path.LINETO,
Path.CLOSEPOLY,
]
path = Path(verts, codes)
CCLocs = mesh.gridCC
insideInd = np.where(path.contains_points(CCLocs))
#Check selected cell centers by plotting
# print insideInd
# fig = plt.figure()
# ax = fig.add_subplot(111)
# patch = patches.PathPatch(path, facecolor='none', lw=2)
# ax.add_patch(patch)
# plt.scatter(CCLocs[insideInd,0],CCLocs[insideInd,1])
# ax.set_xlim(-10,10)
# ax.set_ylim(-20,0)
# plt.axes().set_aspect('equal')
# plt.show()
mtrue = sighalf*np.ones([mesh.nC,])
mtrue[insideInd] = sigplate
mtrue = np.log(mtrue)
return mtrue
评论列表
文章目录