Changeset 21341 for issm/trunk/src/m/plot/processmesh.py
- Timestamp:
- 11/04/16 13:48:43 (8 years ago)
- Location:
- issm/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk
-
issm/trunk/src
- Property svn:mergeinfo changed
-
issm/trunk/src/m/plot/processmesh.py
r17806 r21341 1 1 from math import isnan 2 import MatlabFuncs as m 3 import numpy as npy 2 import numpy as np 4 3 5 4 def processmesh(md,data,options): … … 13 12 """ 14 13 15 # some checks14 # {{{ check mesh size parameters 16 15 if md.mesh.numberofvertices==0: 17 16 raise ValueError('processmesh error: mesh is empty') 18 17 if md.mesh.numberofvertices==md.mesh.numberofelements: 19 18 raise ValueError('processmesh error: the number of elements is the same as the number of nodes') 20 19 # }}} 20 # {{{ treating non data plots mesh 21 21 if len(data)==0 or not isinstance(data,dict): 22 23 22 if 'latlon' not in options.getfieldvalue('coord','xy').lower(): #convert to lower case for comparison 24 x=md.mesh.x 25 if 'x2d' in dir(md.mesh): x2d=md.mesh.x2d 26 y=md.mesh.y 27 if 'y2d' in dir(md.mesh): y2d=md.mesh.x2d 23 try: 24 x=md.mesh.x2d 25 except AttributeError: 26 x=md.mesh.x 27 try: 28 y=md.mesh.x2d 29 except AttributeError: 30 y=md.mesh.y 28 31 else: 29 32 x=md.mesh.long 30 33 y=md.mesh.lat 31 32 if 'z' in dir(md.mesh): 34 try: 33 35 z=md.mesh.z 34 e lse:35 z=np y.zeros_like(md.mesh.x)36 except AttributeError: 37 z=np.zeros_like(md.mesh.x) 36 38 37 if 'elements2d' in dir(md.mesh): 38 elements2d=md.mesh.elements2d 39 elements2d=elements2d-1 # subtract one since python indexes from zero 40 elements=md.mesh.elements 41 elements=elements-1 39 try: 40 elements2d=md.mesh.elements2d-1 41 except AttributeError: 42 elements=md.mesh.elements-1 42 43 43 44 #is it a 2D plot? 44 if md.mesh.dimension()==2 :45 if md.mesh.dimension()==2 or options.getfieldvalue('layer',0)>=1: 45 46 is2d=1 46 47 else: 47 if options.getfieldvalue('layer',0)>=1: 48 is2d=1 49 else: 50 is2d=0 48 is2d=0 51 49 52 50 #layer projection? … … 54 52 if 'latlon' in options.getfieldvalue('coord','xy').lower(): 55 53 raise ValueError('processmesh error: cannot work with 3D mesh in lat-lon coords') 56 #we modify the mesh temporarily to a 2D mesh from which the 3D mesh was extruded57 x=x2d58 y=y2d59 z=zeros(size(x2d))60 elements=elements2d61 54 #we modify the mesh temporarily to a 2D mesh from which the 3D mesh was extruded 55 #Basile: does not seem necessary as we already picked x as x2d 56 # x=x2d 57 # y=y2d 58 # z=zeros(size(x2d)) 59 # elements=elements2d 62 60 else: 63 61 #Process mesh for plotting
Note:
See TracChangeset
for help on using the changeset viewer.