pycmor.data_request package#
Submodules#
pycmor.data_request.collection module#
- class pycmor.data_request.collection.CMIP6DataRequest(tables: Dict[str, CMIP6DataRequestTable], flattable_variables: bool = True, include_table_headers_in_variables: bool = True)[source]#
Bases:
DataRequest- GIT_URL = 'https://github.com/PCMDI/cmip6-cmor-tables/'#
The URL of the CMIP6 data request repository.
- Type:
- _IGNORE_TABLE_FILES = ['CMIP6_CV_test.json', 'CMIP6_coordinate.json', 'CMIP6_CV.json', 'CMIP6_formula_terms.json', 'CMIP6_grids.json', 'CMIP6_input_example.json']#
Table files to ignore when reading from a directory.
- Type:
List[str]
- _registry = {}#
- classmethod from_directory(directory: str) CMIP6DataRequest[source]#
Create a DataRequest from a directory of tables.
- classmethod from_git(url: str = None, branch: str = 'main') CMIP6DataRequest[source]#
Create a DataRequest from a git repository.
- classmethod from_tables(tables: Dict[str, DataRequestTable]) CMIP6DataRequest[source]#
Create a DataRequest from a dictionary of tables.
- classmethod from_tables_dir(directory: str) CMIP6DataRequest[source]#
Deprecated since version Use: from_directory instead.
- class pycmor.data_request.collection.CMIP6IgnoreTableFiles(*values)[source]#
Bases:
EnumTable files to ignore when reading from a directory.
- COORDINATE = 'CMIP6_coordinate.json'#
- CV = 'CMIP6_CV.json'#
- CV_TEST = 'CMIP6_CV_test.json'#
- FORMULA_TERMS = 'CMIP6_formula_terms.json'#
- GRIDS = 'CMIP6_grids.json'#
- INPUT_EXAMPLE = 'CMIP6_input_example.json'#
- class pycmor.data_request.collection.CMIP7DataRequest(tables: Dict[str, DataRequestTable], variables: Dict[str, CMIP7DataRequestVariable] = None)[source]#
Bases:
DataRequest- GIT_URL = 'https://github.com/CMIP-Data-Request/CMIP7_DReq_Software/'#
The URL of the CMIP7 data request repository.
- Type:
- _registry = {}#
- classmethod from_directory(directory: str) CMIP7DataRequest[source]#
Creates the CMIP7 data request from a directory
- classmethod from_json_file(jfile: str) CMIP7DataRequest[source]#
Creates a CMIP7DataRequest instance from a single JSON file
- classmethod from_tables(tables: Dict[str, DataRequestTable]) CMIP7DataRequest[source]#
Create a DataRequest from a dictionary of tables.
- classmethod from_tables_dir(directory: str) CMIP7DataRequest[source]#
Deprecated since version Use: from_directory instead.
- class pycmor.data_request.collection.DataRequest[source]#
Bases:
object- _registry = {'CMIP6': <class 'pycmor.data_request.collection.CMIP6DataRequest'>, 'CMIP7': <class 'pycmor.data_request.collection.CMIP7DataRequest'>}#
- abstractmethod classmethod from_directory(directory: str) DataRequest[source]#
Create a DataRequest from a directory of tables.
- abstractmethod classmethod from_git(url: str, branch: str = 'master') DataRequest[source]#
Create a DataRequest from a git repository.
- abstractmethod classmethod from_tables(tables: Dict[str, DataRequestTable]) DataRequest[source]#
Create a DataRequest from a dictionary of tables.
- abstractmethod classmethod from_tables_dir(directory: str) DataRequest[source]#
Create a DataRequest from a directory of tables.
Deprecated since version Use: from_directory instead.
pycmor.data_request.table module#
- class pycmor.data_request.table.CMIP6DataRequestTable(header: CMIP6DataRequestTableHeader, variables: List[DataRequestVariable])[source]#
Bases:
DataRequestTableDataRequestTable for CMIP6.
- _registry = {}#
- classmethod from_dict(data: dict) CMIP6DataRequestTable[source]#
Create a DataRequestTable from a dictionary.
- classmethod from_json_file(jfile) CMIP6DataRequestTable[source]#
- get_variable(name: str, find_by='name') DataRequestVariable[source]#
Returns the first variable with the matching name.
- Parameters:
name (str)
- Return type:
- property header: CMIP6DataRequestTableHeader#
Header of the table.
- class pycmor.data_request.table.CMIP6DataRequestTableHeader(_table_id: str, _realm: List[str], _table_date: pendulum.date.Date, _approx_interval: float, _generic_levels: List[str], _data_specs_version: semver.version.Version = Version(major=1, minor=0, patch=33, prerelease=None, build=None), _cmor_version: semver.version.Version = Version(major=3, minor=5, patch=0, prerelease=None, build=None), _mip_era: str = 'CMIP6', _Conventions: str = 'CF-1.7 CMIP-6.2', _missing_value: float = 1e+20, _int_missing_value: int = -999, _product: str = 'model-output')[source]#
Bases:
DataRequestTableHeader- _HARD_CODED_DATA_SPECS_REPLACEMENTS = {'01.00.27': '1.0.27', '01.00.33': '1.0.33'}#
- _cmor_version: Version = Version(major=3, minor=5, patch=0, prerelease=None, build=None)#
- _data_specs_version: Version = Version(major=1, minor=0, patch=33, prerelease=None, build=None)#
- _registry = {'CMIP6JSONDataRequestTableHeader': <class 'pycmor.data_request.table.CMIP6JSONDataRequestTableHeader'>}#
- _table_date: Date#
- property cmor_version: Version#
CMOR version.
- property data_specs_version: Version#
Data specifications version.
- classmethod from_dict(data: dict) CMIP6DataRequestTableHeader[source]#
Create a DataRequestTableHeader from a dictionary.
- property table_date: Date#
Date of the table.
- class pycmor.data_request.table.CMIP6JSONDataRequestTableHeader(_table_id: str, _realm: List[str], _table_date: pendulum.date.Date, _approx_interval: float, _generic_levels: List[str], _data_specs_version: semver.version.Version = Version(major=1, minor=0, patch=33, prerelease=None, build=None), _cmor_version: semver.version.Version = Version(major=3, minor=5, patch=0, prerelease=None, build=None), _mip_era: str = 'CMIP6', _Conventions: str = 'CF-1.7 CMIP-6.2', _missing_value: float = 1e+20, _int_missing_value: int = -999, _product: str = 'model-output')[source]#
Bases:
CMIP6DataRequestTableHeader- _registry = {}#
- _table_date: Date#
- classmethod from_json_file(jfile) CMIP6JSONDataRequestTableHeader[source]#
- class pycmor.data_request.table.CMIP7DataRequestTable(header: CMIP7DataRequestTableHeader, variables: List[DataRequestVariable])[source]#
Bases:
DataRequestTableDataRequestTable for CMIP7.
- _registry = {}#
- classmethod from_all_var_info_json(table_name: str) CMIP7DataRequestTable[source]#
- classmethod from_dict(data: dict) CMIP7DataRequestTable[source]#
Create a DataRequestTable from a dictionary.
- classmethod from_json_file(jfile) CMIP7DataRequestTable[source]#
- get_variable(name: str, find_by='name') DataRequestVariable[source]#
Returns the first variable with the matching name.
- Parameters:
name (str)
- Return type:
- property header: CMIP7DataRequestTableHeader#
Header of the table.
- class pycmor.data_request.table.CMIP7DataRequestTableHeader(_table_id: str, _realm: List[str], _approx_interval: float, _generic_levels: List[str], _data_specs_version: semver.version.Version = Version(major=1, minor=0, patch=0, prerelease=None, build=None), _cmor_version: semver.version.Version = Version(major=3, minor=5, patch=0, prerelease=None, build=None), _mip_era: str = 'CMIP7', _Conventions: str = 'CF-1.7 CMIP-7.0', _missing_value: float = 1e+20, _int_missing_value: int = -999, _product: str = 'model-output', _table_date: pendulum.date.Date = Date(2024, 11, 22))[source]#
Bases:
DataRequestTableHeader- _cmor_version: Version = Version(major=3, minor=5, patch=0, prerelease=None, build=None)#
- _data_specs_version: Version = Version(major=1, minor=0, patch=0, prerelease=None, build=None)#
- _registry = {}#
- _table_date: Date = Date(2024, 11, 22)#
- property cmor_version: Version#
CMOR version.
- property data_specs_version: Version#
Data specifications version.
- classmethod from_all_var_info(table_name: str, all_var_info: dict = None) CMIP7DataRequestTableHeader[source]#
- property table_date: Date#
Date of the table.
- class pycmor.data_request.table.DataRequestTable[source]#
Bases:
objectAbstract base class for a generic data request table.
- _registry = {'CMIP6': <class 'pycmor.data_request.table.CMIP6DataRequestTable'>, 'CMIP7': <class 'pycmor.data_request.table.CMIP7DataRequestTable'>}#
- abstractmethod classmethod from_dict(data: dict) DataRequestTable[source]#
Create a DataRequestTable from a dictionary.
- abstractmethod get_variable(name: str) DataRequestVariable[source]#
Retrieve a variable’s details by name.
- abstract property header: DataRequestTableHeader#
Header of the table.
- abstractmethod classmethod table_dict_from_directory(path: str) dict[source]#
Create a dictionary of tables from a directory.
- abstract property variables: List[DataRequestVariable]#
List of variables in the table.
- class pycmor.data_request.table.DataRequestTableHeader[source]#
Bases:
object- _registry = {'CMIP6': <class 'pycmor.data_request.table.CMIP6DataRequestTableHeader'>, 'CMIP7': <class 'pycmor.data_request.table.CMIP7DataRequestTableHeader'>}#
- abstract property cmor_version: Version#
CMOR version.
- abstract property data_specs_version: Version#
Data specifications version.
- abstractmethod classmethod from_dict(data: dict) DataRequestTableHeader[source]#
Create a DataRequestTableHeader from a dictionary.
- abstract property table_date: date#
Date of the table.
pycmor.data_request.variable module#
This module defines the DataRequestVariable abstract base class and its
concrete implementation CMIP6DataRequestVariable.
The DataRequestVariable class outlines the necessary properties and methods
that any variable class should implement. It includes properties such as frequency,
modeling realm, standard name, units, cell methods, cell measures, long name,
comment, dimensions, out name, type, positive direction, valid minimum and
maximum values, acceptable minimum and maximum mean absolute values, and the
table name.
The CMIP6DataRequestVariable class is a concrete implementation of the
DataRequestVariable class, specifically for CMIP6 variables. It uses the
dataclass decorator to automatically generate the __init__, __repr__,
and other special methods.
The module also provides class methods for constructing DataRequestVariable
instances from dictionaries and JSON files, as well as a method for converting
a DataRequestVariable instance to a dictionary representation.
- class pycmor.data_request.variable.CMIP6DataRequestVariable(_variable_id: str, _name: str, _frequency: str, _modeling_realm: str, _standard_name: str, _units: str, _cell_methods: str, _cell_measures: str, _long_name: str, _comment: str, _dimensions: tuple[str, ...], _out_name: str, _typ: type, _positive: str, _valid_min: float, _valid_max: float, _ok_min_mean_abs: float, _ok_max_mean_abs: float, _table_name: str | None = None)[source]#
Bases:
DataRequestVariable- _registry = {'CMIP6JSONDataRequestVariable': <class 'pycmor.data_request.variable.CMIP6JSONDataRequestVariable'>}#
- clone() CMIP6DataRequestVariable[source]#
Create a copy of this variable
- classmethod from_dict(data: dict) CMIP6DataRequestVariable[source]#
Create a DataRequestVariable instance from a dictionary.
- class pycmor.data_request.variable.CMIP6JSONDataRequestVariable(_variable_id: str, _name: str, _frequency: str, _modeling_realm: str, _standard_name: str, _units: str, _cell_methods: str, _cell_measures: str, _long_name: str, _comment: str, _dimensions: tuple[str, ...], _out_name: str, _typ: type, _positive: str, _valid_min: float, _valid_max: float, _ok_min_mean_abs: float, _ok_max_mean_abs: float, _table_name: str | None = None)[source]#
Bases:
CMIP6DataRequestVariable- _registry = {}#
- classmethod from_json_file(jfile: str, varname: str) CMIP6DataRequestVariable[source]#
Create a DataRequestVariable instance from a JSON file.
- class pycmor.data_request.variable.CMIP7DataRequestVariable(_frequency: str, _modeling_realm: str, _standard_name: str, _units: str, _cell_methods: str, _cell_measures: str, _long_name: str, _comment: str, _dimensions: tuple[str, ...], _out_name: str, _typ: type, _positive: str, _spatial_shape: str, _temporal_shape: str, _cmip6_cmor_table: str, _name: str, _table_name: str | None = None)[source]#
Bases:
DataRequestVariable- _registry = {}#
- clone() CMIP7DataRequestVariable[source]#
Create a copy of this variable
- class pycmor.data_request.variable.DataRequestVariable[source]#
Bases:
objectAbstract base class for a generic variable.
- _registry = {'CMIP6': <class 'pycmor.data_request.variable.CMIP6DataRequestVariable'>, 'CMIP7': <class 'pycmor.data_request.variable.CMIP7DataRequestVariable'>}#
- _type_strings = {'boolean': <class 'bool'>, 'char': <class 'str'>, 'character': <class 'str'>, 'double': <class 'float'>, 'float': <class 'float'>, 'int': <class 'int'>, 'integer': <class 'int'>, 'logical': <class 'bool'>, 'long': <class 'int'>, 'real': <class 'float'>, 'short': <class 'int'>, 'string': <class 'str'>}#
conversion of string names in the tables to actual Python types
- Type:
- abstractmethod clone() DataRequestVariable[source]#
Create a copy of this variable
- classmethod from_dict(data: dict) DataRequestVariable[source]#
Create a DataRequestVariable instance from a dictionary.
- classmethod from_json_file(jfile: str, varname: str) DataRequestVariable[source]#
Create a DataRequestVariable instance from a JSON file.