src.cmip6 module¶
Code to parse CMIP6 controlled vocabularies and elements of the CMIP6 DRS.
Specifications for the above were taken from the CMIP6 planning document. This was accessed at http://goo.gl/v1drZl – we aren’t aware of a permanent URL for this information.
The CMIP6 controlled vocabularies (lists of registered MIPs, modeling centers, etc.)
are derived from data in the
PCMDI/cmip6-cmor-tables
repo, which is included as a git subtree under /data.
Warning
Functionality here has been added as needed for the project and is incomplete. For example, parsing subexperiments is not supported.
-
class
src.cmip6.CMIP6_CVs(*args, **kwargs)[source]¶ Bases:
src.util.basic.SingletonInterface for looking up information from the CMIP6 controlled vocabulary (CV) file.
Lookups are implemented in an ad-hoc way with
util.MultiMap; a more robust solution would usesqlite.-
__init__(unittest=False)[source]¶ Constructor. Only executed once, since this is a
Singleton. Reads and parses data in CMIP6_CV.json.
-
is_in_cv(category, items)[source]¶ Determine if items take values that are valid for the CV category category.
-
get_lookup(source, dest)[source]¶ Find the appropriate lookup table to convert values in source (keys) to values in dest (values), generating it if necessary.
-
lookup(source_items, source, dest)[source]¶ Look up the corresponding dest values for source_items (keys).
-
lookup_single(source_item, source, dest)[source]¶ The same as
lookup(), but perform lookup for a single source_item, and raise KeyError if the number of values returned is != 1.
-
table_id_from_freq(frequency)[source]¶ Specialized lookup to determine which MIP tables use data at the requested frequency.
Should really be handled as a special case of
lookup().- Parameters
frequency (
CMIP6DateFrequency) – DateFrequency- Returns
List of MIP table
table_idnames, if any, that use data at the given frequency.
-
-
class
src.cmip6.CMIP6DateFrequency(quantity, unit=None)[source]¶ Bases:
src.util.datelabel.DateFrequencySubclass of
DateFrequencyto parse data frequency information as encoded in MIP tables, DRS filenames, etc.Extends DateFrequency in that this records if the data is a climatological average, although this information is not currently used.
Reference: CMIP6 planning document page 16.
-
__init__()¶ Initialize self. See help(type(self)) for accurate signature.
-
format_local()¶ String representation as used in framework’s local directory hierarchy (defined in
src.data_manager.DataManager.dest_path().)
-
classmethod
from_struct(str_)¶ Object instantiation method used by
src.util.dataclass.mdtf_dataclass()for type coercion.
-
property
is_static¶ Property indicating time-independent data (e.g.,
fxin CMIP6 DRS.)
-
max= datetime.timedelta(days=999999999, seconds=86399, microseconds=999999)¶
-
min= datetime.timedelta(days=-999999999)¶
-
resolution= datetime.timedelta(microseconds=1)¶
-
-
class
src.cmip6.CMIP6_VariantLabel(first_arg=None, *args, **kwargs)[source]¶ Bases:
objectregex_dataclasswhich represents and parses the CMIP6 DRS variant label identifier string (e.g., r1i1p1f1.)References: https://earthsystemcog.org/projects/wip/mip_table_about, although this doesn’t document all cases used in CMIP6. See also note 8 on page 9 of the CMIP6 planning document.
-
__init__(variant_label: str = sentinel.Mandatory, realization_index: int = None, initialization_index: int = None, physics_index: int = None, forcing_index: int = None) → None¶ Initialize self. See help(type(self)) for accurate signature.
-
__post_init__(*args, **kwargs)¶
-
classmethod
from_string(str_, *args)¶ Create an object instance from a string representation str_. Used by
regex_dataclass()for parsing field values and automatic type coercion.
-
-
class
src.cmip6.CMIP6_MIPTable(first_arg=None, *args, **kwargs)[source]¶ Bases:
objectregex_dataclasswhich represents and parses the MIP table identifier string.Reference: https://earthsystemcog.org/projects/wip/mip_table_about, although this doesn’t document all cases used in CMIP6.
-
table_freq: dataclasses.InitVar = ''¶
-
frequency: CMIP6DateFrequency¶
-
__init__(table_id: str = sentinel.Mandatory, table_prefix: str = '', table_freq: dataclasses.InitVar = '', table_suffix: str = '', table_qualifier: str = '') → None¶ Initialize self. See help(type(self)) for accurate signature.
-
classmethod
from_string(str_, *args)¶ Create an object instance from a string representation str_. Used by
regex_dataclass()for parsing field values and automatic type coercion.
-
-
class
src.cmip6.CMIP6_GridLabel(first_arg=None, *args, **kwargs)[source]¶ Bases:
objectregex_dataclasswhich represents and parses the CMIP6 DRS grid label identifier string.Reference: CMIP6 planning document, note 11 on page 11.
-
global_mean: dataclasses.InitVar = ''¶
-
zonal_mean: dataclasses.InitVar = ''¶
-
__init__(grid_label: str = sentinel.Mandatory, global_mean: dataclasses.InitVar = '', regrid: str = '', grid_number: int = 0, region: str = '', zonal_mean: dataclasses.InitVar = '') → None¶ Initialize self. See help(type(self)) for accurate signature.
-
classmethod
from_string(str_, *args)¶ Create an object instance from a string representation str_. Used by
regex_dataclass()for parsing field values and automatic type coercion.
-
-
class
src.cmip6.CMIP6_DRSDirectory(first_arg=None, *args, **kwargs)[source]¶ Bases:
src.cmip6.CMIP6_VariantLabel,src.cmip6.CMIP6_MIPTable,src.cmip6.CMIP6_GridLabelregex_dataclasswhich represents and parses the DRS directory path.Reference: CMIP6 planning document, page 17.
Warning
This regex will fail on paths involving subexperiments.
-
variant_label: src.cmip6.CMIP6_VariantLabel = ''¶
-
table_id: src.cmip6.CMIP6_MIPTable = ''¶
-
grid_label: src.cmip6.CMIP6_GridLabel = ''¶
-
version_date: src.util.datelabel.Date = None¶
-
__init__(grid_label: src.cmip6.CMIP6_GridLabel = '', global_mean: dataclasses.InitVar = '', regrid: str = '', grid_number: int = 0, zonal_mean: dataclasses.InitVar = '', table_id: src.cmip6.CMIP6_MIPTable = '', table_prefix: str = '', table_freq: dataclasses.InitVar = '', table_suffix: str = '', table_qualifier: str = '', variant_label: src.cmip6.CMIP6_VariantLabel = '', realization_index: int = None, initialization_index: int = None, physics_index: int = None, forcing_index: int = None, directory: str = sentinel.Mandatory, activity_id: str = '', institution_id: str = '', source_id: str = '', experiment_id: str = '', version_date: src.util.datelabel.Date = None) → None¶ Initialize self. See help(type(self)) for accurate signature.
-
__post_init__(*args, **kwargs)¶
-
forcing_index= None¶
-
classmethod
from_string(str_, *args)¶ Create an object instance from a string representation str_. Used by
regex_dataclass()for parsing field values and automatic type coercion.
-
global_mean= ''¶
-
grid_number= 0¶
-
initialization_index= None¶
-
physics_index= None¶
-
realization_index= None¶
-
region= ''¶
-
regrid= ''¶
-
table_freq= ''¶
-
table_prefix= ''¶
-
table_qualifier= ''¶
-
table_suffix= ''¶
-
zonal_mean= ''¶
-
-
class
src.cmip6.CMIP6_DRSFilename(first_arg=None, *args, **kwargs)[source]¶ Bases:
src.cmip6.CMIP6_VariantLabel,src.cmip6.CMIP6_MIPTable,src.cmip6.CMIP6_GridLabelregex_dataclasswhich represents and parses the DRS filename.Reference: CMIP6 planning document, page 14-15.
-
table_id: src.cmip6.CMIP6_MIPTable = ''¶
-
variant_label: src.cmip6.CMIP6_VariantLabel = ''¶
-
grid_label: src.cmip6.CMIP6_GridLabel = ''¶
-
start_date: src.util.datelabel.Date = None¶
-
end_date: src.util.datelabel.Date = None¶
-
date_range: util.DateRange¶
-
__init__(grid_label: src.cmip6.CMIP6_GridLabel = '', global_mean: dataclasses.InitVar = '', regrid: str = '', grid_number: int = 0, zonal_mean: dataclasses.InitVar = '', table_id: src.cmip6.CMIP6_MIPTable = '', table_prefix: str = '', table_freq: dataclasses.InitVar = '', table_suffix: str = '', table_qualifier: str = '', variant_label: src.cmip6.CMIP6_VariantLabel = '', realization_index: int = None, initialization_index: int = None, physics_index: int = None, forcing_index: int = None, filename: str = sentinel.Mandatory, variable_id: str = '', source_id: str = '', experiment_id: str = '', start_date: src.util.datelabel.Date = None, end_date: src.util.datelabel.Date = None) → None¶ Initialize self. See help(type(self)) for accurate signature.
-
forcing_index= None¶
-
classmethod
from_string(str_, *args)¶ Create an object instance from a string representation str_. Used by
regex_dataclass()for parsing field values and automatic type coercion.
-
global_mean= ''¶
-
grid_number= 0¶
-
initialization_index= None¶
-
physics_index= None¶
-
realization_index= None¶
-
region= ''¶
-
regrid= ''¶
-
table_freq= ''¶
-
table_prefix= ''¶
-
table_qualifier= ''¶
-
table_suffix= ''¶
-
zonal_mean= ''¶
-
-
class
src.cmip6.CMIP6_DRSPath(first_arg=None, *args, **kwargs)[source]¶ Bases:
src.cmip6.CMIP6_DRSDirectory,src.cmip6.CMIP6_DRSFilenameregex_dataclasswhich represents and parses a full CMIP6 DRS path.-
directory: src.cmip6.CMIP6_DRSDirectory = ''¶
-
__init__(grid_label: src.cmip6.CMIP6_GridLabel = '', global_mean: dataclasses.InitVar = '', regrid: str = '', grid_number: int = 0, zonal_mean: dataclasses.InitVar = '', table_id: src.cmip6.CMIP6_MIPTable = '', table_prefix: str = '', table_freq: dataclasses.InitVar = '', table_suffix: str = '', table_qualifier: str = '', variant_label: src.cmip6.CMIP6_VariantLabel = '', realization_index: int = None, initialization_index: int = None, physics_index: int = None, forcing_index: int = None, filename: src.cmip6.CMIP6_DRSFilename = '', variable_id: str = '', source_id: str = '', experiment_id: str = '', start_date: src.util.datelabel.Date = None, end_date: src.util.datelabel.Date = None, directory: src.cmip6.CMIP6_DRSDirectory = '', activity_id: str = '', institution_id: str = '', version_date: src.util.datelabel.Date = None, path: str = sentinel.Mandatory) → None¶ Initialize self. See help(type(self)) for accurate signature.
-
__post_init__(*args, **kwargs)¶
-
activity_id= ''¶
-
end_date= None¶
-
experiment_id= ''¶
-
filename: src.cmip6.CMIP6_DRSFilename = ''¶
-
forcing_index= None¶
-
classmethod
from_string(str_, *args)¶ Create an object instance from a string representation str_. Used by
regex_dataclass()for parsing field values and automatic type coercion.
-
global_mean= ''¶
-
grid_label= ''¶
-
grid_number= 0¶
-
initialization_index= None¶
-
institution_id= ''¶
-
physics_index= None¶
-
realization_index= None¶
-
region= ''¶
-
regrid= ''¶
-
source_id= ''¶
-
start_date= None¶
-
table_freq= ''¶
-
table_id= ''¶
-
table_prefix= ''¶
-
table_qualifier= ''¶
-
table_suffix= ''¶
-
variable_id= ''¶
-
variant_label= ''¶
-
version_date= None¶
-
zonal_mean= ''¶
-