# Buggy code
def resample(
    self, destination=None, datasets=None, compute=True, unload=True, **resample_kwargs
):
    """Resample the datasets and return a new scene."""
    to_resample = [
        dataset
        for (dsid, dataset) in self.datasets.items()
        if (not datasets) or dsid in datasets
    ]

    if destination is None:
        destination = self.max_area(to_resample)
    new_scn = self._resampled_scene(to_resample, destination, **resample_kwargs)

    new_scn.attrs = self.attrs.copy()
    new_scn.dep_tree = self.dep_tree.copy()

    # MUST set this after assigning the resampled datasets otherwise
    # composite prereqs that were resampled will be considered "wishlisted"
    if datasets is None:
        new_scn.wishlist = self.wishlist
    else:
        new_scn.wishlist = set([DatasetID.from_dict(ds.attrs) for ds in new_scn])

    # recompute anything from the wishlist that needs it (combining
    # multiple resolutions, etc.)
    keepables = None
    if compute:
        nodes = [
            self.dep_tree[i]
            for i in new_scn.wishlist
            if i in self.dep_tree and not self.dep_tree[i].is_leaf
        ]
        keepables = new_scn.compute(nodes=nodes)
    if new_scn.missing_datasets:
        # copy the set of missing datasets because they won't be valid
        # after they are removed in the next line
        missing = new_scn.missing_datasets.copy()
        new_scn._remove_failed_datasets(keepables)
        missing_str = ", ".join(str(x) for x in missing)
        LOG.warning("The following datasets were not created: {}".format(missing_str))
    if unload:
        new_scn.unload(keepables)

    return new_scn


# Traceback (TypeError)
TypeError                                 Traceback (most recent call last)
/home/a000680/laptop/Pytroll/demo/modis/satpy_issue_5march2018.py in <module>()
59
60 scn.load(['solar_azimuth_angle', 'solar_zenith_angle',
---> 61           'satellite_zenith_angle', 'satellite_azimuth_angle'], resolution=1000)

/home/a000680/usr/src/satpy/satpy/scene.pyc in load(self, wishlist, calibration, resolution, polarization, compute, unload, **kwargs)
639             raise KeyError("Unknown datasets: {}".format(unknown_str))
640
--> 641         self.read(**kwargs)
642         keepables = None
643         if compute:

/home/a000680/usr/src/satpy/satpy/scene.pyc in read(self, nodes, **kwargs)
580             required_nodes = self.wishlist - set(self.datasets.keys())
581             nodes = self.dep_tree.leaves(nodes=required_nodes)
--> 582         return self.read_datasets(nodes, **kwargs)
583
584     def compute(self, nodes=None):

/home/a000680/usr/src/satpy/satpy/scene.pyc in read_datasets(self, dataset_nodes, **kwargs)
443             if ds_id in self.datasets and self.datasets[ds_id].is_loaded():
444                 continue
--> 445             reader_name = node.data['reader_name']
446             reader_datasets.setdefault(reader_name, set()).add(ds_id)
447

TypeError: 'NoneType' object has no attribute '__getitem__'

# Fixed code
def resample(
    self, destination=None, datasets=None, compute=True, unload=True, **resample_kwargs
):
    """Resample the datasets and return a new scene."""
    to_resample = [
        dataset
        for (dsid, dataset) in self.datasets.items()
        if (not datasets) or dsid in datasets
    ]

    if destination is None:
        destination = self.max_area(to_resample)
    new_scn = self._resampled_scene(to_resample, destination, **resample_kwargs)

    new_scn.attrs = self.attrs.copy()
    new_scn.dep_tree = self.dep_tree.copy()

    # MUST set this after assigning the resampled datasets otherwise
    # composite prereqs that were resampled will be considered "wishlisted"
    if datasets is None:
        new_scn.wishlist = self.wishlist.copy()
    else:
        new_scn.wishlist = set([DatasetID.from_dict(ds.attrs) for ds in new_scn])

    # recompute anything from the wishlist that needs it (combining
    # multiple resolutions, etc.)
    keepables = None
    if compute:
        nodes = [
            self.dep_tree[i]
            for i in new_scn.wishlist
            if i in self.dep_tree and not self.dep_tree[i].is_leaf
        ]
        keepables = new_scn.compute(nodes=nodes)
    if new_scn.missing_datasets:
        # copy the set of missing datasets because they won't be valid
        # after they are removed in the next line
        missing = new_scn.missing_datasets.copy()
        new_scn._remove_failed_datasets(keepables)
        missing_str = ", ".join(str(x) for x in missing)
        LOG.warning("The following datasets were not created: {}".format(missing_str))
    if unload:
        new_scn.unload(keepables)

    return new_scn