#!/usr/bin/env python # coding: utf-8 # #
# << 01-ECMWF MARS archive - WebAPI           03-ECMWF Web Coverage Service (WCS) >> # ##

2. ECMWF Web Mapping Service (WMS)

# - [2.1 Service Description](#service-description) # - [2.2 Available datasets](#datasets) # - [2.3 How to access the service](#service-example) #
# ## 2.1 Service Description # The WMS service operated by ECMWF is part of the ecCharts services to provide forecast weather maps to its users. The service is based on an in-house developed Python package translating WMS requests into the internal request to generate maps which is based on the Magics/Metview parameter language. Currently the serviceprovides WMS version 1.1.1 and 1.3.1. # Access is controlled through tokens which are restricted to ranges of IP addresses. The token “public” contains, besides selected weather forecast maps and maps from the Copernicus Atmosphere Monitoring Service (CAMS). #
# ## 2.2 Available datasets # Access Point: http://apps.ecmwf.int/wms/?token=public&request=GetCapabilities&version=1.3.1 # - [Weather Forecast Maps](#weather_maps) # - [Copernicus Atmosphere Monitoring Service Maps](#cams_maps) # - [Features](#features) # ### Weather Forecast Maps # | Parameter | Id | Type/Level | Spatial resolution | Temporal resolution | Frequency | Format | Note | # |------------------------|----------------|------------------|-----------------|-----------------------|-------------|------------|-----------------| # |500 hPa Geopotential | z500_public | ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 10 | 12 hourly | png, pdf | | # |850 hPa temperature | t850_public | ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 10 | 12 hourly | png, pdf | | # |Wind speed at 850 hPa | ws850_public | ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 10 | 12 hourly | png, pdf | | # |Ensemble mean for 500 hPa geopotential | z500_mean_public | ECMWF probabilistic forecast / Pressure level | Global | past 5 days, up to day 10 | 12 hourly | png, pdf | Ensemble data consist of 50 ensemble members and control forecast | # |Ensemble mean for 850 hPa temperature | t850_mean_public | ECMWF probabilistic forecast / Pressure level | Global | past 5 days, up to day 10 | 12 hourly | png, pdf | Ensemble data consist of 50 ensemble members and control forecast | # |Ensemble mean for 850 hPa wind speed | ws850_mean_public | ECMWF probabilistic forecast / Pressure level | Global | past 5 days, up to day 10 | 12 hourly | png, pdf | Ensemble data consist of 50 ensemble members and control forecast | # |Ensemble mean for mean sea level pressure | msl_mean_public | ECMWF probabilistic forecast / Pressure level | Global | past 5 days, up to day 10 | 12 hourly | png, pdf | Ensemble data consist of 50 ensemble members and control forecast | # |Ensemble spread for 500 hPa geopotential |z500_spread_public | ECMWF probabilistic forecast / Pressure level | Global | past 5 days, up to day 10 | 12 hourly | png, pdf | Spread is represented as the standard deviation | # |Ensemble spread for 850 hPa temperature |t850_spread_public | ECMWF probabilistic forecast / Pressure level | Global | past 5 days, up to day 10 | 12 hourly | png, pdf | Spread is represented as the standard deviation | # |Ensemble spread for 850 hPa wind speed |ws850_spread_public | ECMWF probabilistic forecast / Pressure level | Global | past 5 days, up to day 10 | 12 hourly | png, pdf | Spread is represented as the standard deviation | # |Ensemble spread for mean sea level pressure |msl_spread_public | ECMWF probabilistic forecast / Pressure level | Global | past 5 days, up to day 10 | 12 hourly | png, pdf | Spread is represented as the standard deviation | # |Mean sea level pressure |msl_public | ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 10 | 12 hourly | png, pdf | | # # ### Copernicus Atmospheric Monitoring Service (CAMS) Maps # - [Carbon Monoxide](#carbon_mono) # - [Carbon Dioxide](#carbon_dioxide) # - [Formaldehyde](#formaldehyde) # - [Methane](#methane) # - [Nitrogen Dioxide](#nitrogen_dioxide) # - [Ozone](#ozone) # - [Sulphur Dioxide](#sulphur_dioxide) # - [Other](#other) # #### Carbon Monoxide # | Parameter | Id | Type/Level | Spatial resolution | Temporal resolution | Frequency | Format | Note | # |------------------------|----------------|------------------|-----------------|-----------------------|-------------|------------|-----------------| # |Carbon monoxide at 300 hPa [ppbv] | composition_co_300hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Carbon monoxide at 50 hPa [ppbv] | composition_co_50hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Carbon monoxide at 500 hPa [ppbv] | composition_co_500hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Carbon monoxide at 700 hPa | composition_co700| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Carbon monoxide at 850 hPa | composition_co_850hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Carbon monoxide at pressure levels (850, 700, 500, 300, 50)| composition_co_upperlevel| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Carbon monoxide at surface [ppbv] | composition_co_surface| ECMWF deterministic forecast / Surface | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Total column of carbon monoxide [10ˆ18 molecules / cm2 ]|composition_co_totalcolumn| ECMWF deterministic forecast /Total column | Global | past 5 days, up to day 4 | 3 hourly | png, pdf | only available from 00UTC run | # #### Carbon Dioxide # | Parameter | Id | Type/Level | Spatial resolution | Temporal resolution | Frequency | Format | Note | # |------------------------|----------------|------------------|-----------------|-----------------------|-------------|------------|-----------------| # |Carbon dioxide at 300 hPa [ppmv] | composition_co2_300hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Carbon dioxide at 50 hPa [ppmv] | composition_co2_50hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Carbon dioxide at 500 hPa [ppmv] | composition_co2_500hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Carbon dioxide at 850 hPa [ppmv] | composition_co2_850hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Carbon dioxide at surface [ppmv] | composition_co2_surface| ECMWF deterministic forecast / Surface | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Total column of carbon dioxide [ppmv]|composition_co2_totalcolumn| ECMWF deterministic forecast / Total column | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # #### Formaldehyde # | Parameter | Id | Type/Level | Spatial resolution | Temporal resolution | Frequency | Format | Note | # |------------------------|----------------|------------------|-----------------|-----------------------|-------------|------------|-----------------| # |Formaldehyde at 300 hPa [ppbv] | composition_hcho_300hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 4 | 3 hourly | png, pdf | only available from 00UTC run | # |Formaldehyde at 50 hPa [ppbv] | composition_hcho_50hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 4 | 3 hourly | png, pdf | only available from 00UTC run | # |Formaldehyde at 500 hPa [ppbv] | composition_hcho_500hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 4 | 3 hourly | png, pdf | only available from 00UTC run | # |Formaldehyde at 850 hPa [ppbv] | composition_hcho_850hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 4 | 3 hourly | png, pdf | only available from 00UTC run | # |Formaldehyde at surface| composition_hcho_surface| ECMWF deterministic forecast /Surface | Global | past 5 days, up to day 4 | 3 hourly | png, pdf | only available from 00UTC run | # |Total column of formaldeyde [10ˆ15 molecules / cm2]|composition_hcho_totalcolumn| ECMWF deterministic forecast / Total column | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # #### Methane # | Parameter | Id | Type/Level | Spatial resolution | Temporal resolution | Frequency | Format | Note | # |------------------------|----------------|------------------|-----------------|-----------------------|-------------|------------|-----------------| # |Methane at 300 hPa [ppbv]| composition_hcho_300hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Methane at 50 hPa [ppbv]| composition_hcho_50hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Methane at 500 hPa [ppbv]| composition_hcho_500hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Methane at 850 hPa [ppbv]| composition_hcho_850hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Methane at surface| composition_hcho_surface| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Total column of methane [ppbv]|composition_ch4_totalcolumn| ECMWF deterministic forecast / Total column | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # #### Nitrogen Dioxide # | Parameter | Id | Type/Level | Spatial resolution | Temporal resolution | Frequency | Format | Note | # |------------------------|----------------|------------------|-----------------|-----------------------|-------------|------------|-----------------| # |Nitrogen dioxide at 300 hPa [ppbv]| composition_no2_300hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Nitrogen dioxide at 50 hPa [ppbv]| composition_no2_50hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Nitrogen dioxide at 500 hPa [ppbv]| composition_no2_500hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Nitrogen dioxide at 850 hPa [ppbv]| composition_no2_850hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Nitrogen dioxide at surface| composition_no2_surface| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Total column of nitrogen dioxide [10ˆ15 molecules / cm2]|composition_no2_totalcolumn| ECMWF deterministic forecast /Total column | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # #### Ozone # | Parameter | Id | Type/Level | Spatial resolution | Temporal resolution | Frequency | Format | Note | # |------------------------|----------------|------------------|-----------------|-----------------------|-------------|------------|-----------------| # |Ozone at 300 hPa [ppbv]|composition_o3_300hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Ozone at 50 hPa [ppbv]|composition_o3_50hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Ozone at 500 hPa [ppbv]|composition_o3_500hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Ozone at 850 hPa [ppbv]|composition_o3_850hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Ozone at surface |composition_o3sfc| ECMWF deterministic forecast / Surface | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Ozone at surface [ppbv]|composition_o3_surface| ECMWF deterministic forecast / Surface | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Total column of ozone|composition_o3_totalcolumn| ECMWF deterministic forecast / Total column | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # #### Sulphur Dioxide # | Parameter | Id | Type/Level | Spatial resolution | Temporal resolution | Frequency | Format | Note | # |------------------------|----------------|------------------|-----------------|-----------------------|-------------|------------|-----------------| # |Sulphur dioxide at 300 hPa [ppbv]|composition_so2_300hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Sulphur dioxide at 50 hPa [ppbv]|composition_so2_50hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Sulphur dioxide at 500 hPa [ppbv]|composition_so2_500hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Sulphur dioxide at 850 hPa [ppbv]|composition_so2_850hpa| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Sulphur dioxide at surface [ppbv]|composition_so2_surface| ECMWF deterministic forecast / Surface | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Total column of sulphur dioxide [0ˆ15 molecules / cm2]|composition_so2_totalcolumn| ECMWF deterministic forecast / Total column | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # #### Other # | Parameter | Id | Type/Level | Spatial resolution | Temporal resolution | Frequency | Format | Note | # |------------------------|----------------|------------------|-----------------|-----------------------|-------------|------------|-----------------| # |Aerosol optical depth at 550 nm | composition_aod550| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Biomass burning aerosol optical depth at 550 nm | composition_bbaod550| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Dust aerosol optical depth at 550 nm |composition_duaod550| ECMWF deterministic forecast / Pressure level | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Fire radiative power [W m-2] | composition_fire| Analysis | Global | past 4 days | 24 hourly | png, pdf | | # |PM10 - coarse particulate matter [microg / m3]|composition_pm10| ECMWF deterministic forecast / Surface | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |PM2.5 - fine particulate matter [microg / m3]|composition_pm2p5| ECMWF deterministic forecast / Surface | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Sea salt aerosol optical depth at 550 nm|composition_ssaod550| ECMWF deterministic forecast / Surface | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # |Sulphate aerosol optical depth at 550 nm|composition_suaod550| ECMWF deterministic forecast / Surface | Global | past 5 days, up to day 5 | 3 hourly | png, pdf | only available from 00UTC run | # ### Features # | Parameter | Id | Style Name | Spatial resolution | Format | # |------------------------|----------------|------------------|-------------|------------|-----------------| # |Background | background | - cream_background
- cream_sky_background
- cream_transparent_background
- darkgreen_background
- grey_background
- evergreen_navy_background
- land_background
- sea_background
- cream_medium_res_background | Global | png, pdf | # |Boundaries | boundaries | - grey_boundaries
- black_boundaries
- red_boundaries
- yellow_boundaries
- thick_black_boundaries | Global | png, pdf | # |Foreground | foreground | - black_foreground
- yellow_foreground
- black_thick_foreground
- medium_res_foreground | Global | png, pdf | # |Grid only, no coastlines | grid | - grid_10x20_tan
- grid_10x20_blue
- grid_1x1_tan
- grid_5x5_tan | Global | png, pdf | # |Rivers | rivers | - blue_rivers
- thick_blue_rivers | Global | png, pdf | #
# ## 2.3 How to access the service? # - [Example in Python](#python_example) # - [Example in R](#r_example) # ### Example in Python # #### Example with owslib # ##### Request layer information # In[1]: from owslib.wms import WebMapService # Create your WebMapService object wms = WebMapService('http://apps.ecmwf.int/wms/?token=public', version='1.1.1') # version 1.3.0 works as well # See available layers list(wms.contents) # Get layer description wms['composition_co2_surface'].title # Get bounding box information in WGS84 wms['composition_co2_surface'].boundingBoxWGS84 # Get available styles wms['composition_co2_surface'].styles # See available methods [op.name for op in wms.operations] # Get available formats wms.getOperationByName('GetMap').formatOptions # ##### Request a map # In[2]: get_ipython().run_line_magic('matplotlib', 'inline') import os, sys import matplotlib.image as mpimg import matplotlib.pyplot as plt def getMap(layerName,bbox,filename): wms.getOperationByName('GetMap').formatOptions img = wms.getmap(layers=[layerName], size=(600,300), srs='EPSG:4326', bbox=bbox, format='image/png', transparent=True) tmpfile = open(filename,'wb') tmpfile.write(img.read()) tmpfile.close() getMap('foreground',(-180,-90,180,90), 'foreground.png') getMap('background',(-180,-90,180,90), 'background.png') getMap('composition_bbaod550',(-180,-90,180,90), 'bbaod550.png') image1=mpimg.imread('background.png') image2=mpimg.imread('bbaod550.png') image3=mpimg.imread('foreground.png') fig = plt.figure(figsize=(12,5)) img1=plt.imshow(image1,extent=[-180,180,-90,90],aspect='auto') img2=plt.imshow(image2,extent=[-180,180,-90,90],aspect='auto') img3=plt.imshow(image3,extent=[-180,180,-90,90],aspect='auto') plt.show() # #### Custom example # In[3]: import requests from IPython.display import Image import xmltodict import ipywidgets as widgets from ipywidgets import interact # In[4]: url = 'http://apps.ecmwf.int/wms/' capa = { "token": "public", "request": "GetCapabilities", "version": "1.1.1", } capa = requests.get(url, capa, ) layers = xmltodict.parse(capa.text) options = [] for layer in layers["WMT_MS_Capabilities"]["Capability"]["Layer"]["Layer"]: options.append(layer["Name"]) # In[6]: def getMap(param): params = { "token": "public", "request": "GetMap", "version": "1.3.1", "srs": "EPSG:4326", "layers": "background,%s,foreground" % param, "width": 800, "height": 400, "format": "image/png", } r= requests.get(url,params, ) with open('workfile.png', 'wb') as png: png.write(r.content) return Image(filename="workfile.png") interact(getMap, param = widgets.Dropdown( options= options) ) # ### Example in R # #### Request layer information # In[7]: # Install R packages, if not already installed # install.packages(c("XML"), "~/miniconda3/lib/R/library") # Load packages library("XML") # GetCapabilities request requestGetMap <- httr::GET(url = "http://apps.ecmwf.int/wms/", query = list(token = "public", version = "1.3.0", request = "GetCapabilities")) # In[6]: # Convert response into a list xmlResponse <- XML::xmlToList(httr::content(requestGetMap, "text", encoding = "UTF-8")) # Extract only layers info allLayers <- xmlResponse[["Capability"]][["Layer"]] # List available layers layerNames <- c() for (i in seq_along(allLayers)) { layerNames <- c(layerNames, allLayers[i]$Layer$Name) } print(layerNames) # #### Request a map # In[ ]: # Install R packages, if not already installed # install.packages(c("rgdal", "rworldmap", "raster", "httr"), "~/miniconda3/lib/R/library") # Load packages library("rworldmap") library("raster") library("httr") # GET request to dowload file via URL requestGetMap <- httr::GET(url = "http://apps.ecmwf.int/wms/", query = list(token = "public", version = "1.3.0", request = "GetMap", layers = "composition_bbaod550")) # Download png file bbaod550 <- download.file(url = requestGetMap$url, destfile = "composition_bbaod550.png") # Convert png image to raster bbaod550Raster <- raster(x = "composition_bbaod550.png", crs = "+proj=longlat +datum=WGS84") extent(bbaod550Raster) <- extent(-180, 180, -90, 90) plot(bbaod550Raster, colNA = NA) # Add a background map newmap <- getMap(resolution = "coarse") plot(newmap, add=TRUE, border = 'gray') #
# © 2017 ECMWF # # This software is licensed under the terms of the Apache Licence Version 2.0 which can be obtained at http://www.apache.org/licenses/LICENSE-2.0. In applying this licence, ECMWF does not waive the privileges and immunities granted to it by virtue of its status as an intergovernmental organisation nor # does it submit to any jurisdiction.