@@ -137,24 +137,7 @@ def calc_mbwi(self, bands, factor=3, save_index=False):
137137
138138 mask = self .loader .invalid_mask
139139
140- # changement for negative SRE values scene
141- min_cte = np .min ([np .min (bands ['Green' ][~ mask ]), np .min (bands ['Red' ][~ mask ]),
142- np .min (bands ['Nir' ][~ mask ]), np .min (bands ['Mir' ][~ mask ]), np .min (bands ['Mir2' ][~ mask ])])
143-
144- if min_cte <= 0 :
145- min_cte = - min_cte + 0.001
146- else :
147- min_cte = 0
148-
149- mbwi = factor * (bands ['Green' ]+ min_cte ) - (bands ['Red' ]+ min_cte ) - (bands ['Nir' ]+ min_cte )\
150- - (bands ['Mir' ]+ min_cte ) - (bands ['Mir2' ]+ min_cte )
151-
152- mbwi [~ mask ] = RobustScaler (copy = False ).fit_transform (mbwi [~ mask ].reshape (- 1 , 1 )).reshape (- 1 )
153- mbwi [~ mask ] = MinMaxScaler (feature_range = (- 1 , 1 ), copy = False ).fit_transform (mbwi [~ mask ].reshape (- 1 , 1 ))\
154- .reshape (- 1 )
155-
156- mask = np .isinf (mbwi ) | np .isnan (mbwi ) | self .loader .invalid_mask
157- mbwi = np .ma .array (mbwi , mask = mask , fill_value = - 9999 )
140+ mbwi , mask = DWutils .calc_mbwi (bands , factor , mask )
158141
159142 self .loader .update_mask (mask )
160143
@@ -165,6 +148,7 @@ def calc_mbwi(self, bands, factor=3, save_index=False):
165148
166149 return mbwi .filled ()
167150
151+
168152 def calc_awei (self , bands , save_index = False ):
169153 """
170154 Calculates the AWEI Water Index and adds it to the bands dictionary
@@ -373,12 +357,16 @@ def create_mask_report(self, image, band_combination, composite_name, pdf_merger
373357 # calculate the sun glint rejection and add it to the pdf report
374358 # the glint will be passed to the
375359 if self .config .calc_glint :
376- glint_processor = DWGlintProcessor (image )
377- pdf_merger_image .append (glint_processor .save_heatmap (self .saver .output_folder ))
360+ glint_processor = DWGlintProcessor .create (image )
361+
362+ # if there is a valid glint_processor, save the heatmap
363+ if glint_processor is not None :
364+ pdf_merger_image .append (glint_processor .save_heatmap (self .saver .output_folder ))
365+ else :
366+ print (f'Glint_mode is On but no Glint Processor is available for this product' )
378367
379368 else :
380369 glint_processor = None
381- # self.calc_glint(image, self.saver.output_folder, pdf_merger_image)
382370
383371 # create a dw_image object with the water mask and all the results
384372 dw_image = self .create_water_mask (band_combination , pdf_merger_image , glint_processor = glint_processor )
0 commit comments