source: cows/trunk/cows/service/imps/data_reader_geoplot_backend/geoplot_slabs/geoplot_slab_grid.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_grid.py@5697
Revision 5697, 2.0 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 time
2import logging
3
4from geoplot.layer_drawer_grid import LayerDrawerGrid
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
11class GeoplotSlabGrid(GeoplotSlabBase):
12
13    style = 'grid'
14    title = 'Grid Boxes'
15                       
16    renderingOptions = [
17        RenderingOption('cmap', "Colour Scheme" ,str,'jet',["bone","jet", "copper", "gray", "winter"] ),
18        RenderingOption('cmap_min', "Legend Min" ,float,None),
19        RenderingOption('cmap_max', "Legend Max" ,float,None),
20        RenderingOption('intervalColourbar', "intervalColourbar" ,bool,False),
21        RenderingOption('intervalNames', "intervalNames" ,str,None),
22        RenderingOption('show_grid_lines', "Draw Grid Boxes" ,bool,False),
23    ]                       
24       
25    def _setupLayerDrawer(self):
26       
27        cmapMin = self.parser.getOption('cmap_min')
28        if cmapMin == None:
29            cmapMin = self.variable.min()
30       
31        cmapMax = self.parser.getOption('cmap_max')
32        if cmapMax == None:
33            cmapMax = self.variable.max()
34           
35        intervalNames = self.parser.getOption('intervalNames')
36        if intervalNames != None:
37            intervalNames = intervalNames.split(',')
38       
39        log.debug("self.transparent = %s" % (self.transparent,))
40       
41        ld = LayerDrawerGrid(self.variable, 
42                             cmap=self.parser.getOption('cmap'), 
43                             showGridLines=self.parser.getOption('show_grid_lines'), 
44                             cmapRange=(cmapMin, cmapMax),
45                             intervalColourbar = self.parser.getOption('intervalColourbar'),
46                             intervalNames=intervalNames,                             
47                             transparent=self.transparent)
48       
49        return ld
50 
Note: See TracBrowser for help on using the repository browser.