Ignore:
Timestamp:
04/12/09 16:07:45 (11 years ago)
Author:
pnorton
Message:

Imroved the colour bar code so that a legend colour bar can be used without specifying any intervals.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • qesdi/geoplot/trunk/lib/geoplot/layer_drawer.py

    r5980 r6089  
    77import logging 
    88import time 
     9import numpy 
    910 
    1011import matplotlib.colors 
     
    1213 
    1314import geoplot.utils as geoplot_utils 
    14 from geoplot.colour_bar import ColourBar 
     15from geoplot.colour_bar import COLOUR_BAR_STYLES 
    1516from geoplot.grid_factory import GridFactory 
    1617from geoplot.map_factory import MapFactory 
    1718from geoplot.colour_scheme import ColourSchemeBuilder 
    1819import geoplot.utils as utils 
     20 
     21from geoplot.colour_bar import COLOUR_SCHEME_SCALE 
    1922 
    2023log = logging.getLogger(__name__) 
     
    3639                 colourBarMax=None,  
    3740                 colourBarScale='linear', 
     41                 colourBarStyle=COLOUR_BAR_STYLES.CONTINUOUS, 
    3842                 intervals=None,  
    3943                 bgcolour='white'): 
     
    4246        self._csBuilder = ColourSchemeBuilder() 
    4347        self._bgcolour = 'white' 
     48         
     49        self.colourBarStyle = colourBarStyle 
    4450         
    4551        self.colourBarScale = colourBarScale 
     
    176182             
    177183        return map         
     184 
     185    def _applyMask(self, grid, scheme, hideOutside): 
     186        """ 
     187        Masks the data outside the scheme bounds if hideOutside is true, also 
     188        masks values less than zero if a log scale is being used 
     189        """ 
     190         
     191        if self._hideOutsideBounds: 
     192            grid.values = numpy.ma.masked_less(grid.values, scheme.norm.vmin) 
     193            grid.values = numpy.ma.masked_greater(grid.values, scheme.norm.vmax) 
     194         
     195        if scheme.scale == COLOUR_SCHEME_SCALE.LOG: 
     196            grid.values = numpy.ma.masked_less_equal(grid.values, 0.0) 
     197             
     198        return grid 
    178199         
    179200    ### properties ###         
Note: See TracChangeset for help on using the changeset viewer.