Image Added
Image Removed
# Metview Macro
# **************************** LICENSE START ***********************************
#
# Copyright 2015 ECMWF. This software is distributed under the terms
# of the Apache License version 2.0. In applying this license, ECMWF does not
# waive the privileges and immunities granted to it by virtue of its status as
# an Intergovernmental Organization or submit itself to any jurisdiction.
#
# ***************************** LICENSE END ************************************
# ------------------------------------------------------------------
# Tags: contour,legend
# Title: Contour Shading and Positional Legend
# Description: Demonstrates how to show a field using contour shading and
# define a positional vertical legend.
# See also:
# https://software.ecmwf.int/magics/Contour+examples+contour5
# ------------------------------------------------------------------
# read the input grib file
my_data = read("t850.grb")
# set up the geographical view
my_view = geoview(map_area_definition : "CORNERS",
map_projection : "CYLINDRICAL",
area : [20.00,-20.00,70.00,50.00])
# set up the coastlines
my_coast = mcoast(map_coastline_thickness : 3,
map_grid_thickness : 2,
map_grid_colour : "GREY",
map_coastline_colour : "RGB(0.4,0.4,0.4)",
map_grid : "ON")
# set up the contour so that colour shading is used
my_contour = mcont(contour_level_selection_type : "LEVEL_LIST",
contour_level_list : [-20,-10,-5,-2.5,-1,-0.5,0,0.5,1,2.5,5,10,20,30],
contour_shade : "ON",
contour_shade_method : "AREA_FILL",
contour_shade_colour_method : "CALCULATE",
contour_shade_colour_direction : "CLOCKWISE",
contour_shade_max_level_colour : "RED",
contour_shade_min_level_colour : "BLUE",
contour_line_colour : "GREY",
contour_line_thickness : 2,
contour_highlight : "OFF",
contour_label : "OFF",
legend : "ON")
# set up the position and properties of the legend
my_legend = mlegend(legend_title : "ON",
legend_box_mode : "POSITIONAL",
legend_box_x_position : 26.00,
legend_box_x_length : 2.00,
legend_box_y_position : 2.00,
legend_box_y_length : 10.00,
legend_display_type : "CONTINUOUS",
legend_border : "OFF",
legend_text_font_size : 0.50,
legend_text_colour : "NAVY",
legend_title_text : "850hpa Temperature",
legend_title_orientation : "VERTICAL")
# set up the title
my_title = mtext(text_font_size : 0.70,
text_lines : ["Contour shading and positional legend.",
"User-defined list of contour levels.",
""],
text_justification : "LEFT",
text_colour : "CHARCOAL")
# define the output media
to_psfile = ps_output
(
output_name : "plot" # extension is added automatically
)
# check the runmode and decide which media to putput the plot to
mode = runmode()
if (mode = "execute") then setoutput(to_psfile)
else if (mode = "batch") then setoutput(to_psfile)
else if (mode = "visualise") then print('screen')
else fail("Only execute, batch and visualise allowed")
end if
# plot the data onto the map
plot(my_view,my_data,my_contour,my_legend,my_coast,my_title)