Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
carsten-forty2 committed Sep 24, 2020
1 parent 473be30 commit 35eb322
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
6 changes: 4 additions & 2 deletions apps/ipynbToGalleryExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
def fixRST(rst):
rst = rst.replace('\n', '')
rst = rst.replace('\r', '\n')
rst = rst.replace(r":raw-latex:`\begin{align}", ".. math::\n\n\t")
rst = rst.replace(r":raw-latex:`\begin{align}", "\n.. math::\n\n\t")
rst = rst.replace("\end{align}`", "")

# some spocky encoding problems with '
Expand All @@ -38,7 +38,9 @@ def convert_ipynb_to_gallery(file_name):
header = "#!/usr/bin/env python\n" +\
"# -*- coding: utf-8 -*-\n"

nb_dict = json.load(open(file_name))
with open(file_name, encoding="utf-8") as fi:
nb_dict = json.load(fi)

cells = nb_dict['cells']

first = True
Expand Down
5 changes: 3 additions & 2 deletions pygimli/viewer/mpl/meshview.py
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,8 @@ def followPath(path, S, rID):

#cMap = plt.cm.get_cmap("Set3", len(ms))

kwargs['lw'] = kwargs.pop('lw', 4)

for i, m in enumerate(ms):
bs = mesh.findBoundaryByMarker(m)
paths = findPaths(bs)
Expand All @@ -608,8 +610,7 @@ def followPath(path, S, rID):
ys = pg.y(mesh.nodes(p))
path = np.array([xs,ys]).T


ax.plot(xs, ys, lw=kwargs.pop('lw', 2), color=col, **kwargs)
ax.plot(xs, ys, color=col, **kwargs)

center = pg.meshtools.interpolateAlongCurve(path,
[pg.utils.cumDist(path)[-1]/2])[0]
Expand Down
30 changes: 20 additions & 10 deletions pygimli/viewer/showmesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,14 @@ def showMesh(mesh, data=None, hold=False, block=False, colorBar=None,
showMesh: bool [False]
Shows the mesh itself additional.
showBoundary: bool [None]
Deprecated. Shows all boundary with marker != 0. A value None means automatic
True for cell data and False for node data.
showBoundaryMarkers: bool [False]
Highlight boundary marker != 0. Replaces showBoundary
Highlight all boundaries with marker != 0. A value None means automatic. Is set True for cell data and False for node data.
marker: bool [False]
Show mesh and boundary marker.
Show cell markers and boundary marker.
boundaryMarkers: bool [False]
Highlight boundaries with marker !=0 and add Marker annotation.
Applies :py:mod:`pygimli.viewer.mpl.drawBoundaryMarkers`.
Dictionary "boundaryProps" can be added and will be forwarded to
:py:mod:`pygimli.viewer.mpl.drawBoundaryMarkers`.
Keyword Arguments
-----------------
Expand All @@ -226,6 +228,8 @@ def showMesh(mesh, data=None, hold=False, block=False, colorBar=None,
Add label to the y axis
fitView: bool
Fit the axes limits to the all content of the axes. Default is True.
boundaryProps: dict
Arguments for plotboundar
All remaining will be forwarded to the draw functions
and matplotlib methods, respectively.
Expand Down Expand Up @@ -276,7 +280,8 @@ def showMesh(mesh, data=None, hold=False, block=False, colorBar=None,
validData = False

if markers:
kwargs["boundaryMarker"] = True
kwargs["boundaryMarkers"] = kwargs.get("boundaryMarkers", True)

if mesh.cellCount() > 0:
uniquemarkers, uniqueidx = np.unique(
np.array(mesh.cellMarkers()), return_inverse=True)
Expand All @@ -292,6 +297,7 @@ def showMesh(mesh, data=None, hold=False, block=False, colorBar=None,
mesh.createNeighborInfos()
if showBoundary is None:
showBoundary = True

elif isinstance(data, pg.core.stdVectorRVector3):
drawSensors(ax, data, **kwargs)
elif isinstance(data, pg.core.R3Vector):
Expand Down Expand Up @@ -383,13 +389,13 @@ def _drawField(ax, mesh, data, **kwargs):
print(e)
traceback.print_exc(file=sys.stdout)


if mesh.cellCount() == 0:
showMesh = False
if mesh.boundaryCount() == 0:
pg.viewer.mpl.drawPLC(ax, mesh, showNodes=True,
fillRegion=False, showBoundary=False,
**kwargs)
fillRegion=False,
showBoundary=False,
**kwargs)
showBoundary = False
#ax.plot(pg.x(mesh), pg.y(mesh), '.', color='black')
else:
Expand All @@ -405,12 +411,16 @@ def _drawField(ax, mesh, data, **kwargs):
color=kwargs.pop('color', "0.1"), linewidth=0.3)
#drawMesh(ax, mesh, **kwargs)

if showBoundary == True or showBoundary == 1:
if bool(showBoundary) == True:
b = mesh.boundaries(mesh.boundaryMarkers() != 0)
pg.viewer.mpl.drawSelectedMeshBoundaries(ax, b,
color=(0.0, 0.0, 0.0, 1.0),
linewidth=1.4)

if kwargs.pop("boundaryMarkers", False):
pg.viewer.mpl.drawBoundaryMarkers(ax, mesh,
**kwargs.pop('boundaryProps', {}))

fitView = kwargs.pop('fitView', fitViewDefault)

if fitView is not False:
Expand Down

0 comments on commit 35eb322

Please sign in to comment.