Changeset 27087
- Timestamp:
- 06/22/22 01:42:55 (3 years ago)
- Location:
- issm/trunk-jpl/src/m/plot
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/plot/applyoptions.py
r26928 r27087 11 11 from plot_contour import plot_contour 12 12 from plot_streamlines import plot_streamlines 13 from plot_edgeoverlay import plot_edgeoverlay 13 14 14 15 … … 156 157 # {{{ ShowBasins TODO 157 158 # }}} 158 # {{{ clim 159 if options.exist('clim'): 160 lims = options.getfieldvalue('clim') 161 assert len(lims) == 2, 'error, clim should be passed as a list of length 2' 162 elif options.exist('caxis'): 159 # {{{ caxis 160 if options.exist('caxis'): 163 161 lims = options.getfieldvalue('caxis') 164 162 assert len(lims) == 2, 'error, caxis should be passed as a list of length 2' 165 options.addfielddefault('c lim', lims)163 options.addfielddefault('caxis', lims) 166 164 else: 167 165 if len(data) > 0: … … 192 190 if options.exist('contourlevels'): 193 191 plot_contour(md, data, options, ax) 192 # }}} 193 # {{{ edgeoverlay 194 if options.exist('edgeoverlay'): 195 edgedata = options.getfieldvalue('edgeoverlay') 196 plot_edgeoverlay(md, edgedata, options, ax) 194 197 # }}} 195 198 # {{{ wrapping TODO -
issm/trunk-jpl/src/m/plot/plot_unit.py
r25125 r27087 52 52 cmap = getcolormap(options) 53 53 if options.exist('cmap_set_over'): 54 over = options.getfieldvalue('cmap_set_over', ' 0.5')54 over = options.getfieldvalue('cmap_set_over', 'k') 55 55 cmap.set_over(over) 56 56 if options.exist('cmap_set_under'): 57 under = options.getfieldvalue('cmap_set_under', ' 0.5')57 under = options.getfieldvalue('cmap_set_under', 'k') 58 58 cmap.set_under(under) 59 59 options.addfield('colormap', cmap) … … 75 75 limextent = 0. 76 76 77 if options.exist('clim'): 78 lims = options.getfieldvalue('clim', [np.nanmin(data), np.nanmax(data)]) 79 elif options.exist('caxis'): 77 if options.exist('caxis'): 80 78 lims = options.getfieldvalue('caxis', [np.nanmin(data), np.nanmax(data)]) 81 79 else: … … 93 91 else: 94 92 norm = mpl.colors.Normalize(vmin=lims[0], vmax=lims[1]) 95 if options.exist('log'):96 norm = mpl.colors.LogNorm(vmin=lims[0], vmax=lims[1])97 else:98 norm = mpl.colors.Normalize(vmin=lims[0], vmax=lims[1])99 93 options.addfield('colornorm', norm) 100 94 # }}} … … 102 96 # Plot depending on the datatype 103 97 # {{{ data are on elements 104 105 98 if datatype == 1: 106 99 if is2d: -
issm/trunk-jpl/src/m/plot/plotmodel.py
r26569 r27087 86 86 # taken from https://matplotlib.org/api/_as_gen/mpl_toolkits.axes_grid1.axes_grid.ImageGrid.html 87 87 # 88 direction = options.list[0].getfieldvalue('direction', 'row') # {"row", "column"}, default: "row"89 axes_pad = options.list[0].getfieldvalue('axes_pad', 0.25) # float or (float, float), default : 0.02; Padding or (horizonal padding, vertical padding) between axes, in inches90 add_all = options.list[0].getfieldvalue('add_all', True) # bool, default: True91 share_all = options.list[0].getfieldvalue('share_all', True) # bool, default: False92 label_mode = options.list[0].getfieldvalue('label_mode', 'L') # {"L", "1", "all"}, default: "L"; Determines which axes will get tick labels: "L": All axes on the left column get vertical tick labels; all axes on the bottom row get horizontal tick labels;. "1": Only the bottom left axes is labelled. "all": all axes are labelled.88 direction = options.list[0].getfieldvalue('direction', 'row') # {"row", "column"}, default: "row" 89 axes_pad = options.list[0].getfieldvalue('axes_pad', 0.25) # float or (float, float), default : 0.02; Padding or (horizonal padding, vertical padding) between axes, in inches 90 add_all = options.list[0].getfieldvalue('add_all', True) # bool, default: True 91 share_all = options.list[0].getfieldvalue('share_all', True) # bool, default: False 92 label_mode = options.list[0].getfieldvalue('label_mode', 'L') # {"L", "1", "all"}, default: "L"; Determines which axes will get tick labels: "L": All axes on the left column get vertical tick labels; all axes on the bottom row get horizontal tick labels;. "1": Only the bottom left axes is labelled. "all": all axes are labelled. 93 93 94 94 # Translate MATLAB colorbar mode to matplotlib -
issm/trunk-jpl/src/m/plot/processdata.py
r26569 r27087 60 60 # quiver plot {{{ 61 61 if datasize[1] > 1 and datasize[0] != numberofvertices + 1: 62 if datasize[0] == numberofvertices and datasize[1] == 2:62 if datasize[0] == numberofvertices and datasize[1] in [2, 3]: 63 63 datatype = 3 64 if md.mesh.dimension() == 3: 65 if datasize[1] == 2: 66 data = np.hstack(data, np.zeros((datasize[0]))) 67 elif datasize[1] > 3: 68 raise ValueError('plotmodel error message: data should have two or three columns of length md.mesh.numberofvertices for a quiver plot') 64 69 else: 65 raise ValueError('plotmodel error message: data should have two columns of length md.mesh.numberofvertices for a quiver plot') 70 #we should have a patch 71 print("Assuming that data provided is a patch") 72 datatype = 4 73 index = md.mesh.elements 74 if np.shape(data)[1] < np.shape(index)[1]: 75 raise ValueError('plotmodel error message: data should have more columns than vertices per elements to plot a patch') 76 procdata = np.zeros((numberofvertices)) 77 procdata[md.mesh.elements -1] = data[:, 0:np.shape(index)[1]] 78 datasize = [numberofvertices, 1] 79 66 80 # }}} 67 81 … … 142 156 nanfill = options.getfieldvalue('nan', -9999) 143 157 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 158 if options.exist('caxis'): 159 [lb, ub] = options.getfieldvalue('caxis') 160 else: 161 lb = np.nanmin(procdata) 162 ub = np.nanmax(procdata) 163 if lb == ub: 164 lb = lb - 0.5 165 ub = ub + 0.5 166 nanfill = lb - 1 167 options.addfielddefault('caxis', [lb, ub]) 168 150 169 procdata[np.isnan(procdata)] = nanfill 151 170 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")) 171 print('from nan processing {} and {}'.format(lb, ub)) 172 if nanfill < lb: 173 options.addfielddefault('cmap_set_under', 'k') 174 elif nanfill > ub: 175 options.addfielddefault('cmap_set_over', 'k') 176 if nanfill < ub and nanfill > lb: 177 print(("WARNING: nan's treated as", nanfill, "by default. Which is in your data interval, change it with ['nan', value] in plotmodel options")) 156 178 # }}} 157 179
Note:
See TracChangeset
for help on using the changeset viewer.