Metview's documentation is now on readthedocs!

# 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
# Title: Rainbow Isolines
# Description: Demonstrates how to plot a field using coloured contour isolines.
# See also:
# https://software.ecmwf.int/magisc/Contour+examples+contour7
# ------------------------------------------------------------------

# read the input grib file
my_data = read("t850.grb")


# set up the coastlines
my_coast = mcoast(map_coastline_land_shade        : "ON",
                  map_coastline_land_shade_colour : "CREAM",
                  map_grid                        : "ON",
                  map_grid_colour                 : "TAN",
                  map_coastline_colour            : "TAN")

# set up the contour so that isolines have colour
my_contour = mcont(contour_level_selection_type                 : "INTERVAL",
                   contour_interval                             : 1.00,
                   contour_highlight                            : "OFF",
                   contour_line_colour_rainbow                  : "ON",
                   contour_line_colour_rainbow_method           : "CALCULATE",
                   contour_line_colour_rainbow_max_level_colour : "RED",
                   contour_line_colour_rainbow_min_level_colour : "BLUE",
                   contour_line_colour_rainbow_direction        : "CLOCKWISE")

# set-up the title
my_title = mtext(text_font_size     : 0.5,
                 text_lines         : ["Rainbow technique to colour the isolines", 
                                       "Computing a range of colours:",
                                       "<font colour='evergreen'>contour_line_colour_rainbow = on</font> ",
                                       "<font colour='evergreen'>contour_line_colour_rainbow_min_level_colour/contour_line_colour_rainbow_max_level_colour</font>",
                                       ""],
                 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_coast,my_data,my_contour,my_title)