0 - Basic Information

In [1]:
from IPython.display import Image, display

display(Image(filename='files/Folie1.PNG'))
In [2]:
display(Image(filename='files/Folie2.PNG'))
In [3]:
display(Image(filename='files/Folie3.PNG'))
In [4]:
display(Image(filename='files/Folie4.PNG'))

1 - Basic Imports

In [5]:
#!/usr/bin/python
# -*- coding: utf-8 -*-

# IPython NoteBook created by Martin Schupfner, DKRZ
# Reference: Martin Juckes 2016 - 
#            dreqPy (Data Request Python API) & dreqPy User's Guide

from dreqPy import dreq

print("Using DreqPy (Data Request Python API) in version %s"\
    % str(dreq.version))

# Initialisation
dq = dreq.loadDreq()
Using DreqPy (Data Request Python API) in version 01.00.31.post3

2 - dq.coll Examples

In [6]:
# dq.coll
# Content Object dq.coll is a dictionary containing the data request sections,
#   with 3 elements (named tuples) for each section:
# - header :  named tuple with info such as title, lable, etc.
# - attDefn:  dictionary containing record attribute definitions
# - items  :  list of records

# Print all entries of dq.coll
print("dq.coll Entries:\n", ", ".join(dq.coll.keys()))
dq.coll Entries:
 __core__, __main__, __sect__, requestVarGroup, requestItem, exptgroup, miptable, CMORvar, objective, spatialShape, requestLink, tableSection, modelConfig, varChoiceLinkC, objectiveLink, remarks, experiment, requestVar, standardname, varChoiceLinkR, var, mip, varChoice, temporalShape, structure, grids, timeSlice, cellMethods, tags, varRelations, varRelLnk, qcranges, places, transfers, units
In [7]:
# header content (Example MIP Variable):
print(".header content Example 'var':\n------------------------------")

for name in dq.coll['var'].header._fields: print("%-15s : %s" \
    %(name, getattr(dq.coll['var'].header, name)))
.header content Example 'var':
------------------------------
tag             : table
label           : var
title           : 1.2 MIP Variable
id              : var
itemLabelMode   : def
level           : 0
maxOccurs       : 1
labUnique       : No
uid             : SECTION:var
description     : Each MIP variable record defines a MIP variable name, associated with a CF Standard Name.
In [8]:
# attDefn content (Example MIP Variable):
print(".attDefn content Example 'var':\n-------------------------------")

for key in dq.coll['var'].attDefn.keys(): 
    print("%-15s : %s" %(key, dq.coll['var'].attDefn[key]))
.attDefn content Example 'var':
-------------------------------
label           : Item <X.1 Core Attributes>: [label] Variable Name
title           : Item <X.1 Core Attributes>: [title] Long name
sn              : Item <X.1 Core Attributes>: [sn] CF Standard Name
units           : Item <X.1 Core Attributes>: [units] Units of Measure
description     : Item <X.1 Core Attributes>: [description] Record Description
procnote        : Item <X.1 Core Attributes>: [procnote] Processing Notes
procComment     : Item <X.1 Core Attributes>: [procComment] Processing Comments
prov            : Item <X.1 Core Attributes>: [prov] Notes on Provenance of Variable Specifications
uid             : Item <X.1 Core Attributes>: [uid] Record Identifier
provmip         : Item <X.1 Core Attributes>: [provmip] MIP Defining this Variable
unid            : Item <X.1 Core Attributes>: [unid] Link to Units section
In [9]:
# items content (Example MIP Variable):
print(".items content Example 'var':\n-----------------------------")

for key in dq.coll['var'].attDefn.keys(): 
    print("%-15s : %s" %(key, getattr(dq.coll['var'].items[0], key)))
.items content Example 'var':
-----------------------------
label           : abs550aer
title           : Ambient Aerosol Absorption Optical Thickness at 550nm
sn              : atmosphere_absorption_optical_thickness_due_to_ambient_aerosol_particles
units           : 1
description     : Optical thickness of atmospheric aerosols at wavelength 550 nanometers.
procnote        : ('',)
procComment     : 
prov            : CMIP5_aero
uid             : 0baf6a333b91c4db341b515c28cd2c05
provmip         : AerChemMIP
unid            : fd6fef50-3468-11e6-ba71-5404a60d96b5

3 - dq.inx Examples

In [10]:
# Index dq.inx is a simple lookup table
#   dq.inx.uid[UID] returns the record corresponding to 'UID'

#   Example from above:
item = dq.inx.uid['0baf6a333b91c4db341b515c28cd2c05']

print(item)
print("Label:", item.label)
print("Title:", item.title)
print("Units:", item.units)
Item <1.2 MIP Variable>: [abs550aer] Ambient Aerosol Absorption Optical Thickness at 550nm
Label: abs550aer
Title: Ambient Aerosol Absorption Optical Thickness at 550nm
Units: 1
In [11]:
#   dq.inx.iref_by_uid[UID]
#    gives a list of IDs of objects linked to 'UID',
#    as a tuple (SECT, ID)

#   Example from above:
id_list = dq.inx.iref_by_uid['0baf6a333b91c4db341b515c28cd2c05']

for ID in id_list:     
    print("#  Section: %-10s\n   UID: %15s\n   %s\n"\
    %(ID[0], ID[1], dq.inx.uid[ID[1]]))
#  Section: vid       
   UID: 19bebf2a-81b1-11e6-92de-ac72891c3257
   Item <1.3 CMOR Variable>: [abs550aer] Ambient Aerosol Absorption Optical Thickness at 550nm

In [12]:
#   dq.inx.iref_by_sect[UID].a[SECT] 
#    gives a list of IDs of 'SECT' linked to 'UID'

#   Example from above:
id_list = dq.inx.iref_by_sect['0baf6a333b91c4db341b515c28cd2c05'].a['CMORvar']

for ID in id_list: 
    item = dq.inx.uid[ID]
    print("%15s | %10s | %s" \
    %(item.label, item.mipTable, item.vid))
      abs550aer |     AERmon | 0baf6a333b91c4db341b515c28cd2c05
In [13]:
# The same can be achieved using dq.coll, though:

#   Example from above:
CMORvar_list = [ item for item in dq.coll['CMORvar'].items \
           if item.vid=='0baf6a333b91c4db341b515c28cd2c05']

for item in CMORvar_list:     
    print("%15s | %10s | %s" \
    %(item.label, item.mipTable, item.vid))
      abs550aer |     AERmon | 0baf6a333b91c4db341b515c28cd2c05

4 - Presentation of dq.coll Sections

Overview over all dq.coll sections and their items' attributes, as well as examples.

In [14]:
from IPython.display import Image, display

# Display Structure of DreqPy
display(Image(filename='files/DreqPyStructure.png'))
In [15]:
def showSect(sect, desc=False, uid=""):
    """
    Print the Content of dq.coll's sections and one example item
    Arg: sect - str     - section key
         desc - boolean - also print description 
                          (Default: False)
         uid  - str     - provide the uid of the example item if desired,
                          else, the example item will be chosen automatically
    """
    
    # print header title
    print(dq.coll[sect].header.title)
    print("-"*len(dq.coll[sect].header.title))
    
    # print Section name and description
    for subsect in dq.coll[sect].attDefn.keys():
        if desc==True:
            print("# %15s  |  %s%s" \
            %(subsect, dq.coll[sect].attDefn[subsect].title, \
            "\n"+dq.coll[sect].attDefn[subsect].description if \
            (str(dq.coll[sect].attDefn[subsect].description)!="" or \
            subsect in str(dq.coll[sect].attDefn[subsect].description)) \
            else ""))
        else:
            print("# %15s  |  %s" \
            %(subsect, dq.coll[sect].attDefn[subsect].title))
            
    # print Example of first item in list
    print("-------\nExample\n-------")
    for subsect in dq.coll[sect].attDefn.keys():
            if uid=="":
                print("# %15s  |  %s"\
                %(subsect, getattr(dq.coll[sect].items[0], subsect) if \
                 subsect not in str(getattr(dq.coll[sect].items[0], subsect)) \
                 else ""))
            else:
                print("# %15s  |  %s"\
                %(subsect, getattr(dq.inx.uid[uid], subsect) if \
                 subsect not in str(getattr(dq.coll[sect].items[0], subsect)) \
                 else ""))
In [16]:
# MIPs
print("Chicken or egg? MIP or Objective?\n"\
      "The CMIP endorsed MIP (Model Intercomparison Project) is linked to scientific objectives.")
display(Image(filename='files/DreqPyStructure_1.png'))
showSect('mip')
#showSect('mip', desc=True) #Activate for additional info if there is any
Chicken or egg? MIP or Objective?
The CMIP endorsed MIP (Model Intercomparison Project) is linked to scientific objectives.
1.1 Model Intercomparison Project
---------------------------------
#           label  |  MIP short name
#           title  |  MIP title
#             uid  |  Record identifier
#     description  |  Description of the Model Intercomparison Project
#             url  |  Project Home Page
-------
Example
-------
#           label  |  AerChemMIP
#           title  |  Aerosols and Chemistry Model Intercomparison Project
#             uid  |  AerChemMIP
#     description  |  
#             url  |  https://wiki.met.no/aerocom/aerchemmip/start
In [17]:
# Objective
showSect('objective')
#showSect('objective', desc=True) #Activate for additional info if there is any
1.6 Scientific objectives
-------------------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record identifier
#     description  |  Description
#             mip  |  Endorsed MIP
-------
Example
-------
#           label  |  aerChem
#           title  |  AerChemMIP diagnostics
#             uid  |  030af762-c570-11e8-8bae-a44cc8186c64
#     description  |  AerChemMIP diagnostics
#             mip  |  AerChemMIP
In [18]:
# Experiments
print("MIPs may define experiments or solely request data from experiments.")
print("Experiments are organised in experiment groups.")
display(Image(filename='files/DreqPyStructure_2.png'))
showSect('experiment')
#showSect('experiment', desc=True) #Activate for additional info if there is any
MIPs may define experiments or solely request data from experiments.
Experiments are organised in experiment groups.
1.5 Experiments
---------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record identifier
#     description  |  Description
#            egid  |  Identifier for experiment group
#             mip  |  MIP defining experiment
#            mcfg  |  Model Source Types
#            tier  |  Tier of Experiment
#          nstart  |  Number of Start Dates
#          starty  |  Start year
#            endy  |  End year
#             yps  |  Years per Simulation Including all Start Years
#            ensz  |  Ensemble size
#            ntot  |  Total number of years
#         comment  |  Comment
-------
Example
-------
#           label  |  1pctCO2
#           title  |  1 percent per year increase in CO2
#             uid  |  f16fc0b0-dd9e-11e6-b89b-ac72891c3257
#     description  |  Increase atmospheric CO2 concentration gradually at a rate of 1 percent per year. The concentration of atmospheric carbon dioxide is increased from the global annual mean 1850 value until quadrupling. 
#            egid  |  f16fbb42-dd9e-11e6-b89b-ac72891c3257
#             mip  |  CMIP
#            mcfg  |  AOGCM | AER CHEM BGC
#            tier  |  [1]
#          nstart  |  1
#          starty  |  
#            endy  |  
#             yps  |  150
#            ensz  |  [1]
#            ntot  |  150
#         comment  |  
In [19]:
# Experiment Groups
showSect('exptgroup')
#showSect('exptgroup', desc=True) #Activate for additional info if there is any
1.9 Experiment Group
--------------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record identifier
#         tierMin  |  Minimum tier of experiments in group
#            ntot  |  Total number of years
-------
Example
-------
#           label  |  Aerchemmip1
#           title  |  Perturbed historical experiments
#             uid  |  8709a634-51c3-11e7-9bc5-5404a60d96b5
#         tierMin  |  1
#            ntot  |  1185
In [20]:
# Request Item
print("The request items build up the data request.")
print("They are linked to (or: requested by) either MIPs, experiments or experiment groups.")
print("Request items hold information about the time slice of the requested variables they include\n"\
      "as well as the possibility to set their priority and tier.")
display(Image(filename='files/DreqPyStructure_3.png'))
showSect('requestItem', True)
#showSect('requestItem', desc=True) #Activate for additional info if there is any
The request items build up the data request.
They are linked to (or: requested by) either MIPs, experiments or experiment groups.
Request items hold information about the time slice of the requested variables they include
as well as the possibility to set their priority and tier.
3.2 Request Item: specifying the number of years for an experiment
------------------------------------------------------------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record Identifier
#             mip  |  The MIP making the request. 
Model Intecomparison Project associated with the requestItem. Redundant because this is specified through the requestLink.
#             tab  |  Redundant?
Redundant attribute ... 
#            expt  |  Name of experiment or group of experiments
This is redundant: the information is provided through the esid link.
#            rlid  |  Identifier of Corresponding Request Link
Link to a requestLink record, which makes the connection to a variableGroup and a set of objectives.
#            esid  |  A link to an experiment, an experiment group or a MIP
This links to an individual experiment, to an experimentGroup, specifying a collection of experiments, or to a MIP. If it links to a MIP it means that the request applies to all experiments defined by that MIP.
#     esidComment  |  Comment on experiment(s) linked to.
An explanatory commemt for the esid attribute.
#          preset  |  Option to override priority set in each variable group
If, for example, preset is set to 2, all priority one variables in the variable group associated with this request are treated as priority 2 variables.
#          treset  |  Option to override tier set for experiment(s)
If, for example, treset is set to 1, all tier 2 and 3 experiments associated with this request are treated as tier 1 variables.
#              ny  |  Default number of years.
Default number of years, only used if experiment specifications are incomplete: will be redundant in final request.
#          nexmax  |  Maximum number of experiments requested.
Used to provide volume estimate before the links to experiment groups was fully functional.
#          nenmax  |  Number of ensemble members requested. 
If set to -1 then the request applies to to all the ensemble members specified in the ensz attribute of the experiment or experiments associated with the request. Note that ensz is a default ensemble size, and nenmax may be greater if one MIP wants more than the default number of ensembles. 
#           nymax  |  Number of years requested.
Number of years specified by the requesting MIP (will be redundant when links to temporal slices are fully implemented).
#          tslice  |  Selection of years from experiment
Optional link to a time slice specifier which will define subset of the years from an experiment.
-------
Example
-------
#           label  |  1pctco2
#           title  |  SEAPODYM.1: 1pctco2
#             uid  |  07f7b74e-26b9-11e7-9d3d-ac72891c3257
#             mip  |  VIACSAB
#             tab  |  
#            expt  |  1pctCO2
#            rlid  |  07e99fba-26b9-11e7-9d3d-ac72891c3257
#            esid  |  f16fc0b0-dd9e-11e6-b89b-ac72891c3257
#     esidComment  |  
#          preset  |  -1
#          treset  |  
#              ny  |  160
#          nexmax  |  
#          nenmax  |  -1
#           nymax  |  -1.0
#          tslice  |  
In [21]:
# Time Slice
showSect('timeSlice')
#showSect('timeSlice', desc=True) #Activate for additional info if there is any
3.11 Time Slices for Output Requests
------------------------------------
#           label  |  Record Label
#           title  |  Record Title
#            type  |  Type of time slice
#           start  |  Start year
#             end  |  End year
#            step  |  Step (years)
#        sliceLen  |  Length of slice
#          nyears  |  Total number of years
#             uid  |  Unique identifier
#       startList  |  Optional list of start times.
#    sliceLenUnit  |  Units of slice length
#     description  |  Description
#           child  |  Child experiment
-------
Example
-------
#           label  |  abrupt20
#           title  |  Years 131 to 150 from start
#            type  |  relativeRange
#           start  |  131
#             end  |  150
#            step  |  
#        sliceLen  |  
#          nyears  |  20.0
#             uid  |  _slice_abrupt20
#       startList  |  
#    sliceLenUnit  |  
#     description  |  
#           child  |  
In [22]:
# Request Variable Group
print("The request variable groups are defined by MIPs.")
display(Image(filename='files/DreqPyStructure_4.png'))
showSect('requestVarGroup')
#showSect('requestVarGroup', desc=True) #Activate for additional info if there is any
The request variable groups are defined by MIPs.
3.1 Request variable group: a collection of request variables
-------------------------------------------------------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record Identifier
#             mip  |  Endorsed MIP defining the variable group
#             ref  |  Reference
#         refNote  |  Reference Note
-------
Example
-------
#           label  |  aer6hr
#           title  |  AerChemMIP 6 hourly data
#             uid  |  188bc360-c5ee-11e6-9285-ac72891c3257
#             mip  |  AerChemMIP
#             ref  |  new
#         refNote  |  AerChemMIP 6 hourly model levels
In [23]:
# Request Link
print("Each request item is linked (via request link) to a request variable group.")
print("Several request items can link to the same request variable group\n"\
      "for a different set of experiments, time slices, priorities, etc.")
print("Of course a request variable group can be requested by MIPs that did not define it.")
display(Image(filename='files/DreqPyStructure_5.png'))
showSect('requestLink',True)
#showSect('requestLink', desc=True) #Activate for additional info if there is any
Each request item is linked (via request link) to a request variable group.
Several request items can link to the same request variable group
for a different set of experiments, time slices, priorities, etc.
Of course a request variable group can be requested by MIPs that did not define it.
3.3 Request link: linking a set of variables and a set of experiments
---------------------------------------------------------------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record Identifier
#             mip  |  Endorsed MIP requesting the data
Link to record defining the MIP using this record.
#             tab  |  Redundant
A redundant attribute.
#       objective  |  Science objectives associated with this request
Every request for model ouput is linked to one or more objectives. The XML link is made via objectiveLink records, each of which associates one requestLink with one objective record.
#            grid  |  Grid options
Specified required or preferred (depending on the value of gridreq) horizontal grid. Options: native (for model grid), 1deg, 2deg, 8 to 25km (8km preferred, less than 25km required), 5 to 25km (5km preferred, less than 25km required), blank (no prerefence).  
#         gridreq  |  Grid option constraints
Is the grid specified by the grid attribute optional (yes) or (no), conditionally (no*1 -- used for ocean data, when native is required only from models using a regular grid)
#         comment  |  Comment
Comment on the requestLink record.
#             ref  |  Reference
Not used.
#         refNote  |  Note on reference
A comment on the provenance of the record.
#           refid  |  Reference to a request Variable Group
Link to the requestVarGroup record defining the variables associated with this requestLink.
#             opt  |  Option for selecting a subset of variables
Option for specifying that only a subset of the variables specified in the requestVarGroup should be used. This option is designed to enable the re-use of groups when an easily identified subset of an existing group is wanted. Forreen completed at the request compilation stage. If 'prioirty' is specified, then only variables with priority less than the value specified by 'opar' should be used.
#            opar  |  parameter associated with *opt*
Parameter associated with 'opar'. If 'opar' is 'priority' it should be set to '1', '2', or '3'.
-------
Example
-------
#           label  |  3hr
#           title  |  3hr
#             uid  |  ef12df16-5629-11e6-9079-ac72891c3257__00
#             mip  |  CMIP
#             tab  |  3hr
#       objective  |  Model Intercomparison
#            grid  |  1deg
#         gridreq  |  
#         comment  |  
#             ref  |  
#         refNote  |  
#           refid  |  ef12df16-5629-11e6-9079-ac72891c3257
#             opt  |  all
#            opar  |  
In [24]:
# Objective Link
print("Request items are linked to scientific objectives (via objective link and request link).")
display(Image(filename='files/DreqPyStructure_6.png'))
showSect('objectiveLink')
#showSect('objectiveLink', desc=True) #Activate for additional info if there is any
Request items are linked to scientific objectives (via objective link and request link).
3.7 Link between scientific objectives and requests
---------------------------------------------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record identifier
#             oid  |  Identifier for a scientific objective
#             rid  |  Identifier for a request link
-------
Example
-------
#           label  |  aerChem
#           title  |  aerChem [AerChemMIP]
#             uid  |  061156dcbfd0c4894c682f3235fbc696702eaaff
#             oid  |  030af762-c570-11e8-8bae-a44cc8186c64
#             rid  |  ef12e39e-5629-11e6-9079-ac72891c3257__00
In [25]:
# Request Variable
print("A request variable group holds a list of request variables.")
print("Request variables are basically links to CMOR variables with an\n"\
      "additional information about the CMOR variables' priority.")
display(Image(filename='files/DreqPyStructure_7.png'))
showSect('requestVar')
#showSect('requestVar', desc=True) #Activate for additional info if there is any
A request variable group holds a list of request variables.
Request variables are basically links to CMOR variables with an
additional information about the CMOR variables' priority.
1.4 Request variable (carrying priority and link to group)
----------------------------------------------------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record identifier
#        priority  |  Variable priority
#             vid  |  Identifier for MIP Output Variable
#            vgid  |  Identifier for Variable Group
#             mip  |  Endorsed MIP
-------
Example
-------
#           label  |  abs550aer
#           title  |  abs550aer ((isd.005))
#             uid  |  4722cdcf7a2270dcbf825458be02db5226203d3b
#        priority  |  1
#             vid  |  19bebf2a-81b1-11e6-92de-ac72891c3257
#            vgid  |  90104242-a26e-11e6-bfbb-ac72891c3257
#             mip  |  CFMIP
In [26]:
# CMOR Variable
showSect('CMORvar')
#showSect('CMORvar', desc=True) #Activate for additional info if there is any
#showSect('CMORvar', uid=[i.uid for i in dq.coll['CMORvar'].items if i.mipTable=="Esubhr" and i.label=="pr"][0])
#showSect('CMORvar', uid=[i.uid for i in dq.coll['CMORvar'].items if i.mipTable=="CFsubhr" and i.label=="pr"][0])
1.3 CMOR Variable
-----------------
#           label  |  CMOR Variable Name
#           title  |  Long name
#             uid  |  Record Identifier
#            stid  |  Link to a record specifying the structure of the variable
#             vid  |  MIP Variable
#         deflate  |  Deflate: NetCDF compression parameter
#   deflate_level  |  Deflate Level: NetCDF compression parameter
#         shuffle  |  Shuffle: NetCDF compression parameter
# defaultPriority  |  Indicative priority for this parameter, which is over-ruled by the requestVar priority setting, but provides a reference for organisation of the CMORvariables
#            type  |  Data value type, e.g. float or double
#  modeling_realm  |  Modeling Realm
#        positive  |  CMOR Directive Positive
# mipTableSection  |  Section of a table
#            mtid  |  Link to MIP table record
#        mipTable  |  The MIP table
#            prov  |  Provenance
#      processing  |  Processing Notes
#        provNote  |  Provenance Note
#       frequency  |  Frequency of Time Steps to be Archived
#        rowIndex  |  Row index of entry in source sheet
#     description  |  Description
#        subGroup  |  Sub-group of variables in a table
-------
Example
-------
#           label  |  abs550aer
#           title  |  Ambient Aerosol Absorption Optical Thickness at 550nm
#             uid  |  19bebf2a-81b1-11e6-92de-ac72891c3257
#            stid  |  dabd02ac-16f4-11e8-b44a-a44cc8186c64
#             vid  |  0baf6a333b91c4db341b515c28cd2c05
#         deflate  |  
#   deflate_level  |  
#         shuffle  |  
# defaultPriority  |  1
#            type  |  real
#  modeling_realm  |  aerosol
#        positive  |  
# mipTableSection  |  AERmon-oth
#            mtid  |  MIPtable::AERmon
#        mipTable  |  AERmon
#            prov  |  AERmon ((isd.003))
#      processing  |  
#        provNote  |  AERmon-oth
#       frequency  |  mon
#        rowIndex  |  -1
#     description  |  Optical thickness of atmospheric aerosols at wavelength 550 nanometers.
#        subGroup  |  
In [27]:
# MIP Variable
print("MIP variables are defined by a MIP and linked to CMOR variables.")
print("They hold information like the variables' unit, etc.")
display(Image(filename='files/DreqPyStructure_8.png'))
showSect('var')
#showSect('var', desc=True) #Activate for additional info if there is any
MIP variables are defined by a MIP and linked to CMOR variables.
They hold information like the variables' unit, etc.
1.2 MIP Variable
----------------
#           label  |  Variable Name
#           title  |  Long name
#              sn  |  CF Standard Name
#           units  |  Units of Measure
#     description  |  Record Description
#        procnote  |  Processing Notes
#     procComment  |  Processing Comments
#            prov  |  Notes on Provenance of Variable Specifications
#             uid  |  Record Identifier
#         provmip  |  MIP Defining this Variable
#            unid  |  Link to Units section
-------
Example
-------
#           label  |  abs550aer
#           title  |  Ambient Aerosol Absorption Optical Thickness at 550nm
#              sn  |  atmosphere_absorption_optical_thickness_due_to_ambient_aerosol_particles
#           units  |  1
#     description  |  Optical thickness of atmospheric aerosols at wavelength 550 nanometers.
#        procnote  |  ('',)
#     procComment  |  
#            prov  |  CMIP5_aero
#             uid  |  0baf6a333b91c4db341b515c28cd2c05
#         provmip  |  AerChemMIP
#            unid  |  fd6fef50-3468-11e6-ba71-5404a60d96b5
In [28]:
# Variable Choice Links
print("CMOR variables can be subject to a variable choice.")
print("Those choices are either defined by a hierarchy (ranked choice),\n"\
      "or the choice is made via the model configuration (configuration choice).")
display(Image(filename='files/DreqPyStructure_9.png'))
showSect('varChoiceLinkC')
#showSect('varChoiceLinkC', desc=True) #Activate for additional info if there is any
print("\n"*2)
showSect('varChoiceLinkR')
#showSect('varChoiceLinkR', desc=True) #Activate for additional info if there is any
CMOR variables can be subject to a variable choice.
Those choices are either defined by a hierarchy (ranked choice),
or the choice is made via the model configuration (configuration choice).
3.6 Links a variable to a choice element
----------------------------------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record identifier
#             vid  |  Variable
#           cfgid  |  Configuration Option
#             cfg  |  Configuration Value
#             cid  |  Choice -- can provide a link to related variables
-------
Example
-------
#           label  |  bigthetao-Omon
#           title  |  bigthetao.Omon
#             uid  |  Choice:bigthetao-Omon
#             vid  |  baa5255c-e5dd-11e5-8482-ac72891c3257
#           cfgid  |  PrognosticConservativeTemperature
#             cfg  |  True
#             cid  |  0c31d56a-0c2d-11e8-9d87-1c4d70487308



3.9 Links a variable to a choice element
----------------------------------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record identifier
#             vid  |  Variable
#             cid  |  Choice
#            rank  |  For ranked choices, the rank of this variable (higher rank makes lower ranks redundant)
-------
Example
-------
#           label  |  hus-3hrPlev
#           title  |  hus [3hrPlev]
#             uid  |  f5bfecd6-26b8-11e7-8344-ac72891c3257
#             vid  |  f2c7178e-26b8-11e7-8344-ac72891c3257
#             cid  |  choices_HighResMIP.overlap.hus
#            rank  |  3
In [29]:
# Model Configuration
showSect('modelConfig')
#showSect('modelConfig', desc=True) #Activate for additional info if there is any

#Variable Choice
print("\n"*2)
showSect('varChoice')
#showSect('varChoice', desc=True) #Activate for additional info if there is any
3.5 Model configuration options
-------------------------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record identifier
#            MIPs  |  MIPs which make use of this feature
#           usage  |  How the feature is relevant to the data request
#            type  |  Type of model
#           range  |  Range of valid values, e.g. xs:boolean
-------
Example
-------
#           label  |  bigthetao
#           title  |  Prognostic Conservative Temperature
#             uid  |  PrognosticConservativeTemperature
#            MIPs  |  
#           usage  |  True for models using conservative temperature as prognostic field.
#            type  |  capability
#           range  |  xs:boolean



3.10 Indicates variables for which a there is a range of potential CMOR Variables
---------------------------------------------------------------------------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record identifier
#     choiceClass  |  Class of choice: heirarchy|cfg
#     description  |  Record description
#         varList  |  A colon separated list of variable names
#      optionList  |  A list of options, one for each variable
-------
Example
-------
#           label  |  bigthetao
#           title  |  Conservative Temperature
#             uid  |  0c31d56a-0c2d-11e8-9d87-1c4d70487308
#     choiceClass  |  ConfigurationOptionSet
#     description  |  Variables which are only needed for models which include conservative termperature as a prognostic variable.
#         varList  |  bigthetao bigthetaoga
#      optionList  |  
In [30]:
# Structure
print("CMOR variables are linked to the structure, that holds information about dimensions ...")
display(Image(filename='files/DreqPyStructure_10.png'))
showSect('structure')
#showSect('structure', desc=True) #Activate for additional info if there is any
CMOR variables are linked to the structure, that holds information about dimensions ...
2.3 Dimensions and related information
--------------------------------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record Identifier
#            spid  |  Spatial Shape
#            tmid  |  Temporal Shape
#           odims  |  Other Dimensions
#            dids  |  Identifiers for records in grids section for dimensions
#          coords  |  Coordinates
#            cids  |  Identifiers for records in grids section for coordinates
#    cell_methods  |  Cell Methods
#   cell_measures  |  Cell Measures
#     flag_values  |  Flag Values
#   flag_meanings  |  FLag Meanings
#     description  |  Description
#        procNote  |  Processing Note
#            prov  |  Provenance
#            cmid  |  Link to Cell Methods Record
-------
Example
-------
#           label  |  str-010
#           title  |  Instantaneous value (i.e. synoptic or time-step value), Global field on model atmosphere half-levels [XY-AH] [amn-tpt]
#             uid  |  f7dc8770-562c-11e6-a2a4-ac72891c3257
#            spid  |  a6563274-8883-11e5-b571-ac72891c3257
#            tmid  |  7a976ce0-8042-11e6-97ee-ac72891c3257
#           odims  |  
#            dids  |  
#          coords  |  
#            cids  |  
#    cell_methods  |  area: mean time: point
#   cell_measures  |  area: areacella
#     flag_values  |  
#   flag_meanings  |  
#     description  |  
#        procNote  |  xyz
#            prov  |  CMIP5/OMIP
#            cmid  |  CellMethods::amn-tpt
In [31]:
# Temporal and Spatial Shape
print("... such as the spatial and temporal shape.")
display(Image(filename='files/DreqPyStructure_11.png'))
showSect('temporalShape')
#showSect('temporalShape', desc=True) #Activate for additional info if there is any
print("\n"*2)
showSect('spatialShape')
#showSect('spatialShape', desc=True) #Activate for additional info if there is any
... such as the spatial and temporal shape.
2.2 Temporal dimension
----------------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record Identifier
#           dimid  |  Identifiers for record in grids section
#      dimensions  |  Dimensions
#     description  |  Description
-------
Example
-------
#           label  |  climatology
#           title  |  Climatological mean
#             uid  |  7a97ae58-8042-11e6-97ee-ac72891c3257
#           dimid  |  dim:time2
#      dimensions  |  time2
#     description  |  



2.1 Spatial dimensions
----------------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record Identifier
#      dimensions  |  List of spatial dimensions
#          dimids  |  Identifiers for records in grids section
#          levels  |  Number of vertical levels (ignored if levelFlag=false)
#       levelFlag  |  Flag set to *false* if number of levels is optional (e.g. determined by the model)
-------
Example
-------
#           label  |  GYB-O
#           title  |  Ocean Basin grid-Meridional Section
#             uid  |  4b5dfb22-43c0-11e8-be0a-1c4d70487308
#      dimensions  |  gridlatitude|olevel|basin
#          dimids  |  ('dim:grid_latitude', 'dim:olevel', 'dim:basin')
#          levels  |  0
#       levelFlag  |  False
In [32]:
# Grids/Dimensions
print("Spatial and temporal shape are linked to a grid entry.")
print("Structure also links to the cell methods.")
display(Image(filename='files/DreqPyStructure_12.png'))
showSect('grids')
#showSect('grids', desc=True) #Activate for additional info if there is any
Spatial and temporal shape are linked to a grid entry.
Structure also links to the cell methods.
1.7 Specification of dimensions
-------------------------------
#           label  |  CMOR dimension
#           title  |  long name
#          tables  |  CMOR table(s)
#             uid  |  Identifier
#        altLabel  |  output dimension name
#     description  |  description
#    standardName  |  standard name
#            axis  |  axis
#           units  |  units
#         isIndex  |  index axis?
#          coords  |  coords_attrib
#          bounds  |  bounds?
#       direction  |  stored direction
#       valid_min  |  valid_min
#       valid_max  |  valid_max
#            type  |  type
#        positive  |  positive
#           value  |  value of a scalar coordinate
#    boundsValues  |  bounds _values
#       requested  |  requested
# boundsRequested  |  bounds_ requested
#    tolRequested  |  tol_on_requests: variance from requested values that is tolerated
#          isGrid  |  grid?
-------
Example
-------
#           label  |  alevel
#           title  |  atmospheric model level
#          tables  |  Amon, aero, 6hrLev, CFmon, CFday, CF3hr, CFsubhr
#             uid  |  dim:alevel
#        altLabel  |  lev
#     description  |  Generic atmospheric model vertical coordinate (nondimensional or dimensional) [use CF standard name apporpriate for model vertical coordinate, e.g. model_level_number or atmosphere_sigma_coordinate]
#    standardName  |  
#            axis  |  Z
#           units  |  
#         isIndex  |  ok
#          coords  |  
#          bounds  |  yes
#       direction  |  
#       valid_min  |  
#       valid_max  |  
#            type  |  double
#        positive  |  up
#           value  |  
#    boundsValues  |  
#       requested  |  
# boundsRequested  |  
#    tolRequested  |  
#          isGrid  |  
In [33]:
# Cell Methods
showSect('cellMethods')
#showSect('cellMethods, desc=True) #Activate for additional info if there is any if there is any
7.1 Cell Methods
----------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  Record Identifier
#    cell_methods  |  Cell Methods String
#     description  |  Record Description
-------
Example
-------
#           label  |  aclim
#           title  |  Annual Climatology
#             uid  |  CellMethods::aclim
#    cell_methods  |  area: mean time: mean within years time: mean over years
#     description  |  
In [34]:
# Standard Name
print("Grids and MIP variables have a defined standard name.")
print("This concludes the list with the most important objects \n"\
    "of the DreqPy CMIP6 Data Request structure.")
display(Image(filename='files/DreqPyStructure.png'))
showSect('standardname')
#showSect('standardname', desc=True) #Activate for additional info if there is any
Grids and MIP variables have a defined standard name.
This concludes the list with the most important objects 
of the DreqPy CMIP6 Data Request structure.
1.8 CF Standard Names
---------------------
#           label  |  Record Label
#           title  |  Record Title
#             uid  |  CF Standard Name
#     description  |  Record Description
#           units  |  Canonical Units
-------
Example
-------
#           label  |  AcousticSignalRoundtripTravelTimeInSeaWater
#           title  |  Acoustic Signal Roundtrip Travel Time in Sea Water
#             uid  |  acoustic_signal_roundtrip_travel_time_in_sea_water
#     description  |  The quantity with standard name acoustic_signal_roundtrip_travel_time_in_sea_water is the time taken for an acoustic signal to propagate from the emitting instrument to a reflecting surface and back again to the instrument. In the case of an instrument based on the sea floor and measuring the roundtrip time to the sea surface, the data are commonly used as a measure of ocean heat content.
#           units  |  s

5 - Advanced Example

Get a list of all variables requested by the CMIP6 Endorsed MIP 'C4MIP':

To attain the requested variables for an experiment, experiment group, or MIP, the first step is to find all requestItem-items (or requestLink-items) related to this experiment/experiment group/MIP.

Then proceed to find all requestVarGroup-items by following the Request Links. The requestVarGroup-items hold the requestVar-items, which finally are linked to the desired CMORvar-items.

In [35]:
# We want a list of all CMOR variables requested by C4MIP 
# 1 Collect all 'requestLink'-items, for requests made by 'C4MIP':
C4MIP_rL = [ rLink for rLink in dq.coll['requestLink'].items\
           if rLink.mip=='C4MIP']
print("%i requestLink-items found for 'C4MIP'.\n" % len(C4MIP_rL))
13 requestLink-items found for 'C4MIP'.

In [36]:
# 2.1 Find the 'requestVarGroup'-items, associated with these requestLinks,
#   (not all requestVarGroups have to be defined by C4MIP!):
C4MIP_rVG = set([ dq.inx.uid[rLink.refid] for rLink in C4MIP_rL ])

print("%i requestVarGroup-items found for 'C4MIP'.\n" % len(C4MIP_rVG))

# 2.2 Get the UIDs of the requestVarGroup-items:
C4MIP_rVG_UIDs = [ rVG.uid for rVG in C4MIP_rVG ]

# 3 Find the 'requestVar'-items, associated with these requestVarGroups:
C4MIP_rV = set([ rV for rV in dq.coll['requestVar'].items\
               if rV.vgid in C4MIP_rVG_UIDs])

print("%i requestVar-items found for 'C4MIP'.\n" % len(C4MIP_rV))
13 requestVarGroup-items found for 'C4MIP'.

764 requestVar-items found for 'C4MIP'.

In [37]:
# 4.1 Get the CMORvar-UIDs from the requestVar-items:
C4MIP_rV_VIDs = [ rV.vid for rV in C4MIP_rV ]

# 4.2 Find the 'CMORvar'-items, associated with these requestVars:
C4MIP_CMORvars = set([ cmvar for cmvar in dq.coll['CMORvar'].items\
                 if cmvar.uid in C4MIP_rV_VIDs ])

print("%i CMORvar-items found for 'C4MIP'\n" % len(C4MIP_CMORvars))
print("Here are the first 10 list entries:")

C4MIP_CMORvars=list(C4MIP_CMORvars) # set -> list conversion
for i in range(0, 10):
    if i<len(C4MIP_CMORvars):
        cmvar = C4MIP_CMORvars[i]
        print(" # %-15s | mipTable: %-10s | Frequency: %-2s\n   LongName: %s\n"\
            %(cmvar.label, cmvar.mipTable, cmvar.frequency, cmvar.title))
661 CMORvar-items found for 'C4MIP'

Here are the first 10 list entries:
 # dmso            | mipTable: Omon       | Frequency: mon
   LongName: Mole Concentration of Dimethyl Sulphide in Sea Water

 # msftbarot       | mipTable: Omon       | Frequency: mon
   LongName: Ocean Barotropic Mass Streamfunction

 # umo             | mipTable: Omon       | Frequency: mon
   LongName: Ocean Mass X Transport

 # dmsos           | mipTable: Omon       | Frequency: mon
   LongName: Surface Mole Concentration of Dimethyl Sulphide in Sea Water

 # msftmrho        | mipTable: Omon       | Frequency: mon
   LongName: Ocean Meridional Overturning Mass Streamfunction

 # dpco2           | mipTable: Omon       | Frequency: mon
   LongName: Delta CO2 Partial Pressure

 # msftmrhompa     | mipTable: Omon       | Frequency: mon
   LongName: Ocean Meridional Overturning Mass Streamfunction Due to Parameterized Mesoscale Advection

 # uo              | mipTable: Omon       | Frequency: mon
   LongName: Sea Water X Velocity

 # dpco2abio       | mipTable: Omon       | Frequency: mon
   LongName: Abiotic Delta Pco Partial Pressure

 # dpco2nat        | mipTable: Omon       | Frequency: mon
   LongName: Natural Delta CO2 Partial Pressure 

In [38]:
# Now we only want the list of variables requested by C4MIP for a certain experiment.
# We use the "requestItems" for this purpose:

# Find all experiments, C4MIP is requesting data from:
# We select all requestItems of C4MIP (via the link rlid to the requestLinks) 
# and list all experiments that C4MIP is requesting data from
C4MIP_rI_esids = [ item.esid for item in dq.coll['requestItem'].items \
           if dq.inx.uid[item.rlid].mip=='C4MIP']
print("%i requestItem-experiment-identifiers found for 'C4MIP'.\n" % len(set(C4MIP_rI_esids)))
      
# The collected "esids" are the unique identifiers of either 
# experiments, experiment groups or MIPs.
# Experiment groups are self explanatory.
# If the "esid" links to a MIP, it means that the respective requestItem is
# valid for all the experiments defined by that MIP
# -> Now let us translate the esids to only experiment ids:
C4MIP_rI_expids = list()
for itemid in set(C4MIP_rI_esids):
        if type(dq.inx.uid[itemid])==type(dq.coll['experiment'].items[0]):
                C4MIP_rI_expids.append(dq.inx.uid[itemid].uid)
        elif type(dq.inx.uid[itemid])==type(dq.coll['exptgroup'].items[0]):
                for exp in dq.coll['experiment'].items:
                        if exp.egid==itemid: C4MIP_rI_expids.append(exp.uid)
        elif type(dq.inx.uid[itemid])==type(dq.coll['mip'].items[0]):  
                for exp in dq.coll['experiment'].items:
                        if exp.mip==itemid: C4MIP_rI_expids.append(exp.uid)                
        else:
            print("Experiment identifier %s links to neither experiment, experiment "\
                  "group nor MIP." % itemid)
print("C4MIP requests data from %i experiments.\n" % len(set(C4MIP_rI_expids)))
19 requestItem-experiment-identifiers found for 'C4MIP'.

C4MIP requests data from 99 experiments.

In [39]:
# Is there one experiment not defined by C4MIP?
for expid in set(C4MIP_rI_expids):
    if dq.inx.uid[expid].mip!="C4MIP": 
        req_expid=expid
        req_explabel=dq.inx.uid[req_expid].label
        print(req_explabel)
        break
1pctCO2
In [40]:
# Which variables are requested for this experiment by C4MIP?

# 1 Collect all possible experiment identifiers for this experiment:
# -> experiment uid, experiment group uid, mip uid
exp_esids=[req_expid, dq.inx.uid[req_expid].egid, dq.inx.uid[req_expid].mip]


# 2 Find the requestLinks with requests by C4MIP, linking to requestItems
# that are requested from one of our experiment identifiers:
exp_rl=[dq.inx.uid[rItem.rlid] for rItem in dq.coll['requestItem'].items \
           if dq.inx.uid[rItem.rlid].mip=='C4MIP' and rItem.esid in exp_esids]

print("%i requestItems found for 'C4MIP' and '%s'.\n" % (len(exp_rl), req_explabel))


# 3.1 Find the 'requestVarGroup'-items, associated with these requestLinks,
#   (not all requestVarGroups have to be defined by C4MIP!):
exp_rVG = set([ dq.inx.uid[rLink.refid].uid for rLink in exp_rl ])

print("%i requestVarGroup-items found for 'C4MIP' and '%s'.\n" % (len(exp_rVG),req_explabel))


# 4 Find the 'requestVar'-items, associated with these requestVarGroups:
exp_rV = set([ rV for rV in dq.coll['requestVar'].items \
               if rV.vgid in exp_rVG])

print("%i requestVar-items found for 'C4MIP' and '%s'.\n" % (len(exp_rV),req_explabel))

# 5 Find the 'CMORvar'-items, associated with these requestVars:
exp_CMORvars = set([ cmvar for cmvar in dq.coll['CMORvar'].items \
                 if cmvar.uid in [rV_i.vid for rV_i in exp_rV] ])

print("%i CMORvar-items found for 'C4MIP' and '%s'.\n" % (len(set(exp_CMORvars)),req_explabel))
6 requestItems found for 'C4MIP' and '1pctCO2'.

6 requestVarGroup-items found for 'C4MIP' and '1pctCO2'.

266 requestVar-items found for 'C4MIP' and '1pctCO2'.

265 CMORvar-items found for 'C4MIP' and '1pctCO2'.

6a - Data Request Volume Estimate

Estimate the Volume from a Data Request

In [41]:
# Import
from dreqPy import scope

# Initialisation
sc = scope.dreqQuery()

print("Using DreqPy (Data Request Python API) in version %s"\
    % str(sc.dq.version))
    
    
# Type   Storage Allocation
#--------------------------
# char   1 Byte
# bool   1 Byte
# short  2 Byte
# int    4 Byte
# long   4 Byte
# float  4 Byte
# double 8 Byte

# Assume 50% compression:
compression   = 50
bytesPerFloat = compression/100.*4.

# Set maximum tier [1,4]
tierMax       = 4

# Set maximum priority [1,3]
priorityMax   = 3

#Force native grid or set native grid as default for more realistic estimates.
# else many requests will be estimated for a 1-degree grid.
sc.gridPolicyDefaultNative=True
#sc.gridPolicyForce='native'

# Print Volume Estimate Configuration settings
print("\nDefault model configuration settings:")
for key in sc.mcfg.keys():
    print("%-5s  %s"  %(str(key), str(sc.mcfg[key])))

# Configure Volume Estimate:
# Example MPI-ESM1.2-HR
#----------------------
# MPIOM Ocean (Res. TP04L40, ~0.4°)
nho  = 6811850/40  # Nr. of hor. mesh points in ocean
nlo  = 40          # Nr. of vertical levels in ocean
# ECHAM 6.3 Atmosphere (Res T127L95, ~1°)
nha  = 7004160/95  # Nr. of hor. mesh points in atm.
nla  = 95          # Nr. of vertical levels in atm.
nlas = 43 #guess   # Nr. of vertical levels in StrSph.
nh1  = 3*128       # Nr. of latitude points
# JSBACH Land Model
nls  = 5           # Nr. of vertical levels in soil model
#Description
mcfg_desc={}
mcfg_desc['nho'] = "Number of horizontal mesh points in ocean"
mcfg_desc['nlo'] = "Number of vertical levels in ocean"
mcfg_desc['nha'] = "Number of horizontal mesh points in atmosphere"
mcfg_desc['nla'] = "Number of vertical levels in atmosphere"
mcfg_desc['nlas']= "Number of vertical levels in stratosphere"
mcfg_desc['nh1'] = "Number of latitude points"
mcfg_desc['nls'] = "Number of vertical levels in soil"

# Apply settings
MCFG={"nho":nho, "nlo":nlo, "nha":nha, "nla":nla, "nlas":nlas, "nls":nls, "nh1":nh1}
sc.setMcfg([int(MCFG[key]) for key in sc.mcfg])

# Print Volume Estimate Configuration settings
print("\nUpdated model configuration settings (Check!):")
for key in sc.mcfg.keys():
    print("%-5s  %-15s - %s"  %(str(key), str(sc.mcfg[key]), mcfg_desc[key]))
Using DreqPy (Data Request Python API) in version 01.00.31beta

Default model configuration settings:
nho    259200
nlo    60
nha    64800
nla    40
nlas   20
nls    5
nh1    100

Updated model configuration settings (Check!):
nho    170296          - Number of horizontal mesh points in ocean
nlo    40              - Number of vertical levels in ocean
nha    73728           - Number of horizontal mesh points in atmosphere
nla    95              - Number of vertical levels in atmosphere
nlas   43              - Number of vertical levels in stratosphere
nls    5               - Number of vertical levels in soil
nh1    384             - Number of latitude points
In [42]:
# Select the MIPs
mips=["CMIP", "ScenarioMIP"]

# Select for example all experiments defined by these MIPs for the selected tiers (tierMax or sc.setTierMax below)
experiments=[exp.uid for exp in dq.coll['experiment'].items if exp.mip in mips and min(exp.tier)<tierMax]

# Selected MIPs and experiments:
print("Selected MIPs:\n-----------------------------")

for mip in mips:
    print("Entry %s:" % mip)
    for key in dq.coll['mip'].attDefn.keys(): 
        print("   %-15s : %s" %(key, getattr(dq.inx.uid[mip], key)))
        
print("\n\nSelected Experiments:\n-----------------------------")

for exp in experiments:
    print("Entry %s:" % exp)
    for key in dq.coll['experiment'].attDefn.keys():         
        if key not in ['label', 'title']: continue
        print("   %-15s : %s" %(key, getattr(dq.inx.uid[exp], key)))  
Selected MIPs:
-----------------------------
Entry CMIP:
   label           : CMIP
   title           : Coupled Model Intercomparison Project
   uid             : CMIP
   description     : Item <X.1 Core Attributes>: [description] Description of the Model Intercomparison Project
   url             : 
Entry ScenarioMIP:
   label           : ScenarioMIP
   title           : Scenario Model Intercomparison Project
   uid             : ScenarioMIP
   description     : Item <X.1 Core Attributes>: [description] Description of the Model Intercomparison Project
   url             : https://cmip.ucar.edu/scenario-mip


Selected Experiments:
-----------------------------
Entry f16fc0b0-dd9e-11e6-b89b-ac72891c3257:
   label           : 1pctCO2
   title           : 1 percent per year increase in CO2
Entry f16fbe1c-dd9e-11e6-b89b-ac72891c3257:
   label           : abrupt-4xCO2
   title           : abrupt quadrupling of CO2
Entry f16fc344-dd9e-11e6-b89b-ac72891c3257:
   label           : amip
   title           : AMIP
Entry f16fc9ac-dd9e-11e6-b89b-ac72891c3257:
   label           : esm-hist
   title           : all-forcing simulation of the recent past with atmospheric CO2 concentration calculated
Entry f16fd136-dd9e-11e6-b89b-ac72891c3257:
   label           : esm-hist-ext
   title           : post-2014 all-forcing simulation with atmospheric CO2 concentration calculated
Entry f16fcc40-dd9e-11e6-b89b-ac72891c3257:
   label           : esm-piControl
   title           : pre-industrial control simulation with CO2 concentration calculated
Entry f16fd636-dd9e-11e6-b89b-ac72891c3257:
   label           : esm-piControl-spinup
   title           : pre-industrial control simulation with CO2 concentration calculated (spin-up)
Entry f16fc5c4-dd9e-11e6-b89b-ac72891c3257:
   label           : historical
   title           : all-forcing simulation of the recent past
Entry f16fcec0-dd9e-11e6-b89b-ac72891c3257:
   label           : historical-ext
   title           : post-2014 all-forcing simulation
Entry f16fb9da-dd9e-11e6-b89b-ac72891c3257:
   label           : piControl
   title           : pre-industrial control
Entry f16fd3b6-dd9e-11e6-b89b-ac72891c3257:
   label           : piControl-spinup
   title           : pre-industrial control (spin-up)
Entry f16f77c2-dd9e-11e6-b89b-ac72891c3257:
   label           : ssp119
   title           : low-end scenario reaching 1.9 W m-2, based on SSP1
Entry f16f6188-dd9e-11e6-b89b-ac72891c3257:
   label           : ssp126
   title           : update of RCP2.6 based on SSP1
Entry f16f5da0-dd9e-11e6-b89b-ac72891c3257:
   label           : ssp245
   title           : update of RCP4.5 based on SSP2
Entry f16f5ab2-dd9e-11e6-b89b-ac72891c3257:
   label           : ssp370
   title           : gap-filling scenario reaching 7.0 based on SSP3
Entry f16f68b8-dd9e-11e6-b89b-ac72891c3257:
   label           : ssp434
   title           : gap-filling scenario reaching 3.4 based on SSP4
Entry f16f6476-dd9e-11e6-b89b-ac72891c3257:
   label           : ssp460
   title           : update of RCP6.0 based on SSP4
Entry f16f73f8-dd9e-11e6-b89b-ac72891c3257:
   label           : ssp534-over
   title           : overshoot of 3.4 W/m**2 branching from ssp585 in 2040
Entry f16f5684-dd9e-11e6-b89b-ac72891c3257:
   label           : ssp585
   title           : update of RCP8.5 based on SSP5
In [43]:
# Filter (=whitelist) variables, specifying a list of CMORvar UIDs
WL = []
# Example: whitelist all variables but "tas"
#WL = [cmvar.uid for cmvar in dq.coll['CMORvar'].items if not cmvar.label=="tas"]

# Alternatively blacklist variables, specifying a list of CMORvar UIDs
BL = []
# Example: blacklist variable "tas"
#BL = [cmvar.uid for cmvar in dq.coll['CMORvar'].items if cmvar.label=="tas"]
In [44]:
# Volsum Class - create object vs
from dreqPy import volsum

def VolumeEstimateWBL(MIP, Expt, WL, BL, priorityMax=3, tierMax=4, bytesPerFloat=2.):
    """
    Function to set up a configuration for
    "dreqPy.scope.dreqQuery"
    and call its function volByMip
    Args:
    MIP:    set(str)  - Set of MIP UIDs
    Expt:   set(str)  - Set of Experiment UIDs
    WL:     list(str) - List of CMORvar UIDs
    BL:     list(str) - List of CMORvar UIDs
    priorityMax : int - Maximum priority of the variables
                         taken into account [1,3]
                         Default: 3
    tierMax:      int  - Maximum supported tier [1,4]
    bytesPerFloat: float - Compression factor
                           Default: 2. # 50% compression
    """

    # Set the experiment filter
    sc.exptFilter=set(Expt)

    # Alternatively, there is also a blacklist-filter
    #sc.exptFilterBlack=set([exp.uid for exp in dq.coll['experiment'].items if exp.uid not in Expt])
    
    #Set maximum supported tier
    sc.setTierMax(tierMax)
    
    # Initialize volsum object
    vs = volsum.vsum(sc, scope.odsz, scope.npy, odir="/home/k/k204212/tmp/")

    # Detailed Volume Estimate (filtered by Experiments and MIPs)
    ss        = 0
    result    = list()
    resultmip = list()
    for mip in mips:
        sm=0

        #run volsum class functions
        vs.run(mip, pmax=priorityMax, doxlsx=False)
        vs.anal(makeTabs=False, olab=mip)

        result.append(list())
        for  exp in experiments:
            x = vs.res['ve'][exp]
            if x>1:
                result[-1].append([mip, dq.inx.uid[exp].label, x*1.e-12*bytesPerFloat, exp])
            ss+=x
            sm+=x        
        resultmip.append([mip, sm*1.e-12*bytesPerFloat])
        
    # For all MIPs
    vs.run(set(mips), pmax=priorityMax, doxlsx=False)
    vs.anal(makeTabs=False, olab='TOTAL')
    z=0
    for mi in vs.res['vm']:
        z+=vs.res['vm'][mi]

    for i in range(0, len(result)):
        result[i]=sorted(result[i], key=lambda x: x[2], reverse=True)
    result.sort(key=lambda x:sum([y[2] for y in x]), reverse=True)
    resultmip.sort(key=lambda x: x[1], reverse=True)    
    
    
    # Get an estimate for whitelisted or without blacklisted variables    
    wbz=0.
    if WL!=[]:
        wbz=sum([vs.res['vu'][uid] for uid in vs.res['vu'].keys() if uid in WL])
    elif BL!=[]:
        wbz=sum([vs.res['vu'][uid] for uid in vs.res['vu'].keys() if not uid in BL])

   
    # Print result for MIPs
    print("Request of every single MIP:")
    for mip_and_res in resultmip:
        print('%-15s:  %5.1f Tb'  % (mip_and_res[0], mip_and_res[1]))
    # Print sum of all MIPs    
    print("\nSum for all MIPs:  %5.1f Tb" % float(ss*1.e-12*bytesPerFloat))
    # Print the estimate for the combined request:
    # as MIPs may request the same data from the same experiments,
    # there might be an overlap (Sum of all requests >= Combined request)
    print("Combined Request:  %5.1f Tb" % float(z*1.e-12*bytesPerFloat))
    print("Overlap         :  %5.1f Tb" % float((ss-z)*1.e-12*bytesPerFloat))
    
    
    # Same for all experiments 
    print("\nVolume estimate of the request for every single Experiment:")
    VolByE    = list()
    resultexp = list()    
    for i in range(0, len(Expt)):
        # Calculate volByMip and sum up for every experiment
        # if statement to avoid bug in version 01.beta.41 and older
        Esize=vs.res['ve'][Expt[i]]
        resultexp.append([dq.inx.uid[Expt[i]].label, Esize*1.e-12*bytesPerFloat])
        VolByE.append(Esize)

    resultexp.sort(key=lambda x: x[1], reverse=True)
    for exp_and_res in resultexp: 
        print('%-20s:  %5.1f Tb'  % (exp_and_res[0], exp_and_res[1]))
    ss=0.
    for val in VolByE: ss+=val
    print("-> Combined Request :  %5.1f Tb" % (ss*1.e-12*bytesPerFloat))
    
    
    # Print estimate including application of Black- or Whitelist
    if BL!=[]:
        print("\nVolume estimate without blacklisted variables:", wbz*1.e-12*bytesPerFloat)
    elif WL!=[]:
        print("\nVolume estimate for whitelisted variables:", wbz*1.e-12*bytesPerFloat)
         

            
# Call the function with above specifications  
VolumeEstimateWBL(mips, experiments, WL, BL, priorityMax, tierMax, bytesPerFloat)
Request of every single MIP:
CMIP           :   53.4 Tb
ScenarioMIP    :    0.0 Tb

Sum for all MIPs:   53.4 Tb
Combined Request:   53.4 Tb
Overlap         :    0.0 Tb

Volume estimate of the request for every single Experiment:
abrupt-4xCO2        :   11.1 Tb
historical          :    7.8 Tb
piControl           :    7.4 Tb
esm-piControl       :    7.4 Tb
amip                :    3.3 Tb
esm-hist            :    3.0 Tb
1pctCO2             :    2.4 Tb
esm-piControl-spinup:    1.3 Tb
piControl-spinup    :    1.3 Tb
ssp119              :    1.1 Tb
ssp126              :    1.1 Tb
ssp245              :    1.1 Tb
ssp370              :    1.1 Tb
ssp434              :    1.1 Tb
ssp460              :    1.1 Tb
ssp585              :    1.1 Tb
ssp534-over         :    0.8 Tb
historical-ext      :    0.1 Tb
esm-hist-ext        :    0.0 Tb
-> Combined Request :   53.4 Tb

6b - Data Request Volume Estimate Legacy

Estimate the Volume from a Data Request - Legacy (outdated)

In [45]:
# Import
from dreqPy import scope

# Initialisation
sc = scope.dreqQuery()

print("Using DreqPy (Data Request Python API) in version %s"\
    % str(sc.dq.version))
    
    
# Type   Storage Allocation
#--------------------------
# char   1 Byte
# bool   1 Byte
# short  2 Byte
# int    4 Byte
# long   4 Byte
# float  4 Byte
# double 8 Byte

# Assume 50% compression:
bytesPerFloat = 2.

# Set maximum tier [1,4]
tierMax       = 4

# Set maximum priority [1,3]
priorityMax   = 3

# Print Volume Estimate Configuration settings
print("\nDefault model configuration settings:")
for key in sc.mcfg.keys():
    print("%-5s  %s"  %(str(key), str(sc.mcfg[key])))

# Configure Volume Estimate:
# Example MPI-ESM1.2-HR
#----------------------
# MPIOM Ocean (Res. TP04L40, ~0.4°)
nho  = 6811850/40  # Nr. of hor. mesh points in ocean
nlo  = 40          # Nr. of vertical levels in ocean
# ECHAM 6.3 Atmosphere (Res T127L95, ~1°)
nha  = 7004160/95  # Nr. of hor. mesh points in atm.
nla  = 95          # Nr. of vertical levels in atm.
nlas = 43 #guess   # Nr. of vertical levels in StrSph.
nh1  = 3*128       # Nr. of latitude points
# JSBACH Land Model
nls  = 5           # Nr. of vertical levels in soil model

# Apply settings
MCFG=[nho, nlo, nha, nla, nlas, nls, nh1]
sc.setMcfg([int(i) for i in MCFG])

# Print Volume Estimate Configuration settings
print("\nUpdated model configuration settings (Check!):")
for key in sc.mcfg.keys():
    print("%-5s  %s"  %(str(key), str(sc.mcfg[key])))
Using DreqPy (Data Request Python API) in version 01.00.31beta

Default model configuration settings:
nho    259200
nlo    60
nha    64800
nla    40
nlas   20
nls    5
nh1    100

Updated model configuration settings (Check!):
nho    170296
nlo    40
nha    73728
nla    95
nlas   43
nls    5
nh1    384
In [46]:
def VolumeEstimateLegacy(MIPorExpt, isMIP=True, priorityMax=3, tierMax=4, bytesPerFloat=2.):
    """
    Function to set up a configuration for 
    "dreqPy.scope.dreqQuery"
    and call its function volByMip
    Args:
    MIPorExpt:    set(str)  - Set of MIP or Experiment UIDs
    isMIP:        bool - MIPorExpt is MIP or Experiment
                         Default: True (MIPorExpt is MIP!)
    priorityMax : int  - Maximum priority of the variables 
                         taken into account [1,3]
                         Default: 3
    tierMax     : int  - Maximum tier of the experiments
                         taken into account [1,2,3,4]
                         Default: 4
    bytesPerFloat: float - Compression factor 
                           Default: 2. # 50% compression     
    """
    
    #Apply tier setting
    sc.setTierMax(tierMax)
    
    # Use dreqPy.scope.dreqQuery-function volByMip  
    if isMIP==True: 
        ss = 0.
        for mip in MIPorExpt:
                # Calculate volByMip and sum up
                x = sc.volByMip(mip, pmax=priorityMax)\
                                *1.e-12*bytesPerFloat
                print('%-15s:  %5.1fTb'  % (mip,x))
                ss += x
        z = sc.volByMip( set(MIPorExpt), pmax=priorityMax)\
                                *1.e-12*bytesPerFloat
            
    # Use dreqPy.scope.dreqQuery-function volByMip with 
    #    additional experiment arg
    else:
        VolByE    = list()
        MIPorExpt = list(MIPorExpt)
        for i in range(0, len(MIPorExpt)):
            #VolByE.append(list)
            Esize = 0. 
            # Calculate volByMip and sum up for every experiment
            # if statement to avoid bug in version 01.beta.41 and older
            Esize+=sc.volByMip(set([mip.uid for mip in dq.coll['mip'].items \
                            if not mip.uid in ['CMIP6', 'DECK', \
                            'PDRMIP', 'SolarMIP', 'SPECS', 'CCMI', 'CMIP5']]), \
                            pmax=priorityMax, exptid=MIPorExpt[i])\
                            *1.e-12*bytesPerFloat
            print('%-15s:  %5.1fTb'  % (dq.inx.uid[MIPorExpt[i]].label, Esize))      
            VolByE.append(Esize)
        ss=0.
        for val in VolByE: ss+=val
        z = sc.volByMip(set([mip.uid for mip in dq.coll['mip'].items \
                        if not mip.uid in ['CMIP6', 'DECK', \
                        'PDRMIP', 'SolarMIP', 'SPECS', 'CCMI', 'CMIP5']]), \
                        pmax=priorityMax, exptid=set(MIPorExpt))\
                        *1.e-12*bytesPerFloat
    
    # Print Info and calculate Overlap (Overlap is 0 for Experiments only!)                  
    print( 'Combined:  %5.1fTb'  % z )
    print( 'Overlap:   %5.1fTb'  % (ss-z) )
In [47]:
# Volume Estimate by MIP

print ( '######### All variables ###########' )
VolumeEstimateLegacy(set(["AerChemMIP", "C4MIP", "LUMIP"]), isMIP=True, \
               priorityMax=3, tierMax=4, bytesPerFloat=2.)

print ( '\n######### Top priority variables ###########' )
VolumeEstimateLegacy(set(["AerChemMIP", "C4MIP", "LUMIP"]), isMIP=True, \
               priorityMax=1, tierMax=4, bytesPerFloat=2.)
######### All variables ###########
LUMIP          :   39.0Tb
AerChemMIP     :  118.6Tb
C4MIP          :  106.7Tb
Combined:  232.9Tb
Overlap:    31.4Tb

######### Top priority variables ###########
LUMIP          :   14.9Tb
AerChemMIP     :   86.4Tb
C4MIP          :   23.5Tb
Combined:  119.5Tb
Overlap:     5.4Tb
In [48]:
# Legacy function sc.volByMip is being used in above examples (outdated) 
print(sc.volByMip(set(["C4MIP", "CFMIP"]), pmax=3, exptid=set([dq.coll['experiment'].items[i].uid for i in range(1,4)])))
1295689193672.0
In [49]:
# Volume Estimate by Experiments

# Get Experiment ids:
ExpIDs=list()
print("%-15s  %-8s  %-36s  %s\n%s" %("Experiment", "Ens.Size", "UID", "MIP", "-"*75))
for exp in dq.coll['experiment'].items:
    if exp.label in ['historical', 'amip', 'abrupt-4xCO2', '1pctCO2', 'piControl', \
                     'ssp245', 'ssp585', 'ssp370', 'ssp126']:        
        ExpIDs.append(exp.uid)     
        print("%-15s  %8s  %36s  %s" % (exp.label, ",".join([str(i) for i in exp.ensz]), exp.uid, exp.mip))
 
# Get Volume Estimates
print ( '\n######### All variables ###########' )
VolumeEstimateLegacy(set(ExpIDs), isMIP=False, \
               priorityMax=3, tierMax=4, bytesPerFloat=2.)

print ( '\n######### Top priority variables ###########' )
VolumeEstimateLegacy(set(ExpIDs), isMIP=False, \
               priorityMax=1, tierMax=1, bytesPerFloat=2.)
Experiment       Ens.Size  UID                                   MIP
---------------------------------------------------------------------------
1pctCO2                 1  f16fc0b0-dd9e-11e6-b89b-ac72891c3257  CMIP
abrupt-4xCO2            5  f16fbe1c-dd9e-11e6-b89b-ac72891c3257  CMIP
amip                    1  f16fc344-dd9e-11e6-b89b-ac72891c3257  CMIP
historical              1  f16fc5c4-dd9e-11e6-b89b-ac72891c3257  CMIP
piControl               1  f16fb9da-dd9e-11e6-b89b-ac72891c3257  CMIP
ssp126                  1  f16f6188-dd9e-11e6-b89b-ac72891c3257  ScenarioMIP
ssp245                1,3  f16f5da0-dd9e-11e6-b89b-ac72891c3257  ScenarioMIP
ssp370               1,10  f16f5ab2-dd9e-11e6-b89b-ac72891c3257  ScenarioMIP
ssp585                  1  f16f5684-dd9e-11e6-b89b-ac72891c3257  ScenarioMIP

######### All variables ###########
ssp370         :   36.9Tb
1pctCO2        :   10.8Tb
ssp245         :   15.2Tb
abrupt-4xCO2   :   19.5Tb
ssp585         :   12.9Tb
historical     :   63.6Tb
amip           :   12.6Tb
piControl      :   67.6Tb
ssp126         :   12.9Tb
Combined:  252.0Tb
Overlap:     0.0Tb

######### Top priority variables ###########
ssp370         :    8.0Tb
1pctCO2        :    8.0Tb
ssp245         :    7.3Tb
abrupt-4xCO2   :    9.4Tb
ssp585         :   11.9Tb
historical     :   51.9Tb
amip           :   10.0Tb
piControl      :   45.6Tb
ssp126         :   11.9Tb
Combined:  163.9Tb
Overlap:     0.0Tb

7 - Additional Functions

"Talk" to the Data Request using this functions

In [50]:
# Auxiliary Functions to find request variables for request Links or request Items
def requestVarTOrequestLink(rv, toScreen=False):
        """
        Args:
          + rv - 'dreqPy.dreq.dreqItem_requestVar'-object
          + toScreen - Boolean (print result to std.out or not)          
        Returns:
          + List of corresponding:
              - 'dreqPy.dreq.dreqItem_requestLink'-objects
        """

        #requestVar -> requestVarGroup.uid
        rvg= set([ y.uid for y in dq.coll['requestVarGroup'].items if y.uid==rv.vgid ])
        #requestVarGroup.uid -> requestLink
        rl = set([ x for x in dq.coll['requestLink'].items if x.refid in rvg])
        
        #print to std.out
        if toScreen==True:
                print("\nrequestLink(s) of requestVar '%s' (uid: %s):" \
                    % (rv.label, rv.uid))
                for i in rl: print(" %s (uid: %s) requested by mip '%s'" \
                        % (i.title, i.uid, i.mip))
                print()

        #return list of requestLink-objects
        return list(rl)

def requestVarTOrequestItem(rv, toScreen=False):
        """
        Args:
          + rv - 'dreqPy.dreq.dreqItem_requestVar'-object
          + toScreen - Boolean (print result to std.out or not)          
        Returns:
          + List of corresponding:
              - 'dreqPy.dreq.dreqItem_requestItem'-objects
        """
        
        #requestVar->requestLink
        rl=set([ x.uid for x in requestVarTOrequestLink(rv) ])
        #requestLink->requestItem
        ri=set([ x for x in dq.coll['requestItem'].items if x.rlid in rl ])

        #print to std.out
        if toScreen==True:
                print("\nrequestItem(s) of requestVar '%s' (uid: %s):" \
                    % (rv.label, rv.uid))
                for i in ri: print("%s (uid: %s) requested by mip '%s'" \
                        % (i.title, i.uid, i.mip))
                print()

        #return list of requestItem-objects
        return list(ri)
    
# Examples
rl = requestVarTOrequestLink(dq.coll['requestVar'].items[9], True)
ri = requestVarTOrequestItem(dq.coll['requestVar'].items[9], True)
requestLink(s) of requestVar 'acabfIs' (uid: 2688feae7b1f694f1fce94f7900c6e192411405c):
 ISMIP6-LImon-01 (uid: efc0c7ac-5629-11e6-9079-ac72891c3257__00) requested by mip 'ISMIP6'


requestItem(s) of requestVar 'acabfIs' (uid: 2688feae7b1f694f1fce94f7900c6e192411405c):
ISMIP6, ISMIP6-LImon-01, esm-hist (uid: 94044f1e-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'
ISMIP6, ISMIP6-LImon-01, historical-ext (uid: 940451d0-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'
ISMIP6, ISMIP6-LImon-01, lig127k (uid: 94046652-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'
ISMIP6, ISMIP6-LImon-01, esm-hist-ext (uid: 94045478-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'
ISMIP6, ISMIP6-LImon-01, ssp585 (uid: 940468c8-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'
ISMIP6, ISMIP6-LImon-01, ISMIP6-1 (uid: 940456e4-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'
ISMIP6, ISMIP6-LImon-01, piControl (uid: 94044096-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'
ISMIP6, ISMIP6-LImon-01, ISMIP6-2 (uid: 94045946-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'
ISMIP6, ISMIP6-LImon-01, ISMIP6-3 (uid: 94045c2a-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'
ISMIP6, ISMIP6-LImon-01, esm-piControl (uid: 9404435c-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'
ISMIP6, ISMIP6-LImon-01, ISMP6-6 (uid: 940463e6-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'
ISMIP6, ISMIP6-LImon-01, amip (uid: 940446ae-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'
ISMIP6, ISMIP6-LImon-01, ISMP6-4 (uid: 94045ef0-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'
ISMIP6, ISMIP6-LImon-01, ISMP6-5 (uid: 94046148-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'
ISMIP6, ISMIP6-LImon-01, 1pctCO2 (uid: 9404492e-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'
ISMIP6, ISMIP6-LImon-01, historical (uid: 94044c6c-267c-11e7-8933-ac72891c3257) requested by mip 'ISMIP6'

In [51]:
# Find all MIPs requesting a CMOR Variable
def CMORvarTOmip(cmvar, toScreen=False):
        """
        Args:
          + cmvar - 'dreqPy.dreq.dreqItem_CMORvar'-object
          + toScreen - Boolean (print result to std.out or not)
        Returns:
          + List of corresponding 'dreqPy.dreq.dreqItem_mip'-objects
        """
        #CMORvar -> requestVar -> mip.label
        mips=set([ x.mip for x in dq.coll['requestVar'].items if x.vid==cmvar.uid ])
        #mip.label -> mip
        mips=set([ x for x in dq.coll['mip'].items if x.label in mips ])        

        #print to stdout
        if toScreen==True:
                print()
                print(str(cmvar.label), ":", [mip.label for mip in mips])
                print()
                
        #return matches
        return list(mips)
    
# Example for arbitrary CMOR Variable UID   
mips = CMORvarTOmip(dq.inx.uid['d22da9f2-4a9f-11e6-b84e-ac72891c3257'], True)
nwdFracLut : ['CMIP', 'LUMIP']

In [52]:
#Find all experiments requesting a CMOR Variable
def CMORvarTOexperiment(cmvar, toScreen=False):
        """
        Args:
          + cmvar - 'dreqPy.dreq.dreqItem_CMORvar'-object
          + toScreen - Boolean (print result to std.out or not)          
        Returns:
          + List of corresponding 'dreqPy.dreq.dreqItem_experiment'-objects
        """

        #CMORvar -> requestVar
        rv=set([ x for x in dq.coll['requestVar'].items if x.vid==cmvar.uid ])
        #requestVar -> requestItem
        ri=list()
        for i in rv:
                for j in requestVarTOrequestItem(i): ri.append(j)
        ri = set(ri)
        #requestItem -> mip,experiment,exptgroup -> experiment
        exp=list()
        for i in ri:
                if type(dq.inx.uid[i.esid])==type(dq.coll['experiment'].items[0]):
                        exp.append(dq.inx.uid[i.esid])
                elif type(dq.inx.uid[i.esid])==type(dq.coll['exptgroup'].items[0]):
                        for e in dq.coll['experiment'].items:
                                if e.egid==i.esid: exp.append(e)
                elif type(dq.inx.uid[i.esid])==type(dq.coll['mip'].items[0]):
                        #print "mip", dq.inx.uid[i.esid].uid, dq.inx.uid[i.esid].label
                        currmip=dq.inx.uid[i.esid].uid
                        for item in dq.coll['experiment'].items:
                                if item.mip==currmip:
                                        exp.append(item)                        
                else:
                        raise TypeError("Type must be dreqPy.dreq.dreqItem_experiment, \
                        dreqPy.dreq.dreqItem_exptgroup or dreqPy.dreq.dreqItem_mip!")
                        sys.exit(1)
                        
        #print to stdout
        exp=set(exp)
        if toScreen==True:
                print("\n%i Experiments linked to CMORvar '%s':" % (len(exp), cmvar.label))
                for i in exp: print("  - %-15s :  %s" % (i.label, i.description))
                print()                
                
        #return matches
        return list(exp)

# Example for arbitrary CMOR Variable UID    
exps = CMORvarTOexperiment(dq.inx.uid['8bb09104-4a5b-11e6-9cd2-ac72891c3257'], True)
17 Experiments linked to CMORvar 'dtauc':
  - esm-piControl   :  A pre-industrial control simulation with non-evolving pre-industrial conditions and atmospheric CO2 calculated. Conditions chosen to be representative of the period prior to the onset of large-scale industrialization, with 1850 being the reference year.  The piControl starts after an initial climate spin-up, during which the climate begins to come into balance with the forcing. The recommended minimum length for the piControl is 500 years. To be performed with an Earth System Model (ESM) that can calculate atmospheric CO2 concentration and account for the fluxes of CO2 between the atmosphere, the ocean, and biosphere.
  - amip            :  An atmosphere only climate simulation using prescribed sea surface temperature and sea ice concentrations but with other conditions as in the Historical simulation.
  - historical      :  Simulation of recent past (1850 to 2014). Impose changing conditions (consistent with observations). Should be initialised from a point early enough in the pre-industrial control run to ensure that the end of all the perturbed runs branching from the end of this historical run end before the end of the control. Only one ensemble member is requested but modelling groups are strongly encouraged to submit at least three ensemble members of their CMIP historical simulation. 
  - historical-ext  :  Extension beyond 2014 of the CMIP6 historical simulation.
  - highres-future  :  High forcing (ScenarioMIP SSP5-85) future scenario (2015-2050) coupled ocean atmosphere simulations at high and standard resolution. For optimal comparison between models aerosol concentrations are recommended (rather than emissions). At least one ensemble member at high resolution, minimum atmosphere 25-50 km at mid-latitudes and ocean resolution of 0.25 degrees, and a minimum of daily coupling between ocean and atmosphere. At least one ensemble member at standard model resolution.
  - highresSST-4xCO2 :  Similar to the CFMIP amip-4xCO2 experiment but with CO2 concentations quadrupled. Historical atmosphere-only simulations of the near past (1979-2014).  HadISST2.2 sea surface temperature and sea ice concentrations at daily 1/4 degree resolution to be used (Kennedy et al. 2017, in prep). The CO2 concentration seen by the radiation scheme is quadrupled with respect to the CMIP6 amip experiment. If the carbon cycle remains active, it should continue to "see" highresSST-present CO2 concentrations.  For optimal comparison between models the use of plume aerosol cocentrations are recommended (rather than emissions). At least one ensemble member at high resolution, minimum 25-50 km at mid-latitudes. Initial conditions from the highresSST-present experiment.
  - highresSST-future :  High forcing (ScenarioMIP SSP5-85) future scenario (2015-2050) atmosphere only simulations at high and standard resolution, with an option to continue to 2100. For optimal comparison between models aerosol concentrations are recommended (rather than emissions). Future SST and SIC are determined from a blend of warming rates derived from an ensemble mean of CMIP5 RCP8.5 simulations and interannual variability derived from the historic 1960-2014 period. At least one ensemble member at high resolution, minimum atmosphere 25-50 km at mid-latitudes. At least one ensemble member at standard model resolution.
  - control-1950    :  The HighResMIP equivalent of the pre-industrial control with fixed 1950s forcing.  The forcing consists of greenhouse gases, including ozone and aerosol loading for a 1950s (~10 year mean) climatology.  For optimal comparison between models, aerosol concentrations are recommended (rather than emissions). Initial conditions from the spinup-1950 experiment. At least one ensemble member at high resolution, minimum atmosphere 25-50 km at mid-latitudes and ocean resolution of 0.25 degrees, and a minimum of daily coupling between ocean and atmosphere. At least one ensemble member at standard model resolution. Run for 100 years. 
  - spinup-1950     :  The HighResMIP equivalent of the pre-industrial spinup with fixed 1950s forcing. The forcing consists of greenhouse gases, including ozone and aerosol loading for a 1950s (~10 year mean) climatology. For optimal comparison between models, use of plume aerosol concentrations is recommended (rather than emissions). Initial ocean conditions are taken from the EN4 (Good et al, 2013) ocean analysis over an average period of 1950-1954.  This spinup is short compared to DECK (30-50 years for example, to be manageable and consistent across resolutions) to produce initial conditions for control-1950 and hist-1950. At least one ensemble member for each resolution used in the coupled simulations (i.e. standard and high), where high is minimum atmosphere 25-50 km at mod-latitudes and ocean resolution of 0.25 degrees, and a minimum of daily coupling between ocean and atmosphere. Run for 30-50 years. 
  - piControl       :  A pre-industrial control simulation with non-evolving pre-industrial conditions. Conditions chosen to be representative of the period prior to the onset of large-scale industrialization, with 1850 being the reference year.  The piControl starts after an initial climate spin-up, during which the climate begins to come into balance with the forcing. The recommended minimum length for the piControl is 500 years.
  - highresSST-LAI  :  Similar to the HighResMIP highresSST-present experiment but using an common LAI dataset across models.  Historical atmosphere-only simulations of the near past (1979-2014).  HadISST2.2 sea surface temperature and sea ice concentrations at daily 1/4 degree resolution to be used (Kennedy et al. 2017, in prep).  Land surface forcing to use a common 1/4 degree resolution mean LAI3g dataset provided by HighResMIP. At least one ensemble member at high resolution, minimum 25-50 km at mid-latitudes. Initial conditions from the highresSST-present experiment.
  - highresSST-p4K  :  Similar to the CFMIP amip-p4K experiment but with a uniform warming of 4K added to the sea surface temperatures (SSTs).  Historical atmosphere-only simulations of the near past (1979-2014). Use HadISST2.2 sea surface temperature and sea ice concentrations at daily 1/4 degree resolution with a uniform warming of 4K added to SSTs (Kennedy et al. 2017, in prep).  Run the experiment parallel to highresSST-present. At least one ensemble member at high resolution, minimum 25-50 km at mid-latitudes. Initial conditions from the highresSST-present experiment.
  - esm-hist        :  Simulation of recent past (1850 to 2014) with atmospheric CO2 concentration calculated. Impose changing conditions (consistent with observations). To be performed with an Earth System Model (ESM) that can calculate atmospheric CO2 concentration and account for the fluxes of CO2 between the atmosphere, the ocean, and biosphere.
  - esm-hist-ext    :  Extension beyond 2014 of the CMIP6 historical simulation with atmospheric CO2 concentration calculated. To be performed with an Earth System Model (ESM) that can calculate atmospheric CO2 concentration and account for the fluxes of CO2 between the atmosphere, the ocean, and biosphere.
  - highresSST-present :  Historical atmosphere-only simulations of the near past (1950-2014). HadISST2.2 sea surface temperature and sea ice concentrations at daily 1/4 degree resolution to be used (Kennedy et al. 2017, in prep).  For optimal comparison between models the use of plume aerosol cocentrations are recommended (rather than emissions). At least one ensemble member at high resolution, minimum 25-50 km at mid-latitudes. At least one ensemble member at standard model resolution as used in the DECK and historical simulations. Initial conditions from either the ERA-20C reanalysis (and then some intial spinup), or a suitably spun-up atmosphere-land initial condition reflecting 1950's conditions.
  - highresSST-smoothed :  Similar to the HighResMIP highresSST-present experiment but with smoothed sea surface temperature (SST). Historical atmosphere-only simulations of the near past (1979-2014) using spatially filtered sea surface temperatures (SSTs). Use spatially low-pass filtered HadISST2.2 SSTs (Kennedy et al. 2017, in prep). The SST filter should be the LOESS filter used by Ma et al. (2015) and Chelton and Xie (2010). Run the experiment parallel to highresSST-present. At least one ensemble member at high resolution, minimum 25-50 km at mid-latitudes. Initial conditions from the highresSST-present experiment.
  - hist-1950       :  Historical coupled ocean atmosphere simulations of the near past (1950-2014) at high and standard resolution. For optimal comparison between models aerosol concentrations are recommended (rather than emissions). At least one ensemble member at high resolution, minimum atmosphere 25-50 km at mid-latitudes and ocean resolution of 0.25 degrees, and a minimum of daily coupling between ocean and atmosphere. At least one ensemble member at standard model resolution.  Initial conditions from spin-up 1950's experiment.

In [53]:
# Find objectives linked to a CMOR variable
def CMORvarTOobjectives(cmvar, toScreen=False):
        """
        Args:
          + cmvar - 'dreqPy.dreq.dreqItem_CMORvar'-object
          + toScreen - Boolean (print result to std.out or not)
        Returns:
          + List of corresponding:
              - 'dreqPy.dreq.dreqItem_objective'-objects
        """
        
        #CMORvar -> requestVar -> requestVarGroup.uid
        rvg = set([ x.vgid for x in dq.coll['requestVar'].items if x.vid==cmvar.uid ])
        #requestVarGroup.uid -> requestLink.uid
        rl  = set([ x.uid for x in dq.coll['requestLink'].items if x.refid in rvg ])
        #requestLink.uid -> objectiveLink -> objective
        ob  = set([ dq.inx.uid[x.oid] for x in dq.coll['objectiveLink'].items if x.rid in rl ])

        #print to std.out
        if toScreen==True:
                print()
                for i in ob: print(str(i.label), i.description)
                print()
                
        #return objective(s)
        return list(ob)
    
# Example for arbitrary CMOR Variable UID
objectives = CMORvarTOobjectives(dq.inx.uid['d22da9f2-4a9f-11e6-b84e-ac72891c3257'], True)
Lulcc Assess and quantify the biogeophysical and carbon cycle consequences for climate of historic and future land cover and land use change
CMIP6baseline Baseline diagnostics to ensure there are no gaps in the request

In [54]:
# List structure/dimensions connected to a CMOR Variable
def CMORvarTOstructure(cmvar, toScreen=False):
        """
        Args:
          + cmvar - 'dreqPy.dreq.dreqItem_CMORvar'-object
          + toScreen - Boolean (print result to std.out or not)
        Returns:
          + List of corresponding:
             - 'dreqPy.dreq.dreqItem_CMORvar'-object
             - 'dreqPy.dreq.dreqItem_cellMethods'-object
             - 'dreqPy.dreq.dreqItem_temporalShape'-object
             - 'dreqPy.dreq.dreqItem_spathialShape'-object
             - List of corresponding 'dreqPy.dreq.dreqItem_grids'-objects
        """
        
        #Follow links to related objects:
        struc=dq.inx.uid[cmvar.stid]
        cm=dq.inx.uid[struc.cmid]
        ts=dq.inx.uid[struc.tmid]
        ss=dq.inx.uid[struc.spid]
        grid=list()
        grid.append(dq.inx.uid[ts.dimid])
        for i in ss.dimids: grid.append(dq.inx.uid[i])

        #Print info to std.out
        if toScreen==True:
                print()
                print("Dimension Info for CMORvar "+str(cmvar.label))
                print("cellMethods  :" , cm.cell_methods)
                print("temporalShape:", ts.label, "|", \
                    ts.dimensions, "|", ts.description)
                print("spatialShape :", ss.label, "|", \
                    ss.dimensions)
                print("grids        :\n------")
                for i in grid: print("", i.label, "|", i.units, "|", \
                        i.standardName, "|", i.description)
                print()
                
        #Return List of objects
        return [cmvar, cm, ts, ss, grid]   
    
# Example for arbitrary CMOR Variable UID
structure_info = CMORvarTOstructure(dq.inx.uid['19bebf2a-81b1-11e6-92de-ac72891c3257'], True)
Dimension Info for CMORvar abs550aer
cellMethods  : area: time: mean
temporalShape: time-mean | time | Item <X.1 Core Attributes>: [description] Description
spatialShape : XY-na | longitude|latitude
grids        :
------
 time | days since ? | time | for time-mean fields
 longitude | degrees_east | longitude | 
 latitude | degrees_north | latitude | 

In [55]:
# Find priorities linked to a CMOR Variable
def CMORvarTOpriority(cmvar, toScreen=False):
        """
        Args:
          + cmvar - 'dreqPy.dreq.dreqItem_CMORvar'-object
          + toScreen - Boolean (print result to std.out or not)          
        Returns:
          + integer List of corresponding priorities
        """

        #priority stored in requestVar and as preset in requestItem
        #CMORvar->requestVar
        rv=[ x for x in dq.coll['requestVar'].items if x.vid==cmvar.uid ]
        #requestVar->requestItem
        ri=list()
        for i in rv:
                for j in requestVarTOrequestItem(i):
                        ri.append(j)

        #add all priorities from requestVar and requestItem
        plist=[ x.preset for x in ri ]  
        for i in [ x.priority for x in rv ]: plist.append(i)
        #remove double entries and "-1", the default preset value
        plist=set(plist)
        plist.remove(-1)
        
        #print to std.out
        if toScreen==True:
                pliststr=[str(i) for i in plist]
                prioritystring=", ".join(pliststr)
                print("\nThe CMORvar %s is linked to \n  \
                - %i requestVar-items\n  - %i requestItem-items.\n\
                Its priorities are: \033[1m%s\033[0m\n" \
                % (cmvar.label, len(rv), len(ri), prioritystring))

        #return list of integers/priorities
        return list(sorted(plist))

# Example for arbitrary CMOR Variable UID
prts = CMORvarTOpriority(dq.inx.uid['19bebf2a-81b1-11e6-92de-ac72891c3257'], True)
The CMORvar abs550aer is linked to 
                  - 7 requestVar-items
  - 103 requestItem-items.
                Its priorities are: 1

In [56]:
# Find time slices linked to CMOR Variables for any request items
def CMORvarTOtimeSlice(cmvar, toScreen=False):
        """
        Args:
          + cmvar - 'dreqPy.dreq.dreqItem_CMORvar'-object
          + toScreen - Boolean (print result to std.out or not)          
        Returns:
          + List of corresponding 'dreqPy.dreq.dreqItem_timeSlice'-objects
            beware: str("notSet") will be one item in the list, 
                    if any requestItems requests the CMORvar for 
                    the entire simulation length!
        """

        #CMORvar -> requestVar
        rv=set([ x for x in dq.coll['requestVar'].items if x.vid==cmvar.uid ])
        #requestVar -> requestItem
        ri=list()
        for i in rv:
                for j in requestVarTOrequestItem(i): ri.append(j)        
        ri = list(set(ri))
        #requestItem -> timeSlice
        ts=list()
        for i in ri:
                try:
                        ts.append(dq.inx.uid[i.tslice])
                except KeyError:
                        ts.append("notSet")
        tsset =list(set(ts))
                        
        #print to stdout        
        if toScreen==True:
                #Group timeSlices and requestItems:
                riset=list()
                n=0
                for i in tsset:
                        riset.append(list())
                        for j in ri:
                                try:
                                        if i.uid==j.tslice:
                                                if j.label not in riset[n]: riset[n].append(j.label)
                                except AttributeError:
                                        if j.label not in riset[n]: riset[n].append(j.label)
                        n+=1
                #print
                ristr=riset
                for i in range(0, len(ristr)): ristr[i]=", ".join(ristr[i])                
                print("\n%i different timeSlices linked to CMORvar '%s' (%s):" % (len(tsset), cmvar.label, cmvar.uid))
                j=0
                for i in tsset:
                        if type(i)==str:
                                print("  - %s (= entire simulation length)\n   \
                                for requestItems %s" %(i, ristr[j]))                                 
                        else:                        
                                print("  - %-15s :  %s\n   %s %s %s %s\n    for requestItems %s" \
                                        %(i.label, i.description \
                                           if not "description" in str(i.description) \
                                           else "", \
                                           "Start: "+str(i.start) \
                                           if not "start" in str(i.start) \
                                           else "", \
                                           "End: "+str(i.end) \
                                           if not "end" in str(i.end) \
                                           else "", \
                                           "Step [a]: "+str(i.step) \
                                           if not "step" in str(i.step) \
                                           else "", \
                                           "SliceLen: "+str(i.sliceLen) \
                                           if not "slice" in str(i.sliceLen) \
                                           else "", ristr[j]))
                        j+=1
                print()               
                
        #return matches
        return tsset

# Example for arbitrary CMOR Variable UID
ts = CMORvarTOtimeSlice(dq.inx.uid['bab5d898-e5dd-11e5-8482-ac72891c3257'], True)
11 different timeSlices linked to CMORvar 'rsdcs' (bab5d898-e5dd-11e5-8482-ac72891c3257):
  - hist36          :  
   Start: 1979 End: 2014  
    for requestItems DamipCfmon3dstd, PmipPmipCfmon
  - notSet (= entire simulation length)
                                   for requestItems AerchemmipCfmon, 1pctco2, HighresmipHighresmipCfmon, amip, CfmipCfmon3dstd, abrupt2xco2, DamipCfmon3dstd, scenariomip1, amip4xco2, CMIP-scenario-ssp119, CMIP-scenario-ssp126, CMIP-scenario-ssp245, CMIP-scenario-ssp370, CMIP-scenario-ssp434, CMIP-scenario-ssp460, CMIP-scenario-ssp534-over, CMIP-scenario-ssp585, scenariomip2, cfmip3, PmipPmipCfmon, gmmip2, GeomipCfmon3dstd, highresmip1, historical
  - piControl100    :  
   Start: 1915 End: 2014  
    for requestItems DamipCfmon3dstd
  - piControl140    :  
   Start: 1875 End: 2014  
    for requestItems CfmipCfmon3dstd
  - DAMIP20         :  
   Start: 2081 End: 2100  
    for requestItems DamipCfmon3dstd
  - piControl165    :  
   Start: 1850 End: 2014  
    for requestItems AerchemmipCfmon
  - piControl200    :  
   Start: 1850 End: 2049  
    for requestItems HighresmipHighresmipCfmon
  - DAMIP42         :  
   Start: 1979 End: 2020  
    for requestItems DamipCfmon3dstd
  - histext         :  Contains:_slice_RFMIP:
   Start: 2015 End: 2019  
    for requestItems PmipPmipCfmon
  - DAMIP42ext      :  
   Start: 2015 End: 2020  
    for requestItems DamipCfmon3dstd
  - piControl040    :  
   Start: 1975 End: 2014  
    for requestItems PmipPmipCfmon

In [57]:
# Find Variable Choices the CMOR Variable is linked to
def CMORvarTOvarChoice(cmvar, toScreen=False):
        """
        Args:
          + cmvar - 'dreqPy.dreq.dreqItem_CMORvar'-object
          + toScreen - Boolean (print result to std.out or not)          
        Returns:
          + List of corresponding 'dreqPy.dreq.dreqItem_varChoice'-objects            
        """

        #CMORvar -> var.uid
        #var=set([ x.uid for x in dq.coll['var'].items if x.uid==cmvar.vid ])
        var=set([x.uid for x in dq.coll['CMORvar'].items])
        #var -> varChoiceLinkC, varChoiceLinkR -> varChoice
        vclc=list(set([ x for x in dq.coll['varChoiceLinkC'].items if x.vid in var ]))
        vclr=list(set([ x for x in dq.coll['varChoiceLinkR'].items if x.vid in var ]))
        vcc=[ dq.inx.uid[x.cid] for x in vclc ]
        vcr=[ dq.inx.uid[x.cid] for x in vclr ]

        #print to std.out
        if toScreen==True:                
                print("%i configuration varChoices found for CMORvar '%s' (%s)" \
                      %(len(vcc), cmvar.label, cmvar.uid))
                for i in range(0, len(vcc)):
                        print("  - %s:\n    %s\n    %s\n    for cfg value %s in modelConfig %s (%s)" \
                              %(str(vcc[i].label), \
                                str(vcc[i].varList), \
                                str(vcc[i].optionList), \
                                str(vclc[i].cfg), \
                                str(dq.inx.uid[vclc[i].cfgid].label), \
                                str(vclc[i].cfgid)))
                print()
                print("%i rank varChoices found for CMORvar '%s' (%s)" \
                      %(len(vcr), cmvar.label, cmvar.uid))
                for i in range(0, len(vcr)):
                        print("  - %s:\n    %s\n    %s\n    for rank %s" \
                              %(str(vcr[i].label), \
                                str(vcr[i].varList), \
                                str(vcr[i].optionList), \
                                str(vclr[i].rank)))
                print()
                        
        #return varChoice-objects
        return vcc+vcr

# Example for arbitrary CMOR Variable UID
vc = CMORvarTOvarChoice(dq.inx.uid['bab5d898-e5dd-11e5-8482-ac72891c3257'], True)
21 configuration varChoices found for CMORvar 'rsdcs' (bab5d898-e5dd-11e5-8482-ac72891c3257)
  - ficeberg:
    ficeberg
    
    for cfg value False in modelConfig IcebergMeltZResolution (DepthResolvedIcebergMelt)
  - TimeVaryingGeothermalFlux:
    hfgeou
    
    for cfg value False in modelConfig TimeVaryingGeothermalFlux (82e1d982-626c-11e7-90be-ac72891c3257)
  - TimeVaryingGeothermalFlux:
    hfgeou
    
    for cfg value True in modelConfig TimeVaryingGeothermalFlux (82e1d982-626c-11e7-90be-ac72891c3257)
  - masscello:
    masscello
    
    for cfg value True in modelConfig BoussinesqOceanConstantTh (BoussinesqOceanConstantTh)
  - masscello:
    masscello
    
    for cfg value False in modelConfig BoussinesqOceanConstantTh (BoussinesqOceanConstantTh)
  - msftmzsmpa:
    msftmzsmpa
    
    for cfg value False in modelConfig CartesianOcean (CartesianOceanGrid)
  - msftmzsmpa:
    msftmzsmpa
    
    for cfg value False in modelConfig CartesianOcean (CartesianOceanGrid)
  - msftmzsmpa:
    msftmzsmpa
    
    for cfg value False in modelConfig CartesianOcean (CartesianOceanGrid)
  - msftmzsmpa:
    msftmzsmpa
    
    for cfg value False in modelConfig CartesianOcean (CartesianOceanGrid)
  - msftmzsmpa:
    msftmzsmpa
    
    for cfg value False in modelConfig CartesianOcean (CartesianOceanGrid)
  - msftmzsmpa:
    msftmzsmpa
    
    for cfg value False in modelConfig CartesianOcean (CartesianOceanGrid)
  - submesoscaleEddy:
    msftmzsmpa msftyzsmpa
    
    for cfg value True in modelConfig submesoscaleEddy (SubmesoscaleEddyParam)
  - submesoscaleEddy:
    msftmzsmpa msftyzsmpa
    
    for cfg value True in modelConfig submesoscaleEddy (SubmesoscaleEddyParam)
  - thkcello:
    thkcello
    
    for cfg value True in modelConfig thkcello (TimeVaryingThkcello)
  - thkcello:
    thkcello
    
    for cfg value False in modelConfig thkcello (TimeVaryingThkcello)
  - thkcello:
    thkcello
    
    for cfg value True in modelConfig thkcello (TimeVaryingThkcello)
  - volcello:
    volcello
    
    for cfg value False in modelConfig volcello (TimeVaryingVolcello)
  - volcello:
    volcello
    
    for cfg value True in modelConfig volcello (TimeVaryingVolcello)
  - bigthetao:
    bigthetao bigthetaoga
    
    for cfg value True in modelConfig bigthetao (PrognosticConservativeTemperature)
  - bigthetao:
    bigthetao bigthetaoga
    
    for cfg value True in modelConfig bigthetao (PrognosticConservativeTemperature)
  - ficeberg:
    ficeberg
    
    for cfg value True in modelConfig IcebergMeltZResolution (DepthResolvedIcebergMelt)

4 rank varChoices found for CMORvar 'rsdcs' (bab5d898-e5dd-11e5-8482-ac72891c3257)
  - overlap-ta:
    3hrPlev:ta; 6hrPlev_extr:ta; 6hrPlev:ta;
    3;2;
    for rank 2
  - overlap-hus:
    3hrPlev:hus; 6hrPlev_extr:hus;
    3;2;
    for rank 2
  - overlap-ta:
    3hrPlev:ta; 6hrPlev_extr:ta; 6hrPlev:ta;
    3;2;
    for rank 3
  - overlap-hus:
    3hrPlev:hus; 6hrPlev_extr:hus;
    3;2;
    for rank 3

In [58]:
# Find all CMORvars requested by a MIP
def mipTOCMORvar(mip, toScreen=False, info=False):
        """
        Args:
          + mip - 'dreqPy.dreq.dreqItem_mip'-object
          + toScreen - Boolean (print result to std.out or not)
          + info - Boolean (print number of matches to std.out or not)
        Returns:
          + List of corresponding:
              - 'dreqPy.dreq.dreqItem_CMORvar'-objects
        """
        
        #mip.label -> requestLink -> requestVarGroup.uid
        requestVarGroup_uid=set([ x.refid for x in dq.coll['requestLink'].items if x.mip==mip.uid ])     
        #requestVarGroup.uid -> requestVar -> CMORvar.uid
        CMORvar_uid=set([ x.vid for x in dq.coll['requestVar'].items if x.vgid in requestVarGroup_uid ])

        #print result to std.out
        if toScreen==True:
                print("\nCMORvars in mip %s:" % mip.label)
                for uid in CMORvar_uid: print(dq.inx.uid[uid].label, end=', ')
                print("\n")
        if info==True:
                print("[Info] mipTOCMORvar : %i CMORvars have been found for mip '%s'." \
                    % (len(CMORvar_uid), mip.label))
        
        #return List of CMORvar objects
        return list(set([dq.inx.uid[uid] for uid in CMORvar_uid]))

# Example for arbitrary MIP
cmvars = mipTOCMORvar(dq.inx.uid["VolMIP"], True, True)
CMORvars in mip VolMIP:
cropFrac, zg500, clwvi, va, rsuscs, lwsffluxaero, fGrazing, lwsnl, gpp, pr, sci, rGrowth, epsi100, hus, prc, vas, cRoot, utendnogw, rlutcs, c3PftFrac, va, zmswaero, baresoilFrac, prsn, c4PftFrac, cCwd, fHarvest, evs, cSoilFast, hfcorr, hfrunoffds2d, mrsol, prveg, so, tntrs, zos, tasmax, rlds, ta, hursmin, prsn, tos, sfdsi, tsl, cfc12global, zg, tasmin, hur, zg, nppWood, rsus, tossq, mrfso, wfo, hfbasin, rsds, clt, friver, swtoafluxaerocs, tntscp, zg, hfss, hcfc22global, clivi, hfevapds, nep, sos, mrsos, uas, hfrainds, landCoverFrac, htovovrt, hfds, pfull, rsdt, ta, tntc, cSoilSlow, wtem, meanage, hus, co2Clim, ra, rMaint, pr, rlds, msftbarot, tntrscs, phalf, shrubFrac, tpf, rlut, cl, nppRoot, fco2nat, vtendnogw, co2massClim, hfsifrazil, ccb, rlus, treeFracSecDec, prc, rsus, mrso, cct, mrros, ficeberg2d, epfy, cSoilMedium, n2oglobalClim, grassFrac, rlut, hfsnthermds2d, fLuc, tos, cLitter, hfsnthermds, ua, uo, masso, tauv, cMisc, rsdscs, sltovgyre, tsn, prw, fLitterSoil, snc, sfcWind, hfgeou, epc100, nbp, rlntds, tasmax, msftmrho, ua, sfcWindmax, prsn, hfrunoffds, prra, cProduct, ficeberg, tntogw, mrro, tran, ps, fco2fos, cLitterBelow, treeFracPrimDec, mrsos, cVeg, siv, vtendogw, ch4, wap, hus, npp, hurs, mfo, omldamax, siu, ua, vtem, lwtoafluxaerocs, wap, rsut, sithick, o2min, hfsso, tauu, ps, tslsi, huss, huss, ps, soga, ch4Clim, cfc113global, ta, treeFracSecEver, ta, thetaoga, hfls, snm, ta, tntmp, rtmt, tas, ua, pflw, nppLeaf, cli, snw, thkcello, thetao, cWood, fgo2, sootsn, cfc11global, msftmz, bigthetao, pastureFrac, hus, tasmin, residualFrac, aod550volso4, ta, masscello, fVegLitter, va, clw, lai, hfdsn, clt, fgco2, evspsblveg, froc, hurs, snw, burntFractionAll, hfibthermds2d, va, hursmax, mrro, swsffluxaero, rsntds, sfcWind, treeFracPrimEver, hflso, htovgyre, wap, psl, hfls, o3Clim, psl, va, hfsifrazil2d, rsds, epfz, tntrl, hur, uas, rh, dpco2, tas, tntnogw, sbl, vas, co2mass, hfibthermds, evspsbl, msftyrhompa, tossq, snd, mlotst, ps, sbl, zmlwaero, co2, cSoil, epcalc100, hfss, treeFrac, mc, n2o, o3, ch4global, fco2antt, mrso, rldscs, siconc, rlus, snc, agesno, cLitterAbove, fVegSoil, ts, cLeaf, utendogw, ci, ua, vo, ch4globalClim, tntrlcs, fsitherm, n2oglobal, n2oClim, psl, rsutcs, rv850, ua, utendepfd, evspsblsoi, fFire, sltovovrt, 

[Info] mipTOCMORvar : 295 CMORvars have been found for mip 'VolMIP'.
In [59]:
# Find all CMORvars requested by all MIPs for a certain experiment
def experimentTOCMORvar(exp, toScreen=False, info=False):
        """
        Args:
          + exp - 'dreqPy.dreq.dreqItem_experiment'-object
          + toScreen - Boolean (print result to std.out or not)    
          + info - Boolean (print number of matches to std.out or not)
        Returns:
          + List of corresponding:
              - 'dreqPy.dreq.dreqItem_CMORvar'-objects
        """

        #experiment -> exptgroup.uid
        egid=list(set([ x.uid for x in dq.coll['exptgroup'].items \
                           if exp.egid==x.uid ]))       
        #experiment -> requestItem.uid          
        #allitems=set([ x.uid for x in dq.coll['requestItem'].items if x.esid==exp.uid ])
        #experiment,exptgroup.uid -> requestLink.uid
        alllinks=set([ x.rlid for x in dq.coll['requestItem'].items \
                          if exp.uid==x.esid or x.esid in egid ])        
        #requestLink.uid -> requestVarGroup.uid
        allvargroups=set([ x.refid for x in dq.coll['requestLink'].items \
                              if x.uid in alllinks ])             
        #Find requestVar from requestVarGroup:requestVarGroup.uid -> CMORvar.uid
        allcmorvars=set([ x.vid for x in dq.coll['requestVar'].items \
                             if x.vgid in allvargroups ])
        #CMORvar -> var.uid
        #allvars=set([ x.vid for x in dq.coll['CMORvar'].items if x.uid in allcmorvars])        
        
        #print results to std.out
        if len(egid)==1:
                egid=egid[0]
        else:
                raise ValueError("Multiple experiment groups found for experiment! \
                An experiment should only belong to one group of experiments!")
        
        if toScreen==True:
                print("\nThe following CMORvars are requested for experiment  %s (%s):" \
                    % (exp.label, exp.uid))
                for i in allcmorvars: print(dq.inx.uid[i].label, end=', ')
        print
        if info==True:
                print("\n[Info] experimentTOCMORvar : "\
                    "Your specified experiment '%s' is in exptgroup '%s'." \
                    % (exp.label, dq.inx.uid[egid].label))
                #print len(allitems), "RequestItems found for your specifications." \
                #    % (len(allitems), exp.label)
                print("[Info] experimentTOCMORvar : "\
                    "%i RequestLinks found for experiment '%s'." \
                    % (len(alllinks), exp.label))
                print("[Info] experimentTOCMORvar : "\
                    "%i RequestVarGroups found for experiment '%s'." \
                    % (len(allvargroups), exp.label))
                #print("[Info] experimentTOCMORvar : \
                #   %i requested Variables found for experiment '%s'." \
                #   % (len(allvars), exp.label))
                print("[Info] experimentTOCMORvar : "\
                    "%i CMORvariables found for experiment '%s'." \
                    % (len(allcmorvars), exp.label))
                
                #return List of CMORvars
        return list(allcmorvars)

# Example for arbitrary Experiment
cmvars = experimentTOCMORvar(dq.inx.uid["f16f6188-dd9e-11e6-b89b-ac72891c3257"], False, True)
[Info] experimentTOCMORvar : Your specified experiment 'ssp126' is in exptgroup 'ScenarioMIP1'.
[Info] experimentTOCMORvar : 85 RequestLinks found for experiment 'ssp126'.
[Info] experimentTOCMORvar : 84 RequestVarGroups found for experiment 'ssp126'.
[Info] experimentTOCMORvar : 974 CMORvariables found for experiment 'ssp126'.
In [60]:
# Find all CMOR Variables linked to a certain cellMethod
def cellMethodsTOCMORvar(cm, toScreen=False, info=False):
        """
        Args:
          + cm - 'dreqPy.dreq.dreqItem_cellMethods'-object
          + toScreen - Boolean (print result to std.out or not)    
          + info - Boolean (print number of matches to std.out or not)
        Returns:
          + List of corresponding:
              - 'dreqPy.dreq.dreqItem_CMORvar'-objects
        """

        #cellMethod -> structure.uid
        struc=set([ x.uid for x in dq.coll['structure'].items if x.cmid==cm.uid ])
        #structure.uid -> CMORvar
        cmvar=set([ x for x in dq.coll['CMORvar'].items if x.stid in struc ])

        #print results to std.out
        if toScreen==True:
                print("\nThe following CMORvars have the cellMethod %s (%s):" \
                    % (cm.label, cm.cell_methods))
                for i in cmvar: print(i.label, end=', ')
                print()
        if info==True:
                print("\n[Info] cellMethodsTOCMORvar : "\
                "%i CMORvars have been found for cellMethod '%s' (%s)." \
                % (len(cmvar), cm.label, cm.cell_methods))
                
        #return list of CMORvars
        return list(cmvar)


# Example for an arbitrary cell method
cmvars = cellMethodsTOCMORvar(dq.coll['cellMethods'].items[4], True, True)
The following CMORvars have the cellMethod am-tmh (area: mean time: mean within hours time: maximum over hours):
prhmax, prhmax, prhmax, 

[Info] cellMethodsTOCMORvar : 3 CMORvars have been found for cellMethod 'am-tmh' (area: mean time: mean within hours time: maximum over hours).
In [61]:
# Find Objectives linked to a MIP
def mipTOobjective(mip, toScreen=False):
        """
        Args:
          + mip - 'dreqPy.dreq.dreqItem_mip'-object
          + toScreen - Boolean (print result to std.out or not)          
        Returns:
          + List of corresponding:
              - 'dreqPy.dreq.dreqItem_objective'-objects
        """

        #mip -> objective
        ob=set([ x for x in dq.coll['objective'].items if x.mip==mip.label ])

        #print to std.out
        if toScreen==True:
                print("\nThe MIP '%s' has the following objective(s):" % mip.label)
                for i in ob: print(" - %-15s: %s" % (i.label, i.description))
                print()
        #return List of objective-objects
        return list(ob)

# Example for arbitrary MIP
objectives = mipTOobjective(dq.inx.uid["VolMIP"], True)
The MIP 'VolMIP' has the following objective(s):
 - Forcing        : Improve understanding of volcanic radiative forcing and constrain related uncertainties. Volcanic eruptions are among the largest sources of uncertainty in historical radiative forcing .
 - Evaluation     : Evaluate models against observations. Improve understanding of the role of background climate conditions in determining the climate response to the 1991 Pinatubo eruption. The evaluation must take into account the idealized character of VolMIP experiments.
 - Predictability : A systematical assessment of regional climate variability - and associated predictability and prediction - during periods of strong volcanic forcing at both intraseasonal-to-seasonal and interannual-to-decadal time scales
 - Variability    : Improve understanding of the mechanism(s) underlying the dynamical climate response to large volcanic eruptions, in particular concerning influence on decadal variability
 - Dynamics       : Improve understanding of the (seasonal to interannual) mechanisms underlying the dynamical atmospheric response to large volcanic eruptions, in particular separating indirect responses from the direct radiative response; improve understanding of decadal feedback mechanisms induced in the coupled ocean-atmosphere system by large volcanic eruptions.
 - Paleo          : Evaluate models against paleo reconstructions This objective is motivated by the mismatch between simulated and reconstructed post-eruption surface cooling for volcanic eruptions during the last millennium. The evaluation must take into account the idealized character of VolMIP experiments.
 - Sensitivity    : Improve the characterization of volcanic forcing and associated climate sensitivity through improved understanding of how the hydrological cycle and the large-scale circulation respond to volcanic forcing, through improved understanding of forced responses of the coupled ocean-atmosphere system, and through improved assessment of internal variability.

In [62]:
# Find objectives linked to an experiment
def experimentTOobjective(exp, toScreen=False, info=False):
        """
        Args:
          + exp - 'dreqPy.dreq.dreqItem_experiment'-object
          + toScreen - Boolean (print result to std.out or not) 
        Returns:
          + List of corresponding:
              - 'dreqPy.dreq.dreqItem_objective'-objects
        """

        #experiment -> exptgroup.uid
        egid=list(set([ x.uid for x in dq.coll['exptgroup'].items \
                       if exp.egid==x.uid ]))       
        #experiment -> requestItem.uid          
        #allitems=set([ x.uid for x in dq.coll['requestItem'].items \
        #    if x.esid==exp.uid ])
        #experiment,exptgroup.uid -> requestLink.uid
        alllinks=set([ x.rlid for x in dq.coll['requestItem'].items \
                      if x.esid==exp.uid or x.esid in egid])        
        #requestLink.uid -> requestVarGroup.uid
        ob=set([ dq.inx.uid[x.oid] for x in dq.coll['objectiveLink'].items \
                if x.rid in alllinks ])
                
        #print results to std.out
        if len(egid)==1:
                egid=egid[0]
        else:
                raise ValueError("Multiple experiment groups found for experiment!" \
                    " An experiment should only belong to one group of experiments!")
        
        if toScreen==True:
                print("\nThe following %i objective(s) are found for experiment %s (%s):" \
                    % (len(ob), exp.label, exp.uid))
                for i in ob: print(" - %-15s: %s" % (i.label, i.description))
        print()
        if info==True:
                print("[Info] experimentTOobjective : Your specified experiment "\
                        "'%s' is in exptgroup '%s'." \
                        % (exp.label, dq.inx.uid[egid].label))            
                print("[Info] experimentTOobjective : "\
                        "%i RequestLinks found for experiment '%s'." \
                        % (len(alllinks), exp.label))
                print("[Info] experimentTOobjective : "\
                        "%i objectives found for experiment '%s'." \
                        % (len(ob), exp.label))
                
        #return List of objectives
        return list(ob)
    
# Example for arbitrary experiment
objectives = experimentTOobjective(dq.inx.uid["f16f6188-dd9e-11e6-b89b-ac72891c3257"], True, True)
The following 27 objective(s) are found for experiment ssp126 (f16f6188-dd9e-11e6-b89b-ac72891c3257):
 - DBPM           : DBPM (dynamic benthic pelagic model) submission to VIACSAB
 - NaturalVariability: analysis of mechanisms of climate variability on long (decadal to centennial) time-scales
 - downscaling    : To support production of downscaled projections of regional climate change
 - OSMOSE         : OSMOSE (Modelling Marine Ecosystems) submission to VIACSAB (http://www.osmose-model.org/)
 - PaleoImpacts   : Link climate changes to quantities measured to reconstruct paleoclimates: vegetation or ocean biological characteristics, ice-sheets, isotopic tracers (in particular carbon and oxygen) in ocean, land and ice-sheets
 - POEM           : Princeton Ocean Ecosystem Model (POEM) submission to VIACSAB
 - Evaluation     : systematic biases : benchmarking (with comparison with results of previous PMIP phases PMIP1, 2, 3)
 - AgMIP          : Agricultural Model Intercomparison and Improvement Project
 - ScenarioBaseline: Baseline diagnostics to ensure there are no gaps in the request from ScenarioMIP experiments
 - FISH-MIP       : Fisheries and Marine Ecosystems Model Intercomparison Project 
 - Forcing        : One of the goals of GeoMIP is to understand the Earth System's response to climate forcing agents - both single forcing agents and combinations of forcings.
 - APECOSM        : Apex Predators ECOSystem Model (APECOSM) impact model submission to VIACSAB (https://doi.org/10.1016/j.pocean.2009.09.013)
 - ForcingsFeedbacks: response of climate forcing to natural forcings: atmospheric composition, insolation, ice-sheets; role of feedbacks: clouds, ocean, sea-ice, vegetation, aerosols...
 - Arctic         : Arctic Climate Impact Assessment (ACIA) and CORDEX-Arctic submission to VIACSAB
 - Atlantis       : Atlantis [Fulton et al. 2004, 2011] is a modelling framework that was developed to support management strategy evaluation for marine systems  and includes dynamic, integrated representations of the biophysical system, human use and adaptive management
 - SMHI-FoUo      : SMHI Oceanography R&D submission to VIACSAB
 - Future         : Geoengineering has been proposed as a method of addressing future climate change.  One of the goals of GeoMIP is to assess the feasibility and resulting effects on the climate of using geoengineering to address climate change.  There is also evidence to suggest that geoengineering can be used to manage some forms of uncertainty in dealing with future climate projections.
 - Bias           : Simulations of geoengineering, particularly multi-model simulations like those found in GeoMIP, can reveal the dominant processes that contribute to systematic model biases.
 - Caribbean      : WMO Caribbean Climate Center submission to VIACSAB
 - ISI-MIP        : Inter-sectoral Model Intercomparison Project (ISI-MIP)
 - climateServices: Climate services submissions to VIACSAB
 - CMIP6baseline  : Baseline diagnostics to ensure there are no gaps in the request
 - Macroecological: Macroecological ( statistical patterns of abundance, distribution and diversity) submission to VIACSAB
 - Madingley      : Madingley General Ecosystem Model  submission to VIACSAB
 - CSP            : Climate Services Partnership submission to VIACSAB
 - Malaria        : Data for malaria studies: submission to VIACSAB
 - DBEM           : DBEM (Dynamic Bioclimate Envelope Model) submission to VIACSAB

[Info] experimentTOobjective : Your specified experiment 'ssp126' is in exptgroup 'ScenarioMIP1'.
[Info] experimentTOobjective : 85 RequestLinks found for experiment 'ssp126'.
[Info] experimentTOobjective : 27 objectives found for experiment 'ssp126'.
In [63]:
# Find all experiments
def mipTOexperimentBYtier(mip, tier=[1,2,3,4], toScreen=False):
        """
        Args:
          + mip - 'dreqPy.dreq.dreqItem_mip'-object
          + tier - List containing desired tiers of the experiment, eg. [2] or [1,2]
          + toScreen - Boolean (print result to std.out or not)         
        Returns:
          + List of corresponding 'dreqPy.dreq.dreqItem_experiment'-objects
        """

        #mip -> requestItem -> [mip/experiment/exptgroup.uid, [tier,reset]]
        exps=[ [x.esid, [] if "Option to override" in str(x.treset) \
                else x.treset] for x in dq.coll['requestItem'].items if x.mip==mip.label]
        #[mip/experiment/exptgroup.uid, [tier,reset]] -> [experiment, [tier, reset]]
        expstier=list()
        exp=list()
        for i in exps:
                if type(dq.inx.uid[i[0]])==type(dq.coll['experiment'].items[0]):
                        exp.append([dq.inx.uid[i[0]], i[1]])
                elif type(dq.inx.uid[i[0]])==type(dq.coll['exptgroup'].items[0]):
                        for e in dq.coll['experiment'].items:
                                if e.egid==i[0]: exp.append([e, i[1]])
                elif type(dq.inx.uid[i[0]])==type(dq.coll['mip'].items[0]):                        
                        currmip=dq.inx.uid[i[0]].uid
                        for item in dq.coll['experiment'].items:
                                if item.mip==currmip:
                                        exp.append([item, i[1]])
                elif type(dq.inx.uid[i[0]])==type(dq.coll['remarks'].items[0]):
                    continue
                else:   
                    raise TypeError("Type must be dreqPy.dreq.dreqItem_experiment, "\
                                        "dreqPy.dreq.dreqItem_exptgroup or "\
                                        "dreqPy.dreq.dreqItem_mip!\n Type is %s" % (str(type(dq.inx.uid[i[0]]))))       
        
        #Filter experiments by requested tier
        for i in exp:
                #if treset performs a experiment.tier override
                if type(i[1])==type(list()) and i[1]!=[]:
                        for t in tier:
                                if t in i[1]:
                                        expstier.append(i[0])
                #if the experiment.tier specifies the tier
                else:
                        for t in tier:                                
                                if t in i[0].tier:
                                        expstier.append(i[0])

        #print to std.out
        expstier=set(expstier)
        if toScreen==True:
                tierstring=[str(t) for t in tier]
                tierstring=", ".join(tierstring)        
                print("\n%i Experiments linked to MIP '%s' for tier %s:" \
                    % (len(expstier), mip.uid, tierstring))
                for i in expstier: print("  - %-15s :  %s" % (i.label, i.description))
                print()
                                                
        #Return experiment-objects of requested tier
        return list(expstier)

# Example for an arbitrary MIP
exps = mipTOexperimentBYtier(dq.inx.uid["VolMIP"], tier=[1], toScreen=True)
9 Experiments linked to MIP 'VolMIP' for tier 1:
  - esm-piControl   :  A pre-industrial control simulation with non-evolving pre-industrial conditions and atmospheric CO2 calculated. Conditions chosen to be representative of the period prior to the onset of large-scale industrialization, with 1850 being the reference year.  The piControl starts after an initial climate spin-up, during which the climate begins to come into balance with the forcing. The recommended minimum length for the piControl is 500 years. To be performed with an Earth System Model (ESM) that can calculate atmospheric CO2 concentration and account for the fluxes of CO2 between the atmosphere, the ocean, and biosphere.
  - historical      :  Simulation of recent past (1850 to 2014). Impose changing conditions (consistent with observations). Should be initialised from a point early enough in the pre-industrial control run to ensure that the end of all the perturbed runs branching from the end of this historical run end before the end of the control. Only one ensemble member is requested but modelling groups are strongly encouraged to submit at least three ensemble members of their CMIP historical simulation. 
  - volc-pinatubo-full :  1991 Pinatubo forcing as used in the CMIP6 historical simulations.  Maintain the same constant boundary forcing as the pre-industrial control integration, except for the volcanic forcing. Requires special diagnostics of parameterised and resolved wave forcings, radiative and latent heating rates. The experiment will not account for the actual climate conditions when the real event occured (e.g., presence and strength of additional forcing factors). Instead, the experiment is designed to span very different initial climate states to systematically assess uncertainties in the post-eruption behaviour that are related to background climate conditions. Sampling of an eastern phase of the Quasi-Biennial Oscillation (QBO), as observed after the 1991 Pinatubo eruption is preferred for those models that spontaneously generate such mode of stratospheric variability. Run at least 25 ensemble members for 3 years. 
  - dcppC-forecast-addPinatubo :  Prediction experiment for 2015 with volcano forcing.  Repeat DCPP-A1 2015 forecast (from the dcppA-hindcast experiment) with Pinatubo forcing. Background volcanic aerosol to be the same as that used in the 1991 hindcast. 10 ensemble members. Run each member for at least 5 years, preferably 10 years.
  - piControl       :  A pre-industrial control simulation with non-evolving pre-industrial conditions. Conditions chosen to be representative of the period prior to the onset of large-scale industrialization, with 1850 being the reference year.  The piControl starts after an initial climate spin-up, during which the climate begins to come into balance with the forcing. The recommended minimum length for the piControl is 500 years.
  - volc-pinatubo-strat :  1991 Pinatubo forcing is expressed with a prescribed perturbation to the total (LW+SW) radiative heating rates. Maintain the same constant boundary forcing as the pre-industrial control integration, except for the volcanic forcing. Requires special diagnostics of parameterised and resolved wave forcings, radiative and latent heating rates. The experiment will not account for the actual climate conditions when the real event occured (e.g., presence and strength of additional forcing factors). Instead, the experiment is designed to span very different initial climate states to systematically assess uncertainties in the post-eruption behaviour that are related to background climate conditions. Sampling of an eastern phase of the Quasi-Biennial Oscillation (QBO), as observed after the 1991 Pinatubo eruption is preferred for those models that spontaneously generate such mode of stratospheric variability. Run at least 25 ensemble members for 3 years. 
  - esm-hist        :  Simulation of recent past (1850 to 2014) with atmospheric CO2 concentration calculated. Impose changing conditions (consistent with observations). To be performed with an Earth System Model (ESM) that can calculate atmospheric CO2 concentration and account for the fluxes of CO2 between the atmosphere, the ocean, and biosphere.
  - volc-pinatubo-surf :  1991 Pinatubo forcing is expressed with a prescribed perturbation to the shortwave flux to mimic the attenuation of solar radiation by volcanic aerosols and therefore the cooling of the surface. Maintain the same constant boundary forcing as the pre-industrial control integration, except for the volcanic forcing. Requires special diagnostics of parameterised and resolved wave forcings, radiative and latent heating rates. The experiment will not account for the actual climate conditions when the real event occured (e.g., presence and strength of additional forcing factors). Instead, the experiment is designed to span very different initial climate states to systematically assess uncertainties in the post-eruption behaviour that are related to background climate conditions. Sampling of an eastern phase of the Quasi-Biennial Oscillation (QBO), as observed after the 1991 Pinatubo eruption is preferred for those models that spontaneously generate such mode of stratospheric variability. Run at least 25 ensemble members for 3 years. 
  - volc-long-eq    :  Idealised equatorial eruption corresponding to an initial emission of 56.2 Tg of SO2. This eruption has a magnitude roughly corresponding to the 1815 Mt Tambora eruption in Indonesia, which was linked to the so-called "year without a summer" in 1816.  Maintain the same constant boundary forcing as the pre-industrial control integration, except for the volcanic forcing. The experiment will not account for the actual climate conditions when the real event occured (e.g., presence and strength of additional forcing factors). Instead, the experiment is designed to span very different initial climate states to systematically assess uncertainties in the post-eruption behaviour that are related to background climate conditions.  If, for instance, year Y of the control integration matches the desired conditions for the initial condition sampling, then the corresponding VolMIP simulation should start with restart data from year Y-1 of the control.  Run nine ensemble members for at least 20 years, but preferably longer (50 years) to cover the multi-decadal oceanic response. Initialisation date from the piControl start year is 1st April.

In [64]:
# Find all CMOR Variables linked to a certain standardname
def standardnameTOCMORvar(sn, toScreen=False):
        """
        Args:
          + sn - 'dreqPy.dreq.dreqItem_var'.sn or 'dreqPy.dreq.dreqItem_standardname'.uid,
                  which is the name of a standardname
          + toScreen - Boolean (print result to std.out or not)          
        Returns:
          + List of corresponding 'dreqPy.dreq.dreqItem_CMORvar'-objects
        """

        #standardname->var.uid
        vl=set([ x.uid for x in dq.coll['var'].items if x.sn==sn ])
        #var->CMORvar
        cmvar=set([ x for x in dq.coll['CMORvar'].items if x.vid in vl ])

        #print to std.out
        if toScreen==True:
                print("\nThe following %i CMORvars have been found for standardname '%s':" \
                    % (len(cmvar), sn))
                for i in cmvar: print("  - %-10s (%-15s)" \
                        % (str(i.label), str(i.mipTable)))
                print()

        #return corresponding 'dreqPy.dreq.dreqItem_CMORvar'-objects
        return list(cmvar)

# Example for an arbitrary standard name
cmvars = standardnameTOCMORvar('atmosphere_absorption_optical_thickness_due_to_ambient_aerosol_particles', True)
The following 2 CMORvars have been found for standardname 'atmosphere_absorption_optical_thickness_due_to_ambient_aerosol_particles':
  - aeroptbnd  (E3hrPt         )
  - abs550aer  (AERmon         )

In [65]:
# Find all CMOR Variables whose standard name includes a certain part
def partOFstandardnameTOCMORvar(sn, toScreen=False):
        """
        Args:
          + sn - 'dreqPy.dreq.dreqItem_var'.sn or 'dreqPy.dreq.dreqItem_standardname'.uid,
                 which is the name of a standardname
          + toScreen - Boolean (print result to std.out or not)          
        Returns:
          + List of corresponding 'dreqPy.dreq.dreqItem_CMORvar'-objects
        """

        #standardname->var.uid
        vl=set([ x.uid for x in dq.coll['var'].items if sn.lower() in x.sn.lower() ])
        #var->CMORvar
        cmvar=set([ (x, dq.inx.uid[x.vid].sn) \
                       for x in dq.coll['CMORvar'].items if x.vid in vl ])

        #print to std.out
        if toScreen==True:
                print("\nThe following %i CMORvars have a standardname including '%s':" \
                    % (len(cmvar), sn.lower()))
                for i in cmvar: print( "  - %-10s (%-15s): %s" \
                        % (str(i[0].label), str(i[0].mipTable), str(i[1])))
                print()

        #return corresponding 'dreqPy.dreq.dreqItem_CMORvar'-objects
        cmvar=[x[0] for x in cmvar]
        return cmvar
    
# Example for an arbitrary part of a standardname
cmvars = partOFstandardnameTOCMORvar("Wet_Deposition", True)
The following 9 CMORvars have a standardname including 'wet_deposition':
  - wetso4     (AERmon         ): minus_tendency_of_atmosphere_mass_content_of_sulfate_dry_aerosol_particles_due_to_wet_deposition
  - wetso2     (AERmon         ): minus_tendency_of_atmosphere_mass_content_of_sulfur_dioxide_due_to_wet_deposition
  - wetoa      (AERmon         ): minus_tendency_of_atmosphere_mass_content_of_particulate_organic_matter_dry_aerosol_particles_due_to_wet_deposition
  - wetnh3     (AERmon         ): minus_tendency_of_atmosphere_mass_content_of_ammonia_due_to_wet_deposition
  - wetnh4     (AERmon         ): minus_tendency_of_atmosphere_mass_content_of_ammonium_dry_aerosol_particles_due_to_wet_deposition
  - wetdust    (AERmon         ): minus_tendency_of_atmosphere_mass_content_of_dust_dry_aerosol_particles_due_to_wet_deposition
  - wetbc      (AERmon         ): minus_tendency_of_atmosphere_mass_content_of_elemental_carbon_dry_aerosol_particles_due_to_wet_deposition
  - wetss      (AERmon         ): minus_tendency_of_atmosphere_mass_content_of_sea_salt_dry_aerosol_particles_due_to_wet_deposition
  - wetnoy     (AERmon         ): minus_tendency_of_atmosphere_mass_content_of_noy_expressed_as_nitrogen_due_to_wet_deposition

8 - Official Web-tools

Official Link

In [ ]: