xoa.cf.assign_cf_specs
- xoa.cf.assign_cf_specs(ds, name=None, register=False)[source]
Set the
cf_specs
encoding toname
in all data vars and coords- Parameters:
ds (xarray.DataArray, xarray.Dataset) –
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
CFSpecs
instance.
- 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'}