diff --git a/CHANGES.md b/CHANGES.md index fdb40f95..c6300615 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ - FIX: Add a fallback in case `map-overlay.kml` is not readable for `Sentinel-1` data ([#180](https://github.com/sertit/eoreader/discussions/180),[#182](https://github.com/sertit/eoreader/issues/182)) - FIX: Remove warning about Dask's lock and client - FIX: Don't throw an error in case of missing cloud coverage, only a warning and set the cloud coverage to 0 [#159](https://github.com/sertit/eoreader/issues/159) +- FIX: Use the sun elevation angle rather than the sun zenith angle for STAC [#158](https://github.com/sertit/eoreader/issues/158) - DOC: Update `conf.py` (remove useless hunks and set Sphinx 7 as base) - DOC: Added the [PAZ product guide](https://earth.esa.int/eogateway/documents/20142/37627/PAZ-Image-Products-Guide.pdf) to the PAZ Product documentation instead of the TerraSAR-X one - by @guillemc23 diff --git a/CI/SCRIPTS_WEEKLY/test_stac_creation.py b/CI/SCRIPTS_WEEKLY/test_stac_creation.py index 9e285abb..66ff8405 100644 --- a/CI/SCRIPTS_WEEKLY/test_stac_creation.py +++ b/CI/SCRIPTS_WEEKLY/test_stac_creation.py @@ -258,7 +258,8 @@ def _test_core( except KeyError: pass - sun_az, sun_el = prod.get_mean_sun_angles() + sun_az, sun_zen = prod.get_mean_sun_angles() + sun_el = 90 - sun_zen compare( item.properties[VIEW_SUN_AZIMUTH], sun_az, @@ -269,6 +270,7 @@ def _test_core( sun_el, f"{VIEW_SUN_ELEVATION} (item.properties)", ) + assert -90 < sun_el < 90 azimuth, off_nadir, incidence_angle = prod.get_mean_viewing_angles() if azimuth is not None: diff --git a/eoreader/stac/stac_extensions.py b/eoreader/stac/stac_extensions.py index e77e198e..1c84ca6b 100644 --- a/eoreader/stac/stac_extensions.py +++ b/eoreader/stac/stac_extensions.py @@ -333,7 +333,12 @@ def __init__(self, prod, **kwargs): "incidence_angle": VIEW_INCIDENCE_ANGLE, } try: - sun_az, sun_el = prod.get_mean_sun_angles() + # This fct gives the sun zenith angle + sun_az, sun_zen = prod.get_mean_sun_angles() + + # STAC wants the sun elevation angle + # https://en.wikipedia.org/wiki/Solar_zenith_angle#Formula + sun_el = 90 - sun_zen # Convert from numpy dtype (which are not JSON serializable) to standard dtype self.sun_az = stac_utils.to_float(sun_az)