def test_simple_with_zip_file(self): p = Simple(path=self.landsat_image, dst_path=self.temp_folder) # test from an unzip file self.path = join(self.base_dir, 'samples', 'test') self.assertTrue(exists(p.run()))
def test_simple_with_zip_file(self): p = Simple(path=self.landsat_image, dst_path=self.temp_folder) # test from an unzip file self.path = join(self.base_dir, "samples", "test") p.run() self.assertTrue(exists(join(self.temp_folder, "test", "test_bands_432.TIF")))
def test_simple_with_clip(self): bounds = [-87.48138427734375, 30.700515832683923, -87.43331909179688, 30.739475058679485] p = Simple(path=self.landsat_image, bands=[1, 2, 3], dst_path=self.temp_folder, bounds=bounds) path = p.run() self.assertTrue(exists(path)) self.assertEqual(map('{0:.2f}'.format, get_bounds(path)), map('{0:.2f}'.format, bounds))
def test_simple_with_clip(self): bounds = [-87.48138427734375, 30.700515832683923, -87.43331909179688, 30.739475058679485] p = Simple(path=self.landsat_image, bands=[1, 2, 3], dst_path=self.temp_folder, bounds=bounds) path = p.run() self.assertTrue(exists(path)) for val, exp in zip(get_bounds(path), bounds): self.assertAlmostEqual(val, exp, 2)
def test_simple_with_out_of_bounds_clip(self): bounds = [-87.66197204589844, 30.732392734006083, -87.57545471191406, 30.806731169315675] expected_bounds = [-87.49691403528307, 30.646646570857722, -87.29976764207227, 30.810617911193567] p = Simple(path=self.landsat_image, bands=[1, 2, 3], dst_path=self.temp_folder, bounds=bounds) path = p.run() self.assertTrue(exists(path)) self.assertEqual(map('{0:.2f}'.format, get_bounds(path)), map('{0:.2f}'.format, expected_bounds))
def test_simple_with_intersecting_bounds_clip(self): bounds = [-87.520515832683923, 30.700515832683923, -87.43331909179688, 30.739475058679485] expected_bounds = [-87.49691403528307, 30.700515832683923, -87.43331909179688, 30.739475058679485] p = Simple(path=self.landsat_image, bands=[1, 2, 3], dst_path=self.temp_folder, bounds=bounds) path = p.run() self.assertTrue(exists(path)) self.assertEqual(map('{0:.2f}'.format, get_bounds(path)), map('{0:.2f}'.format, expected_bounds))
def test_simple_with_intersecting_bounds_clip(self): bounds = [-87.520515832683923, 30.700515832683923, -87.43331909179688, 30.739475058679485] expected_bounds = [-87.49691403528307, 30.700515832683923, -87.43331909179688, 30.739475058679485] p = Simple(path=self.landsat_image, bands=[1, 2, 3], dst_path=self.temp_folder, bounds=bounds) path = p.run() self.assertTrue(exists(path)) for val, exp in zip(get_bounds(path), expected_bounds): self.assertAlmostEqual(val, exp, 2)
def preprocess(download_key, src_path=DEFAULT_DOWNLOAD_PATH, dst_path=DEFAULT_PROCESSED_PATH, ndvi=False, pansharpen=False, verbose=False, ndvigrey=False, bounds=None): try: bands = [2,3,4] if pansharpen: p = PanSharpen(src_path, bands=bands, dst_path=dst_path, verbose=verbose, bounds=bounds) elif ndvigrey: p = NDVI(src_path, verbose=verbose, dst_path=dst_path, bounds=bounds) elif ndvi: p = NDVIWithManualColorMap(src_path, dst_path=dst_path, verbose=verbose, bounds=bounds) else: p = Simple(src_path, bands=bands, dst_path=dst_path, verbose=verbose, bounds=bounds) except IOError as err: print str(err) exit(str(err)) except FileDoesNotExist as err: print str(err) exit(str(err)) return p.run()
os.makedirs(dest_path) dwner = Downloader(verbose=False, download_dir='{}\\{}'.format(data_dir, dest_path)) if tile in [('032', '037'), ('033', '037')]: print 'already have this tile' else: candidate_scenes = srcher.search(paths_rows="{},{},{},{}".format( path, row, path, row), start_date=s_date, end_date=e_date, cloud_min=0, cloud_max=max_cloud_prcnt, limit=return_scenes) print 'total images for tile {} is {}'.format( tile, candidate_scenes['total_returned']) x = 0 if candidate_scenes["status"] == "SUCCESS": for scene_image in candidate_scenes["results"]: print "Downloading:", (str(scene_image['sceneID'])) print 'Downloading tile {} of {}'.format( x, candidate_scenes['total_returned']) dwner.download([str(scene_image['sceneID'])]) Simple( join('{}\\{}'.format(data_dir, dest_path), str(scene_image['sceneID']) + ".tar.bz")) x += 1 else: print 'nothing' print 'done'
def test_simple_with_bands(self): p = Simple(path=self.landsat_image, bands=[1, 2, 3], dst_path=self.temp_folder) p.run() self.assertTrue(exists(join(self.temp_folder, "test", "test_bands_123.TIF")))
def test_simple_no_bands(self): p = Simple(path=self.landsat_image, dst_path=self.temp_folder) p.run() self.assertTrue(exists(join(self.temp_folder, "test", "test_bands_432.TIF")))
def test_simple_with_bands(self): p = Simple(path=self.landsat_image, bands=[1, 2, 3], dst_path=self.temp_folder) self.assertTrue(exists(p.run()))