From dc629bfbfc0f5fa3cc4fefcb6340c9c1cb04b5fb Mon Sep 17 00:00:00 2001 From: Thibaut ROMAIN <thibaut.romain@csgroup.eu> Date: Mon, 7 Jun 2021 22:59:42 +0200 Subject: [PATCH 1/2] [MAJA-3302] Less restrictive method for missing detfoo angles --- .../l2_pipelines/reduce_lut_computation.py | 35 ++++++++++++------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/orchestrator/processor/l2_pipelines/reduce_lut_computation.py b/orchestrator/processor/l2_pipelines/reduce_lut_computation.py index 1130566e..3cf02461 100644 --- a/orchestrator/processor/l2_pipelines/reduce_lut_computation.py +++ b/orchestrator/processor/l2_pipelines/reduce_lut_computation.py @@ -68,6 +68,25 @@ class MajaReduceLutComputation(MajaModule): self.out_keys_provided = ["cr_lut"] self._lut_pipeline = OtbPipelineManager() + def find_missing_detector(self,listDTF,key,adjacent_dtf_nb): + nb_bands = 13 + wrongDTFFound = False + adjacentDTFFound = False + for i in range(0,nb_bands): + if [elem for elem in listDTF[i].values() if "D"+str(key)+".tif" in elem]: + dft_wrong = [elem for elem in listDTF[i].values() if "D"+str(key)+".tif" in elem][0] + wrongDTFFound = True + + if [elem for elem in listDTF[i].values() if "D"+str(key)+".tif" in elem]: + dft_adjacent = [elem for elem in listDTF[i].values() if "D"+str(adjacent_dtf_nb)+".tif" in elem][0] + adjacentDTFFound = True + + if wrongDTFFound == True and adjacentDTFFound == True: + return dft_wrong, dft_adjacent + + LOGGER.warning("Error on input L1 product: Missing detector {}".format(key)) + return "", "" + def run(self, dict_of_input, dict_of_output): LOGGER.info("Lut computation start") l_writeL2 = dict_of_input.get("Params").get("WriteL2ProductToL2Resolution") @@ -118,7 +137,7 @@ class MajaReduceLutComputation(MajaModule): if len(l_ViewingZenithAngle) != len(dict_of_input.get("Plugin").BandsDefinitions.L2CoarseBandMap): # Some viewing angles are missing for one or more bands, in that case the product is malformed but we have to continue processing anyway, we take a mean of all viewing angles for this band - listDTF = dict_of_input.get("L1Info").MuscateData["ZoneMaskFileNames"] + L1_dtf_list = dict_of_input.get("L1Info").MuscateData["ZoneMaskFileNames"] adjacent_dft_nb = 0 if key == sorted(m_ViewingZenithAnglesMap.keys())[0]: adjacent_dft_nb = int(key)+1 @@ -127,24 +146,16 @@ class MajaReduceLutComputation(MajaModule): else: raise MajaDataException("Error on input L1 product: missing Viewing angles in the center of the image for some l2 coarse band on detector "+key) - if [elem for elem in listDTF[-1].values() if "D"+key+".tif" in elem]: - dft_wrong = [elem for elem in listDTF[-1].values() if "D"+key+".tif" in elem][0] - else: - raise MajaDataException("Error on input L1 product: Missing detector {}".format(key)) - - if [elem for elem in listDTF[-1].values() if "D"+key+".tif" in elem]: - dft_adjacent = [elem for elem in listDTF[-1].values() if "D"+str(adjacent_dft_nb)+".tif" in elem][0] - else: - raise MajaDataException("Error on input L1 product: Missing detector {}".format(dft_adjacent)) + dtf_wrong, dtf_adjacent = self.find_missing_detector(L1_dtf_list,int(key),adjacent_dft_nb) #Checking if the adjacent dtf contains the part covered by the dtf with missing angles output_dtf_bandmath = os.path.join(rlc_working,"Bandmath_DTF.tif") output_binary = os.path.join(rlc_working,"DTF_"+key+"_binary.tif") - dtf_bm_app = OtbAppHandler("BandMath", {"il": [dft_adjacent, dft_wrong], + dtf_bm_app = OtbAppHandler("BandMath", {"il": [dtf_adjacent, dtf_wrong], "out" : output_dtf_bandmath + ":uint8", "exp": "(im1b1>0 && im2b1>0)? 1:0"}, write_output=False) self._lut_pipeline.add_otb_app(dtf_bm_app) - binary_dtf_app = OtbAppHandler("BandMath", {"il": [dft_wrong], + binary_dtf_app = OtbAppHandler("BandMath", {"il": [dtf_wrong], "out" : output_binary + ":uint8", "exp": "im1b1 > 0 ? 1:0"}, write_output=False) self._lut_pipeline.add_otb_app(binary_dtf_app) -- GitLab From 88d9152934e264031044b0d86ab891ed54e7e4d2 Mon Sep 17 00:00:00 2001 From: Thibaut ROMAIN <thibaut.romain@csgroup.eu> Date: Tue, 8 Jun 2021 10:50:36 +0200 Subject: [PATCH 2/2] [MAJA-3302] Add verbosity on missing detector error --- .../processor/l2_pipelines/reduce_lut_computation.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/orchestrator/processor/l2_pipelines/reduce_lut_computation.py b/orchestrator/processor/l2_pipelines/reduce_lut_computation.py index 3cf02461..7e98ae07 100644 --- a/orchestrator/processor/l2_pipelines/reduce_lut_computation.py +++ b/orchestrator/processor/l2_pipelines/reduce_lut_computation.py @@ -84,7 +84,7 @@ class MajaReduceLutComputation(MajaModule): if wrongDTFFound == True and adjacentDTFFound == True: return dft_wrong, dft_adjacent - LOGGER.warning("Error on input L1 product: Missing detector {}".format(key)) + LOGGER.warning("Missing detector file in L1 masks list : maskName-R1-D-{}".format(key) + ".tif") return "", "" def run(self, dict_of_input, dict_of_output): @@ -145,8 +145,11 @@ class MajaReduceLutComputation(MajaModule): adjacent_dft_nb = int(key)-1 else: raise MajaDataException("Error on input L1 product: missing Viewing angles in the center of the image for some l2 coarse band on detector "+key) - + + #if the product doest not contain angles for a particular detector, we can try to find this detector and its adjacent in the product's masks list dtf_wrong, dtf_adjacent = self.find_missing_detector(L1_dtf_list,int(key),adjacent_dft_nb) + if dtf_wrong == "" or dtf_adjacent == "": + raise MajaDataException("Error on input L1 product: Missing detector "+key+" file") #Checking if the adjacent dtf contains the part covered by the dtf with missing angles output_dtf_bandmath = os.path.join(rlc_working,"Bandmath_DTF.tif") -- GitLab