Esempio n. 1
0
    def test_getitem(self):
        """__getitem__ for sat scenes.
        """

        # empty scene
        self.scene = SatelliteInstrumentScene()

        self.assertRaises(KeyError, self.scene.__getitem__,
                          np.random.uniform(100))
        self.assertRaises(KeyError, self.scene.__getitem__,
                          int(np.random.uniform(10000)))
        self.assertRaises(KeyError, self.scene.__getitem__,
                          random_string(4))

        # scene with 3 channels

        channels = [["00_7", (0.5, 0.7, 0.9), 2500],
                    ["06_4", (5.7, 6.4, 7.1), 5000],
                    ["11_5", (10.5, 11.5, 12.5), 5000]]

        class SatelliteInstrumentScene2(SatelliteInstrumentScene):

            """Dummy satinst class.
            """
            channel_list = channels

        self.scene = SatelliteInstrumentScene2()
        for chn in channels:
            self.assertEquals(self.scene[chn[0]].name, chn[0])
            for i in range(3):
                self.assertEquals(self.scene[chn[1][i]].wavelength_range[i],
                                  chn[1][i])
            self.assertEquals(self.scene[chn[2]].resolution, chn[2])
            self.assertEquals(self.scene[(chn[0], chn[2])].name, chn[0])

        self.assertRaises(KeyError, self.scene.__getitem__, [])
        self.assertRaises(KeyError, self.scene.__getitem__, random_string(5))
        self.assertRaises(TypeError, self.scene.__getitem__, set([]))
        self.assertRaises(KeyError, self.scene.__getitem__, 5.0)

        self.assertEquals(len(self.scene.__getitem__(5000, aslist=True)), 2)

        chans = self.scene.__getitem__(5000, aslist=True)
        self.assertEquals(self.scene[chans[0].name].name, channels[1][0])
        self.assertEquals(self.scene[chans[1].name].name, channels[2][0])
Esempio n. 2
0
 def create_scene(satname, satnumber, instrument, time_slot, orbit,
                  area=None, variant=''):
     """Create a compound satellite scene.
     """
     
     satellite = (satname, satnumber, variant)
     
     instrument_scene = SatelliteInstrumentScene(satellite=satellite,
                                                 instrument=instrument,
                                                 area=area,
                                                 orbit=orbit,
                                                 time_slot=time_slot)
     
     compositer = get_sat_instr_compositer(satellite, instrument)
     instrument_scene._CompositerClass = compositer
     
     if compositer is not None:
         # Pass weak ref to compositor to allow garbage collection
         instrument_scene.image = compositer(weakref.proxy(instrument_scene))
     return instrument_scene 
Esempio n. 3
0
    def create_scene(satname, satnumber, instrument, time_slot, orbit,
                     area=None, variant=''):
        """Create a compound satellite scene.
        """

        satellite = (satname, satnumber, variant)

        instrument_scene = SatelliteInstrumentScene(satellite=satellite,
                                                    instrument=instrument,
                                                    area=area,
                                                    orbit=orbit,
                                                    time_slot=time_slot)

        compositer = get_sat_instr_compositer(satellite, instrument)
        instrument_scene._CompositerClass = compositer

        if compositer is not None:
            # Pass weak ref to compositor to allow garbage collection
            instrument_scene.image = compositer(
                weakref.proxy(instrument_scene))
        return instrument_scene
Esempio n. 4
0
    def __init__(self,
                 filename=None,
                 time_slot=None,
                 satellite=None,
                 instrument=None):

        # Setting up a granule from metadata

        if filename is None:
            SatelliteInstrumentScene.__init__(self,
                                              time_slot=time_slot,
                                              satellite=(satellite.satname,
                                                         satellite.number,
                                                         satellite.variant),
                                              instrument=instrument)
            conf = ConfigParser()
            conf.read(os.path.join(CONFIG_PATH, self.fullname + ".cfg"))
            self.file_template = str(
                conf.get(instrument + "-granules", "filename", raw=True))
            self.directory = str(
                conf.get(instrument + "-granules", "dir", raw=True))

            self.file_name = time_slot.strftime(self.file_template)
            self.directory = time_slot.strftime(self.directory)
            self.file_type = conf.get(instrument + "-granules", "type")
            self.granularity = datetime.timedelta(
                seconds=int(conf.get(instrument + "-granules", "granularity")))
            self.span = float(
                conf.get(instrument + "-granules", "full_scan_period"))
            self.scan_width = int(
                conf.get(instrument + "-granules", "scan_width"))
            return

        # Setting up a granule from a filename

        filelist = glob.glob(os.path.join(CONFIG_PATH, "*.cfg"))

        the_directory, the_name = os.path.split(filename)

        self.satname = None

        for fil in filelist:
            conf = ConfigParser()
            conf.read(fil)
            try:
                instruments = eval(conf.get("satellite", "instruments"))
                for instrument in instruments:
                    directory = str(conf.get(instrument + "-granules", "dir"))
                    file_template = str(
                        conf.get(instrument + "-granules",
                                 "filename",
                                 raw=True))
                    file_glob = globify(file_template)

                    if (os.path.samefile(the_directory, directory)
                            and fnmatch(the_name, file_glob)):
                        try:
                            self.file_template = file_template
                            self.file_name = the_name

                            pos1, pos2 = beginning(self.file_template)
                            time_slot = strptime(self.file_name[:pos2],
                                                 self.file_template[:pos1])

                            SatelliteInstrumentScene.__init__(
                                self,
                                time_slot=time_slot,
                                satellite=(conf.get("satellite", "satname"),
                                           conf.get("satellite", "number"),
                                           conf.get("satellite", "variant")),
                                instrument=instrument)

                            self.file_type = conf.get(instrument + "-granules",
                                                      "type")
                            self.directory = the_directory
                            self.granularity = datetime.timedelta(seconds=int(
                                conf.get(instrument +
                                         "-granules", "granularity")))
                            self.span = float(
                                conf.get(instrument + "-granules",
                                         "full_scan_period"))
                            self.scan_width = int(
                                conf.get(instrument + "-granules",
                                         "scan_width"))
                        except (NoSectionError, NoOptionError):
                            raise IOError("Inconsistency detected in " + fil)
                        break

                if self.satname is not None:
                    break

            except (NoSectionError, NoOptionError):
                pass

        if not self.satname:
            raise ValueError("Can't find any matching satellite for " +
                             filename)
Esempio n. 5
0
    def __init__(self, filename=None, time_slot=None,
                 satellite=None, instrument=None):

        # Setting up a granule from metadata

        if filename is None:
            SatelliteInstrumentScene.__init__(self, time_slot=time_slot,
                                              satellite=(satellite.satname,
                                                         satellite.number,
                                                         satellite.variant),
                                              instrument=instrument)
            conf = ConfigParser()
            conf.read(os.path.join(CONFIG_PATH, self.fullname + ".cfg"))
            self.file_template = str(conf.get(instrument+"-granules",
                                              "filename", raw=True))
            self.directory = str(conf.get(instrument+"-granules",
                                          "dir", raw=True))
            
            self.file_name = time_slot.strftime(self.file_template)
            self.directory = time_slot.strftime(self.directory)
            self.file_type = conf.get(instrument + "-granules", "type")
            self.granularity = datetime.timedelta(
                seconds=int(conf.get(instrument + "-granules", "granularity")))
            self.span = float(conf.get(instrument + "-granules",
                                       "full_scan_period"))
            self.scan_width = int(conf.get(instrument + "-granules",
                                           "scan_width"))
            return

        # Setting up a granule from a filename
        
        filelist = glob.glob(os.path.join(CONFIG_PATH, "*.cfg"))

        the_directory, the_name = os.path.split(filename)

        self.satname = None
        
        for fil in filelist:
            conf = ConfigParser()
            conf.read(fil)
            try:
                instruments = eval(conf.get("satellite", "instruments"))
                for instrument in instruments:
                    directory = str(conf.get(instrument+"-granules", "dir"))
                    file_template = str(conf.get(instrument+"-granules",
                                                 "filename", raw=True))
                    file_glob = globify(file_template)

                    if(os.path.samefile(the_directory, directory) and
                       fnmatch(the_name, file_glob)):
                        try:
                            self.file_template = file_template
                            self.file_name = the_name

                            pos1, pos2 = beginning(self.file_template)
                            time_slot = strptime(self.file_name[:pos2],
                                                 self.file_template[:pos1])
        
                            SatelliteInstrumentScene.__init__(
                                self,
                                time_slot=time_slot,
                                satellite=(conf.get("satellite", "satname"),
                                           conf.get("satellite", "number"),
                                           conf.get("satellite", "variant")),
                                instrument=instrument)

                            self.file_type = conf.get(instrument +
                                                      "-granules", "type")
                            self.directory = the_directory
                            self.granularity = datetime.timedelta(
                                seconds=int(conf.get(instrument + "-granules",
                                                     "granularity")))
                            self.span = float(conf.get(instrument +
                                                       "-granules",
                                                       "full_scan_period"))
                            self.scan_width = int(conf.get(instrument +
                                                           "-granules",
                                                           "scan_width"))
                        except (NoSectionError, NoOptionError):
                            raise IOError("Inconsistency detected in " + fil)
                        break

                if self.satname is not None:
                    break
                    
            except (NoSectionError, NoOptionError):
                pass

            
        if not self.satname:
            raise ValueError("Can't find any matching satellite for "+filename)
Esempio n. 6
0
class TestSatelliteInstrumentScene(unittest.TestCase):

    """Class for testing the SatelliteInstrumentScene class.
    """

    scene = None

    def setUp(self):
        """Patch foreign modules.
        """
        patch_configparser()
        patch_projector()

    def test_init_area(self):
        """Creation of a satellite instrument scene.
        """
        channels = [["00_7", (0.5, 0.7, 0.9), 2500],
                    ["06_4", (5.7, 6.4, 7.1), 5000],
                    ["11_5", (10.5, 11.5, 12.5), 5000]]

        class SatelliteInstrumentScene2(SatelliteInstrumentScene):

            """Dummy satinst class.
            """
            channel_list = channels
        # area

        area = random_string(int(np.random.uniform(9)) + 1)

        self.scene = SatelliteInstrumentScene2(area=area)
        self.assertEquals(self.scene.satname, "")
        self.assertEquals(self.scene.number, "")
        self.assertEquals(self.scene.area, area)
        self.assert_(self.scene.orbit is None)
        self.assert_(self.scene.time_slot is None)
        self.assert_(self.scene.lat is None)
        self.assert_(self.scene.lon is None)
        self.assert_(self.scene.instrument_name is None)
        self.assertEquals(self.scene.channels_to_load, set([]))
        for i, chn in enumerate(self.scene.channels):
            self.assertEquals(chn.name, channels[i][0])
            self.assertEquals(chn.wavelength_range, list(channels[i][1]))
            self.assertEquals(chn.resolution, channels[i][2])

        self.assertRaises(TypeError,
                          SatelliteInstrumentScene2,
                          area=np.random.uniform(1000))

        self.assertRaises(TypeError,
                          SatelliteInstrumentScene2,
                          area=int(np.random.uniform(1000)))

        self.assertRaises(TypeError,
                          SatelliteInstrumentScene2,
                          area=[])

    def test_init_orbit(self):
        """Creation of a satellite instrument scene.
        """
        channels = [["00_7", (0.5, 0.7, 0.9), 2500],
                    ["06_4", (5.7, 6.4, 7.1), 5000],
                    ["11_5", (10.5, 11.5, 12.5), 5000]]

        class SatelliteInstrumentScene2(SatelliteInstrumentScene):

            """Dummy satinst class.
            """
            channel_list = channels

        # orbit

        orbit = random_string(int(np.random.uniform(9)) + 1)

        self.scene = SatelliteInstrumentScene2(orbit=orbit)
        self.assertEquals(self.scene.satname, "")
        self.assertEquals(self.scene.number, "")
        self.assertEquals(self.scene.orbit, orbit)
        self.assert_(self.scene.area is None)
        self.assert_(self.scene.time_slot is None)
        self.assert_(self.scene.lat is None)
        self.assert_(self.scene.lon is None)
        self.assert_(self.scene.instrument_name is None)
        self.assertEquals(self.scene.channels_to_load, set([]))
        for i, chn in enumerate(self.scene.channels):
            self.assertEquals(chn.name, channels[i][0])
            self.assertEquals(chn.wavelength_range, list(channels[i][1]))
            self.assertEquals(chn.resolution, channels[i][2])

    def test_init_time_slot(self):
        """Creation of a satellite instrument scene.
        """
        channels = [["00_7", (0.5, 0.7, 0.9), 2500],
                    ["06_4", (5.7, 6.4, 7.1), 5000],
                    ["11_5", (10.5, 11.5, 12.5), 5000]]

        class SatelliteInstrumentScene2(SatelliteInstrumentScene):

            """Dummy satinst class.
            """
            channel_list = channels

        # time_slot

        time_slot = datetime.datetime.now()

        self.scene = SatelliteInstrumentScene2(time_slot=time_slot)
        self.assertEquals(self.scene.satname, "")
        self.assertEquals(self.scene.number, "")
        self.assertEquals(self.scene.time_slot, time_slot)
        self.assert_(self.scene.orbit is None)
        self.assert_(self.scene.area is None)
        self.assert_(self.scene.lat is None)
        self.assert_(self.scene.lon is None)
        self.assert_(self.scene.instrument_name is None)
        self.assertEquals(self.scene.channels_to_load, set([]))
        for i, chn in enumerate(self.scene.channels):
            self.assertEquals(chn.name, channels[i][0])
            self.assertEquals(chn.wavelength_range, list(channels[i][1]))
            self.assertEquals(chn.resolution, channels[i][2])

    def test_init(self):
        """Creation of a satellite instrument scene.
        """

        channels = [["00_7", (0.5, 0.7, 0.9), 2500],
                    ["06_4", (5.7, 6.4, 7.1), 5000],
                    ["11_5", (10.5, 11.5, 12.5), 5000]]

        class SatelliteInstrumentScene2(SatelliteInstrumentScene):

            """Dummy satinst class.
            """
            channel_list = channels

        self.scene = SatelliteInstrumentScene2()
        self.assertEquals(self.scene.satname, "")
        self.assertEquals(self.scene.number, "")
        self.assert_(self.scene.time_slot is None)
        self.assert_(self.scene.orbit is None)
        self.assert_(self.scene.area is None)
        self.assert_(self.scene.lat is None)
        self.assert_(self.scene.lon is None)
        self.assert_(self.scene.instrument_name is None)
        self.assertEquals(self.scene.channels_to_load, set([]))
        for i, chn in enumerate(self.scene.channels):
            self.assertEquals(chn.name, channels[i][0])
            self.assertEquals(chn.wavelength_range, list(channels[i][1]))
            self.assertEquals(chn.resolution, channels[i][2])

    def test_setitem(self):
        """__setitem__ for sat scenes.
        """

        channels = [["00_7", (0.5, 0.7, 0.9), 2500],
                    ["06_4", (5.7, 6.4, 7.1), 5000],
                    ["11_5", (10.5, 11.5, 12.5), 5000]]

        class SatelliteInstrumentScene2(SatelliteInstrumentScene):

            """Dummy satinst class.
            """
            channel_list = channels

        self.scene = SatelliteInstrumentScene2()

        self.assertRaises(TypeError, self.scene.__setitem__, 10.8, "rsutienrt")

        a = np.ma.array([1, 2, 3])
        self.scene[6.4] = a
        self.assertTrue(
            isinstance(self.scene[6.4].data, np.ma.core.MaskedArray))

    def test_getitem(self):
        """__getitem__ for sat scenes.
        """

        # empty scene
        self.scene = SatelliteInstrumentScene()

        self.assertRaises(KeyError, self.scene.__getitem__,
                          np.random.uniform(100))
        self.assertRaises(KeyError, self.scene.__getitem__,
                          int(np.random.uniform(10000)))
        self.assertRaises(KeyError, self.scene.__getitem__,
                          random_string(4))

        # scene with 3 channels

        channels = [["00_7", (0.5, 0.7, 0.9), 2500],
                    ["06_4", (5.7, 6.4, 7.1), 5000],
                    ["11_5", (10.5, 11.5, 12.5), 5000]]

        class SatelliteInstrumentScene2(SatelliteInstrumentScene):

            """Dummy satinst class.
            """
            channel_list = channels

        self.scene = SatelliteInstrumentScene2()
        for chn in channels:
            self.assertEquals(self.scene[chn[0]].name, chn[0])
            for i in range(3):
                self.assertEquals(self.scene[chn[1][i]].wavelength_range[i],
                                  chn[1][i])
            self.assertEquals(self.scene[chn[2]].resolution, chn[2])
            self.assertEquals(self.scene[(chn[0], chn[2])].name, chn[0])

        self.assertRaises(KeyError, self.scene.__getitem__, [])
        self.assertRaises(KeyError, self.scene.__getitem__, random_string(5))
        self.assertRaises(TypeError, self.scene.__getitem__, set([]))
        self.assertRaises(KeyError, self.scene.__getitem__, 5.0)

        self.assertEquals(len(self.scene.__getitem__(5000, aslist=True)), 2)

        chans = self.scene.__getitem__(5000, aslist=True)
        self.assertEquals(self.scene[chans[0].name].name, channels[1][0])
        self.assertEquals(self.scene[chans[1].name].name, channels[2][0])

    def test_check_channels(self):
        """Check loaded channels.
        """

        # No data loaded

        channels = [["00_7", (0.5, 0.7, 0.9), 2500],
                    ["06_4", (5.7, 6.4, 7.1), 5000],
                    ["11_5", (10.5, 11.5, 12.5), 5000]]

        class SatelliteInstrumentScene2(SatelliteInstrumentScene):

            """Dummy satinst class.
            """
            channel_list = channels

        self.scene = SatelliteInstrumentScene2()
        for chn in channels:
            self.assertRaises(
                NotLoadedError, self.scene.check_channels, chn[0])
            self.assertRaises(
                NotLoadedError, self.scene.check_channels, chn[2])
            for i in range(3):
                self.assertRaises(NotLoadedError,
                                  self.scene.check_channels,
                                  chn[1][i])

        # With data

        self.scene[0.7] = np.ma.array(np.random.rand(3, 3),
                                      mask=np.array(np.random.rand(3, 3) * 2,
                                                    dtype=int))
        self.scene[6.4] = np.ma.array(np.random.rand(3, 3),
                                      mask=np.array(np.random.rand(3, 3) * 2,
                                                    dtype=int))
        self.scene[11.5] = np.ma.array(np.random.rand(3, 3),
                                       mask=np.array(np.random.rand(3, 3) * 2,
                                                     dtype=int))
        self.assertTrue(self.scene.check_channels(0.7, 6.4, 11.5))
        self.assertRaises(
            KeyError, self.scene.check_channels, random_string(5))

    def test_loaded_channels(self):
        """Loaded channels list.
        """
        # No data loaded

        channels = [["00_7", (0.5, 0.7, 0.9), 2500],
                    ["06_4", (5.7, 6.4, 7.1), 5000],
                    ["11_5", (10.5, 11.5, 12.5), 5000]]

        class SatelliteInstrumentScene2(SatelliteInstrumentScene):

            """Dummy satinst class.
            """
            channel_list = channels

        self.scene = SatelliteInstrumentScene2()
        self.assertEquals(self.scene.loaded_channels(), set([]))

        # With data

        self.scene[0.7] = np.ma.array(np.random.rand(3, 3),
                                      mask=np.array(np.random.rand(3, 3) * 2,
                                                    dtype=int))
        self.scene[6.4] = np.ma.array(np.random.rand(3, 3),
                                      mask=np.array(np.random.rand(3, 3) * 2,
                                                    dtype=int))
        self.scene[11.5] = np.ma.array(np.random.rand(3, 3),
                                       mask=np.array(np.random.rand(3, 3) * 2,
                                                     dtype=int))

        self.assertEquals(set([chn.name for chn in self.scene.loaded_channels()]),
                          set(["00_7", "06_4", "11_5"]))

    def test_project(self):
        """Projecting a scene.
        """
        area = random_string(8)
        area2 = random_string(8)
        # scene with 3 channels

        channels = [["00_7", (0.5, 0.7, 0.9), 2500],
                    ["06_4", (5.7, 6.4, 7.1), 5000],
                    ["11_5", (10.5, 11.5, 12.5), 5000]]

        class SatelliteInstrumentScene2(SatelliteInstrumentScene):

            """Dummy satinst class.
            """
            instrument_name = random_string(8)
            channel_list = channels

        # case of a swath

        self.scene = SatelliteInstrumentScene2(area=None)

        # With data

        self.scene[0.7] = np.ma.array(np.random.rand(3, 3),
                                      mask=np.array(np.random.rand(3, 3) * 2,
                                                    dtype=int))
        self.scene[6.4] = np.ma.array(np.random.rand(3, 3),
                                      mask=np.array(np.random.rand(3, 3) * 2,
                                                    dtype=int))
        self.scene[6.4].area = MagicMock()

        res = self.scene.project(area2)
        self.assertEquals(res[0.7].shape, (3, 3))
        self.assertEquals(res[6.4].shape, (3, 3))
        self.assertRaises(KeyError, res.__getitem__, 11.5)

        self.scene[0.7].area = self.scene[6.4].area
        res = self.scene.project(area2, channels=[0.7])
        self.assertEquals(res[0.7].shape, (3, 3))
        self.assertRaises(KeyError, res.__getitem__, 6.4)

        res = self.scene.project(area2, channels=[0.7, 11.5])
        self.assertEquals(res[0.7].shape, (3, 3))
        self.assertRaises(KeyError, res.__getitem__, 11.5)

        res = self.scene.project(area2, channels=[])
        self.assertRaises(KeyError, res.__getitem__, 0.7)

        self.assertRaises(TypeError, self.scene.project,
                          area2, channels=11.5)

        # case of a grid

        self.scene = SatelliteInstrumentScene2(area=area)

        # With data

        self.scene[0.7] = np.ma.array(np.random.rand(3, 3),
                                      mask=np.array(np.random.rand(3, 3) * 2,
                                                    dtype=int))
        self.scene[6.4] = np.ma.array(np.random.rand(3, 3),
                                      mask=np.array(np.random.rand(3, 3) * 2,
                                                    dtype=int))
        self.scene[11.5] = np.ma.array(np.random.rand(3, 3),
                                       mask=np.array(np.random.rand(3, 3) * 2,
                                                     dtype=int))

        res = self.scene.project(area2)
        self.assertEquals(res[11.5].shape, (3, 3))

        self.scene[0.7].area = MagicMock()
        res = self.scene.project(area2, channels=[0.7])
        self.assertEquals(res[0.7].shape, (3, 3))
        self.assertRaises(KeyError, res.__getitem__, 6.4)

        self.scene[6.4].area = MagicMock()
        self.scene[11.5].area = MagicMock()
        res = self.scene.project(area2)
        self.assertEquals(res[0.7].shape, (3, 3))

        # case of self projection

        self.scene = SatelliteInstrumentScene2(area=area)

        # With data

        self.scene[0.7] = np.ma.array(np.random.rand(3, 3),
                                      mask=np.array(np.random.rand(3, 3) * 2,
                                                    dtype=int))
        self.scene[6.4] = np.ma.array(np.random.rand(3, 3),
                                      mask=np.array(np.random.rand(3, 3) * 2,
                                                    dtype=int))
        self.scene[11.5] = np.ma.array(np.random.rand(3, 3),
                                       mask=np.array(np.random.rand(3, 3) * 2,
                                                     dtype=int))

        self.scene[6.4].area = MagicMock()
        res = self.scene.project(area)
        self.assertEquals(res[0.7].shape, (3, 3))
        self.assertEquals(res[6.4].shape, (3, 3))
        self.assertEquals(res[11.5].shape, (3, 3))

        self.scene[11.5].area = self.scene[6.4].area
        self.scene[0.7].area = self.scene[6.4].area
        res = self.scene.project(area, channels=None)
        self.assertEquals(res[0.7].shape, (3, 3))
        self.assertEquals(res[6.4].shape, (3, 3))
        self.assertEquals(res[11.5].shape, (3, 3))

    def test_load(self):
        """Loading channels into a scene.
        """

        channels = [["00_7", (0.5, 0.7, 0.9), 2500],
                    ["06_4", (5.7, 6.4, 7.1), 5000],
                    ["11_5", (10.5, 11.5, 12.5), 5000]]

        class SatelliteInstrumentScene2(SatelliteInstrumentScene):

            """Dummy satinst class.
            """
            instrument_name = random_string(8)
            channel_list = channels

        self.scene = SatelliteInstrumentScene2()

        self.assertRaises(TypeError, self.scene.load, "00_7")

        self.scene.load(["00_7"])
        self.assertEquals(set(), self.scene.channels_to_load)

        self.scene = SatelliteInstrumentScene2()
        self.scene.load()
        self.assertEquals(set(),
                          self.scene.channels_to_load)

        self.scene.load(["CTTH"])

        # Test the reinitialization of channels_to_load
        # self.scene = SatelliteInstrumentScene2()

        # self.assertRaises(ValueError, self.scene.load, ["00_7"], area_extent="bla")

        # self.scene.load(["00_7"], area_extent="bla")
        # self.assertEquals(set(["00_7"]), self.scene.channels_to_load)

        # self.scene.load(["06_4"])
        # self.assertEquals(len(self.scene.loaded_channels()), 1)
        # self.assertEquals(self.scene.loaded_channels()[0].name, "06_4")

        # self.scene.load(["CTTH"])

    # def test_assemble_segments(self):
    #     """Assembling segments in a single satscene object.
    #     """
    #     channels = [["00_7", (0.5, 0.7, 0.9), 2500],
    #                 ["06_4", (5.7, 6.4, 7.1), 5000],
    #                 ["11_5", (10.5, 11.5, 12.5), 5000]]

    #     class SatelliteInstrumentScene2(SatelliteInstrumentScene):
    #         """Dummy satinst class.
    #         """
    #         satname = random_string(8)
    #         number = random_string(8)
    #         instrument_name = random_string(8)
    #         channel_list = channels

    #     self.scene = SatelliteInstrumentScene2()
    #     scene2 = SatelliteInstrumentScene2()

    #     self.scene.lon = np.ma.array(np.random.rand(3, 3),
    #                                  mask = np.array(np.random.rand(3, 3) * 2,
    #                                                  dtype = int))

    #     self.scene.lat = np.ma.array(np.random.rand(3, 3),
    #                                  mask = np.array(np.random.rand(3, 3) * 2,
    #                                                  dtype = int))

    #     self.scene[0.7] = np.ma.array(np.random.rand(3, 3),
    #                                   mask = np.array(np.random.rand(3, 3) * 2,
    #                                                   dtype = int))
    #     self.scene[6.4] = np.ma.array(np.random.rand(3, 3),
    #                                   mask = np.array(np.random.rand(3, 3) * 2,
    #                                                   dtype = int))

    #     scene2.lon = np.ma.array(np.random.rand(3, 3),
    #                                  mask = np.array(np.random.rand(3, 3) * 2,
    #                                                  dtype = int))

    #     scene2.lat = np.ma.array(np.random.rand(3, 3),
    #                                  mask = np.array(np.random.rand(3, 3) * 2,
    #                                                  dtype = int))

    #     scene2[0.7] = np.ma.array(np.random.rand(3, 3),
    #                               mask = np.array(np.random.rand(3, 3) * 2,
    #                                               dtype = int))
    #     scene2[11.5] = np.ma.array(np.random.rand(3, 3),
    #                                mask = np.array(np.random.rand(3, 3) * 2,
    #                                                dtype = int))

    #     big_scene = mpop.scene.assemble_segments([self.scene, scene2])

    #     data0 = big_scene[0.7].data
    #     data1 = self.scene[0.7].data
    #     data2 = scene2[0.7].data

    #     self.assertTrue(np.ma.allclose(data0, np.ma.concatenate((data1, data2)),
    #                                    rtol=EPSILON))

    #     data0 = big_scene[0.7].data.mask
    #     data1 = self.scene[0.7].data.mask
    #     data2 = scene2[0.7].data.mask

    #     self.assertTrue(np.ma.allclose(data0, np.ma.concatenate((data1, data2)),
    #                                    rtol=EPSILON))

    #     data0 = big_scene[6.4].data
    #     data1 = self.scene[6.4].data
    #     data2 = np.ma.masked_all_like(data1)

    #     self.assertTrue(np.ma.allclose(data0, np.ma.concatenate((data1, data2)),
    #                                    rtol=EPSILON))

    #     data0 = big_scene[6.4].data.mask
    #     data1 = self.scene[6.4].data.mask
    #     data2 = data2.mask

    #     self.assertTrue(np.ma.allclose(data0, np.ma.concatenate((data1, data2)),
    #                                    rtol=EPSILON))

    #     data0 = big_scene[11.5].data
    #     data2 = scene2[11.5].data
    #     data1 = np.ma.masked_all_like(data2)

    #     self.assertTrue(np.ma.allclose(data0, np.ma.concatenate((data1, data2)),
    #                                    rtol=EPSILON))

    #     data0 = big_scene[11.5].data.mask
    #     data1 = data1.mask
    #     data2 = scene2[11.5].data.mask

    #     self.assertTrue(np.ma.allclose(data0, np.ma.concatenate((data1, data2)),
    #                                    rtol = EPSILON))

    def tearDown(self):
        """Unpatch foreign modules.
        """
        unpatch_configparser()
        unpatch_projector()