This notebook will provide you guidance how to explore ECMWF data to produce the map from the ECMWF open charts web product.
The original product can be found on this link: https://charts.ecmwf.int/products/medium-simulated-wv
Some ECMWF real-time products are governed by the ECMWF Standard Licence Agreement and are not free or open. Access to these products depends on your use case. To find out which licence applies to you, please visit: Use cases and licence conditions page.
To find out how to obtain the access to the ECMWF forecast data please visit our Access page.
This product takes in input parameter:
In this example, we will use:
First we need to install them in the current Jupyter kernel:
#!pip install ecmwf-api-client metview metview-python
import metview as mv
from ecmwfapi import *
import requests
filename = "medium-simulated-wv.grib"
If you already have the access to the ECMWF archived forecast data, you can use the next cell to download data from the MARS archive:
server = ECMWFService("mars")
server.execute(
{
"class": "od",
"date": "-1",
"expver": "1",
"levtype": "sfc",
"param": "260510",
"step": "12",
"stream": "oper",
"time": "00",
"type": "ssd",
"channel":"5/6",
"ident":"57",
"grid": "0.25/0.25"
},
filename)
Alternatevly we have prepared small sample dataset to explore
url = f"https://get.ecmwf.int/repository/opencharts-sample-data/{filename}"
r = requests.get(url)
with open(filename, 'wb') as file:
file.write(r.content)
Now we can use ecmwf.data to read the file.
data = mv.read(filename)
The describe() function will give us the overview of the dataset.
data.describe()
parameter | typeOfLevel | level | date | time | step | number | paramId | class | stream | type | experimentVersionNumber |
---|---|---|---|---|---|---|---|---|---|---|---|
clbt | None | 20220306 | 0 | 12 | None | 260510 | od | oper | ssd | 0001 |
And an overview of one parameter, where we can see more information, such as units or type of level.
data.describe('clbt')
shortName | clbt |
---|---|
name | Cloudy brightness temperature |
paramId | 260510 |
units | K |
typeOfLevel | None |
level | |
date | 20220306 |
time | 0 |
step | 12 |
number | None |
class | od |
stream | oper |
type | ssd |
experimentVersionNumber | 0001 |
We can use ls() function to list all the fields in the file we downloaded.
data.ls()
centre | shortName | typeOfLevel | level | dataDate | dataTime | stepRange | dataType | number | gridType | |
---|---|---|---|---|---|---|---|---|---|---|
Message | ||||||||||
0 | ecmf | clbt | None | <NA> | 20220306 | 0 | 12 | ssd | None | regular_ll |
1 | ecmf | clbt | None | <NA> | 20220306 | 0 | 12 | ssd | None | regular_ll |
In order to be able to use the visual style from open charts, we need to convert the brightness temperature to Censius.
clbt_5 = data.select(channel= 5) - 273.15
clbt_6 = data.select(channel= 6) - 273.15
And finally, we can plot the data on the map.
First we will plot the data on 500 hPa (channel 6).
# define coastlines
coast = mv.mcoast(
map_coastline_colour="charcoal",
map_coastline_resolution="medium",
map_coastline_land_shade="on",
map_coastline_land_shade_colour="cream",
map_coastline_sea_shade="off",
map_boundaries="on",
map_boundaries_colour= "charcoal",
map_boundaries_thickness = 1,
map_disputed_boundaries = "off",
map_grid_colour="tan",
map_label_height=0.35,
)
# define view
view = mv.geoview(
area_mode="name",
area_name="europe",
coastlines=coast
)
#define styles
clbt_6_shade = mv.mcont(legend= "on",
contour_automatics_settings = "style_name",
contour_style_name = "sim_image_wv_500")
title = mv.mtext(
text_lines=["Simulated images - Water vapour channel 6",
"START TIME: <grib_info key='base-date' format='%a %d %B %Y %H'/> ",
"VALID TIME: <grib_info key='valid-date' format='%a %d %B %Y %H'/>, STEP: <grib_info key='step' />"],
text_font_size=0.4,
text_colour = 'charcoal')
ecmwf_text = mv.mtext(
text_lines = ["© European Centre for Medium-Range Weather Forecasts (ECMWF)",
"Source: www.ecmwf.int Licence: CC-BY-4.0 and ECMWF Terms of Use",
"https://apps.ecmwf.int/datasets/licences/general/"],
text_justification = 'center',
text_font_size = 0.3,
text_mode = "positional",
text_box_x_position = 6.,
text_box_y_position = -0.2,
text_box_x_length = 8,
text_box_y_length = 2,
text_colour = 'charcoal')
# generate plot
mv.setoutput('jupyter', plot_widget=False)
mv.plot(view, clbt_6, clbt_6_shade, title, ecmwf_text)
And in the end we plot the Brightness temperature at level 300 hPa (channel 5).
# define coastlines
coast = mv.mcoast(
map_coastline_colour="charcoal",
map_coastline_resolution="medium",
map_coastline_land_shade="on",
map_coastline_land_shade_colour="cream",
map_coastline_sea_shade="off",
map_boundaries="on",
map_boundaries_colour= "charcoal",
map_boundaries_thickness = 1,
map_disputed_boundaries = "off",
map_grid_colour="tan",
map_label_height=0.35,
)
# define view
view = mv.geoview(
area_mode="name",
area_name="europe",
coastlines=coast
)
#define styles
clbt_5_shade = mv.mcont(legend= "on",
contour_automatics_settings = "style_name",
contour_style_name = "sim_image_wv_500")
title = mv.mtext(
text_lines=["Simulated images - Water vapour channel 5",
"START TIME: <grib_info key='base-date' format='%a %d %B %Y %H'/> ",
"VALID TIME: <grib_info key='valid-date' format='%a %d %B %Y %H'/>, STEP: <grib_info key='step' where='shortName=msl' />"],
text_font_size=0.4,
text_colour = 'charcoal')
ecmwf_text = mv.mtext(
text_lines = ["© European Centre for Medium-Range Weather Forecasts (ECMWF)",
"Source: www.ecmwf.int Licence: CC-BY-4.0 and ECMWF Terms of Use",
"https://apps.ecmwf.int/datasets/licences/general/"],
text_justification = 'center',
text_font_size = 0.3,
text_mode = "positional",
text_box_x_position = 6.,
text_box_y_position = -0.2,
text_box_x_length = 8,
text_box_y_length = 2,
text_colour = 'charcoal')
# generate plot
mv.setoutput('jupyter', plot_widget=False)
mv.plot(view, clbt_5, clbt_5_shade, title, ecmwf_text)
To generate the png file you can run the following cell.
png = mv.png_output(
output_name = "medium-simulated-wv-ch6", # specify relative or full path
output_title = "medium-simulated-wv-ch6", # title used by a viewer
output_width = 1000, # set width in pixels
)
mv.setoutput(png)
mv.plot(view, clbt_6, clbt_6_shade, title, ecmwf_text)
To generate the png file you can run the following cell.
png = mv.png_output(
output_name = "medium-simulated-wv-ch5", # specify relative or full path
output_title = "medium-simulated-wv-ch5", # title used by a viewer
output_width = 1000, # set width in pixels
)
mv.setoutput(png)
mv.plot(view, clbt_5, clbt_5_shade, title, ecmwf_text)
Note that plot produced using this dataset will slightly differ from one from Open Charts. This is due to different resolution of the data.
The data used here is on 0.25x0.25 resolution, while high resolution data is 0.1x0.1 grid.