# Buggy code
def _make_area_from_coords(self, coords):
    """Create an apropriate area with the given *coords*."""
    if len(coords) == 2:
        lon_sn = coords[0].info.get("standard_name")
        lat_sn = coords[1].info.get("standard_name")
        if lon_sn == "longitude" and lat_sn == "latitude":
            sdef = SwathDefinition(*coords)
            sensor_str = sdef.name = "_".join(self.info["sensors"])
            shape_str = "_".join(map(str, coords[0].shape))
            sdef.name = "{}_{}_{}_{}".format(
                sensor_str, shape_str, coords[0].info["name"], coords[1].info["name"]
            )
            return sdef
        else:
            raise ValueError(
                "Coordinates info object missing standard_name key: " + str(coords)
            )
    elif len(coords) != 0:
        raise NameError("Don't know what to do with coordinates " + str(coords))


# 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 _make_area_from_coords(self, coords):
    """Create an appropriate area with the given *coords*."""
    if len(coords) == 2:
        lon_sn = coords[0].attrs.get("standard_name")
        lat_sn = coords[1].attrs.get("standard_name")
        if lon_sn == "longitude" and lat_sn == "latitude":
            key = None
            try:
                key = (coords[0].data.name, coords[1].data.name)
                sdef = self.coords_cache.get(key)
            except AttributeError:
                sdef = None
            if sdef is None:
                sdef = SwathDefinition(*coords)
                if key is not None:
                    self.coords_cache[key] = sdef
            sensor_str = "_".join(self.info["sensors"])
            shape_str = "_".join(map(str, coords[0].shape))
            sdef.name = "{}_{}_{}_{}".format(
                sensor_str, shape_str, coords[0].attrs["name"], coords[1].attrs["name"]
            )
            return sdef
        else:
            raise ValueError(
                "Coordinates info object missing standard_name key: " + str(coords)
            )
    elif len(coords) != 0:
        raise NameError("Don't know what to do with coordinates " + str(coords))