Ejemplo n.º 1
0
    def test_config(self):
        root = 'tests'
        base = pkg_resources.resource_filename('tests',
                                               'data/downloader_config.yml')
        filepath = os.path.join(root, base)
        if not os.path.isfile(filepath):
            filepath = base

        temp = os.path.join(os.path.dirname(filepath), 'temp')
        try:
            shutil.rmtree(temp)
        except Exception:
            pass
        os.mkdir(temp)

        args_list = ['--configuration', filepath]
        args = self.parser.parse_args(args_list)
        main(args)
        location = os.path.dirname(base)
        self.assertTrue(
            os.path.isdir(os.path.join(location, 'temp',
                                       self.config_scenes[0])))
        self.assertTrue(
            os.path.isfile(
                os.path.join(
                    location, 'temp', self.config_scenes[0],
                    'LT05_L1TP_043030_20070511_20160908_01_T1_B3.TIF')))
        shutil.rmtree(temp)
Ejemplo n.º 2
0
    def test_zipped(self):
        print('Testing zipped...')
        root = 'tests'
        base = pkg_resources.resource_filename('tests',
                                               'data/downloader_config.yml')
        filepath = os.path.join(root, base)
        if not os.path.isfile(filepath):
            filepath = base

        temp = os.path.join(os.path.dirname(filepath), 'temp')
        try:
            shutil.rmtree(temp)
        except Exception:
            pass
        os.mkdir(temp)
        args_list = [
            '--satellite', self.sat, '--start', self.start, '--end', self.end,
            '--zipped', '--path',
            str(self.path), '--row',
            str(self.row), '-o', temp
        ]
        args = self.parser.parse_args(args_list)
        main(args)
        self.assertTrue(
            os.path.isfile(os.path.join(temp, 'LE70360282007122EDC00.tar.gz')))
        shutil.rmtree(temp)
Ejemplo n.º 3
0
def load_data(*args, **kwargs):

    from landslide_pipeline.pipeline import LOCATION, TIMES, SATELLITE_INFO, OUTPUT
    from landslide_pipeline.utils import get_paths_rows

    pr = get_paths_rows((LOCATION['min_longitude'], LOCATION['min_latitude']),
                        (LOCATION['max_longitude'], LOCATION['max_latitude']))
    import glob
    for (path, row) in pr:

        this_args = {
            'row':
            str(row),
            'path':
            str(path),
            'start':
            TIMES['start'],
            'end':
            TIMES['end'],
            'satellite':
            SATELLITE_INFO['satellite'],
            'output_path':
            OUTPUT['output_path'] + '/P' + str(path) + 'R' + str(row)
        }

        landsat_cli.main(this_args)

    this_args.pop('row', None)
    this_args.pop('path', None)
    kwargs['image_prefixes'] = glob.glob(OUTPUT['output_path'] + '/*/*')
    kwargs.update(this_args)
    return kwargs
Ejemplo n.º 4
0
    def test_metadata_creation(self):
        wrs = os.path.join(
            os.path.dirname(__file__).replace('tests', 'landsat'), 'wrs')
        scenes = os.path.join(
            os.path.dirname(__file__).replace('tests', 'landsat'), 'scenes')

        try:
            shutil.rmtree(wrs)
        except:
            pass
        try:
            shutil.rmtree(scenes)
        except:
            pass

        args_list = [
            '--satellite', self.sat, '--start', self.start, '--end', self.end,
            '--return-list', '--path',
            str(self.path), '--row',
            str(self.row)
        ]

        args = self.parser.parse_args(args_list)
        main(args)
        self.assertTrue(os.path.isdir(wrs))
        self.assertTrue(
            os.path.isfile(os.path.join(wrs, 'wrs2_descending.shp')))
        self.assertTrue(os.path.isdir(scenes))
Ejemplo n.º 5
0
 def test_pymetric_config(self):
     root = 'tests'
     base = pkg_resources.resource_filename(
         'tests', 'data/downloader_config_pymetric.yml')
     filepath = os.path.join(root, base)
     temp = os.path.join(os.path.dirname(filepath), 'temp')
     try:
         shutil.rmtree(temp)
     except Exception:
         pass
     os.mkdir(temp)
     args_list = ['--configuration', filepath]
     args = self.parser.parse_args(args_list)
     main(args)
     self.assertTrue(
         os.path.isfile(
             os.path.join(temp, 'landsat', '041', '027', '2015',
                          'LC08_041027_20150228.tar.gz')))
     self.assertTrue(
         os.path.isfile(
             os.path.join(temp, 'landsat', '041', '027', '2015',
                          'LC08_041027_20150417.tar.gz')))
     self.assertTrue(
         os.path.isfile(
             os.path.join(temp, 'landsat', '041', '027', '2015',
                          'LC08_041027_20150503.tar.gz')))
Ejemplo n.º 6
0
 def test_latlon(self):
     print('Testing valid lat lon...')
     args_list = [
         '--satellite', self.sat, '--start', self.start, '--end', self.end,
         '--return-list', '--lat', self.lat, '--lon', self.lon
     ]
     args = self.parser.parse_args(args_list)
     scenes = main(args)
     self.assertEqual(scenes, self.scene_list)
Ejemplo n.º 7
0
 def test_path_row(self):
     print('Testing valid path row...')
     args_list = [
         '--satellite', self.sat, '--start', self.start, '--end', self.end,
         '--return-list', '--path',
         str(self.path), '--row',
         str(self.row)
     ]
     args = self.parser.parse_args(args_list)
     scenes = main(args)
     self.assertEqual(scenes, self.scene_list)