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
ncremapor cut down to a few variables keeps thebounds,cell_measures,coordinatesandgrid_mappingattributes 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 movescoordinatesfrom 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