# Buggy code
def compute(self, data, fill_value=None, **kwargs):
    """Resample the given data using bilinear interpolation"""
    del kwargs

    target_shape = self.target_geo_def.shape
    if data.ndim == 3:
        output_shape = list(target_shape)
        output_shape.append(data.shape[-1])
        res = np.zeros(output_shape, dtype=data.dtype)
        for i in range(data.shape[-1]):
            res[:, :, i] = get_sample_from_bil_info(
                data[:, :, i].ravel(),
                self.cache["bilinear_t"],
                self.cache["bilinear_s"],
                self.cache["input_idxs"],
                self.cache["idx_arr"],
                output_shape=target_shape,
            )

    else:
        res = get_sample_from_bil_info(
            data.ravel(),
            self.cache["bilinear_t"],
            self.cache["bilinear_s"],
            self.cache["input_idxs"],
            self.cache["idx_arr"],
            output_shape=target_shape,
        )
    res = np.ma.masked_invalid(res)

    return res


# 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 compute(self, data, fill_value=None, **kwargs):
    """Resample the given data using bilinear interpolation"""
    del kwargs

    target_shape = self.target_geo_def.shape
    if data.ndim == 3:
        output_shape = list(target_shape)
        output_shape.append(data.shape[-1])
        res = np.zeros(output_shape, dtype=data.dtype)
        for i in range(data.shape[-1]):
            res[:, :, i] = get_sample_from_bil_info(
                data[:, :, i].ravel(),
                self.cache["bilinear_t"],
                self.cache["bilinear_s"],
                self.cache["input_idxs"],
                self.cache["idx_arr"],
                output_shape=target_shape,
            )

    else:
        res = get_sample_from_bil_info(
            data.ravel(),
            self.cache["bilinear_t"],
            self.cache["bilinear_s"],
            self.cache["input_idxs"],
            self.cache["idx_arr"],
            output_shape=target_shape,
        )
    res = np.ma.masked_invalid(res)

    return res