source: qesdi/geoplot/trunk/lib/geoplot/layer_drawer_contour.py @ 6103

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/qesdi/geoplot/trunk/lib/geoplot/layer_drawer_contour.py@6103
Revision 6103, 2.5 KB checked in by pnorton, 10 years ago (diff)

Trying to get the different colour bars and plot options to work with the different legend types.

Line 
1"""
2A layer drawer that draws contours of the data onto an image object.
3"""
4
5import logging
6
7from geoplot.contour_drawer import ContourDrawer
8from geoplot.layer_drawer import LayerDrawerBase
9
10log = logging.getLogger(__name__)
11
12class LayerDrawerContour(LayerDrawerBase):
13    "Draw only the layer section of the plot"
14   
15    def __init__(self, cdmsVar,  numLines=10, fontSize='medium', labelInterval=1, 
16                 lineWidth=0.5, **kwargs):
17       
18        LayerDrawerBase.__init__(self, **kwargs)
19       
20        self._contourDrawer = ContourDrawer()
21        self.cdmsVar = cdmsVar
22        self.fontSize = fontSize
23        self.labelInterval =labelInterval
24        self.lineWidth = lineWidth
25        log.debug("kwargs = %s" % (kwargs,))
26        self.numLines = numLines
27       
28    def _drawToAxes(self, axes, xLimits, yLimits):
29        """
30        Draw the contours onto the axes.
31        """
32       
33        grid = self._buildGrid(self.cdmsVar, xLimits, yLimits)
34       
35        scheme = self._csBuilder.buildScheme(self.colourBarStyle, grid=grid)
36       
37        #if the projection is 'latlon' then no transformation is needed.
38        if self.projection == 'latlon':
39            basemap = None
40        else:
41            map = self._getMap(xLimits, yLimits)
42            basemap = map.basemap       
43       
44       
45        cmap = scheme.colourMap
46       
47        #set the bad colour to transparent
48        cmap.set_bad('w', 0.0)
49       
50        self._contourDrawer.draw(axes, grid, scheme,
51                                 basemap=basemap, fontSize=self.fontSize)
52   
53    ### properties ###
54         
55    def __set_numLines(self, value):
56        self._csBuilder.numIntervals = value - 1
57   
58    def __get_numLines(self):
59        return self._csBuilder.numIntervals + 1
60
61    numLines = property(__get_numLines, __set_numLines)
62   
63    def __set_fontSize(self, value):
64        self._fontSize = value
65   
66    def __get_fontSize(self):
67        return self._fontSize
68
69    fontSize = property(__get_fontSize, __set_fontSize)
70   
71    def __set_labelInterval(self, value):
72        self._contourDrawer.contourLabelInterval = value
73   
74    def __get_labelInterval(self):
75        return self._contourDrawer.contourLabelInterval
76
77    labelInterval = property(__get_labelInterval, __set_labelInterval)
78   
79    def __set_lineWidth(self, value):
80        self._contourDrawer.contourLineWidth = value
81   
82    def __get_lineWidth(self):
83        return self._contourDrawer.contourLineWidth
84   
85    lineWidth = property(__get_lineWidth, __set_lineWidth)
86
87       
Note: See TracBrowser for help on using the repository browser.