Commit 35da7287 authored by Lozac'h Loic's avatar Lozac'h Loic
Browse files

wrapping eodags1

parent d9f1315e
[APP]
exit_download=True
checksum_download=False
abandon_download=True
[KEY_BINDINGS]
query_check=^S ^Q ^D ^E
[ESA]
username=loic.lozach
password=PMUQc22$
[DOWNLOADS]
path=/data/downloads
[DEMDATA]
urlsrmt=http://step.esa.int/auxdata/dem/SRTMGL1/
srtmhgtzip=/data/SRTM/SRTMHGTZIP
......
......@@ -12,17 +12,10 @@ def download_eodag():
print()
def process_command(cmd):
# my_env = os.environ.copy()
# my_env["PATH"] = "/work/python/theia_download:" + my_env["PATH"] , env=my_env
print("Starting : "+" ".join(cmd))
p = Popen(cmd, stdout=PIPE, cwd="/work/python/theia_download")
# p.wait()
output = p.communicate()[0]
if p.returncode != 0:
print("process failed %d : %s" % (p.returncode, output))
exit()
print(output)
return p.returncode
process = Popen(" ".join(cmd), stdout=PIPE, stderr=STDOUT, shell=True)
while stream_process(process):
time.sleep(0.1)
def download_cds(m_year, m_month, m_day, m_time, m_latmax, m_lonmin, m_latmin, m_lonmax, outfile):
c = cdsapi.Client()
......@@ -217,7 +210,16 @@ if __name__ == "__main__":
subparsers = parser.add_subparsers(help='Choose server', dest="pipeline")
# Short pipeline
list_parser = subparsers.add_parser('scihub', help="Download from Copernicus Scihub server")
list_parser = subparsers.add_parser('eodag', help="Download S1 through Eodag API")
list_parser.add_argument('-downdir', action='store', required=True, help="Download directory")
list_parser.add_argument('-tile_str', action='store', required=True, help="S2 Tile name, ex. T30UVU")
list_parser.add_argument('-startdate', action='store', required=True, help="Starting date S1, ex. 2020-08-31")
list_parser.add_argument('-enddate', action='store', required=True, help="Ending date S1, ex. 2020-09-31")
list_parser = subparsers.add_parser('eodagrestart', help="Restart download S1 through Eodag API using Eodag SearchResult geojson files")
list_parser.add_argument('-downdir', action='store', required=True, help="Download directory")
list_parser.add_argument('-remaining_geojson', action='store', required=True, help="Remaining geojson file created from eodag pipeline")
list_parser.add_argument('-alternate_geojson', action='store', required=False, help="[Optional] Alternate geojson file created from eodag pipeline")
list_parser = subparsers.add_parser('cds', help="Download ERA5 temperature image file according to S1 dates")
list_parser.add_argument('-s1dir', action='store', required=True, help="Calibrated Sentinel1 directory")
......@@ -228,10 +230,17 @@ if __name__ == "__main__":
args=parser.parse_args()
if args.pipeline == 'scihub' :
os.system('mode con: cols={} lines={}'.format(140,40))
main = tui.MainTUI(query_string=sq) #query_string=sq
main.run()
if args.pipeline == 'eodag' :
cmd=["python", "manage.py", "runscript", "freezeDetectWrapper", "--traceback", "--script-args",
"12", "downdir@"+args.downdir, "tile_str@"+args.tile_str, "startdate@"+args.startdate, "enddate@"+args.enddate
]
process_command(cmd)
elif args.pipeline == 'eodagrestart' :
cmd=["python", "manage.py", "runscript", "freezeDetectWrapper", "--traceback", "--script-args",
"13", "remaining_geojson@"+args.remaining_geojson, "downdir@"+args.downdir, "alternate_geojson@"+args.alternate_geojson
]
process_command(cmd)
elif args.pipeline == 'cds' :
outabs = os.path.abspath(args.outdir)
if not os.path.exists(outabs):
......
import os, argparse, shlex, datetime
from frozenapp import load, process
from frozenapp import load, process, eodags1
......@@ -9,6 +9,18 @@ def init1_RPGImport(rpg_shp, verbose):
def init2_TilesEnveloppesImport(envelopes_dir, verbose):
load.envelopes_import(envelopes_dir, verbose)
def eodag_download( mrgstile, startdate, enddate, downdir):
eds = eodags1.EodagS1()
eds.search_and_download(0, mrgstile, startdate, enddate, downdir)
def eodag_restart( remaining_geojson, downdir, alternate_geojson=None):
eds = eodags1.EodagS1()
eds.import_geojson(products_geojson,alternate_products_geojson=alternate_geojson)
eds.start_downloads(downdir)
def init3_Sentinel1ImagesImport(tile_str, calibrated_S1_dir, ZIP_S1_dir, verbose):
load.sentinel1Image_import(tile_str, calibrated_S1_dir, ZIP_S1_dir, verbose)
......@@ -70,6 +82,9 @@ def run(*args):
argsdict[arg.split("@")[0]]=bool(int(arg.split("@")[1]))
if arg.split("@")[0] == 'year':
argsdict[arg.split("@")[0]]=int(arg.split("@")[1])
if arg.split("@")[0] == 'alternate_geojson':
if arg.split("@")[1] == 'None':
argsdict[arg.split("@")[0]]=None
if arg.split("@")[0] == 'outdir':
if arg.split("@")[1] == 'None':
argsdict[arg.split("@")[0]]=None
......@@ -152,6 +167,13 @@ def run(*args):
elif choix == 11:
proc11_normalize_rsquare(argsdict["tile_str"],argsdict["year"], argsdict["outdir"])
elif choix == 12:
eodag_download( argsdict["tile_str"],argsdict["startdate"], argsdict["enddate"], argsdict["downdir"])
elif choix == 13:
eodag_restart( argsdict["remaining_geojson"], argsdict["downdir"], argsdict["alternate_geojson"])
else:
print("Wrong argument.")
exit()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment