# Buggy code
def get_dataset(self, ds_id, ds_info, out=None):
    """Get output data and metadata of specified dataset"""
    var_path = ds_info["file_key"]
    fill_value = ds_info.get("fill_value", 65535)
    dtype = ds_info.get("dtype", np.float32)

    if out is None:
        shape = self.get_shape(ds_id, ds_info)
        out = np.ma.empty(shape, dtype=dtype)
        out.mask = np.zeros(shape, dtype=np.bool)

    data = self[var_path]
    if (
        ds_info.get("standard_name") == "longitude"
        or ds_info.get("standard_name") == "latitude"
    ) and ds_id.resolution == 10000:
        # FIXME: Lower frequency channels need CoRegistration parameters
        # applied
        out.mask[:] = data[:, ::2] == fill_value
        out.data[:] = data[:, ::2].astype(dtype) * self[var_path + "/attr/SCALE FACTOR"]
    else:
        out.mask[:] = data == fill_value
        out.data[:] = data.astype(dtype) * self[var_path + "/attr/SCALE FACTOR"]

    i = getattr(out, "info", {})
    i.update(ds_info)
    i.update(
        {
            "units": self[var_path + "/attr/UNIT"],
            "platform": self["/attr/PlatformShortName"].item(),
            "sensor": self["/attr/SensorShortName"].item(),
            "start_orbit": int(self["/attr/StartOrbitNumber"].item()),
            "end_orbit": int(self["/attr/StopOrbitNumber"].item()),
        }
    )
    i.update(ds_id.to_dict())
    cls = ds_info.pop("container", Dataset)
    return cls(out.data, mask=out.mask, copy=False, **i)


# 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, ds_id, ds_info):
    """Get output data and metadata of specified dataset"""
    var_path = ds_info["file_key"]
    fill_value = ds_info.get("fill_value", 65535)
    metadata = self.get_metadata(ds_id, ds_info)

    data = self[var_path]
    if (
        ds_info.get("standard_name") == "longitude"
        or ds_info.get("standard_name") == "latitude"
    ) and ds_id.resolution == 10000:
        # FIXME: Lower frequency channels need CoRegistration parameters applied
        data = data[:, ::2] * self[var_path + "/attr/SCALE FACTOR"]
    else:
        data = data * self[var_path + "/attr/SCALE FACTOR"]
    data = data.where(data != fill_value)
    data.attrs.update(metadata)
    return data