# Buggy code
def get_dataset(self, key, info, out=None, xslice=slice(None), yslice=slice(None)):
    """Load a dataset."""
    logger.debug("Reading in get_dataset %s.", key.name)

    variable = self.nc["Rad"]

    radiances = (
        np.ma.masked_equal(
            variable[yslice, xslice], variable.attrs["_FillValue"], copy=False
        )
        * variable.attrs["scale_factor"]
        + variable.attrs["add_offset"]
    )
    # units = variable.attrs['units']
    units = self.calibrate(radiances)

    # convert to satpy standard units
    if units == "1":
        radiances[:] *= 100.0
        units = "%"

    out.data[:] = radiances
    out.mask[:] = np.ma.getmask(radiances)
    out.info.update(
        {
            "units": units,
            "platform_name": self.platform_name,
            "sensor": self.sensor,
            "satellite_latitude": self.nc["nominal_satellite_subpoint_lat"][()],
            "satellite_longitude": self.nc["nominal_satellite_subpoint_lon"][()],
            "satellite_altitude": self.nc["nominal_satellite_height"][()],
        }
    )
    out.info.update(key.to_dict())

    return out


# 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, xslice=slice(None), yslice=slice(None)):
    """Load a dataset."""
    logger.debug("Reading in get_dataset %s.", key.name)

    radiances = self.nc["Rad"][xslice, yslice].expand_dims("time")

    res = self.calibrate(radiances)

    # convert to satpy standard units
    if res.attrs["units"] == "1":
        res = res * 100
        res.attrs["units"] = "%"

    res.attrs.update(
        {
            "platform_name": self.platform_name,
            "sensor": self.sensor,
            "satellite_latitude": float(self.nc["nominal_satellite_subpoint_lat"]),
            "satellite_longitude": float(self.nc["nominal_satellite_subpoint_lon"]),
            "satellite_altitude": float(self.nc["nominal_satellite_height"]),
        }
    )
    res.attrs.update(key.to_dict())

    return res