Debian Codegraph @

docs/tutorial/magics/z500_t850/solution/z500_t850.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 #Setting of the output file name
14 output = output({"output_formats":['ps', 'png'],
15 'output_name':'z500_t850_europe'})
16
17 #Setting the coordinates of the geographical area
18 europe = mmap({
19 "subpage_upper_right_longitude": 65.,
20 "subpage_map_projection": "polar_stereographic",
21 "subpage_map_vertical_longitude": 0.,
22 "subpage_lower_left_longitude": -37.27,
23 "subpage_lower_left_latitude": 21.51,
24 "subpage_upper_right_latitude": 51.28})
25
26 #Coastlines setting
27 coast = mcoast( { "map_grid": "on",
28 "map_grid_colour" : "tan",
29 "map_coastline_colour": "tan"})
30
31 #Import the z500 data
32 z500 = mgrib({ "grib_input_file_name" : "../z500.grb",
33 "grib_id": "z500"})
34
35 #Define the simple contouring for z500
36 z500_contour = mcont({
37 "legend": "off",
38 "contour_level_selection_type": "interval",
39 "contour_line_colour": "black",
40 "contour_hilo_height": 0.25,
41 "contour_line_thickness": 1,
42 "contour_hilo": "on",
43 "contour_hilo_quality": "high",
44 "contour_label": "off",
45 "contour_highlight_colour": "black",
46 "contour_highlight_thickness": 2,
47 "contour_interval": 5.})
48
49 #Import the t850 data
50 t850 = mgrib({ "grib_input_file_name" : "../t850.grb",
51 "grib_id": "t850"})
52
53
54 #Define the shading for t850
55 t850_contour = mcont({
56 "legend":"on",
57 "contour_shade": "on",
58 "contour_hilo": "off",
59 "contour": "off",
60 "contour_label": "off",
61 "contour_shade_method": "area_fill",
62 "contour_shade_max_level": 48.,
63 "contour_shade_min_level": -48.,
64 "contour_level_selection_type": "interval",
65 "contour_interval": 4.,
66 "contour_shade_colour_method": "list",
67 "contour_shade_colour_list": ["rgb(0,0,0.5)","rgb(0,0,0.5)",
68 "rgb(0,0,0.85)","rgb(0,0,0.5)","rgb(0,0,0.85)","rgb(0.25,0,1)",
69 "blue_purple","greenish_blue","blue_green","bluish_green",
70 "yellow_green","greenish_yellow","yellow",
71 "orangish_yellow","orange_yellow","yellowish_orange",
72 "orange","reddish_orange","red_orange","orangish_red",
73 "red","magenta","magenta","magenta"]
74 })
75
76 lines = [ "<grib_info id='z500' key='base-date' format='Base Date:%A %d %B %Y at %H UTC'/>",
77 "<grib_info id='z500' key='start-date' format='Valid Date:%A %d %B %Y at %H UTC'/>",
78 "<grib_info id='z500' key='name' format='parameter %s'/> <grib_info id='z500' key='level' format=' at %s hPa' />",
79 "<grib_info id='t850' key='name' format='parameter %s'/> <grib_info id='t850' key='level' format=' at %s hPa' />",
80 " I can also put my own title !"
81 ]
82
83 title = mtext({
84 "text_lines" : lines,
85 "text_html" : "true",
86 "text_colour" : "black",
87 "text_mode": "positional",
88 "text_box_x_position": 1.5,
89 "text_box_y_position": 14.,
90 "text_box_x_length": 20.,
91 "text_box_y_length": 3.5,
92 "text_border": "on",
93 "text_border_colour": "black",
94 "text_box_blanking": "on",
95 "text_justification" : "left"})
96
97 #add a legend
98 legend = mlegend({"legend":"on",
99 "legend_text_colour":"black",
100 "legend_box_mode": "positional",
101 "legend_box_x_position": 28.3,
102 "legend_box_y_position": 1.,
103 "legend_box_x_length": 2.,
104 "legend_box_y_length": 13.,
105 "legend_display_type": "continuous" })
106
107 #To the plot
108 plot(output, europe, t850, t850_contour, z500, z500_contour, coast, title, legend)
109