xcmor.Cmorizer#

class xcmor.Cmorizer(project=None, url=None, template=None)[source]#

Cmorizer class supporting preconfigured MIPs.

Parameters:
projectstr, optional

Pre-configures MIP, e.g.,

  • CMIP6

  • CORDEX

urlstr, optional

Base URL or directory of cmor tables.

templatestr, optional

CMOR talbe naming template, e.g.:

CMIP6_{table_id}.json

e.g. CMIP6_Amon.json

Returns:
cmorizerCmorizer object.
__init__(project=None, url=None, template=None)[source]#

Methods

__init__([project, url, template])

cmorize(ds, mip_table, dataset_table[, ...])

Lazy cmorization.

Attributes

required

List required global attributes.

_init_tables(project, url, template)[source]#
cmorize(ds, mip_table, dataset_table, mapping_table=None, time_units=None, **kwargs)[source]#

Lazy cmorization.

Cmorizes an xarray Dataset or DataArray object. The cmorizations tries to follow the approach of the original cmor library in adding, manipulating and interpreting dataseta attributes and cmor table vocabulary.

Parameters:
dsDataArray, Dataset

Dataset that should be cmorized.

mip_tabledict, str

The MIP table, can either be a dictionary or a path to a cmor table in json format or a table_id from the MIP.

dataset_tabledict, str

The input dataset cmor table, can either be a dictionary or a path to a cmor table in json format.

mapping_table: dict

The mapping table maps input variable names to mip table variable keys.

time_units: str

Time units for NetCDF encoding. Default is days since the beginning of the time interval.

Returns:
Cmorized Dataset.

Examples

>>> from xcmor.datasets import reg_ds
>>> from xcmor import Cmorizer
>>>
>>> cmor = Cmorizer()
>>> ds_out = cmor.cmorize(
...     reg_ds.rename(temperature="tas").tas,
...     "Amon",
...     cmor.tables["input_example"],
... )
property required#

List required global attributes.