Commit cff71fc4 authored by Gaetano Raffaele's avatar Gaetano Raffaele
Browse files

ENH: fetch command in main script.

parent e4f18942
No related merge requests found
Showing with 32 additions and 2 deletions
+32 -2
......@@ -26,7 +26,8 @@ def fetch(shp, dt, output_fld, credentials):
os.makedirs(output_fld, exist_ok=True)
dag.download_all(res, outputs_prefix=output_fld, extract=True)
return S1GRDPipeline(output_fld)
# return S1GRDPipeline(output_fld)
return
class S1GRDPipeline:
......
......@@ -3,7 +3,7 @@ import sys
import argparse
import OBIA.segmentation
import VHR.vhrbase
from TimeSeries import s2theia, s2planetary, s1base, s1planetary
from TimeSeries import s2theia, s2planetary, s1base, s1planetary, planet_mosaics
def run_segmentation(img, threshold, cw, sw , out_seg,
n_first_iter, margin, roi, n_proc, memory,
......@@ -80,6 +80,24 @@ def preprocess_s1(in_fld, roi, out_fld, dem_fld=None, geoid=None, direction=None
s1.write_outputs(out_fld)
return
def fetch(imagery, shp, dt, out_fld, auth):
assert(imagery in ['s2theia', 's2planetary', 's1grd', 's1rtc', 'planetmosaics'])
if imagery != 's2planetary' and auth is None:
raise ValueError("Please provide authentication information.")
if imagery == 's2theia':
s2theia.fetch(shp,dt,out_fld,auth)
elif imagery == 's2planetary':
s2planetary.fetch(shp,dt,out_fld)
elif imagery == 's1grd':
s1base.fetch(shp,dt,out_fld,auth)
elif imagery == 's1rtc':
s1planetary.fetch(shp, dt, out_fld, auth)
elif imagery == 'planetmosaics':
planet_mosaics.fetch(shp, dt, out_fld, auth)
return
def main(args):
parser = argparse.ArgumentParser(prog="moringa", add_help=False)
subpar = parser.add_subparsers(dest="cmd")
......@@ -137,6 +155,14 @@ def main(args):
s1prepr.add_argument("--provider", type=str, default='native',
help="S1 image provider. Currently supported: 'native' (e.g. esa/peps), 'planetary'")
fetchp = subpar.add_parser("fetch", help="Query and download products from the imagery-specific providers.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
fetchp.add_argument("imagery", type=str, help="Name of the images to fetch (supp.: s2theia, s2planetary, s1grd, s1rtc, planetmosaics.")
fetchp.add_argument("roi", type=str, help="Path to a vector GIS file whose extent will be used for spatial query.")
fetchp.add_argument("date_range", type=str, help="Date query in the YYYY-MM-DD/YYYY-MM-DD format.")
fetchp.add_argument("out_folder", type=str, help="Output folder where fetched data will be downloaded.")
fetchp.add_argument("--auth", type=str, default=None, help="Authentication information (credentials file, API key, etc.)")
if len(args) == 1:
parser.print_help()
sys.exit(0)
......@@ -160,6 +186,9 @@ def main(args):
preprocess_s1(arg.in_folder, arg.roi, arg.out_folder, arg.dem_fld, arg.geoid, arg.direction, arg.satellite,
arg.skip_despeckle, arg.provider)
if arg.cmd == "fetch":
fetch(arg.imagery, arg.roi, arg.date_range, arg.out_folder, arg.auth)
return 0
if __name__ == "__main__":
......
Supports Markdown
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