From 7bd634e67f028141802c09753647608541cf761f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABlle=20USSEGLIO?= <gaelle.usseglio@cnes.fr> Date: Thu, 19 Mar 2020 10:53:20 +0000 Subject: [PATCH] ENH : Check roi format for SAR_MultiSlc* chaons --- python_src/SAR_MultiSlc.py | 4 ++++ python_src/SAR_MultiSlc_IW.py | 4 ++++ python_src/utils/func_utils.py | 14 ++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/python_src/SAR_MultiSlc.py b/python_src/SAR_MultiSlc.py index c3e68d8..f609f7b 100644 --- a/python_src/SAR_MultiSlc.py +++ b/python_src/SAR_MultiSlc.py @@ -191,6 +191,10 @@ if __name__ == "__main__": func_utils.check_ifExist(hgts_path) func_utils.check_ifExist(master_Image) + # ====== Check roi format (if roi) + if roi : + func_utils.check_roiFormat(roi) + # ====== Create global folder with starting and ending dates + master date output_glob = "{}/output_{}_to_{}_m_{}".format(output_dir, start_time, end_time, master_date) diff --git a/python_src/SAR_MultiSlc_IW.py b/python_src/SAR_MultiSlc_IW.py index 188cf06..22b642a 100644 --- a/python_src/SAR_MultiSlc_IW.py +++ b/python_src/SAR_MultiSlc_IW.py @@ -188,6 +188,10 @@ if __name__ == "__main__": func_utils.check_ifExist(hgts_path) func_utils.check_ifExist(master_Image) + # ====== Check roi format (if roi) + if roi : + func_utils.check_roiFormat(roi) + # ====== Check regex for Burst index firstBurst, lastBurst, burstList = func_utils.check_burstIndex(burst_index) print("from check regex",firstBurst, lastBurst)########################################################### diff --git a/python_src/utils/func_utils.py b/python_src/utils/func_utils.py index 62efd84..6106d86 100644 --- a/python_src/utils/func_utils.py +++ b/python_src/utils/func_utils.py @@ -473,6 +473,20 @@ def selectBurst(dictMaster, dictSlave, firstBurst, lastBurst, nbBurstSlave): return validBurstMaster, validBurstSlave +def check_roiFormat(roi): + """ + Check the roi format, must be 'ulx uly lrx lry' (ex: -roi 2.44115 48.96126 2.44176 48.95927) + """ + regx_exp = re.compile("^([+-]?([0-9]+([.][0-9]*)?|[.][0-9]+)\s){4}$") + if not roi.endswith(' '): + roi = roi + ' ' + + res = regx_exp.match(roi) + # If res = None => does not match with the correct format => quit the progrm + if not res : + print("Wrong format for roi paramater, must be 'ulx uly lrx lry' (ex: -roi 2.44115 48.96126 2.44176 48.95927)") + quit() + def str2bool(v): """ Conversion between a string to a boolean (several ways to say yes into json configuration file). -- GitLab