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

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

Made some modifications to the data renderer backend. The display options are now attached to each of the slabs rather than being stored in the shared option parser and the controller.

I've also added some code to generate the display options JSON string.

RevLine 
[5692]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('num_contour_lines', "Number of Contour Lines" ,int,10),
23        RenderingOption('contour_font_size', "Contour Label Size" ,str,'medium',["small","medium", "large",]),
24        RenderingOption('contour_label_interval', "Interval Between Labels" ,int,1),
25    ]
26
27    def _setupLayerDrawer(self):
28       
29        cmapMin = self.parser.getOption('cmap_min')
30        if cmapMin == None:
31            cmapMin = self.variable.min()
32       
33        cmapMax = self.parser.getOption('cmap_max')
34        if cmapMax == None:
35            cmapMax = self.variable.max()
36           
37        ld = LayerDrawerContour(self.variable, 
38                                 cmap=self.parser.getOption('cmap'), 
39                                 cmapRange=(cmapMin, cmapMax),
40                                 labelInterval= self.parser.getOption('contour_label_interval'),
41                                 numLines = self.parser.getOption('num_contour_lines'),
42                                 fontSize = self.parser.getOption('contour_font_size'),
43                                 transparent=self.transparent)
44       
45        return ld
46
47
48               
49   
50
Note: See TracBrowser for help on using the repository browser.