Skip to content

Commit

Permalink
BREAKING CHANGES: Remove deprecated features #94,#95, #96
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-braun committed Feb 18, 2025
1 parent cda641c commit 96df598
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 115 deletions.
29 changes: 25 additions & 4 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,46 @@
# Release History

## 0.21.10 (2024-02-18)
## 0.22.0 (2025-mm-dd)

- **BREAKING CHANGES: Remove deprecated features** ([#94](https://github.com/sertit/eoreader/issues/94), [#95](https://github.com/sertit/eoreader/issues/95), [#96](https://github.com/sertit/eoreader/issues/96))
- `resolution` keyword if favor of `pixel_size`
- `GREEN1` band in favor of `GREEN_1`
- `utils.stack_dict` function in favor of `utils.stack` (remove `band` argument)
- deprecated spectral indices in favor of [awesome spectral index](https://awesome-ee-spectral-indices.readthedocs.io/en/latest/) ones).
- `AFRI_1_6`: `AFRI1600`
- `AFRI_2_1`: `AFRI2100`
- `BSI`: `BI`
- `NDGRI`: `NGRDI`
- `NDRE1`: `NDREI`
- `RGI`: `RGRI`
- `WV_BI`: `NHFD`
- `WI`: `WI2015`
- `RDI`: `DSI`
- `DSWI`: `DSWI5`
- `GRI`: `DSWI4`
- `WV_SI`: `NDSIWV`
- `PANI`: `BITM`

## 0.21.10 (2025-02-18)

- ENH: Allow the user to change the default resampling per product and free the `resolution` keyword in `load` and `stack` ([#103](https://github.com/sertit/eoreader/discussions/103))
- ENH: For Sentinel-2 L2A products, use the `MSK_CLDPRB_20m` for computing clouds, as they are more precise than legacy L1C `MSK_CLOUDS_B00` masks. ([#174](https://github.com/sertit/eoreader/issues/174))
- FIX: Fix Sentinel-2 Theia footprints when the nodata area is wider than the data area ([#201](https://github.com/sertit/eoreader/issues/201))
- FIX: Pop `driver` keyword in stack function to only use it for writing, allowing people to drive stack as COGs ([#181](https://github.com/sertit/eoreader/issues/181), [#202](https://github.com/sertit/eoreader/discussions/202))
- FIX: Pop `driver` keyword in stack function to only use it for writing, allowing people to save stack as COGs ([#181](https://github.com/sertit/eoreader/issues/181), [#202](https://github.com/sertit/eoreader/discussions/202))
- FIX: Simplify L7 footprint ([#198](https://github.com/sertit/eoreader/issues/198))
- FIX: Make RPC reprojection work with DEM stored on cloud ([#200](https://github.com/sertit/eoreader/issues/200))
- FIX: Fix DIMAP V2 mask reprojection when all mask values are equal to 1 (resulting in a failure of computing the bands in case of nodata)
- FIX: Fix import of `SaocomSensorMode` and `TsxProduct` from `eoreader.product`
- FIX: Upgrade to v2.0.0 of projection STAC extension
- DEPS: Add `tifffile` as a dependency to allow to write COGs with `dask` ([#181](https://github.com/sertit/eoreader/issues/181), [#202](https://github.com/sertit/eoreader/discussions/202))

## 0.21.9 (2024-01-22)
## 0.21.9 (2025-01-22)

- FIX: Better management of temporary directories (name, cleaning, etc)
- FIX: Align `Sentinel-3 SLSTR` clean band path creation on optical's method
- DOC: Update documentation (intersphinx mapping, ...)

## 0.21.8 (2024-01-13)
## 0.21.8 (2025-01-13)

- ENH: Add a new type (`BandsType`) for list of BandType
- ENH: Add a new environment variable `EOREADER_NOF_BANDS_IN_CHUNKS` to control the number of the bands in chunks when using `dask`. ([#178](https://github.com/sertit/eoreader/discussions/178))
Expand Down
31 changes: 17 additions & 14 deletions ci/on_push/test_others.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,12 @@
)
from eoreader import utils
from eoreader.bands import (
AFRI_1_6,
BLUE,
CA,
CLOUDS,
DEM,
GREEN,
GREEN1,
GREEN_1,
HH,
HILLSHADE,
HV,
Expand Down Expand Up @@ -465,26 +464,30 @@ def test_deprecation():
custom=True,
sensor_type=SensorType.OPTICAL,
pixel_size=2.0,
band_map={GREEN1: 1, RED: 2, BLUE: 3, NIR: 4, SWIR_1: 5},
band_map={GREEN_1: 1, RED: 2, BLUE: 3, NIR: 4, SWIR_1: 5},
remove_tmp=True,
)
window = Window(200, 500, 200, 500)

# Check deprecation for GREEN1
with pytest.deprecated_call():
# Check end of deprecation for GREEN1
with pytest.raises(InvalidTypeError):
to_band("GREEN1")
with pytest.deprecated_call():
with pytest.raises(InvalidTypeError):
prod_green1.load("GREEN1", window=window)
with pytest.deprecated_call():
prod_green1.load(GREEN1, window=window)

# Check deprecation for deprecated spectral indices
with pytest.deprecated_call():
prod_green1.load(AFRI_1_6, window=window)
# Check end of deprecation for deprecated spectral indices
with pytest.raises(InvalidTypeError):
prod_green1.load("AFRI_1_6", window=window)

# Check end of deprecation for resolution keyword
with pytest.raises(TypeError):
prod_green1.load(SWIR_1, resolution=20.0, window=window)

with pytest.raises(ImportError):
pass

# Check deprecation for resolution keyword
with pytest.deprecated_call():
prod_green1.load(SWIR_1, resolution=2.0, window=window)
with pytest.raises(ImportError):
pass


def test_constellations():
Expand Down
12 changes: 1 addition & 11 deletions eoreader/bands/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
"RV_DSPK",
]

from eoreader.bands.band_names import GREEN1 # To be deprecated
from eoreader.bands.band_names import (
BLUE,
CA,
Expand Down Expand Up @@ -161,7 +160,6 @@
"BLUE",
"GREEN",
"GREEN_1",
"GREEN1", # To be deprecated
"YELLOW",
"RED",
"VRE_1",
Expand Down Expand Up @@ -481,15 +479,7 @@ def convert_to_band(tc) -> BandNames:
if band_or_idx:
return band_or_idx
else:
if tc == "GREEN1":
from sertit import logs

logs.deprecation_warning(
"`GREEN1` is deprecated in favor of `GREEN_1`. `GREEN1` will be removed in a future release."
)
return GREEN1
else:
raise _ite(f"Unknown band or index: {tc}")
raise _ite(f"Unknown band or index: {tc}")

if as_list:
band_list = []
Expand Down
7 changes: 0 additions & 7 deletions eoreader/bands/band_names.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,6 @@ class SpectralBandNames(BandNames):
GREEN I
"""

# old alias, to be deprecated
GREEN1 = "GREEN_I"
"""
GREEN I
"""

@classmethod
def stac_to_eoreader(cls, common_name: str, name: str) -> "SpectralBandNames":
"""
Expand Down Expand Up @@ -369,7 +363,6 @@ def eoreader_to_stac(cls, eoreader_name: "SpectralBandNames") -> StacCommonNames

# -- PlanetScope PSB.SD instrument additional band --
GREEN_1 = SpectralBandNames.GREEN_1
GREEN1 = SpectralBandNames.GREEN_1 # To be deprecated

EOREADER_STAC_MAP = {
CA: StacCommonNames.COASTAL,
Expand Down
35 changes: 0 additions & 35 deletions eoreader/bands/indices.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,22 +52,6 @@
LOGGER = logging.getLogger(EOREADER_NAME)
np.seterr(divide="ignore", invalid="ignore")

DEPRECATED_SPECTRAL_INDICES = {
"AFRI_1_6": "AFRI1600",
"AFRI_2_1": "AFRI2100",
"BSI": "BI",
"NDGRI": "NGRDI",
"NDRE1": "NDREI",
"RGI": "RGRI",
"WV_BI": "NHFD",
"WI": "WI2015",
"RDI": "DSI",
"DSWI": "DSWI5",
"GRI": "DSWI4",
"WV_SI": "NDSIWV",
"PANI": "BITM",
}

# Using NIR instead of NARROW_NIR to follow ASI approach
# (see: https://github.com/awesome-spectral-indices/awesome-spectral-indices/issues/27)
# Goal with this dict: to have as many indices as possible implemented in ASI
Expand Down Expand Up @@ -148,11 +132,6 @@ def _compute_params(_bands, **_kwargs):
parameters["L"] = 1.0

index_arr = spyndex.computeIndex(index, parameters)

elif index in DEPRECATED_SPECTRAL_INDICES:
index_arr = spyndex.computeIndex(
DEPRECATED_SPECTRAL_INDICES[index], _compute_params(bands, **kwargs)
)
elif index in EOREADER_DERIVATIVES:
idx_name = EOREADER_DERIVATIVES[index][0]
params = {
Expand Down Expand Up @@ -299,11 +278,6 @@ def get_eoreader_indices() -> list:
if name[0].isupper():
eoreader_indices.append(fct.__name__)

# Add aliases
for eoreader_idx, spyndex_idx in DEPRECATED_SPECTRAL_INDICES.items():
if hasattr(spyndex.indices, spyndex_idx):
eoreader_indices.append(eoreader_idx)

# Add derivatives
for index, deriv_list in EOREADER_DERIVATIVES.items():
if hasattr(spyndex.indices, deriv_list[0]):
Expand Down Expand Up @@ -349,7 +323,6 @@ def is_spyndex_idx(index: str) -> bool:


# Check that no EOReader index name shadows Spyndex indices
assert not any(is_spyndex_idx(alias) for alias in DEPRECATED_SPECTRAL_INDICES)
assert not any(is_spyndex_idx(alias) for alias in EOREADER_DERIVATIVES)


Expand All @@ -368,14 +341,6 @@ def get_needed_bands(index: str) -> list:
if is_eoreader_idx(index):
if index in EOREADER_DERIVATIVES:
return list(EOREADER_DERIVATIVES[index][1].values())
elif index in DEPRECATED_SPECTRAL_INDICES:
# Don't need gamma etc.
return [
SPYNDEX_TO_EOREADER_DICT.get(band)
for band in getattr(
spyndex.indices, DEPRECATED_SPECTRAL_INDICES[index]
).bands
]
else:
# Get source code from this fct
code = inspect.getsource(eval(index))
Expand Down
10 changes: 4 additions & 6 deletions eoreader/products/custom_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from lxml.builder import E
from rasterio import crs
from rasterio.enums import Resampling
from sertit import logs, misc, path, rasters, types
from sertit import misc, path, rasters, types
from sertit.misc import ListEnum
from sertit.types import AnyPathStrType, AnyPathType

Expand Down Expand Up @@ -62,7 +62,6 @@ class CustomFields(ListEnum):
BAND_MAP = "band_map"
CONSTELLATION = "constellation"
INSTRUMENT = "instrument"
RES = "resolution"
PIX_SIZE = "pixel_size"
PROD_TYPE = "product_type"
SUN_AZ = "sun_azimuth"
Expand Down Expand Up @@ -218,11 +217,10 @@ def _set_pixel_size(self) -> None:
Set product default pixel size (in meters)
"""
pixel_size = self.kwargs.get(CustomFields.PIX_SIZE.value)
if pixel_size is None and CustomFields.RES.value in self.kwargs:
logs.deprecation_warning(
"`resolution` is deprecated in favor of `pixel_size` to avoid confusion."
if pixel_size is None and "resolution" in self.kwargs:
raise TypeError(
"'resolution' has been deprecated in favor of 'pixel_size' to avoid confusion. Removed since 0.22.0."
)
pixel_size = self.kwargs.pop(CustomFields.RES.value)

if pixel_size is None:
with rasterio.open(str(self.get_default_band_path())) as ds:
Expand Down
19 changes: 2 additions & 17 deletions eoreader/products/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
from sertit import (
AnyPath,
files,
logs,
misc,
path,
rasters,
Expand All @@ -62,7 +61,6 @@
from eoreader import EOREADER_NAME, cache, utils
from eoreader.bands import (
DEM,
GREEN1,
HILLSHADE,
NEEDED_BANDS,
SLOPE,
Expand Down Expand Up @@ -915,16 +913,8 @@ def load(
xr.Dataset: Dataset with a variable per band
"""
if not pixel_size and "resolution" in kwargs:
logs.deprecation_warning(
"`resolution` is deprecated in favor of `pixel_size` to avoid confusion. `resolution` will be removed in a future release."
)
pixel_size = kwargs.pop("resolution")

if (types.is_iterable(bands) and ("GREEN1" in bands or GREEN1 in bands)) or (
bands == "GREEN1" or bands == GREEN1
):
logs.deprecation_warning(
"`GREEN1` is deprecated in favor of `GREEN_1`. `GREEN1` will be removed in a future release."
raise TypeError(
"'resolution' has been deprecated in favor of 'pixel_size' to avoid confusion. Removed since 0.22.0."
)

# Check if all bands are valid
Expand Down Expand Up @@ -975,11 +965,6 @@ def _load(
for band in bands:
if is_index(band):
if self._has_index(band):
if band in indices.DEPRECATED_SPECTRAL_INDICES:
logs.deprecation_warning(
"Aliases of Awesome Spectral Indices won't be available in future versions of EOReader. "
f"Please use {indices.DEPRECATED_SPECTRAL_INDICES[band]} instead of {band}"
)
index_list.append(band)
else:
raise InvalidIndexError(
Expand Down
21 changes: 0 additions & 21 deletions eoreader/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,27 +374,6 @@ def simplify_wrapper(self):
return simplify_wrapper


def stack_dict(
bands: list, band_xds: xr.Dataset, save_as_int: bool, nodata: float, **kwargs
) -> (xr.DataArray, type):
"""
Stack a dictionary containing bands in a DataArray
Args:
bands (list): List of bands (to keep the right order of the stack)
band_xds (xr.Dataset): Dataset containing the bands
save_as_int (bool): Convert stack to uint16 to save disk space (and therefore multiply the values by 10.000)
nodata (float): Nodata value
Returns:
(xr.DataArray, type): Stack as a DataArray and its dtype
"""
logs.deprecation_warning(
"Deprecated function. Please use `utils.stack` instead. 'bands' is not necessary anymore"
)
return stack(band_xds, save_as_int, nodata, **kwargs)


def stack(
band_xds: xr.Dataset, save_as_int: bool, nodata: float, **kwargs
) -> (xr.DataArray, type):
Expand Down

0 comments on commit 96df598

Please sign in to comment.