From f127a8ccc99c42f20ded7351de58e3971d9c1b40 Mon Sep 17 00:00:00 2001 From: BRAUN REMI Date: Mon, 17 Feb 2025 15:51:53 +0100 Subject: [PATCH] Fix S2 L2A cloud mask for very old baselines --- eoreader/products/optical/s2_product.py | 29 ++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/eoreader/products/optical/s2_product.py b/eoreader/products/optical/s2_product.py index 0dbbea8b..bbc8e465 100644 --- a/eoreader/products/optical/s2_product.py +++ b/eoreader/products/optical/s2_product.py @@ -1438,11 +1438,30 @@ def _open_clouds_l2a( band_dict = {} if bands: - mask_path = path.get_file_in_dir( - self.path, - f"{self._get_qi_folder()}/MSK_CLDPRB_20m.jp2", - exact_name=True, - ) + try: + if self.is_archived: + mask_path = self._get_archived_rio_path( + f"{self._get_qi_folder()}.*MSK_CLDPRB_20m.jp2" + ) + else: + mask_path = path.get_file_in_dir( + self.path, + f"{self._get_qi_folder()}/MSK_CLDPRB_20m.jp2", + exact_name=True, + ) + except FileNotFoundError: + # For some old processing baselines + # (2.04 ? But not for all products... i.e. S2A_MSIL2A_20170406T105021_N0204_R051_T30SWD_20170406T105317.SAFE) + if self.is_archived: + mask_path = self._get_archived_rio_path( + f"{self._get_qi_folder()}.*_CLD_20m.jp2" + ) + else: + mask_path = path.get_file_in_dir( + self.path, + f"{self._get_qi_folder()}/*_CLD_20m.jp2", + exact_name=True, + ) # Old mask proba files are not geocoded if self._processing_baseline < 2.07: