from IPython.display import Image
Image(url='https://vesg.ipsl.upmc.fr/thredds/fileServer/IPSLFS/jservon/CliMAF_Notebooks_html/CliMAF-logo-small.png')
In this notebook we will see how to make a multi-model ensemble with CORDEX. Compared with CMIP5 and CMIP6, CORDEX datasets are defined not only by one model but by a GCM/RCM couple (driving_model/model).
from climaf.api import *
clog('critical') # min verbosity = critical < warning < info < debug = max verbosity
The specificity of CORDEX is that it works as GCM/RCM couples. We propose here a way to build a multi-model CORDEX ensemble
from natsort import natsorted
# -- Let's make a dictionary to specify the general request:
req_dict = dict(project = 'CORDEX',
CORDEX_domain = 'EUR-11',
frequency = 'daily',
experiment = 'historical',
period = '2000',
variable = 'tas'
)
# -- Do the initial request to retrieve all the possible results:
req = ds(model = '*',
driving_model = '*',
realization = '*',
**req_dict)
# -- We will now:
# - make a loop on all the available 'driving_model' (GCMs)
# - for each driving_model, we check the model (RCMs) available
# - and for each GCM/RCM couple, we check the available realizations
# - store all the matching datasets in myens_dict
# - and create the ensemble with cens
myens_dict = dict()
for GCM in req.explore('choices')['driving_model']:
dumreq = ds(model='*',
realization = '*',
driving_model = GCM,
**req_dict)
RCMs = dumreq.explore('choices')['model']
if not isinstance(RCMs, list):
RCMs = [RCMs]
for RCM in RCMs:
dum2req = ds(model=RCM,
driving_model = GCM,
realization = '*',
**req_dict)
print 'GCM = ',GCM,' RCM = ',RCM
res_choices = dum2req.explore('choices')
if res_choices:
# -- If multiple realizations are available, we take the first one
if isinstance(res_choices['realization'], list):
dum2req.kvp['realization'] = natsorted(dum2req.explore('choices')['realization'])[0]
myens_dict[GCM+'_'+RCM] = dum2req.explore('resolve')
#
my_CORDEX_ens = cens(myens_dict)
clog('critical')
summary(my_CORDEX_ens)
from climaf.api import *
req_dict = dict(project = 'CORDEX',
CORDEX_domain = 'EUR-11',
frequency = 'fx',
experiment = '*',
period = 'fx',
realization = 'r0i0p0',
variable = 'sftlf'
)
# -- Do the initial request to retrieve all the possible results:
req = ds(model = '*',
driving_model = '*',
**req_dict)
req.explore('choices')
For the available operators, we invite you to go deeper in CliMAF documentation and other CliMAF notebooks.