From 9a22bc59b409e01990c586100ce3b2379d7f41fc Mon Sep 17 00:00:00 2001 From: BRAUN REMI Date: Tue, 14 Nov 2023 12:55:34 +0100 Subject: [PATCH] ENH: Calibration step for `Capella` products now exists in ESA SNAP. Add it in pre-processing. --- CHANGES.md | 1 + eoreader/products/sar/capella_product.py | 12 +++++++----- eoreader/products/sar/sar_product.py | 9 +-------- eoreader/reader.py | 2 +- 4 files changed, 10 insertions(+), 14 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index bc73153f..bf4e6381 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,7 @@ - **ENH: Manage Sentinel-2 as formatted on the cloud (Element84 or Sinergise's way). ([#104](https://github.com/sertit/eoreader/issues/104)** - **ENH: Handle Python 3.12. ([#113](https://github.com/sertit/eoreader/issues/113)** - **ENH: Guard against S1 COG format, not yet handled by SNAP.** +- **ENH: Calibration step for `Capella` products now exists in ESA SNAP. Add it in pre-processing.** - FIX: Fix jpg, png... quicklooks management when plotting - FIX: Fix an `xarray` issue when trying to compute percentiles when stacking bands - CI: Update pre-commit hooks diff --git a/eoreader/products/sar/capella_product.py b/eoreader/products/sar/capella_product.py index 9d537ab3..ad10dde3 100644 --- a/eoreader/products/sar/capella_product.py +++ b/eoreader/products/sar/capella_product.py @@ -181,8 +181,6 @@ def _set_pixel_size(self) -> None: def _set_instrument(self) -> None: """ Set instrument - - ICEYE: https://earth.esa.int/eogateway/missions/iceye """ self.instrument = "SAR X-band" @@ -209,7 +207,11 @@ def _post_init(self, **kwargs) -> None: """ # Private attributes self.snap_filename = str(next(self.path.glob("*CAPELLA*.json")).name) - self._raw_band_regex = f"{self.name}.tif" + try: + self._raw_band_regex = str(next(self.path.glob(f"{self.name}.tif")).name) + except StopIteration: + # For SICD and SIDD + self._raw_band_regex = str(next(self.path.glob(f"{self.name}.ntf")).name) # Post init done by the super class super()._post_init(**kwargs) @@ -420,7 +422,7 @@ def _read_mtd(self) -> (etree._Element, dict): def get_raw_band_paths(self, **kwargs) -> dict: """ Return the existing path of the VV band (as they come with the archived products). - ICEYE product only contains a VV band ! + Capella product only contains a VV band ! Args: **kwargs: Additional arguments @@ -436,7 +438,7 @@ def get_raw_band_paths(self, **kwargs) -> dict: ) except FileNotFoundError: raise InvalidProductError( - "An ICEYE product should at least contain one band !" + f"An {self.constellation.name} product should at least contain one band !" ) return band_paths diff --git a/eoreader/products/sar/sar_product.py b/eoreader/products/sar/sar_product.py index 49f45e3e..0469d41b 100644 --- a/eoreader/products/sar/sar_product.py +++ b/eoreader/products/sar/sar_product.py @@ -692,14 +692,7 @@ def _pre_process_sar(self, band: sab, pixel_size: float = None, **kwargs) -> str # Pre-process graph if PP_GRAPH not in os.environ: - if self.constellation == Constellation.CAPELLA: - LOGGER.debug( - "SNAP Error: [NodeId: Calibration] Mission Capella is currently not supported for calibration. Removing this step." - ) - pp_graph = utils.get_data_dir().joinpath( - "grd_sar_preprocess_fallback.xml" - ) - elif ( + if ( self.constellation == Constellation.CSG and self.sar_prod_type == SarProductType.CPLX ): diff --git a/eoreader/reader.py b/eoreader/reader.py index 24ee3235..ccb96489 100644 --- a/eoreader/reader.py +++ b/eoreader/reader.py @@ -258,7 +258,7 @@ class Constellation(ListEnum): Constellation.MAXAR: r"\d{12}_\d{2}_P\d{3}_(MUL|PAN|PSH|MOS)", Constellation.ICEYE: r"((SM|SL|SC|SLEA)[HW]*_\d{5,}|ICEYE_X\d_(SM|SL|SC|SLEA)H*_\d{5,}_\d{8}T\d{6})", Constellation.SAOCOM: r".+EOL1[ABCD]SARSAO1[AB]\d+(-product|)", - Constellation.CAPELLA: r"CAPELLA_C\d{2}_S[PMS]_(GEO|GEC|SLC)_(HH|VV)_\d{14}_\d{14}", + Constellation.CAPELLA: r"CAPELLA_C\d{2}_S[PMS]_(GEO|GEC|SLC|SICD|SIDD)_(HH|VV)_\d{14}_\d{14}", Constellation.SV1: [ r"\d{13}_\d{2}", r"SV1-0[1-4]_\d{8}_L(1B|2A)\d{10}_\d{13}_\d{2}-(MUX|PSH)\.xml",