Changeset 6139 for qesdi


Ignore:
Timestamp:
15/12/09 15:27:48 (10 years ago)
Author:
pnorton
Message:

Made some further adjustments to the scheme builder code.

Location:
qesdi/geoplot/trunk/lib/geoplot
Files:
4 edited

Legend:

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

    r6118 r6139  
    8484        cbRange = self._getCbarRange(grid) 
    8585         
     86        log.debug("cbRange = %s" % (cbRange,)) 
     87         
    8688        if self.colourBarScale == COLOUR_SCHEME_SCALE.LOG: 
    8789            cbRange = self._adjustCBRangeForLog(cbRange) 
     
    140142 
    141143        if not grid is None: 
    142             cbMin = self.colourBarMin if self.colourBarMin != None else grid.getMinValue() 
    143             cbMax = self.colourBarMax if self.colourBarMax != None else grid.getMaxValue() 
     144            cbMin = self.colourBarMin if not self.colourBarMin is None else grid.getMinValue() 
     145            cbMax = self.colourBarMax if not self.colourBarMax is None else grid.getMaxValue() 
    144146        else: 
    145             cbMin = self.colourBarMin if self.colourBarMin != None else 0 
    146             cbMax = self.colourBarMax if self.colourBarMax != None else 1 
     147            cbMin = self.colourBarMin if not self.colourBarMin is None else 0 
     148            cbMax = self.colourBarMax if not self.colourBarMax is None else 1 
    147149         
    148150        # check for masked values in vmin and vmax, can occur when data is completly masked 
    149151        if cbMin.__class__ == numpy.ma.MaskedArray and cbMin.mask == True: 
    150             cbMin = None 
     152            cbMin = 0 
    151153             
    152154        if cbMax.__class__ == numpy.ma.MaskedArray and cbMax.mask == True: 
    153             cbMax = None         
     155            cbMax = 1         
    154156         
    155157        if cbMin is not None and cbMax is not None and cbMin > cbMax: 
  • qesdi/geoplot/trunk/lib/geoplot/colour_scheme_intervals.py

    r6118 r6139  
    7474        newBounds = bounds 
    7575         
    76         lowerBoundRemoved = False 
     76#        lowerBoundRemoved = False 
    7777                 
    7878        #start with the maximum of the first bound 
    79         for i in range(0, len(bounds)): 
     79        for i in range(1, len(bounds)): 
    8080            if bounds[i] <= cbRange.minimum: 
    81                 lowerBoundRemoved = True 
     81#                lowerBoundRemoved = True 
    8282                newBounds = newBounds[1:] 
    8383            else: 
    8484                break 
    8585         
    86         # if bounds lower than the minimum were removed add the minimum in as a 
    87         # bound 
    88         if lowerBoundRemoved: 
    89             newBounds = numpy.insert(newBounds, 0, cbRange.minimum) 
     86#        # if bounds lower than the minimum were removed add the minimum in as a 
     87#        # bound 
     88#        if lowerBoundRemoved: 
     89#            newBounds = numpy.insert(newBounds, 0, cbRange.minimum) 
    9090         
    91         upperBoundRemoved = False 
     91#        upperBoundRemoved = False 
    9292         
    9393        #start with the lower of the top bound 
    94         for i in range(len(bounds) - 1, -1, -1): 
     94        for i in range(len(bounds) - 2, -1, -1): 
    9595            if bounds[i] > cbRange.maximum: 
    9696                upperBoundRemoved = True 
     
    9999                break 
    100100             
    101         if upperBoundRemoved: 
    102             newBounds = numpy.append(newBounds, cbRange.maximum) 
     101#        if upperBoundRemoved: 
     102#            newBounds = numpy.append(newBounds, cbRange.maximum) 
    103103 
    104104        return newBounds 
  • qesdi/geoplot/trunk/lib/geoplot/tests/unit/test_colour_scheme_builder.py

    r6118 r6139  
    129129        adjustedRange = self.builder._adjustCBRangeForLog(Range(-10,-1)) 
    130130        nt.assert_almost_equal(adjustedRange.minimum, 1e-2) 
    131         nt.assert_almost_equal(adjustedRange.maximum, 1)         
     131        nt.assert_almost_equal(adjustedRange.maximum, 1) 
     132         
     133    def test_009_defaultCbarRange(self): 
     134         
     135         
     136        scheme = self.builder.buildScheme() 
     137         
     138        nt.assert_almost_equal(scheme.norm.vmin, 0) 
     139        nt.assert_almost_equal(scheme.norm.vmax, 1)        
    132140         
    133141if __name__ == '__main__': 
  • qesdi/geoplot/trunk/lib/geoplot/tests/unit/test_colour_scheme_interval_builder.py

    r6118 r6139  
    5555        cbInterval = self.builder.buildCSInterval(Range(25,45), COLOUR_SCHEME_SCALE.LINEAR, boundsString) 
    5656 
    57         expectedBounds = [25.0, 30.0, 40.0, 45] 
     57        expectedBounds = [20.0, 30.0, 40.0, 50.0] 
    5858        expectedMidpoints = geoplot.utils.getMidpoints(expectedBounds) 
    5959         
     
    9393        nt.assert_equal(len(cbInterval.midpoints), 11)             
    9494 
    95     def test_008_boundsPartiallyOutsideRangeAreCorrected(self): 
     95    def test_008_boundsPartiallyOutsideRangeLeft(self): 
    9696        boundsString = "10,160," 
    9797        cbInterval = self.builder.buildCSInterval(Range(0,100), COLOUR_SCHEME_SCALE.LINEAR, boundsString, 11) 
    98         expectedBounds = [10.0,100.0] 
     98        expectedBounds = [10.0,160.0] 
    9999         
    100100        nt.assert_true(test_utils._areNumericListsEqual(cbInterval.bounds, expectedBounds),  
     
    103103        boundsString = "-10,50" 
    104104        cbInterval = self.builder.buildCSInterval(Range(0,100), COLOUR_SCHEME_SCALE.LINEAR, boundsString, 11) 
    105         expectedBounds = [0.0,50.0] 
     105        expectedBounds = [-10.0,50.0] 
    106106         
    107107        nt.assert_true(test_utils._areNumericListsEqual(cbInterval.bounds, expectedBounds),  
Note: See TracChangeset for help on using the changeset viewer.