From dccb0ae1288a492463cf83cb7b540671f00d598e Mon Sep 17 00:00:00 2001 From: BRAUN REMI Date: Thu, 20 Jul 2023 18:01:46 +0200 Subject: [PATCH] FIX: Upgraded to EO STAC extension v1.1.0 #83 --- CHANGES.md | 1 + CI/SCRIPTS/test_satellites.py | 2 +- CI/SCRIPTS/test_stac.py | 15 ++++++++++----- eoreader/stac/stac_extensions.py | 4 +++- eoreader/stac/stac_utils.py | 6 ++++-- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 9c86bd54..31fdc732 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ - FIX: Minor fix in RasterioError handling when reading bands - FIX: Fix Landsat L2 surface reflectance and temperature computation ([#99](https://github.com/sertit/eoreader/issues/99)) - FIX: Test thermal bands in CI +- FIX: Upgraded to EO STAC extension v1.1.0 ([#83](https://github.com/sertit/eoreader/issues/83)) ## 0.20.2 (2023-06-22) diff --git a/CI/SCRIPTS/test_satellites.py b/CI/SCRIPTS/test_satellites.py index 40fa58aa..e99f8d65 100644 --- a/CI/SCRIPTS/test_satellites.py +++ b/CI/SCRIPTS/test_satellites.py @@ -68,7 +68,7 @@ "MERIT_DEM.vrt", ] -WRITE_ON_DISK = True +WRITE_ON_DISK = False def set_dem(dem_path): diff --git a/CI/SCRIPTS/test_stac.py b/CI/SCRIPTS/test_stac.py index 122e23f7..680f36f4 100644 --- a/CI/SCRIPTS/test_stac.py +++ b/CI/SCRIPTS/test_stac.py @@ -90,9 +90,14 @@ def compare(to_be_checked, ref, topic): """ Compare two fields """ - assert ( - ref == to_be_checked - ), f"Non equal {topic}: ref ={ref} != to_be_checked={to_be_checked}" + try: + assert ( + ref == to_be_checked + ), f"Non equal {topic}: ref ={ref} != to_be_checked={to_be_checked}" + except AssertionError: + assert to_be_checked.startswith("No") and to_be_checked.endswith( + "available" + ), f"Non equal {topic}: ref ={ref} != to_be_checked={to_be_checked}" def _test_core( @@ -170,7 +175,7 @@ def _test_core( compare( item.stac_extensions, [ - "https://stac-extensions.github.io/eo/v1.0.0/schema.json", + "https://stac-extensions.github.io/eo/v1.1.0/schema.json", "https://stac-extensions.github.io/projection/v1.1.0/schema.json", "https://stac-extensions.github.io/view/v1.0.0/schema.json", ], @@ -180,7 +185,7 @@ def _test_core( compare( item.stac_extensions, [ - "https://stac-extensions.github.io/eo/v1.0.0/schema.json", + "https://stac-extensions.github.io/eo/v1.1.0/schema.json", "https://stac-extensions.github.io/projection/v1.1.0/schema.json", ], "item.stac_extensions", diff --git a/eoreader/stac/stac_extensions.py b/eoreader/stac/stac_extensions.py index 464743f9..cebca1a5 100644 --- a/eoreader/stac/stac_extensions.py +++ b/eoreader/stac/stac_extensions.py @@ -173,7 +173,9 @@ def add_to_item(self, item) -> None: Band.create( name=band.name, common_name=common_name, - description=band.description, + description="No description available" + if len(band.description) < 1 + else band.description, center_wavelength=center_wavelength, full_width_half_max=full_width_half_max, solar_illumination=solar_illumination, diff --git a/eoreader/stac/stac_utils.py b/eoreader/stac/stac_utils.py index 2c727858..38df4517 100644 --- a/eoreader/stac/stac_utils.py +++ b/eoreader/stac/stac_utils.py @@ -39,8 +39,10 @@ def fill_common_mtd(asset: Any, prod, **kwargs) -> None: **kwargs: Additional arguments """ # Basics - asset.common_metadata.title = kwargs.get(TITLE) - asset.common_metadata.description = kwargs.get(DESCRIPTION) + asset.common_metadata.title = kwargs.get(TITLE, "No title available") + asset.common_metadata.description = kwargs.get(DESCRIPTION, "") + if len(asset.common_metadata.description) < 1: + asset.common_metadata.description = "No description available" # Date and Time asset.common_metadata.created = datetime.utcnow()