Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

# Metview Macro

#  **************************** LICENSE START ***********************************
# 
#  Copyright 20152016 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 geographical viewcontour for vorticity field
my_viewcontour = geoviewmcont(mapcontour_level_areaselection_definitiontype : "CORNERSLEVEL_LIST",
                  map_projection  contour_level_list           : "POLAR_STEREOGRAPHIC",
 [ -200.0,
                                   area                : [21.51,-37100.27,51.28,65.00])

# 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",
0,
                                        contour_level_list           : [ -20075.0,
                                                     -10050.0,
                                                     -7530.0, 
                                                     -5020.0, 
                                                     -3015.0, 
                                                     -2013.0, 
                                                     -1511.0, 
                                                      -139.0, 
                                                      -117.0, 
                                                      -95.0, 
                                                      -73.0, 
                                                      -51.0, 
                                                       -31.0, 
                                                      -1 3.0, 
                                                       15.0, 
                                                       37.0, 
                                                       59.0, 
                                                       711.0, 
                                                       913.0, 
                                                      1115.0, 
                                                      1320.0, 
                                                      1530.0, 
                                                      2050.0, 
                                                      3075.0, 
                                                      50100.0, 
                                                      75200.0], 
                    contour_shade                : "ON",
                100.0, 
   contour_shade_colour_method  : "LIST",
                    contour_shade_method         : "AREA_FILL",
                 200.0],
   contour_shade_colour_list    : ["rgb(0,0,0.3)",
            contour_shade                : "ON",
                    contour_shade_colour_method  : "LISTrgb(0,0,0.5)",
                    contour_shade_method         : "AREA_FILL",
                    contour_shade_colour_list     : ["rgb(0,0,0.37)",
                                                    "rgb(0,0,0.59)",
                                                    "rgb(0,0.15,0.71)",
                                                    "rgb(0,0.3,0.91)",
                                                    "rgb(0,0.1545,1)",
                                                    "rgb(0,0.36,1)",
                                                    "rgb(0,0.4575,1)",
                                                    "rgb(0,0.685,1)",
                                                    "rgb(0.2,0.7595,1)",
                                                    "rgb(0.45,0.851,1)",
                                                    "rgb(0.275,0.951,1)",
                                                    "rgb(0.45,1,1)none",
                                                    "rgb(0.751,1,10)",
                                                      "none"rgb(1,0.9,0)",
                                                    "rgb(1,10.8,0)",
                                                    "rgb(1,0.97,0)",
                                                    "rgb(1,0.86,0)",
                                                    "rgb(1,0.75,0)",
                                                    "rgb(1,0.64,0)",
                                                    "rgb(1,0.53,0)",
                                                    "rgb(1,0.415,0)",
                                                    "rgb(10.9,0.3,0)",
                                                    "rgb(10.7,0.15,0)",
                                                    "rgb(0.95,0,0)",
                                                    "rgb(0.73,0,0)"],
                    legend                       : "ON",
        "rgb(0.5,0,0)",
             contour_hilo                 : "OFF",
                    contour             "rgb(0.3,0,0)"],
         : "OFF",
          legend          contour_highlight             : "ONOFF",
                    contour_hilolabel                 : "OFF",)

# set up the wind plotting               contour     
my_wind = mwind(wind_legend_text             : "BLACK WIND FLAGS : "OFF(IN KNOTS)",
                    contour_highlightwind_arrow_unit_velocity            : "OFF"10.00,
                wind_flag_origin_marker     contour_label : "DOT",
              : "OFF")

# set up the wind plotting wind_thinning_factor         : 10,
              
my_wind = mwind(wind_legendflag_textlength             : "BLACK WIND FLAGS (IN KNOTS)"0.30,
                wind_arrowflag_origin_unit_velocity     marker_size : 0.10.00,
                wind_flag_origin_markerfield_type              : "DOTFLAGS",
                wind_thinningflag_factorcolour         : 10,
   : "BLACK")

#            wind_flag_length set up the coastlines
my_coast = mcoast(map_coastline_sea_shade            : 0.30"ON",
                  windmap_flagcoastline_originland_markershade_sizecolour : 0.10"CREAM",
                wind_field_type  map_grid            : "FLAGS",
                wind_flag_colour : "ON",
            : "BLACK")

# set up the coastlines
my_coast = mcoast(map_coastline_sealand_shade         : "ON",
                  map_coastline_landsea_shade_colour  : "CREAMWHITE",
                  map_gridlabel                        : "ON",
                  map_coastline_land_shade       colour            : "TAN")

# set up the geographical view
my_view = geoview(map_area_definition : "ONCORNERS",
                  map_coastline_sea_shade_colourprojection      : "WHITEPOLAR_STEREOGRAPHIC",
                  map_label area                      : "ON": [21.51,-37.27,51.28,65.00],
                  map_coastline_colour  coastlines          : "TAN"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_coast,my_title)