source: cows/trunk/cows/service/imps/data_reader_geoplot_backend/geoplot_slabs/geoplot_slab_grid.py @ 5877

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

Modified the geoplot renderer to take advantage of the faster layer drawer.

Line 
1import time
2import logging
3
4from geoplot.layer_drawer_grid import LayerDrawerGrid
5from geoplot.layer_drawer_grid_fast import LayerDrawerGridFast
6
7from cows.service.imps.data_reader_geoplot_backend.rendering_option import RenderingOption
8from cows.service.imps.data_reader_geoplot_backend.geoplot_slabs.geoplot_slab_base import GeoplotSlabBase
9
10log = logging.getLogger(__name__)
11
12class GeoplotSlabGrid(GeoplotSlabBase):
13
14    style = 'grid'
15    title = 'Grid Boxes'
16                       
17    renderingOptions = [
18        RenderingOption('cmap', "Colour Scheme" ,str,'jet',["bone","jet", "copper", "gray", "winter"] ),
19        RenderingOption('cbar_style', 'Colour Bar Style', str, 'continuous', ['continuous','legend']),
20        RenderingOption('disable_subset', "Disable Subsetting" ,bool,False),
21        RenderingOption('cmap_min', "Legend Min" ,float,None),
22        RenderingOption('cmap_max', "Legend Max" ,float,None),
23        RenderingOption('intervals', "intervals" ,str,None),
24        RenderingOption('intervalNames', "intervalNames" ,str,None),
25        RenderingOption('show_grid_lines', "Draw Grid Boxes" ,bool,False),
26    ]                       
27       
28    def _setupLayerDrawer(self):
29       
30        cmapMin = self.parser.getOption('cmap_min')
31        cmapMax = self.parser.getOption('cmap_max')
32           
33        intervalNames = self.parser.getOption('intervalNames')
34        if intervalNames != None:
35            intervalNames = intervalNames.split(',')
36       
37        log.debug("self.transparent = %s" % (self.transparent,))
38        log.debug("self.bgcolour = %s" % (self.bgcolour,))
39   
40        if self.parser.getOption('disable_subset'):
41            ldClass = LayerDrawerGrid
42        else:
43            ldClass = LayerDrawerGridFast
44   
45   
46        ld = ldClass(self.variable, 
47                     cmap=self.parser.getOption('cmap'), 
48                     showGridLines=self.parser.getOption('show_grid_lines'), 
49                     colourBarMin=cmapMin,
50                     colourBarMax=cmapMax,
51                     bgcolour = self.bgcolour,
52                     intervals = self.parser.getOption('intervals'),   
53                     transparent=self.transparent)
54       
55        return ld
56 
Note: See TracBrowser for help on using the repository browser.