Skip to content

Commit

Permalink
FIX: Fix clean band path for Sentinel-3 SLSTR products
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-braun committed Oct 17, 2024
1 parent 237b9f4 commit 76a9d18
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 0.21.5.post0 (2024-10-17)

- FIX: Fix (really) window's name coming from a vector with an underscore after it
- FIX: Fix clean band path for Sentinel-3 SLSTR products

## 0.21.5 (2024-10-17)

Expand Down
31 changes: 28 additions & 3 deletions eoreader/products/optical/s3_slstr_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@
from functools import reduce
from typing import Union

import geopandas as gpd
import numpy as np
import xarray as xr
from rasterio import features
from rasterio.enums import Resampling
from sertit import path, rasters, types
from sertit import files, path, rasters, types
from sertit.misc import ListEnum
from sertit.types import AnyPathStrType, AnyPathType

Expand All @@ -58,7 +59,13 @@
to_str,
)
from eoreader.exceptions import InvalidTypeError
from eoreader.keywords import CLEAN_OPTICAL, SLSTR_RAD_ADJUST, SLSTR_STRIPE, SLSTR_VIEW
from eoreader.keywords import (
CLEAN_OPTICAL,
SLSTR_RAD_ADJUST,
SLSTR_STRIPE,
SLSTR_VIEW,
TO_REFLECTANCE,
)
from eoreader.products import S3DataType, S3Product, S3ProductType
from eoreader.products.optical.optical_product import DEF_CLEAN_METHOD, CleanMethod
from eoreader.stac import ASSET_ROLE, BT, CENTER_WV, DESCRIPTION, FWHM, GSD, ID, NAME
Expand Down Expand Up @@ -1162,6 +1169,24 @@ def _get_clean_band_path(
suffix = self._get_suffix(band, **kwargs)
res_str = self._pixel_size_to_str(pixel_size)

# Window name
window = kwargs.get("window")

win_suffix = ""
if window is not None:
if path.is_path(window):
win_suffix = f"{path.get_filename(window)}"
elif isinstance(window, gpd.GeoDataFrame):
win_suffix = f"{window.attrs.get('name')}"

if not win_suffix:
win_suffix = f"win{files.hash_file_content(str(window))}"

win_suffix += "_"

# Radiometric processing
rad_proc = "" if kwargs.get(TO_REFLECTANCE, True) else "_as_is"

return self._get_band_folder(writable).joinpath(
f"{self.condensed_name}_{band.name}_{suffix}_{res_str.replace('.', '-')}_{cleaning_method.value}.tif",
f"{self.condensed_name}_{band.name}_{suffix}_{res_str.replace('.', '-')}_{win_suffix}{cleaning_method.value}{rad_proc}.tif",
)

0 comments on commit 76a9d18

Please sign in to comment.