# Buggy code
def get_angles(self, angle_id):
    """Get sun-satellite viewing angles"""

    tic = datetime.now()

    sunz40km = self._data["ang"][:, :, 0] * 1e-2
    satz40km = self._data["ang"][:, :, 1] * 1e-2
    azidiff40km = self._data["ang"][:, :, 2] * 1e-2

    try:
        from geotiepoints.interpolator import Interpolator
    except ImportError:
        logger.warning(
            "Could not interpolate sun-sat angles, python-geotiepoints missing."
        )
        self.sunz, self.satz, self.azidiff = sunz40km, satz40km, azidiff40km
    else:
        cols40km = np.arange(24, 2048, 40)
        cols1km = np.arange(2048)
        lines = sunz40km.shape[0]
        rows40km = np.arange(lines)
        rows1km = np.arange(lines)

        along_track_order = 1
        cross_track_order = 3

        satint = Interpolator(
            [sunz40km, satz40km, azidiff40km],
            (rows40km, cols40km),
            (rows1km, cols1km),
            along_track_order,
            cross_track_order,
        )
        self.sunz, self.satz, self.azidiff = satint.interpolate()

        logger.debug("Interpolate sun-sat angles: time %s", str(datetime.now() - tic))

    return Dataset(getattr(self, ANGLES[angle_id]), copy=False)


# 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_angles(self, angle_id):
    """Get sun-satellite viewing angles"""

    tic = datetime.now()

    sunz40km = self._data["ang"][:, :, 0] * 1e-2
    satz40km = self._data["ang"][:, :, 1] * 1e-2
    azidiff40km = self._data["ang"][:, :, 2] * 1e-2

    try:
        from geotiepoints.interpolator import Interpolator
    except ImportError:
        logger.warning(
            "Could not interpolate sun-sat angles, python-geotiepoints missing."
        )
        self.sunz, self.satz, self.azidiff = sunz40km, satz40km, azidiff40km
    else:
        cols40km = np.arange(24, 2048, 40)
        cols1km = np.arange(2048)
        lines = sunz40km.shape[0]
        rows40km = np.arange(lines)
        rows1km = np.arange(lines)

        along_track_order = 1
        cross_track_order = 3

        satint = Interpolator(
            [sunz40km, satz40km, azidiff40km],
            (rows40km, cols40km),
            (rows1km, cols1km),
            along_track_order,
            cross_track_order,
        )
        self.sunz, self.satz, self.azidiff = satint.interpolate()

        logger.debug("Interpolate sun-sat angles: time %s", str(datetime.now() - tic))

    return create_xarray(getattr(self, ANGLES[angle_id]))