| 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 = 'contour4' |
| 15 |
|
| 16 |
#Setting of the output file name |
| 17 |
output = output(output_formats = ['png'], |
| 18 |
output_name_first_page_number = "off", |
| 19 |
output_name = ref) |
| 20 |
|
| 21 |
#Setting the coordinates of the geographical area |
| 22 |
projection = mmap(subpage_upper_right_longitude = 65.00, |
| 23 |
subpage_upper_right_latitude = 51.28, |
| 24 |
subpage_lower_left_latitude = 21.51, |
| 25 |
subpage_lower_left_longitude = -37.27, |
| 26 |
subpage_map_projection = 'polar_stereographic') |
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
#Coastlines setting |
| 31 |
coast = mcoast( map_grid = "on", |
| 32 |
map_grid_colour = "tan", |
| 33 |
map_coastline_land_shade = 'on', |
| 34 |
map_coastline_land_shade_colour = 'cream', |
| 35 |
map_coastline_colour = "tan") |
| 36 |
|
| 37 |
|
| 38 |
#Import the t850 data |
| 39 |
t850 = mgrib(grib_input_file_name = "t850.grb", |
| 40 |
grib_field_position = 1) |
| 41 |
|
| 42 |
|
| 43 |
#Define a red contour for the positif values |
| 44 |
positif = mcont( legend = "off", |
| 45 |
contour_level_selection_type = "interval", |
| 46 |
contour_interval=5., |
| 47 |
contour_min_level=2., |
| 48 |
contour_line_colour = "red", |
| 49 |
contour_line_thickness = 2, |
| 50 |
contour_label = "on", |
| 51 |
contour_label_height = 0.3, |
| 52 |
contour_highlight="off") |
| 53 |
|
| 54 |
|
| 55 |
#Define a blue contour for the negative values |
| 56 |
negatif = mcont( legend = "off", |
| 57 |
contour_level_selection_type = "interval", |
| 58 |
contour_interval=5., |
| 59 |
contour_max_level=-2., |
| 60 |
contour_min_level=-1000., |
| 61 |
contour_line_colour = "blue", |
| 62 |
contour_line_thickness = 2, |
| 63 |
contour_label = "on", |
| 64 |
contour_label_height = 0.4, |
| 65 |
contour_highlight="off") |
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
#Define a blue contour for the negative values |
| 70 |
zero = mcont( legend = "off", |
| 71 |
contour_min_level=-1., |
| 72 |
contour_max_level=1., |
| 73 |
contour_level_selection_type = "level_list", |
| 74 |
contour_level_list=[0.], |
| 75 |
contour_line_colour = "black", |
| 76 |
contour_line_thickness = 4, |
| 77 |
contour_label = "off", |
| 78 |
contour_highlight="off") |
| 79 |
|
| 80 |
|
| 81 |
title = mtext( |
| 82 |
text_lines = ["Positive values are <font colour='red'>red </font>", |
| 83 |
"Negative values are <font colour='blue'>blue </font>", |
| 84 |
"0 is a black line "], |
| 85 |
text_justification = "left", |
| 86 |
text_font_size = 0.8, |
| 87 |
text_colour = "charcoal") |
| 88 |
|
| 89 |
|
| 90 |
#To the plot |
| 91 |
plot(output, projection, coast, t850, positif, t850, negatif, t850, zero, title) |
| 92 |
|
| 93 |
#For documentation only |
| 94 |
tofortran(ref, output, projection, coast, t850, positif, negatif, zero, title) |
| 95 |
tomv4(ref, positif, negatif, zero) |
| 96 |
tohtml(ref, positif, negatif, zero) |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|