diff --git a/TimeSeries/s1base.py b/TimeSeries/s1base.py index 923b2f0d8eeb741340599eb3ba5d74ed2cd3b0af..33d6404e831bff052253631c5e8bb38ed61ee9b4 100644 --- a/TimeSeries/s1base.py +++ b/TimeSeries/s1base.py @@ -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: diff --git a/moringa.py b/moringa.py index e57911a86b5cad493f4cb11fcac7b8e42ce041a7..7dbba599008c1953217df9a0153bccf5da95266b 100755 --- a/moringa.py +++ b/moringa.py @@ -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__":