Metview's documentation is now on readthedocs!

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

# Metview Macro

#  **************************** LICENSE START ***********************************
# 
#  Copyright 2016 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: wind
# Title: Vorticity and Wind
# Description: Demonstrates how to combine a contour field and a wind field into a
#              single plot (inspired by an ecCharts product).
# See also:
# https://software.ecmwf.int/magics/Wind+examples+wind4
# ------------------------------------------------------------------


# read input grib files
my_vorticity= read("vorticity.grib")
my_uvwind= read("wind.grib")

# set up the contour for vorticity field
my_contour = mcont(contour_level_selection_type : "LEVEL_LIST",
                   contour_level_list           : [ -200.0,
                                                    -100.0,
                                                     -75.0,
                                                     -50.0,
                                                     -30.0, 
                                                     -20.0, 
                                                     -15.0, 
                                                     -13.0, 
                                                     -11.0, 
                                                      -9.0, 
                                                      -7.0, 
                                                      -5.0, 
                                                      -3.0, 
                                                      -1.0, 
                                                       1.0, 
                                                       3.0, 
                                                       5.0, 
                                                       7.0, 
                                                       9.0, 
                                                      11.0, 
                                                      13.0, 
                                                      15.0, 
                                                      20.0, 
                                                      30.0, 
                                                      50.0, 
                                                      75.0, 
                                                     100.0, 
                                                     200.0],
                    contour_shade                : "ON",
                    contour_shade_colour_method  : "LIST",
                    contour_shade_method         : "AREA_FILL",
                    contour_shade_colour_list    : ["rgb(0,0,0.3)",
                                                    "rgb(0,0,0.5)",
                                                    "rgb(0,0,0.7)",
                                                    "rgb(0,0,0.9)",
                                                    "rgb(0,0.15,1)",
                                                    "rgb(0,0.3,1)",
                                                    "rgb(0,0.45,1)",
                                                    "rgb(0,0.6,1)",
                                                    "rgb(0,0.75,1)",
                                                    "rgb(0,0.85,)",
                                                    "rgb(0.2,0.95,1)",
                                                    "rgb(0.45,1,1)",
                                                    "rgb(0.75,1,1)",
                                                    "none",
                                                    "rgb(1,1,0)",
                                                    "rgb(1,0.9,0)",
                                                    "rgb(1,0.8,0)",
                                                    "rgb(1,0.7,0)",
                                                    "rgb(1,0.6,0)",
                                                    "rgb(1,0.5,0)",
                                                    "rgb(1,0.4,0)",
                                                    "rgb(1,0.3,0)",
                                                    "rgb(1,0.15,0)",
                                                    "rgb(0.9,0,0)",
                                                    "rgb(0.7,0,0)",
                                                    "rgb(0.5,0,0)",
                                                    "rgb(0.3,0,0)"],
                    legend                       : "ON",
                    contour_hilo                 : "OFF",
                    contour                      : "OFF",
                    contour_highlight            : "OFF",
                    contour_label                : "OFF")

# set up the wind plotting                    
my_wind = mwind(wind_legend_text             : "BLACK WIND FLAGS (IN KNOTS)",
                wind_arrow_unit_velocity     : 10.00,
                wind_flag_origin_marker      : "DOT",
                wind_thinning_factor         : 10,
                wind_flag_length             : 0.30,
                wind_flag_origin_marker_size : 0.10,
                wind_field_type              : "FLAGS",
                wind_flag_colour             : "BLACK")

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

# set up the geographical view
my_view = geoview(map_area_definition : "CORNERS",
                  map_projection      : "POLAR_STEREOGRAPHIC",
                  area                : [21.51,-37.27,51.28,65.00],
                  coastlines          : my_coast)

# set up the title
my_title = mtext(text_font_size      : 0.60,
                 text_lines          : ["Vorticity and wind flags","Vorticity at 700 hPa",""],
                 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_vorticity,my_contour,my_uvwind,my_wind,my_title)
  • No labels