! 🚧 UNDER CONSTRUCTION !
Lazy in-memory cmorization with xarray.
This package aims at implementing a climate model output rewriter (cmor) tool based on xarray. Actually, the process of cmorization mostly deals with making climate model output data compliant with the Climate and Weather Forecast meta data conventions (CF-conventions) and, in most cases, does not really touch the data itself. This makes it ideal for handling cmorization with xarray data structures since they allow easy manipulation of meta data using python dictionaries.
While the original cmor library offers a wide variety of APIs for different programming languages (including python) to rewrite climate model output to NetCDF files, xcmor focuses more on lazy cmorization in memory without neccessarily having to actually rewrite the dataset to a filesystem. However, this is, of course, also possible using xarrays versatile IO features.
from xcmor import Cmorizer
from xcmor.datasets import reg_ds
cmor = Cmorizer()
ds_out = cmor.cmorize(
reg_ds.rename(temperature="tas").tas, "Amon", cmor.tables["input_example"]
)