Debian Codegraph @

docs/confluence/contour/contour5.py

raw
1 # (C) Copyright 1996-2016 ECMWF.
2 #
3 # This software is licensed under the terms of the Apache Licence Version 2.0
4 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5 # In applying this licence, ECMWF does not waive the privileges and immunities
6 # granted to it by virtue of its status as an intergovernmental organisation nor
7 # does it submit to any jurisdiction.
8
9
10 #importing Magics module
11 from Magics.macro import *
12
13
14 ref = 'contour5'
15 #Setting of the output file name
16 output = output(output_formats = ['png'],
17 output_name_first_page_number = "off",
18 output_name = ref)
19
20 #Setting the coordinates of the geographical area
21 projection = mmap(
22 subpage_x_length = 24.,
23 subpage_upper_right_longitude = 50.00,
24 subpage_upper_right_latitude = 65.00,
25 subpage_lower_left_latitude = 25.00,
26 subpage_lower_left_longitude = -20.00,
27 subpage_map_projection = 'cylindrical')
28
29
30
31 #Coastlines setting
32 coast = mcoast( map_grid = "on",
33 map_grid_colour = "grey",
34 map_grid_thickness = 2,
35 map_coastline_colour = "RGB(0.4,0.4,0.4)",
36 map_coastline_thickness = 3)
37
38
39 #Import the t850 data
40 t850 = mgrib(grib_input_file_name = "t850.grb",
41 grib_field_position = 1)
42
43
44
45 #Define a contour using a predefined contour level_list
46 contour = mcont( legend = "on",
47 contour_level_selection_type = "level_list",
48 contour_level_list=[-20., -10., -5., -2.5, -1, -0.5, 0., 0.5, 1, 2.5, 5, 10, 20, 50],
49 contour_line_colour = "grey",
50 contour_line_thickness = 2,
51 contour_label = "off",
52 contour_highlight="off",
53 contour_shade = "on",
54 contour_shade_method = "area_fill",
55 contour_shade_colour_method = "calculate",
56 contour_shade_max_level_colour = "red",
57 contour_shade_min_level_colour = "blue",
58 contour_shade_colour_direction = "clockwise"
59 )
60
61
62
63 title = mtext(
64 text_lines = ["<font size='1'>Using Shading and positional legend ...</font>",
65 "<font colour='evergreen'>contour_level_selection_type = level_list</font> ",
66 " uses a user-defined list of contour levels.",
67 "[-20., -10., -5., -2.5, -1, -0.5, 0., 0.5, 1, 2.5, 5, 10, 20, 50]"],
68 text_justification = "left",
69 text_font_size = 0.8,
70 text_colour = "charcoal")
71
72
73 legend = mlegend(legend='on',
74 legend_display_type='continuous',
75 legend_border='off',
76 legend_title='on',
77 legend_title_text='My Title',
78 legend_title_orientation='vertical',
79 legend_text_font_size=0.5,
80 legend_text_colour="navy",
81 legend_box_mode ='positional',
82 legend_box_x_position = 26.,
83 legend_box_x_length=2.,
84 legend_box_y_position=2.,
85 legend_box_y_length=10.
86 )
87
88 #To the plot
89 plot(output, projection, t850, contour, coast, legend,title)
90
91 #For documentation only
92 tofortran(ref, output, projection, t850, contour, coast, legend,title)
93 tomv4(ref, contour)
94 tohtml(ref, t850, contour)
95
96
97
98
99
100
101
102
103
104
105
106
107
108