source: cows/trunk/cows/service/imps/data_reader_geoplot_backend/geoplot_slabs/geoplot_slab_contour.py @ 5761

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/cows/trunk/cows/service/imps/data_reader_geoplot_backend/geoplot_slabs/geoplot_slab_contour.py@5761
Revision 5761, 2.4 KB checked in by pnorton, 11 years ago (diff)

Added the ability to set background colours and some other options for the data renderer implementation.

Line 
1import logging
2import time
3
4from geoplot.layer_drawer_contour import LayerDrawerContour
5
6from cows.service.imps.data_reader_geoplot_backend.rendering_option import RenderingOption
7from cows.service.imps.data_reader_geoplot_backend.geoplot_slabs.geoplot_slab_base import GeoplotSlabBase
8
9log = logging.getLogger(__name__)
10
11
12
13class GeoplotSlabContour(GeoplotSlabBase):
14
15    style = 'contour'
16    title = 'Contour Lines'
17                     
18    renderingOptions = [
19        RenderingOption('cmap', "Colour Scheme" ,str,'jet',["bone","jet", "copper", "gray", "winter"] ),
20        RenderingOption('cmap_min', "Legend Min" ,float,None),
21        RenderingOption('cmap_max', "Legend Max" ,float,None),
22        RenderingOption('intervalColourbar', "intervalColourbar" ,bool,False),
23        RenderingOption('intervalNames', "intervalNames" ,str,None),
24        RenderingOption('cmap_max', "Legend Max" ,float,None),
25        RenderingOption('num_contour_lines', "Number of Contour Lines" ,int,10),
26        RenderingOption('contour_font_size', "Contour Label Size" ,str,'medium',["small","medium", "large",]),
27        RenderingOption('contour_label_interval', "Interval Between Labels" ,int,1),
28    ]
29
30    def _setupLayerDrawer(self):
31       
32        cmapMin = self.parser.getOption('cmap_min')
33        if cmapMin == None:
34            cmapMin = self.variable.min()
35       
36        cmapMax = self.parser.getOption('cmap_max')
37        if cmapMax == None:
38            cmapMax = self.variable.max()
39       
40        intervalNames = self.parser.getOption('intervalNames')
41        if intervalNames != None:
42            intervalNames = intervalNames.split(',')
43       
44           
45        ld = LayerDrawerContour(self.variable, 
46                                 cmap=self.parser.getOption('cmap'), 
47                                 cmapRange=(cmapMin, cmapMax),
48                                 bgcolour = slef.bgcolour,
49                                 labelInterval= self.parser.getOption('contour_label_interval'),
50                                 numLines = self.parser.getOption('num_contour_lines'),
51                                 fontSize = self.parser.getOption('contour_font_size'),
52                                 intervalColourbar = self.parser.getOption('intervalColourbar'),
53                                 intervalNames=intervalNames,
54                                 transparent=self.transparent)
55       
56        return ld
57
58
59               
60   
61
Note: See TracBrowser for help on using the repository browser.