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] [DEMDATA]
urlsrmt=http://step.esa.int/auxdata/dem/SRTMGL1/ urlsrmt=http://step.esa.int/auxdata/dem/SRTMGL1/
srtmhgtzip=/data/SRTM/SRTMHGTZIP srtmhgtzip=/data/SRTM/SRTMHGTZIP
......
...@@ -12,17 +12,10 @@ def download_eodag(): ...@@ -12,17 +12,10 @@ def download_eodag():
print() print()
def process_command(cmd): 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)) print("Starting : "+" ".join(cmd))
p = Popen(cmd, stdout=PIPE, cwd="/work/python/theia_download") process = Popen(" ".join(cmd), stdout=PIPE, stderr=STDOUT, shell=True)
# p.wait() while stream_process(process):
output = p.communicate()[0] time.sleep(0.1)
if p.returncode != 0:
print("process failed %d : %s" % (p.returncode, output))
exit()
print(output)
return p.returncode
def download_cds(m_year, m_month, m_day, m_time, m_latmax, m_lonmin, m_latmin, m_lonmax, outfile): def download_cds(m_year, m_month, m_day, m_time, m_latmax, m_lonmin, m_latmin, m_lonmax, outfile):
c = cdsapi.Client() c = cdsapi.Client()
...@@ -217,7 +210,16 @@ if __name__ == "__main__": ...@@ -217,7 +210,16 @@ if __name__ == "__main__":
subparsers = parser.add_subparsers(help='Choose server', dest="pipeline") subparsers = parser.add_subparsers(help='Choose server', dest="pipeline")
# Short 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 = 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") list_parser.add_argument('-s1dir', action='store', required=True, help="Calibrated Sentinel1 directory")
...@@ -228,10 +230,17 @@ if __name__ == "__main__": ...@@ -228,10 +230,17 @@ if __name__ == "__main__":
args=parser.parse_args() args=parser.parse_args()
if args.pipeline == 'scihub' : if args.pipeline == 'eodag' :
os.system('mode con: cols={} lines={}'.format(140,40)) cmd=["python", "manage.py", "runscript", "freezeDetectWrapper", "--traceback", "--script-args",
main = tui.MainTUI(query_string=sq) #query_string=sq "12", "downdir@"+args.downdir, "tile_str@"+args.tile_str, "startdate@"+args.startdate, "enddate@"+args.enddate
main.run() ]
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' : elif args.pipeline == 'cds' :
outabs = os.path.abspath(args.outdir) outabs = os.path.abspath(args.outdir)
if not os.path.exists(outabs): if not os.path.exists(outabs):
......
import os, argparse, shlex, datetime 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): ...@@ -9,6 +9,18 @@ def init1_RPGImport(rpg_shp, verbose):
def init2_TilesEnveloppesImport(envelopes_dir, verbose): def init2_TilesEnveloppesImport(envelopes_dir, verbose):
load.envelopes_import(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): def init3_Sentinel1ImagesImport(tile_str, calibrated_S1_dir, ZIP_S1_dir, verbose):
load.sentinel1Image_import(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): ...@@ -70,6 +82,9 @@ def run(*args):
argsdict[arg.split("@")[0]]=bool(int(arg.split("@")[1])) argsdict[arg.split("@")[0]]=bool(int(arg.split("@")[1]))
if arg.split("@")[0] == 'year': if arg.split("@")[0] == 'year':
argsdict[arg.split("@")[0]]=int(arg.split("@")[1]) 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("@")[0] == 'outdir':
if arg.split("@")[1] == 'None': if arg.split("@")[1] == 'None':
argsdict[arg.split("@")[0]]=None argsdict[arg.split("@")[0]]=None
...@@ -152,6 +167,13 @@ def run(*args): ...@@ -152,6 +167,13 @@ def run(*args):
elif choix == 11: elif choix == 11:
proc11_normalize_rsquare(argsdict["tile_str"],argsdict["year"], argsdict["outdir"]) 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: else:
print("Wrong argument.") print("Wrong argument.")
exit() 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