docs: def decode_coords(ds, gridfile=None):
          """
          Sets the coordinates and bounds in a dataset
  
          This static method sets those coordinates and bounds that are marked
          marked in the netCDF attributes as coordinates in :attr:`ds` (without
          deleting them from the variable attributes because this information is
          necessary for visualizing the data correctly)
  
          Parameters
          ----------
          ds: xarray.Dataset
              The dataset to decode
          gridfile: str
              The path to a separate grid file or a xarray.Dataset instance which
              may store the coordinates used in `ds`
  
          Returns
          -------
          xarray.Dataset
              `ds` with additional coordinates"""
          def add_attrs(obj):
              if 'coordinates' in obj.attrs:
                  extra_coords.update(obj.attrs['coordinates'].split())
                  obj.encoding['coordinates'] = obj.attrs.pop('coordinates')
              if 'bounds' in obj.attrs:
                  extra_coords.add(obj.attrs['bounds'])
          if gridfile is not None and not isinstance(gridfile, xr.Dataset):
              gridfile = open_dataset(gridfile)
          extra_coords = set(ds.coords)
          for k, v in six.iteritems(ds.variables):
              add_attrs(v)
          add_attrs(ds)
          if gridfile is not None:
              ds.update({k: v for k, v in six.iteritems(gridfile.variables)
                         if k in extra_coords})
          if xr_version < (0, 11):
              ds.set_coords(extra_coords.intersection(ds.variables),
                            inplace=True)
          else:
              ds._coord_names.update(extra_coords.intersection(ds.variables))
          return ds