# Buggy code
def __call__(self, projectables, optional_datasets=None, **info):
    """Get the atmospherical correction. Uses pyspectral."""
    from pyspectral.atm_correction_ir import AtmosphericalCorrection

    band = projectables[0]

    if optional_datasets:
        satz = optional_datasets[0]
    else:
        from pyorbital.orbital import get_observer_look

        lons, lats = band.info["area"].get_lonlats()

        try:
            dummy, satel = get_observer_look(
                band.info["satellite_longitude"],
                band.info["satellite_latitude"],
                band.info["satellite_altitude"],
                band.info["start_time"],
                lons,
                lats,
                0,
            )
        except KeyError:
            raise KeyError("Band info is missing some meta data!")
        satz = 90 - satel
        del satel

    LOG.info("Correction for limb cooling")
    corrector = AtmosphericalCorrection(band.info["platform_name"], band.info["sensor"])

    atm_corr = corrector.get_correction(satz, band.info["name"], band)

    proj = Dataset(atm_corr, copy=False, **band.info)
    self.apply_modifier_info(band, proj)

    return proj


# 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 __call__(self, projectables, optional_datasets=None, **info):
    """Get the atmospherical correction. Uses pyspectral."""
    from pyspectral.atm_correction_ir import AtmosphericalCorrection

    band = projectables[0]

    if optional_datasets:
        satz = optional_datasets[0]
    else:
        from pyorbital.orbital import get_observer_look

        lons, lats = band.attrs["area"].get_lonlats_dask(CHUNK_SIZE)

        try:
            dummy, satel = get_observer_look(
                band.attrs["satellite_longitude"],
                band.attrs["satellite_latitude"],
                band.attrs["satellite_altitude"],
                band.attrs["start_time"],
                lons,
                lats,
                0,
            )
        except KeyError:
            raise KeyError("Band info is missing some meta data!")
        satz = 90 - satel
        del satel

    LOG.info("Correction for limb cooling")
    corrector = AtmosphericalCorrection(
        band.attrs["platform_name"], band.attrs["sensor"]
    )

    atm_corr = corrector.get_correction(satz, band.attrs["name"], band)
    proj = band - atm_corr
    proj.attrs = band.attrs
    self.apply_modifier_info(band, proj)

    return proj