def test_query_non_4326(): os.chdir(os.path.dirname(os.path.abspath(__file__))) test_conf = load_test_conf() query_out = pyeo.queries_and_downloads.sent2_query(test_conf["sent_2"]["user"], test_conf["sent_2"]["pass"], "test_data/wuhan_aoi_epsg32650.shp", "20180101", "20180130") assert len(query_out) > 0
def test_download_s2_pairs(monkeypatch): monkeypatch.setattr(pyeo.queries_and_downloads, "download_s2_data", mock_download) l1_dir = "test_data/test_pairs/L1" l2_dir = "test_data/test_pairs/L2" test_conf = load_test_conf() pyeo.queries_and_downloads.download_s2_pairs(l1_dir, l2_dir, test_conf)
def test_query_and_download(): os.chdir(os.path.dirname(os.path.abspath(__file__))) test_conf = load_test_conf() user = test_conf["sent_2"]["user"] passwd = test_conf["sent_2"]["pass"] images = pyeo.queries_and_downloads.sent2_query( test_conf["sent_2"]["user"], test_conf["sent_2"]["pass"], "test_data/mt_kippiri.geojson", "20210501T00.00.00", "20210504", cloud=100, query_func=pyeo.queries_and_downloads._rest_query) assert len(images) > 0 try: shutil.rmtree("test_outputs/L1") except FileNotFoundError: pass try: shutil.rmtree("test_outputs/L2") except FileNotFoundError: pass os.mkdir("test_outputs/L1") os.mkdir("test_outputs/L2") pyeo.queries_and_downloads.download_s2_data(images, "test_outputs/L1", "test_outputs/L2", source='aws', user=user, passwd=passwd) for image_id in images: assert os.path.exists( "test_outputs/L1/{}".format(images[image_id]['title'] + ".SAFE"))
def test_pair_filter_with_dl(): # Pickle this at some point so it down't depend on having a download os.chdir(os.path.dirname(os.path.abspath(__file__))) test_aoi = r"test_data/merak.geojson" start = "20180101" end = "20181210" conf = load_test_conf() test_results = pyeo.queries_and_downloads.check_for_s2_data_by_date(test_aoi, start, end, conf) filtered_test_results = pyeo.queries_and_downloads.filter_non_matching_s2_data(test_results) assert len(filtered_test_results) != 0
def test_rest_query(): os.chdir(os.path.dirname(os.path.abspath(__file__))) test_conf = load_test_conf() query_out = pyeo.queries_and_downloads.sent2_query( test_conf["sent_2"]["user"], test_conf["sent_2"]["pass"], "test_data/wuhan_large.shp", "2021-01-01T00:00:00.000Z", "2021-03-30T00:00:00.000Z", cloud=100, query_func=pyeo.queries_and_downloads._rest_query) assert len(query_out) > 0
def test_landsat_query_and_download(): os.chdir(os.path.dirname(os.path.abspath(__file__))) test_conf = load_test_conf() images = pyeo.queries_and_downloads.landsat_query(test_conf, "test_data/merak.geojson", "20180101", "20180110") assert len(images) > 0 out_dir = "test_data/landsat_from_usgs" try: shutil.rmtree(out_dir) except FileNotFoundError: pass os.mkdir(out_dir) products = pyeo.queries_and_downloads.download_landsat_data(images, out_dir, test_conf)
def test_preprocessing(): os.chdir(os.path.dirname(os.path.abspath(__file__))) try: shutil.rmtree("test_outputs/L2") except FileNotFoundError: pass conf = load_test_conf() pyeo.raster_manipulation.atmospheric_correction("test_data/L1", "test_outputs/L2", conf['sen2cor']['path']) assert os.path.isfile( "test_outputs/L2/S2B_MSIL2A_20180103T172709_N0206_R012_T13QFB_20180103T192359.SAFE/GRANULE/L2A_T13QFB_A004328_20180103T172711/IMG_DATA/R10m/T13QFB_20180103T172709_B08_10m.jp2" ) assert os.path.isfile( "test_outputs/L2/S2A_MSIL2A_20180329T171921_N0206_R012_T13QFB_20180329T221746.SAFE/GRANULE/L2A_T13QFB_A014452_20180329T173239/IMG_DATA/R10m/T13QFB_20180329T173239_B08_10m.jp2" )
def test_query_and_download(): os.chdir(os.path.dirname(os.path.abspath(__file__))) test_conf = load_test_conf() user = test_conf["sent_2"]["user"] passwd = test_conf["sent_2"]["pass"] images = pyeo.queries_and_downloads.sent2_query(test_conf["sent_2"]["user"], test_conf["sent_2"]["pass"], "test_data/merak.geojson", "20180101", "20180130") assert len(images) > 0 try: shutil.rmtree("test_outputs/L1") except FileNotFoundError: pass os.mkdir("test_outputs/L1") pyeo.queries_and_downloads.download_s2_data(images, "test_outputs/L1", source='scihub', user=user, passwd=passwd) for image_id in images: assert os.path.exists("test_outputs/L1/{}".format(images[image_id]['title']+".SAFE"))