def remove_deprecated_dims(ds):
    """Remove dimensions that do not occur in any of the variables of the given dataset."""
    # get all valid dims
    var_dims = []
    for v in ds.data_vars:
        var_dims.extend(ds[v].dims)
    # drop deprecated dims
    for d in ds.dims:
        if d not in var_dims:
            ds = ds.drop(d)
    return ds