xcmor.Cmorizer.cmorize

xcmor.Cmorizer.cmorize#

Cmorizer.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"],
... )