xoa.cf.assign_cf_specs#
- xoa.cf.assign_cf_specs(ds, name=None, register=False, set_encoding=True)[source]#
Set the
cf_specsencoding tonamein all data vars and coords- Parameters:
name (None, str, CFSpecs, xarray.DataArray, xarray.Dataset) –
If a
CFSpecs, it must have a registration name :[register] name=registration_name
If not provided,
infer_cf_specs()is called to infer the best named registered specs.register (bool) – Register the specs if name is a named, unregistered
CFSpecsinstance.set_encoding (bool) – Set the “cf_specs” encoding to name.
- Returns:
xarray.Dataset, xarray.DataArray
Example
In [1]: ds = xr.Dataset({'temp': ('lon', [5])}, coords={'lon': [6]}) In [2]: assign_cf_specs(ds, "mycroco"); In [3]: ds.encoding Out[3]: {'cf_specs': 'mycroco'} In [4]: ds.temp.encoding Out[4]: {'cf_specs': 'mycroco'} In [5]: ds.lon.encoding Out[5]: {'cf_specs': 'mycroco'}