Skip to content

Commit

Permalink
FIX: Don't try to mosaic bands of mono-mosaics
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-braun committed Oct 18, 2024
1 parent d52ae8d commit d86aeeb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
49 changes: 30 additions & 19 deletions eosets/mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit d86aeeb

Please sign in to comment.