Skip to content

Commit

Permalink
FIX: Fix error in looking for bands in Sentinel-2 L1C archived products
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-braun committed Jul 15, 2024
1 parent 5d9acd4 commit bfff73a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- FIX: Fix iceye product when extent file (*.kml) not found ([#135](https://github.com/sertit/eoreader/pull/135))
- FIX: Add missing `pystac[validation]` in setup.py
- FIX: Handle RCM and RS2 products that doesn't bundle their extent in a KML file ([#155](https://github.com/sertit/eoreader/issues/155))
- FIX: Fix error in looking for bands in Sentinel-2 L1C archived products ([#168](https://github.com/sertit/eoreader/issues/168))
- OPTIM: Search correctly nested metadata in the Reader (without accidentally using a recursive glob)
- CI: Fix S3 endpoint management with `sertit>=1.37`

Expand Down
31 changes: 18 additions & 13 deletions eoreader/products/optical/s2_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -563,19 +563,24 @@ def _get_res_band_folder(self, band_list: list, pixel_size: float = None) -> dic
dir_name = band_dir

if self.is_archived:
# Open the zip file
with zipfile.ZipFile(self.path, "r") as zip_ds:
# Get the band folder (use dirname is the first of the list is a band)
band_path = [
os.path.dirname(f.filename)
for f in zip_ds.filelist
if dir_name in f.filename
][0]

# Workaround for a bug involving some bad archives
if band_path.startswith("/"):
band_path = band_path[1:]
s2_bands_folder[band] = band_path
# Get the band folder (use dirname is the first of the list is a band)
band_path = os.path.dirname(
path.get_archived_rio_path(
self.path, f"{self._get_image_folder()}.*{dir_name}"
)
)

# Workaround for a bug involving some bad archives
if band_path.startswith("/"):
band_path = band_path[1:]

# Workaround for PEPS Sentinel-2 archives with incomplete manifest (without any directory)
if band_path.endswith(".jp2"):
band_path = os.path.dirname(band_path)
else:
band_path = os.path.basename(band_path)

s2_bands_folder[band] = band_path
else:
# Search for the name of the folder into the S2 products
try:
Expand Down

0 comments on commit bfff73a

Please sign in to comment.