#Metview Macro
# **************************** LICENSE START ***********************************
#
# Copyright 2019 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 ************************************
#
# read ENS forecast
g = read("wgust_ens.grib")
# filter out a timestep
wg = read(data: g, step: 78)
# create mask (with 0s and 1s) for windgust > 22 m/s
wg_mask = wg > 22
# compute probability
prob = mean(wg_mask) * 100
# define contour shading
cont = mcont(
legend : "on",
contour_line_colour : "charcoal",
contour_highlight : "off",
contour_min_level : 1,
contour_level_count : 6,
contour_shade : "on",
contour_shade_colour_method : "palette",
contour_shade_method : "area_fill",
contour_shade_palette_name : "eccharts_purple_magenta_6"
)
# define coastline
coast = mcoast(
map_coastline_land_shade : "on",
map_coastline_land_shade_colour : "RGB(0.6328,0.6299,0.6299)",
map_coastline_sea_shade : "on",
map_coastline_sea_shade_colour : "RGB(0.8196,0.8196,0.8196)",
map_grid_colour : "charcoal",
map_grid_longitude_increment : 10
)
# define map view
view = geoview(
map_area_definition : "corners",
area : [40,-20,60,10],
coastlines: coast
)
# define title
title = mtext(text_lines: ["Wind gust probability > 22 m/s"], text_font_size: 0.5)
# define the output plot file
setoutput(pdf_output(output_name : 'ens_prob'))
# generate plot
plot(view, prob, cont, title)
|
|
import metview as mv
# **************************** LICENSE START ***********************************
#
# Copyright 2019 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 ************************************
#
# read ENS forecast
g = mv.read("wgust_ens.grib")
# filter out a timestep
wg = mv.read(data=g, step=78)
# create mask (with 0s and 1s) for windgust > 22 m/s
wg_mask = wg > 22
# compute probability
prob = mv.mean(wg_mask) * 100
# define contour shading
cont = mv.mcont(
legend = "on",
contour_line_colour = "charcoal",
contour_highlight = "off",
contour_min_level = 1,
contour_level_count = 6,
contour_shade = "on",
contour_shade_colour_method = "palette",
contour_shade_method = "area_fill",
contour_shade_palette_name = "eccharts_purple_magenta_6"
)
# define coastline
coast = mv.mcoast(
map_coastline_land_shade = "on",
map_coastline_land_shade_colour = "RGB(0.6328,0.6299,0.6299)",
map_coastline_sea_shade = "on",
map_coastline_sea_shade_colour = "RGB(0.8196,0.8196,0.8196)",
map_grid_colour = "charcoal",
map_grid_longitude_increment = 10
)
# define map view
view = mv.geoview(
map_area_definition = "corners",
area = [40,-20,60,10],
coastlines = coast
)
# define title
title = mv.mtext(text_lines = ["Wind gust probability > 22 m/s"], text_font_size = 0.5)
# define the output plot file
mv.setoutput(mv.pdf_output(output_name = 'ens_prob'))
# generate plot
mv.plot(view, prob, cont, title)
|
|
|