# Buggy code
def get_enhanced_image(
    dataset,
    enhancer=None,
    fill_value=None,
    ppp_config_dir=None,
    enhancement_config_file=None,
    overlay=None,
    decorate=None,
):
    mode = _determine_mode(dataset)
    if ppp_config_dir is None:
        ppp_config_dir = get_environ_config_dir()

    if enhancer is None:
        enhancer = Enhancer(ppp_config_dir, enhancement_config_file)

    if enhancer.enhancement_tree is None:
        raise RuntimeError(
            "No enhancement configuration files found or specified, cannot"
            " automatically enhance dataset"
        )

    if dataset.info.get("sensor", None):
        enhancer.add_sensor_enhancements(dataset.info["sensor"])

    # Create an image for enhancement
    img = to_image(dataset, mode=mode, fill_value=fill_value)
    enhancer.apply(img, **dataset.info)

    img.info.update(dataset.info)

    if overlay is not None:
        add_overlay(img, dataset.info["area"], **overlay)

    if decorate is not None:
        add_decorate(img, **decorate)

    return img


# 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_enhanced_image(
    dataset,
    enhancer=None,
    fill_value=None,
    ppp_config_dir=None,
    enhancement_config_file=None,
    overlay=None,
    decorate=None,
):
    mode = _determine_mode(dataset)
    if ppp_config_dir is None:
        ppp_config_dir = get_environ_config_dir()

    if enhancer is None:
        enhancer = Enhancer(ppp_config_dir, enhancement_config_file)

    if enhancer.enhancement_tree is None:
        raise RuntimeError(
            "No enhancement configuration files found or specified, cannot"
            " automatically enhance dataset"
        )

    if dataset.attrs.get("sensor", None):
        enhancer.add_sensor_enhancements(dataset.attrs["sensor"])

    # Create an image for enhancement
    img = to_image(dataset, mode=mode, fill_value=fill_value)
    enhancer.apply(img, **dataset.attrs)

    img.info.update(dataset.attrs)

    if overlay is not None:
        add_overlay(img, dataset.attrs["area"], **overlay)

    if decorate is not None:
        add_decorate(img, **decorate)

    return img