polaris.cf.drop_dangling_references

polaris.cf.drop_dangling_references(ds: Dataset) → Dataset[source]

Drop each attribute that names a variable the dataset does not have. A file remapped with ncremap or cut down to a few variables keeps the bounds, cell_measures, coordinates and grid_mapping attributes of its source, which name variables (lat_vertices, area, crs) that did not come along, and the CF checker reports each as an error. xarray moves coordinates from a variable’s attributes into its encoding when it reads a file, and writes it back from there, so both are checked.

Parameters:

ds (xarray.Dataset) – A dataset about to be written

Returns:

ds (xarray.Dataset) – A shallow copy of the dataset without the dangling references