source: qesdi/geoplot/trunk/lib/geoplot/tests/drawing/draw_test_grid_plot.py @ 5876

Subversion URL: http://proj.badc.rl.ac.uk/svn/ndg/qesdi/geoplot/trunk/lib/geoplot/tests/drawing/draw_test_grid_plot.py@5876
Revision 5876, 2.6 KB checked in by pnorton, 11 years ago (diff)

Added a faster layer drawer for the grid, a new style of colour bar and colour schemes which now hold the normalisation and colour map instances.

Line 
1import os
2import logging
3
4import geoplot
5from geoplot.tests.make_data_functions import fnSinXAddCosY_10to10
6
7log = logging.getLogger(__name__)
8       
9
10if __name__ == '__main__':
11
12    from geoplot.tests.drawing import getDrawingOutputDir
13    from geoplot.log_util import SHORT_LOG_FORMAT_STRING, LOG_FORMAT_STRING
14    logging.basicConfig(level=logging.DEBUG, format=SHORT_LOG_FORMAT_STRING)
15   
16    outputDir = getDrawingOutputDir()
17   
18    from geoplot.grid_plot import GridPlot
19    from geoplot.tests.make_ll_grid_data import makeLLVar
20
21    plot_format = 'png'
22    outputFile = outputDir + '/grid_plot_lat_lon.' + plot_format
23
24    eg_metadata_list = [("Dataset", "MOHC Probabilistic Land"),
25                        ("Variable", "Mean Temperature"),
26                        ("Emissions Scenario", "Medium (A1B)"),
27                        ("Time Slice", "2040-2079"),
28                        ("Temporal Av. Period", "Spring"),
29                        ("Percentile", "10th")]
30
31    # show the whole grid
32    #xLimits=(-13.0, 6.2), yLimits=(47.0, 61.0)
33    # show the whole of the uk
34    #xLimits=(-11.0, 2.8), yLimits=(48.0, 60.0)
35    #xLimits=( -2.0,   2.0), yLimits=( 50.0, 54.0),
36    #xLimits=(  0.0, 359.8), yLimits=(-90.0, 89.8),
37    xLimits=(-20.0,  15.0); yLimits=( 40.0, 70.0)
38    #xLimits=( -7.0,   2.0), yLimits=( 54.0, 64.0)  scotland
39    #xLimits=( -8.0,   1.0), yLimits=( 52.0, 64.0) ,
40
41    #var = makeLLVar(lonBounds=xLimits, latBounds=yLimits, nx=20, ny=20)
42    from geoplot.legend_colour_bar import LegendColourBar
43    geoplot.plot_base.ColourBar = LegendColourBar
44    LegendColourBar.__name__ = 'ColourBar'
45   
46    var = makeLLVar(lonBounds=xLimits, latBounds=yLimits, nx=20, ny=20, function=fnSinXAddCosY_10to10, missing_value=-999)
47
48    plot =  GridPlot(cdmsVar=var, format = plot_format,
49                    fontSize = 'medium', units = 'A Test Plot',
50                    plotTitle = "A Test Plot", showGridLines = True,
51                    drawLogo = True, metadataList = eg_metadata_list,
52                    drawCoast = True, drawRivers = True,
53                    drawColourBar = True, drawValues = True,
54                    xLimits=xLimits, yLimits=yLimits,
55                    colourBarPosition='vertical',
56                    intervalColourbar=True,
57                   
58                    intervals="-10,-7.5,-5,-2.5,0,2.5,5,7.5,10",
59                    #intervalNames=','.join(list('abcdefgh'))
60                   
61                    #intervalNames=','.join(list('abcdefghijklmnopqrst'))
62                    )
63
64    plot.drawMap(outputFile)
65   
66    log.debug('wrote %s' % outputFile)   
Note: See TracBrowser for help on using the repository browser.