# Buggy code
def get_dataset(self, dsid, info, out=None):
    """Load a dataset."""

    logger.debug("Reading %s.", dsid.name)
    variable = self.nc[dsid.name]

    info = {"platform_name": self.platform_name, "sensor": self.sensor}

    try:
        values = np.ma.masked_equal(
            variable[:], variable.attrs["_FillValue"], copy=False
        )
    except KeyError:
        values = np.ma.array(variable[:], copy=False)
    if "scale_factor" in variable.attrs:
        values = values * variable.attrs["scale_factor"]
        info["scale_factor"] = variable.attrs["scale_factor"]
    if "add_offset" in variable.attrs:
        values = values + variable.attrs["add_offset"]
        info["add_offset"] = variable.attrs["add_offset"]
    if "valid_range" in variable.attrs:
        info["valid_range"] = variable.attrs["valid_range"]
    if "units" in variable.attrs:
        info["units"] = variable.attrs["units"]
    if "standard_name" in variable.attrs:
        info["standard_name"] = variable.attrs["standard_name"]

    if self.pps and dsid.name == "ctth_alti":
        info["valid_range"] = (0.0, 8500.0)
    if self.pps and dsid.name == "ctth_alti_pal":
        values = values[1:, :]

    proj = Dataset(np.squeeze(values), copy=False, **info)
    return proj


# 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, dsid, info):
    """Load a dataset."""
    logger.debug("Reading %s.", dsid.name)
    variable = self.nc[dsid.name]

    variable = remove_empties(variable)

    if "scale_factor" in variable.attrs or "add_offset" in variable.attrs:
        scale = variable.attrs.get("scale_factor", 1)
        offset = variable.attrs.get("add_offset", 0)
        if np.issubdtype((scale + offset).dtype, np.floating):
            if "_FillValue" in variable.attrs:
                variable = variable.where(variable != variable.attrs["_FillValue"])
            if "valid_range" in variable.attrs:
                variable = variable.where(variable <= variable.attrs["valid_range"][1])
                variable = variable.where(variable >= variable.attrs["valid_range"][0])
            if "valid_max" in variable.attrs:
                variable = variable.where(variable <= variable.attrs["valid_max"])
            if "valid_min" in variable.attrs:
                variable = variable.where(variable >= variable.attrs["valid_min"])

        variable = variable * scale + offset

    variable.attrs.update({"platform_name": self.platform_name, "sensor": self.sensor})

    variable.attrs.setdefault("units", "1")

    ancillary_names = variable.attrs.get("ancillary_variables", "")
    try:
        variable.attrs["ancillary_variables"] = ancillary_names.split()
    except AttributeError:
        pass

    if "standard_name" in info:
        variable.attrs.setdefault("standard_name", info["standard_name"])

    if self.pps and dsid.name == "ctth_alti":
        variable.attrs["valid_range"] = (0.0, 8500.0)
    if self.pps and dsid.name == "ctth_alti_pal":
        variable = variable[1:, :]

    return variable