4.2.1.9. Access to WMS data
The CEDA data server at https://data.cci.ceda.ac.uk/ provides access via the OGC Web Map Service (WMS) to CCI datasets. This notebook demonstrates how to retrieve CCI data via WMS from the CEDA server, using OWSLib as the client.
If owslib is not already installed in the Python environment, uncomment the following cell to install it with mamba.
[1]:
# ! mamba install --yes owslib
Import some required libraries, including OWSLib as the WMS client.
[2]:
from owslib.wms import WebMapService
from esa_climate_toolbox.core import list_ecvs, list_ecv_datasets
from IPython.display import Image
List the available ECVs.
[3]:
list_ecvs()
[3]:
['SEASURFACESALINITY',
'BIOMASS',
'CLOUD',
'AEROSOL',
'VEGETATION',
'LST',
'LC',
'FIRE',
'LAKES',
'PERMAFROST',
'SEALEVEL',
'OZONE',
'WATERVAPOUR',
'ICESHEETS',
'OC',
'SEASTATE',
'SOILMOISTURE',
'SEAICE',
'GHG',
'SNOW',
'RD',
'SST']
List the available datasets for the cloud ECV.
[4]:
print("\n".join(map(lambda x: x[0], list_ecv_datasets("CLOUD"))))
esacci.CLOUD.mon.L3C.CLD_PRODUCTS.MODIS.Aqua.MODIS_AQUA.2-0.r1
esacci.CLOUD.mon.L3C.CLD_PRODUCTS.MODIS.Terra.MODIS_TERRA.2-0.r1
esacci.CLOUD.mon.L3C.CLD_PRODUCTS.multi-sensor.multi-platform.ATSR2-AATSR.3-0.r1
esacci.CLOUD.mon.L3C.CLD_PRODUCTS.multi-sensor.multi-platform.AVHRR-AM.3-0.r1
esacci.CLOUD.mon.L3C.CLD_PRODUCTS.multi-sensor.multi-platform.AVHRR-PM.3-0.r1
esacci.CLOUD.mon.L3C.CLD_PRODUCTS.multi-sensor.multi-platform.MERIS-AATSR.2-0.r1
ESACCI-L3C_CLOUD-CLD_PRODUCTS-MODIS_AQUA-200208-201412-fv2.0_kr1.0
ESACCI-L3C_CLOUD-CLD_PRODUCTS-ATSR2_AATSR-199506-201204-fv3.0-kr1.1
ESACCI-L3C_CLOUD-CLD_PRODUCTS-AVHRR_AM-199109-201612-fv3.0-kr1.1
ESACCI-L3C_CLOUD-CLD_PRODUCTS-AVHRR_PM-198201-201612-fv3.0-kr1.1
ESACCI-L3C_CLOUD-CLD_PRODUCTS-MERIS-AATSR_ENVISAT-200301-201112_fv2.0_kr1.0
ESACCI-L3C_CLOUD-CLD_PRODUCTS-AVHRR_NOAA-1982-2016-fv3.0.zarr
Select a dataset from the list and store its name in a variable for use in the following steps.
[5]:
ds_id = "esacci.CLOUD.mon.L3C.CLD_PRODUCTS.multi-sensor.multi-platform.ATSR2-AATSR.3-0.r1"
Create a local representation of the WMS service for the selected dataset.
[6]:
wms_url = f"https://data.cci.ceda.ac.uk/thredds/wms/{ds_id}?service=WMS&version=1.3.0"
wms = WebMapService(wms_url, version="1.3.0", timeout=600)
List the data variables available from this service.
[7]:
list(wms.contents)
[7]:
['nday',
'nday_low',
'nday_mid',
'nday_hig',
'nobs',
'nobs_day',
'nobs_clear_day',
'nobs_cloudy_day',
'nobs_clear_night',
'nobs_cloudy_night',
'nobs_clear_twl',
'nobs_cloudy_twl',
'nobs_cloudy',
'nretr_clear',
'nretr_cloudy',
'toa_swup',
'toa_swdn',
'toa_swup_clr',
'toa_lwup',
'toa_lwup_clr',
'toa_swup_low',
'toa_swup_mid',
'toa_swup_hig',
'toa_lwup_low',
'toa_lwup_mid',
'toa_lwup_hig',
'boa_swup',
'boa_swup_clr',
'boa_lwup',
'boa_lwup_clr',
'boa_swdn',
'boa_swdn_clr',
'boa_lwdn',
'boa_lwdn_clr',
'cee',
'cee_corr_unc',
'cee_prop_unc',
'cee_std',
'cee_unc',
'cer',
'cer_corr_unc',
'cer_ice',
'cer_ice_corr_unc',
'cer_ice_prop_unc',
'cer_ice_std',
'cer_ice_unc',
'cer_liq',
'cer_liq_corr_unc',
'cer_liq_prop_unc',
'cer_liq_std',
'cer_liq_unc',
'cer_prop_unc',
'cer_std',
'cer_unc',
'cfc',
'cfc_corr_unc',
'cfc_day',
'cfc_high',
'cfc_low',
'cfc_mid',
'cfc_night',
'cfc_prop_unc',
'cfc_std',
'cfc_twl',
'cfc_unc',
'cla_vis006',
'cla_vis006_corr_unc',
'cla_vis006_ice',
'cla_vis006_ice_std',
'cla_vis006_ice_unc',
'cla_vis006_liq',
'cla_vis006_liq_std',
'cla_vis006_liq_unc',
'cla_vis006_prop_unc',
'cla_vis006_std',
'cla_vis006_unc',
'cla_vis008',
'cla_vis008_corr_unc',
'cla_vis008_ice',
'cla_vis008_ice_std',
'cla_vis008_ice_unc',
'cla_vis008_liq',
'cla_vis008_liq_std',
'cla_vis008_liq_unc',
'cla_vis008_prop_unc',
'cla_vis008_std',
'cla_vis008_unc',
'cot',
'cot_corr_unc',
'cot_ice',
'cot_ice_corr_unc',
'cot_ice_prop_unc',
'cot_ice_std',
'cot_ice_unc',
'cot_liq',
'cot_liq_corr_unc',
'cot_liq_prop_unc',
'cot_liq_std',
'cot_liq_unc',
'cot_log',
'cot_prop_unc',
'cot_std',
'cot_unc',
'cph',
'cph_corr_unc',
'cph_day',
'cph_day_corr_unc',
'cph_day_prop_unc',
'cph_day_std',
'cph_day_unc',
'cph_prop_unc',
'cph_std',
'cph_unc',
'cth',
'cth_corr_unc',
'cth_corrected',
'cth_corrected_corr_unc',
'cth_corrected_prop_unc',
'cth_corrected_std',
'cth_corrected_unc',
'cth_prop_unc',
'cth_std',
'cth_unc',
'ctp',
'ctp_corr_unc',
'ctp_corrected',
'ctp_corrected_corr_unc',
'ctp_corrected_prop_unc',
'ctp_corrected_std',
'ctp_corrected_unc',
'ctp_log',
'ctp_prop_unc',
'ctp_std',
'ctp_unc',
'ctt',
'ctt_corr_unc',
'ctt_corrected',
'ctt_corrected_corr_unc',
'ctt_corrected_prop_unc',
'ctt_corrected_std',
'ctt_corrected_unc',
'ctt_prop_unc',
'ctt_std',
'ctt_unc',
'iwp',
'iwp_allsky',
'iwp_corr_unc',
'iwp_prop_unc',
'iwp_std',
'iwp_unc',
'lwp',
'lwp_allsky',
'lwp_corr_unc',
'lwp_prop_unc',
'lwp_std',
'lwp_unc',
'nretr_cloudy_day',
'nretr_cloudy_day_ice',
'nretr_cloudy_day_liq',
'nretr_cloudy_high',
'nretr_cloudy_ice',
'nretr_cloudy_liq',
'nretr_cloudy_low',
'nretr_cloudy_mid',
'stemp_clear',
'stemp_clear_corr_unc',
'stemp_clear_prop_unc',
'stemp_clear_std',
'stemp_clear_unc',
'stemp_cloudy',
'stemp_cloudy_corr_unc',
'stemp_cloudy_prop_unc',
'stemp_cloudy_std',
'stemp_cloudy_unc']
Select the iwp (ice water path) variable from the list and store its name in a variable.
[8]:
data_id = "iwp"
Check the bounding box for the selected dataset and variable; we can see that it is of global extent.
[9]:
wms.contents[data_id].boundingBox
[9]:
(-179.75, -89.75, 179.75, 89.75, 'CRS:84')
Check what times are available, filtering to the year 2011.
[10]:
[t for t in wms[data_id].timepositions if t.startswith("2011")]
[10]:
['2011-01-01T00:00:00.000Z',
'2011-02-01T00:00:00.000Z',
'2011-03-01T00:00:00.000Z',
'2011-04-01T00:00:00.000Z',
'2011-05-01T00:00:00.000Z',
'2011-06-01T00:00:00.000Z',
'2011-07-01T00:00:00.000Z',
'2011-08-01T00:00:00.000Z',
'2011-09-01T00:00:00.000Z',
'2011-10-01T00:00:00.000Z',
'2011-11-01T00:00:00.000Z',
'2011-12-01T00:00:00.000Z']
Request a map for the chosen dataset and variable from the WMS server, selecting a time from the list above and a bounding box covering latitudes from 80°S to 50°N, then display the map in the notebook.
[11]:
response = wms.getmap(
layers=["iwp"],
styles=["boxfill/rainbow"],
size=[800, 600],
srs="EPSG:4326",
bbox=[-180.0, -80.0, 180.0, 50.0],
format="image/png",
time="2011-12-01T00:00:00.000Z"
)
Image(response.read())
[11]: