# Buggy code
def get_dataset(self, key, info):
    """Get a dataset from the file."""

    if key.name in CHANNEL_NAMES:
        dataset = self.calibrate([key])[0]
        # dataset.info.update(info)
    elif key.name in ["longitude", "latitude"]:
        if self.lons is None or self.lats is None:
            self.navigate()
        if key.name == "longitude":
            return Dataset(self.lons, id=key, **info)
        else:
            return Dataset(self.lats, id=key, **info)
    else:  # Get sun-sat angles
        if key.name in ANGLES:
            if isinstance(getattr(self, ANGLES[key.name]), np.ndarray):
                dataset = Dataset(getattr(self, ANGLES[key.name]), copy=False)
            else:
                dataset = self.get_angles(key.name)
        else:
            logger.exception("Not a supported sun-sensor viewing angle: %s", key.name)
            raise

    # TODO get metadata

    if not self._shape:
        self._shape = dataset.shape

    return dataset


# Traceback (AttributeError)
[INFO: 2017-12-12 08:14:04 : satpy.writers.cf_writer] Saving datasets to NetCDF4/CF.
[INFO: 2017-12-12 08:14:04 : satpy.writers.cf_writer] No longitude and latitude data to save.
[INFO: 2017-12-12 08:14:04 : satpy.writers.cf_writer] No grid mapping to save.
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-24-58ece08c15f3> in <module>()
----> 1 lcl.save_datasets(writer='cf', filename='/tmp/foo.nc')

/home/lahtinep/Software/pytroll/packages/satpy/satpy/scene.pyc in save_datasets(self, writer, datasets, **kwargs)
632             datasets = self.datasets.values()
633         writer = self.get_writer(writer, **kwargs)
--> 634         writer.save_datasets(datasets, **kwargs)
635
636     def get_writer(self, writer="geotiff", **kwargs):

/home/lahtinep/Software/pytroll/packages/satpy/satpy/writers/cf_writer.pyc in save_datasets(self, datasets, filename, **kwargs)
176                     coords = [line_coord, pixel_coord]
177
--> 178                 domain = cf.Domain(dim=coords,
179                                    aux=aux,
180                                    ref=grid_mapping)

AttributeError: 'module' object has no attribute 'Domain'

# Fixed code
def get_dataset(self, key, info):
    """Get a dataset from the file."""

    if key.name in CHANNEL_NAMES:
        dataset = self.calibrate([key])[0]
    elif key.name in ["longitude", "latitude"]:
        if self.lons is None or self.lats is None:
            self.navigate()
        if key.name == "longitude":
            dataset = create_xarray(self.lons)
        else:
            dataset = create_xarray(self.lats)
        dataset.attrs = info
    else:  # Get sun-sat angles
        if key.name in ANGLES:
            if isinstance(getattr(self, ANGLES[key.name]), np.ndarray):
                dataset = getattr(self, ANGLES[key.name])
            else:
                dataset = self.get_angles(key.name)
        else:
            logger.exception("Not a supported sun-sensor viewing angle: %s", key.name)
            raise

    # TODO get metadata

    if not self._shape:
        self._shape = dataset.shape

    return dataset