source: issm/branches/trunk-larour-NatGeoScience2016/src/m/plot/plot_elementnumbering.py@ 21759

Last change on this file since 21759 was 21759, checked in by Eric.Larour, 8 years ago

CHG: merged branch back to trunk-jpl 21754.

File size: 1.5 KB
Line 
1try:
2 import pylab as p
3except ImportError:
4 print "could not import pylab, matplotlib has not been installed, no plotting capabilities enabled"
5
6import numpy as np
7from processmesh import processmesh
8from applyoptions import applyoptions
9from plot_icefront import plot_icefront
10
11def plot_elementnumbering(md,options,fig,axgrid,gridindex):
12 '''
13 plot_elementnumbering - plot element numberign (starting at 1 matlab and c convention)
14
15 Usage:
16 plot_elementnumbering(md,options,fig,axes)
17
18 See also: PLOTMODEL
19 '''
20 x,y,z,elements,is2d,isplanet=processmesh(md,[],options)
21
22 ax=axgrid[gridindex]
23 fig.delaxes(axgrid.cbar_axes[gridindex])
24
25 if is2d:
26 ax.triplot(x,y,elements)
27 else:
28 print 'Not Implemented Yet'
29
30 XLims=[np.min(x),np.max(x)]
31 YLims=[np.min(y),np.max(y)]
32 #plot mesh
33 ax.triplot(x,y,elements)
34 highlightpos=options.getfieldvalue('highlight','none')
35 if highlightpos!='none':
36 #if just one element duplicate it to avoid coloring issues
37 if type(highlightpos)==int:
38 highlightpos=[highlightpos,highlightpos]
39 #convert from to matlab numbering
40 highlightpos=[pos-1 for pos in highlightpos]
41 colors=np.asarray([0.5 for element in elements[highlightpos]])
42 ax.tripcolor(x,y,elements[highlightpos],facecolors=colors,alpha=0.5)
43 # and numbers
44 for i,element in enumerate(elements):
45 ax.text(np.mean(x[element]),np.mean(y[element]),str(i+1),ha='center',va='center',clip_on=True)
46
47 #apply options
48 options.addfielddefault('title','Element numbers (matlab indexation)')
49 options.addfielddefault('colorbar','off')
50 applyoptions(md,[],options,fig,axgrid,gridindex)
51
Note: See TracBrowser for help on using the repository browser.