diff --git a/script_examples/download_tiles.csv b/script_examples/download_tiles.csv new file mode 100644 index 0000000000000000000000000000000000000000..5e580ac763afc22808b090378bb06dca2fb5c7f3 --- /dev/null +++ b/script_examples/download_tiles.csv @@ -0,0 +1,4 @@ +tile;start_time;end_time;max_clouds;site;nom + +40KCB;2019-01-01;;;France;Reunion +#37KFR;;;;TAAF_Eparses;Europa diff --git a/script_examples/download_tiles.py b/script_examples/download_tiles.py new file mode 100644 index 0000000000000000000000000000000000000000..647578699f37a1a06b9274392b8aacb7ffd3fc7b --- /dev/null +++ b/script_examples/download_tiles.py @@ -0,0 +1,51 @@ +# -*- coding:utf-8 -*- + +""" + Download L1C products from a tile and dates list provided by a csv file + + peps and scihub hub limits can be adjusted (line 53) + - usually PEPS is faster for recent data (limit max 8) + - scihub is better for a few months old products (limit max 2) + +""" + +import logging +import pandas as pd +from sen2chain import DataRequest, DownloadAndProcess, Tile +import datetime +import os +import time +import math + +logger = logging.getLogger("Downloading L1C") +logging.basicConfig(level=logging.INFO) + +fwd = os.path.dirname(os.path.realpath(__file__)) + +# Path to csv process list +tiles_file = fwd + "/download_tiles.csv" + +# default number of days to check before today +# if this field is empty in the csv file +delta_t = 15 + +tiles_list = pd.read_csv(tiles_file, sep = ';', na_values="", comment='#') + +for index, row in tiles_list.iterrows(): + try: + if math.isnan(row.start_time): + row.start_time = (datetime.datetime.now()-datetime.timedelta(days=delta_t)).strftime('%Y-%m-%d') + except: + pass + try: + if math.isnan(row.end_time): + row.end_time = (datetime.datetime.now()+datetime.timedelta(days=1)).strftime('%Y-%m-%d') + except: + pass + + tuile = Tile(row.tile) + req = DataRequest(start_date=row.start_time, end_date=row.end_time).from_tiles([row.tile]) + DownloadAndProcess(req, hubs_limit={"peps":8, "scihub":0}, process_products=False, indices_list=[], nodata_clouds=False, quicklook=False, max_processes=8) + time.sleep(1) + tuile = Tile(row.tile) +