Skip to content

Commit

Permalink
FIX: Use the sun elevation angle rather than the sun zenith angle for…
Browse files Browse the repository at this point in the history
… STAC #158
  • Loading branch information
remi-braun committed Dec 3, 2024
1 parent 8020c5b commit 1549fb0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion CI/SCRIPTS_WEEKLY/test_stac_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down
7 changes: 6 additions & 1 deletion eoreader/stac/stac_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1549fb0

Please sign in to comment.