Skip to content
Snippets Groups Projects
Commit 36f180e4 authored by Gaëlle USSEGLIO's avatar Gaëlle USSEGLIO
Browse files

ENH : Add protection on master Image check into SAR_MultiSlc chains

parent 7081dd0e
No related branches found
No related tags found
No related merge requests found
...@@ -124,13 +124,41 @@ if __name__ == "__main__": ...@@ -124,13 +124,41 @@ if __name__ == "__main__":
light_version = dict_Global['parameter']['clean'] light_version = dict_Global['parameter']['clean']
light_version = func_utils.str2bool(light_version) light_version = func_utils.str2bool(light_version)
func_utils.check_ifExist(dict_Global['in']['Input_Path'])
if master_ext[0] == "h5" : # Cosmo case if master_ext[0] == "h5" : # Cosmo case
master_Image = func_utils.get_imgFromDir(dict_Global['in']['Master_Image'], dict_Global['in']['Input_Path']) master_Image = func_utils.get_imgFromDir(dict_Global['in']['Master_Image'], dict_Global['in']['Input_Path'])
if not master_Image :
print(master_Image_base + " not found into given input path " + \
dict_Global['in']['Input_Path'])
print("Please check your input path")
quit()
else :
correct = func_utils.check_image_pattern(master_Image_base, mode="Cosmo")
if not correct :
print("Master image " + master_Image_base + " does not respect naming conventions for Cosmo")
quit()
master_date = master_Image_base.split("_")[8][:8] master_date = master_Image_base.split("_")[8][:8]
pol = master_Image_base.split("_")[5] pol = master_Image_base.split("_")[5]
else : #S1 SM case else : #S1 SM case
master_Image = func_utils.get_imgFromSAFE(dict_Global['in']['Master_Image'], dict_Global['in']['Input_Path']) master_Image = func_utils.get_imgFromSAFE(dict_Global['in']['Master_Image'], dict_Global['in']['Input_Path'])
if not master_Image :
print(master_Image_base + " not found into given input path " + \
dict_Global['in']['Input_Path'])
print("Please check your input path")
quit()
else :
correct = func_utils.check_image_pattern(master_Image_base, mode="S1SM")
if not correct :
print("Master image " + master_Image_base + " does not respect naming conventions for S1SM")
quit()
master_date = master_Image_base.split("-")[4].split("t")[0] master_date = master_Image_base.split("-")[4].split("t")[0]
pol = master_Image_base.split("-")[3] pol = master_Image_base.split("-")[3]
manifest = master_Image.split("measurement")[0]+"/manifest.safe" manifest = master_Image.split("measurement")[0]+"/manifest.safe"
......
...@@ -112,7 +112,22 @@ if __name__ == "__main__": ...@@ -112,7 +112,22 @@ if __name__ == "__main__":
start_time = int(dict_Global['in']['Start_Date']) start_time = int(dict_Global['in']['Start_Date'])
end_time = int(dict_Global['in']['End_Date']) end_time = int(dict_Global['in']['End_Date'])
master_Image_base = dict_Global['in']['Master_Image'] master_Image_base = dict_Global['in']['Master_Image']
func_utils.check_ifExist(dict_Global['in']['Input_Path'])
master_Image = func_utils.get_imgFromSAFE(dict_Global['in']['Master_Image'], dict_Global['in']['Input_Path']) master_Image = func_utils.get_imgFromSAFE(dict_Global['in']['Master_Image'], dict_Global['in']['Input_Path'])
if not master_Image :
print(master_Image_base + " not found into given input path " + \
dict_Global['in']['Input_Path'])
print("Please check your input path")
quit()
else :
correct = func_utils.check_image_pattern(master_Image_base, mode="S1IW")
if not correct :
print("Master image " + master_Image_base + " does not respect naming conventions for S1IW")
quit()
master_date = master_Image_base.split("-")[4].split("t")[0] master_date = master_Image_base.split("-")[4].split("t")[0]
pol = master_Image_base.split("-")[3] pol = master_Image_base.split("-")[3]
iw = master_Image_base.split("-")[1] iw = master_Image_base.split("-")[1]
......
...@@ -249,6 +249,41 @@ def get_imgFromDir(arg, searchDir="."): ...@@ -249,6 +249,41 @@ def get_imgFromDir(arg, searchDir="."):
img = str("".join(img)) img = str("".join(img))
return img return img
def check_image_pattern(img, mode="S1SM") :
"""
Check pattern for current image. Must be cohetrent according to the sensor and mode
"""
correct_pattern = False
if mode == "S1SM" :
# Mode S1 SM
pattern = "".join(["s1.", "-", '\w{1}', '\d', "-slc-", '\w{2}', "-", '\d{8}', "t", '\d{6}', "-", '\d{8}', "t", '\d{6}'])
if re.match(pattern, img) :
correct_pattern = True
elif mode == "Cosmo":
# Mode Cosmo
pattern = "".join(["CSKS", '\d'])
if re.match(pattern, img) :
pattern_dates = "".join(['\d{14}', "_", '\d{14}'])
dates = re.findall(pattern_dates, img)
if len(dates) == 1 :
correct_pattern = True
else :
# Mode S1 IW
pattern = "".join(["s1.", "-", '\w{2}', '\d', "-slc-", '\w{2}', "-", '\d{8}', "t", '\d{6}', "-", '\d{8}', "t", '\d{6}'])
if re.match(pattern, img) :
correct_pattern = True
return correct_pattern
def image_envelope(inTIF, outSHP): def image_envelope(inTIF, outSHP):
""" """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment