Skip to content

Commit

Permalink
ENH: Add a is_stacked parameters for EOReader's Product to docume…
Browse files Browse the repository at this point in the history
…nt either its bands are delivered stacked or file by file.
  • Loading branch information
remi-braun committed Apr 2, 2024
1 parent c214ec3 commit 7e8c26e
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 0.21.1 (2024-mm-dd)

- ENH: Add a `is_stacked` parameters for EOReader's `Product` to document either its bands are delivered stacked or file by file.
- FIX: Correct `SWIR_CIRRUS` spectral band's enum value (to `SWIR_CIRRUS` instead of `CIRRUS`), avoiding shadowing cloud band `CIRRUS` ([#131](https:/sertit/eoreader/issues/131))
- FIX: Raise proper exception (`UnhandledArchiveError`) for archived data that needs to be extracted before use. A warning wasn't enough.
- FIX: Remove unused `pixel_spacing` for SAR Products
Expand Down
14 changes: 13 additions & 1 deletion CI/SCRIPTS/test_satellites.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import xarray as xr
from geopandas import gpd
from matplotlib import pyplot as plt
from sertit import AnyPath, ci, path
from sertit import AnyPath, ci, misc, path

from CI.scripts_utils import (
CI_EOREADER_S3,
Expand All @@ -29,6 +29,7 @@
HH,
HH_DSPK,
HILLSHADE,
PAN,
RED,
SLOPE,
SWIR_2,
Expand Down Expand Up @@ -158,6 +159,17 @@ def check_prod(pattern_path: str) -> Product:
# Instrument
assert prod.instrument is not None

# Stacked product
if len(prod.get_raw_band_paths()) > 1:
raw_bands = prod.get_raw_band_paths()
# PAN is not considered here
raw_bands.pop(PAN)
ci.assert_val(
prod.is_stacked,
len(misc.unique(raw_bands.values())) == 1,
"Stacked product",
)

return prod


Expand Down
4 changes: 4 additions & 0 deletions eoreader/products/custom_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ def _pre_init(self, **kwargs) -> None:
Function used to pre_init the products
(setting needs_extraction and so on)
"""

# Custom products are stacked
self.is_stacked = True

self.needs_extraction = False

# -- Parse the kwargs
Expand Down
3 changes: 3 additions & 0 deletions eoreader/products/optical/planet_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ def _pre_init(self, **kwargs) -> None:
Function used to pre_init the products
(setting needs_extraction and so on)
"""
# Planet products are stacked
self.is_stacked = True

# Update namespace map key (if needed)
if self.constellation == Constellation.RE:
self._nsmap_key = "re"
Expand Down
2 changes: 1 addition & 1 deletion eoreader/products/optical/re_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def _post_init(self, **kwargs) -> None:

self._has_cloud_cover = True

# Pre init done by the super class
# Post init done by the super class
super()._post_init(**kwargs)

def _set_pixel_size(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion eoreader/products/optical/s2_e84_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _post_init(self, **kwargs) -> None:
"""
self.tile_name = self._get_tile_name()

# Pre init done by the super class
# Post init done by the super class
super()._post_init(**kwargs)

def _get_constellation(self) -> Constellation:
Expand Down
13 changes: 12 additions & 1 deletion eoreader/products/optical/vhr_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ def __init__(
# Initialization from the super class
super().__init__(product_path, archive_path, output_path, remove_tmp, **kwargs)

def _pre_init(self, **kwargs) -> None:
"""
Function used to pre_init the products
(setting needs_extraction and so on)
"""
# VHR products are stacked
self.is_stacked = True

# Pre init done by the super class
super()._pre_init(**kwargs)

def _post_init(self, **kwargs) -> None:
"""
Function used to post_init the products
Expand All @@ -98,7 +109,7 @@ def _post_init(self, **kwargs) -> None:
# Job ID
self._job_id = self._get_job_id()

# Pre init done by the super class
# Post init done by the super class
super()._post_init(**kwargs)

def get_default_band_path(self, **kwargs) -> AnyPathType:
Expand Down
3 changes: 3 additions & 0 deletions eoreader/products/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ def __init__(
self.is_ortho = True
"""True if the images are orthorectified and the footprint is retrieved easily."""

self.is_stacked = False
"""True if the bands are stacked (like for VHR data)."""

self._stac = None

# Manage output
Expand Down

0 comments on commit 7e8c26e

Please sign in to comment.