polaris.cf.drop_inherited_attrs
- polaris.cf.drop_inherited_attrs(ds: Dataset, names: Iterable[str]) Dataset[source]
Clear the attributes of each named variable whose attributes are identical to another variable’s. xarray propagates attributes through arithmetic, comparisons,
where()andones_like(), so a variable with exactly another’s attributes was derived from it and describes itself as that variable (abottomDepthmade fromones_like(xCell)calls itself the x coordinate of cell centers). A label someone wrote for a variable never duplicates another variable’s whole attribute set, so those are kept. Use beforeadd_var_attrs()to give the cleared variables their own attributes.- Parameters:
ds (xarray.Dataset) – A dataset about to be written
names (iterable of str) – The variables to consider, typically the ones a table of attributes can describe. Variables not in the dataset are ignored.
- Returns:
ds (xarray.Dataset) – A shallow copy of the dataset with the inherited attributes cleared