Changeset 27232 for issm/trunk/src/m/plot/processdata.py
- Timestamp:
- 08/25/22 16:50:29 (3 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/processdata.py
r26744 r27232 8 8 datatype = 2 -> nodes 9 9 datatype = 3 -> node quivers 10 datatype = 4 -> patch 10 datatype = 4 -> P1 patch 11 datatype = 5 -> P0 patch 12 datatype = 6 -> edges 11 13 12 14 Usage: … … 24 26 else: 25 27 numberofvertices2d = np.nan 28 29 try: 30 numberofedges = md.mesh.numberofedges 31 except AttributeError: 32 numberofedges = np.nan 26 33 27 34 if options.exist('amr'): … … 52 59 # }}} 53 60 54 # 61 # log {{{ 55 62 if options.exist('log'): 56 63 cutoff = options.getfieldvalue('log', 1) … … 58 65 # }}} 59 66 60 # 67 # quiver plot {{{ 61 68 if datasize[1] > 1 and datasize[0] != numberofvertices + 1: 62 if datasize[0] == numberofvertices and datasize[1] == 2:69 if datasize[0] == numberofvertices and datasize[1] in [2, 3]: 63 70 datatype = 3 71 if md.mesh.dimension() == 3: 72 if datasize[1] == 2: 73 data = np.hstack(data, np.zeros((datasize[0]))) 74 elif datasize[1] > 3: 75 raise ValueError('plotmodel error message: data should have two or three columns of length md.mesh.numberofvertices for a quiver plot') 64 76 else: 65 raise ValueError('plotmodel error message: data should have two columns of length md.mesh.numberofvertices for a quiver plot') 77 #we should have a patch 78 print("Assuming that data provided is a patch") 79 datatype = 4 80 index = md.mesh.elements 81 if np.shape(data)[1] < np.shape(index)[1]: 82 raise ValueError('plotmodel error message: data should have more columns than vertices per elements to plot a patch') 83 procdata = np.zeros((numberofvertices)) 84 procdata[md.mesh.elements -1] = data[:, 0:np.shape(index)[1]] 85 datasize = [numberofvertices, 1] 86 66 87 # }}} 67 88 68 # 89 # element data{{{ 69 90 if datasize[0] == numberofelements and datasize[1] == 1: 70 91 #initialize datatype if non patch … … 93 114 # }}} 94 115 95 # 96 if datasize[0] in [numberofvertices, numberofvertices2d] and datasize[1] == 1:116 # node data {{{ 117 elif datasize[0] in [numberofvertices, numberofvertices2d] and datasize[1] == 1: 97 118 datatype = 2 98 119 # AMR {{{ … … 101 122 procdata = procdata[nonan] 102 123 # }}} 103 # 124 # Mask {{{ 104 125 if options.exist('mask'): 105 126 flags = options.getfieldvalue('mask') … … 119 140 # }}} 120 141 121 # spc time series {{{ 122 if datasize[0] == numberofvertices + 1: 142 # edge data {{{ 143 elif datasize[0] in [numberofedges] and datasize[1] == 1: 144 datatype = 6 145 procdata = np.zeros((md.mesh.numberofelements)) 146 repeat = np.zeros((md.mesh.numberofelements)) 147 for index, edge in enumerate(md.mesh.edges[:, -2:]): 148 procdata[edge - 1] += data[index] * np.asarray(edge - 1 > -1, dtype=int) 149 repeat[edge - 1] += np.asarray(edge - 1 > -1, dtype=int) 150 procdata = procdata / repeat 151 152 # }}} 153 # }}} 154 155 # spc time series {{{ 156 elif datasize[0] == numberofvertices + 1: 123 157 datatype = 2 124 158 spccol = options.getfieldvalue('spccol', 0) … … 127 161 procdata = procdata[0:-1, spccol] 128 162 129 #mask?130 131 #layer projection?132 133 #control arrow density if quiver plot134 163 # }}} 135 164 136 # convert rank - 2 array to rank -1 {{{165 # convert rank -2 array to rank -1 {{{ 137 166 if np.ndim(procdata) == 2 and np.shape(procdata)[1] == 1: 138 167 procdata = procdata.reshape(-1, ) … … 142 171 nanfill = options.getfieldvalue('nan', -9999) 143 172 if np.any(np.isnan(procdata)): 144 lb = np.nanmin(procdata) 145 ub = np.nanmax(procdata) 146 if lb == ub: 147 lb = lb - 0.5 148 ub = ub + 0.5 149 nanfill = lb - 1 173 if options.exist('caxis'): 174 [lb, ub] = options.getfieldvalue('caxis') 175 else: 176 lb = np.nanmin(procdata) 177 ub = np.nanmax(procdata) 178 if lb == ub: 179 lb = lb - 0.5 180 ub = ub + 0.5 181 nanfill = lb - 1 182 options.addfielddefault('caxis', [lb, ub]) 183 150 184 procdata[np.isnan(procdata)] = nanfill 151 185 procdata = np.ma.array(procdata, mask=np.isnan(procdata)) 152 #clim looks to be deprecated and replaced by caxis 153 #options.addfielddefault('clim', [lb, ub]) 154 options.addfielddefault('cmap_set_under', '1') 155 print(("WARNING: nan's treated as", nanfill, "by default. Change using pairoption 'nan', nan_fill_value in plotmodel call")) 186 if nanfill < lb: 187 options.addfielddefault('cmap_set_under', 'r') 188 elif nanfill > ub: 189 options.addfielddefault('cmap_set_over', 'k') 190 if nanfill < ub and nanfill > lb: 191 print(("WARNING: nan's treated as", nanfill, "by default. Which is in your data interval, change it with ['nan', value] in plotmodel options")) 156 192 # }}} 157 193
Note:
See TracChangeset
for help on using the changeset viewer.