source: qesdi/geoplot/trunk/lib/geoplot/tests/drawing/draw_test_grid_plot_rotated.py @ 5610

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

Modified the existing plot_base into a grid_plot class that uses the new map and grid factories.

I've also modified the plot_lat_lon, plot_national and plot_rotated to used the grid_plot as a base class.

Line 
1
2import sys
3import os
4import logging
5import pkg_resources
6import cdms2 as cdms
7
8
9log = logging.getLogger(__name__)
10       
11
12if __name__ == '__main__':
13   
14    from geoplot.tests.drawing import getDrawingOutputDir
15    from geoplot.log_util import SHORT_LOG_FORMAT_STRING, LOG_FORMAT_STRING
16    logging.basicConfig(level=logging.DEBUG, format=SHORT_LOG_FORMAT_STRING)
17   
18    from geoplot.plot_rotated_grid import PlotRotatedGrid
19   
20    outputsDir = getDrawingOutputDir()
21    testDataDir = pkg_resources.resource_filename('geoplot', 'tests/data')
22   
23#    dataFile = testDataDir + '/rg_test.nc'
24#    dataVariable = 'air_temperature'
25
26    dataFile = testDataDir + '/rg_test3.nc'
27    dataVariable = 'temp'
28
29#    dataFile = testDataDir +'/grid_box_25km_subset.nc'
30
31#    dataFile = testDataDir +'/grid_box_25km_subset.cdml'
32#    dataVariable = 'cdf_temp_dmean_tmean_abs'
33   
34
35#    f = cdms.open(dataFile)
36#    var = f(dataVariable, squeeze = 1)
37#    var.setMissing(0.0)
38    #rotated_pole_var = f[var.grid_mapping]
39
40    f = cdms.open(dataFile)
41    var = f(dataVariable, squeeze=1)
42    rotated_pole_var = f['rotated_pole']
43   
44#    from geoplot.tests.make_rotated_grid_data import makeRotatedGridVar
45#    var, rotated_pole_var = makeRotatedGridVar()
46
47    eg_metadata_list = [("Dataset", "MOHC Probabilistic Land"),
48                        ("Variable", "Mean Temperature"),
49                        ("Emissions Scenario", "Medium (A1B)"),
50                        ("Time Slice", "2040-2079"),
51                        ("Temporal Av. Period", "Spring"),
52                        ("Percentile", "10th")]
53
54    #c = [( 255, 255, 255)]
55    #import geoplot.utils
56    #cmap = geoplot.utils.generateDiscreteCmap(c, "ukcip08") # create the custom colour map
57    #cmap.set_bad('w')   # sets the bad data colour to white (same as the default colour map)
58
59#southwest xLimits = (-6.0, -1.0), yLimits = (50.0, 54.0)
60#wales xLimits = (-5.7, -2.0), yLimits = (51.0, 53.5),
61#southeast xLimits = (-2.0, 2.0), yLimits = (50.0, 54.0),
62#northeast xLimits = (-3.0, 0.5), yLimits = (52.0, 60.0),
63#northwest xLimits = (-3.5, -1.5), yLimits = (53.0, 55.0),
64#scotland xLimits = (-7.5, -0.5), yLimits = (54.0, 61.0),
65#northernireland xLimits = (-8.0,-5.0), yLimits = (53.0, 56.0),
66#isleofman xLimits = (-4.8,-4.2), yLimits = (54.0, 54.5),
67
68    prg = PlotRotatedGrid(var, rotated_pole_var,
69                         drawValues=False, fontSize="large",
70                         units="degrees C", plotTitle="A Test Plot",
71                         drawLogo=True, metadataList=eg_metadata_list, showGridLines=True,
72#                         xLimits = (-8.0,-5.0), yLimits = (53.0, 56.0),
73                         xLimits=(-17.0, 6.0), yLimits=(47.0, 62.0),
74                         #xLimits=(0.0, 5.0), yLimits=(50.0, 55.0),                                                 
75                         colourBarPosition='horizontal', drawRivers=False,
76                         drawColourBar=True, format='jpg', outputCMYK=False)
77
78    outputFile = outputsDir + '/rotated_grid_test.' + prg.format
79   
80    prg.drawMap(outputFile)
81    log.debug('wrote %s' % (outputFile,))
82
83    #prg.format = "ps"
84    #outputFile = outputsDir + '/rotated_grid_test.' + prg.format
85    #prg.drawMap(outputFile)
86    #log.debug('wrote %s' % outputFile)
Note: See TracBrowser for help on using the repository browser.