From d86aeeb9bea31e6295a396c64bec998798cb218e Mon Sep 17 00:00:00 2001 From: BRAUN REMI Date: Fri, 18 Oct 2024 13:35:40 +0200 Subject: [PATCH] FIX: Don't try to mosaic bands of mono-mosaics --- CHANGES.md | 1 + eosets/mosaic.py | 49 +++++++++++++++++++++++++++++------------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a8abf23..a395ebc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,7 @@ - FIX: Fix band retrieving when the env variable `CI_EOREADER_BAND_FOLDER` is set, in case of multiple files of the same band from different satellite data are present in the directory - FIX: Don't force set `remove_tmp` to `True` for `eoreader.Product` in `Mosaic`. +- FIX: Don't try to mosaic bands of mono-mosaics - CI: Add more tests ## 0.2.3 (2024-10-16) diff --git a/eosets/mosaic.py b/eosets/mosaic.py index a3a6c82..5c66b6c 100644 --- a/eosets/mosaic.py +++ b/eosets/mosaic.py @@ -399,26 +399,37 @@ def load( for band in bands_path: output_path = bands_path[band] if not output_path.is_file(): - LOGGER.debug(f"Merging bands {to_str(band)[0]}") - if self.mosaic_method == MosaicMethod.VRT: - prod_paths = [] - for prod_path in prod_band_paths[band]: - out_path, exists = self._get_out_path( - os.path.basename(prod_path) - ) - if not exists: - if AnyPath(prod_path).parent.is_relative_to(self.output): - # If EOReader's band: move - shutil.move(prod_path, out_path) - else: - # If raw product's band: copy - files.copy(prod_path, out_path) - prod_paths.append(out_path) - else: - prod_paths = prod_band_paths[band] + if self.nof_prods > 1: + LOGGER.debug(f"Merging bands {to_str(band)[0]}") + if self.mosaic_method == MosaicMethod.VRT: + prod_paths = [] + for prod_path in prod_band_paths[band]: + out_path, exists = self._get_out_path( + os.path.basename(prod_path) + ) + if not exists: + if AnyPath(prod_path).parent.is_relative_to( + self.output + ): + # If EOReader's band: move + shutil.move(prod_path, out_path) + else: + # If raw product's band: copy + files.copy(prod_path, out_path) + prod_paths.append(out_path) + else: + prod_paths = prod_band_paths[band] - # Don't pass kwargs here because of unwanted errors - merge_fct(prod_paths, output_path) + # Don't pass kwargs here because of unwanted errors + merge_fct(prod_paths, output_path) + else: + prod_path = prod_band_paths[band][0] + if AnyPath(prod_path).parent.is_relative_to(self.output): + # If EOReader's band: move + shutil.move(prod_path, output_path) + else: + # If raw product's band: copy + files.copy(prod_path, output_path) # Load in memory and update attribute merged_dict[band] = self._update_attrs(