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

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@5697
Revision 5697, 2.3 KB checked in by pnorton, 11 years ago (diff)

Extended the options available on the grid and contour slabs in the data reader backend. Also fixed a bug with the slab_option_parser and improved the legend rendering code.

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                                 labelInterval= self.parser.getOption('contour_label_interval'),
49                                 numLines = self.parser.getOption('num_contour_lines'),
50                                 fontSize = self.parser.getOption('contour_font_size'),
51                                 intervalColourbar = self.parser.getOption('intervalColourbar'),
52                                 intervalNames=intervalNames,
53                                 transparent=self.transparent)
54       
55        return ld
56
57
58               
59   
60
Note: See TracBrowser for help on using the repository browser.