# Buggy code
def get_dataset(self, key, info, out=None, xslice=slice(None), yslice=slice(None)):
    if key.name not in self.channel_order_list:
        raise KeyError("Channel % s not available in the file" % key.name)
    elif key.name not in ["HRV"]:
        ch_idn = self.channel_order_list.index(key.name)
        data = dec10216(self.memmap["visir"]["line_data"][:, ch_idn, :])[::-1, ::-1]

        data = np.ma.masked_array(data, mask=(data == 0))
        res = Dataset(data, dtype=np.float32)
    else:
        data2 = dec10216(self.memmap["hrv"]["line_data"][:, 2, :])[::-1, ::-1]
        data1 = dec10216(self.memmap["hrv"]["line_data"][:, 1, :])[::-1, ::-1]
        data0 = dec10216(self.memmap["hrv"]["line_data"][:, 0, :])[::-1, ::-1]
        # Make empty array:
        shape = data0.shape[0] * 3, data0.shape[1]
        data = np.zeros(shape)
        idx = range(0, shape[0], 3)
        data[idx, :] = data2
        idx = range(1, shape[0], 3)
        data[idx, :] = data1
        idx = range(2, shape[0], 3)
        data[idx, :] = data0

        data = np.ma.masked_array(data, mask=(data == 0))
        res = Dataset(data, dtype=np.float32)

    if res is not None:
        out = res
    else:
        return None

    self.calibrate(out, key)
    out.info["units"] = info["units"]
    out.info["wavelength"] = info["wavelength"]
    out.info["standard_name"] = info["standard_name"]
    out.info["platform_name"] = self.platform_name
    out.info["sensor"] = "seviri"

    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)):
    if key.name not in self.channel_order_list:
        raise KeyError("Channel % s not available in the file" % key.name)
    elif key.name not in ["HRV"]:
        ch_idn = self.channel_order_list.index(key.name)
        data = dec10216(self.memmap["visir"]["line_data"][:, ch_idn, :])[::-1, ::-1]
    else:
        data2 = dec10216(self.memmap["hrv"]["line_data"][:, 2, :])[::-1, ::-1]
        data1 = dec10216(self.memmap["hrv"]["line_data"][:, 1, :])[::-1, ::-1]
        data0 = dec10216(self.memmap["hrv"]["line_data"][:, 0, :])[::-1, ::-1]
        # Make empty array:
        shape = data0.shape[0] * 3, data0.shape[1]
        data = np.zeros(shape)
        idx = range(0, shape[0], 3)
        data[idx, :] = data2
        idx = range(1, shape[0], 3)
        data[idx, :] = data1
        idx = range(2, shape[0], 3)
        data[idx, :] = data0

    res = xr.DataArray(data, dims=["y", "x"]).where(data != 0).astype(np.float32)

    if res is not None:
        out = res
    else:
        return None

    self.calibrate(out, key)
    out.attrs["units"] = info["units"]
    out.attrs["wavelength"] = info["wavelength"]
    out.attrs["standard_name"] = info["standard_name"]
    out.attrs["platform_name"] = self.platform_name
    out.attrs["sensor"] = "seviri"

    return out