NCAS-CMS / cf-python

A CF-compliant Earth Science data analysis library
http://ncas-cms.github.io/cf-python
MIT License
119 stars 19 forks source link

Converting field(s) to & from CF-compliant `xarray.Dataset` #773

Open sadielbartholomew opened 3 months ago

sadielbartholomew commented 3 months ago

A common way to work with weather and climate datasets is of course the xarray library, so it would be nice to have a means to convert to and from an xarray.Dataset if it has sufficient and conformant-enough CF metadata and suitable structure, for which the xarray.decode_cf function may be able to assist on the xarray-side.

Ideally we can have a method for such a conversion and/or at least a recipe in the documentation showing how this can be done, for both a trivially-convertible case and for a case of a field and/or Dataset that needs some tweaks to get the right structure before the conversion can be made.

Note in #706 we considered and supported input of xarray arrays, so that helps towards this.