Changeset 6103 for qesdi/geoplot/trunk/lib/geoplot/contour_drawer.py
 Timestamp:
 09/12/09 16:08:34 (11 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

qesdi/geoplot/trunk/lib/geoplot/contour_drawer.py
r5946 r6103 45 45 self._contourFont = config['Fonts']['ContourLines'] 46 46 47 def draw(self, axes, grid, basemap=None, normalize=None, cmap=None, scale=COLOUR_SCHEME_SCALE.LINEAR, fontSize='medium'):47 def draw(self, axes, grid, scheme, basemap=None, fontSize='medium'): 48 48 """ 49 49 Draws contour lines from the grid's data on the axis. … … 56 56 drawn on the axis. 57 57 """ 58 59 if cmap == None:60 cmap = matplotlib.cm.get_cmap()61 cmap.set_bad("w")62 58 63 59 #transform the grid data to the correct projection 64 60 grid_mapUnits = grid.transform(basemap) 65 61 66 self._drawContours(axes, cmap, grid_mapUnits, normalize, fontSize, scale)62 self._drawContours(axes, scheme, grid_mapUnits, fontSize) 67 63 68 def _drawContours(self, axes, cmap, grid_mapUnits, normalize, fontSize, scale):64 def _drawContours(self, axes, scheme, grid_mapUnits, fontSize): 69 65 """ 70 66 Draws the contour lines onto the axes. … … 75 71 76 72 if valuesFound == True: 77 78 79 if normalize == None : 80 normalize = matplotlib.colors.Normalize(0, 1) 81 82 log.debug("scale = %s" % (scale,)) 83 if scale == COLOUR_SCHEME_SCALE.LOG: 84 85 #lev_exp = np.arange(np.floor(np.log10(z.min())1), 86 # np.ceil(np.log10(z.max())+1)) 87 #levs = np.power(10, lev_exp) 88 lmin = N.log10(normalize.vmin) 89 lmax = N.log10(normalize.vmax) 90 levels = N.logspace(lmin, lmax, self.numContourLines) 91 labelFormat = "%.1E" 92 else: 93 levels = N.linspace(normalize.vmin, normalize.vmax, self.numContourLines) 94 labelFormat = "%1.3f" 73 74 # if scheme.scale == COLOUR_SCHEME_SCALE.LOG: 75 # 76 # #lev_exp = np.arange(np.floor(np.log10(z.min())1), 77 # # np.ceil(np.log10(z.max())+1)) 78 # #levs = np.power(10, lev_exp) 79 # lmin = N.log10(scheme.norm.vmin) 80 # lmax = N.log10(scheme.norm.vmax) 81 # levels = N.logspace(lmin, lmax, self.numContourLines) 82 # labelFormat = "%.1E" 83 # else: 84 # levels = N.linspace(scheme.norm.vmin, scheme.norm.vmax, self.numContourLines) 85 # labelFormat = "%1.3f" 95 86 96 87 97 extent=(grid_mapUnits.boundsX.min(), grid_mapUnits.boundsX.max(),98 grid_mapUnits.boundsY.min(), grid_mapUnits.boundsY.max())99 88 100 89 CS = axes.contour(grid_mapUnits.midpointsX, 101 90 grid_mapUnits.midpointsY, 102 91 grid_mapUnits.values, 103 levels,104 cmap= cmap,92 scheme.bounds, 93 cmap=scheme.colourMap, 105 94 origin='lower', 106 95 linewidths=self.contourLineWidth, 107 norm= normalize,96 norm=scheme.norm, 108 97 extend='neither', 109 98 ) … … 111 100 labelDictionary = self._contourFont.getDict(fontSize) 112 101 113 axes.clabel(CS,levels[0::self.contourLabelInterval], fontsize=labelDictionary['size'], 114 fmt=labelFormat) 102 axes.clabel(CS, 103 scheme.bounds[0::self.contourLabelInterval], 104 fontsize=labelDictionary['size'], 105 fmt=scheme.labelFormat) 115 106 116 107 axes.set_aspect('auto')
Note: See TracChangeset
for help on using the changeset viewer.