From eda09a1a4c6112045ceab4448b510794bf856166 Mon Sep 17 00:00:00 2001 From: BRAUN REMI Date: Mon, 22 Jul 2024 11:15:26 +0200 Subject: [PATCH] FIX: Force the loading of `DimapV1` bands in `float32` --- CHANGES.md | 1 + eoreader/products/optical/gs2_product.py | 11 +++++------ eoreader/products/optical/vis1_product.py | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index f4aaf897..b252be36 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -12,6 +12,7 @@ - FIX: Handle RCM and RS2 products that doesn't bundle their extent in a KML file ([#155](https://github.com/sertit/eoreader/issues/155)) - FIX: Fix error in looking for bands in Sentinel-2 L1C archived products ([#168](https://github.com/sertit/eoreader/issues/168)) - FIX: Handle wrongly recognized Planet products because of the recursive nested mtd in the Reader ([#169](https://github.com/sertit/eoreader/issues/169)) +- FIX: Force the loading of `DimapV1` bands in `float32` - OPTIM: Search correctly nested metadata in the Reader (without accidentally using a recursive glob) - CI: Fix S3 endpoint management with `sertit>=1.37` diff --git a/eoreader/products/optical/gs2_product.py b/eoreader/products/optical/gs2_product.py index aa0e0bfa..060de209 100644 --- a/eoreader/products/optical/gs2_product.py +++ b/eoreader/products/optical/gs2_product.py @@ -405,14 +405,13 @@ def get_curr_band_mtd(root_mtd): # Compute band in radiance band_arr = bias + band_arr * gain + band_arr = self._toa_rad_to_toa_refl(band_arr, band, e_sun, sun_earth_dist) - # To float32 - if band_arr.dtype != np.float32: - band_arr = band_arr.astype(np.float32) + # To float32 + if band_arr.dtype != np.float32: + band_arr = band_arr.astype(np.float32) - return self._toa_rad_to_toa_refl(band_arr, band, e_sun, sun_earth_dist) - else: - return band_arr + return band_arr @cache def _read_mtd(self) -> (etree._Element, dict): diff --git a/eoreader/products/optical/vis1_product.py b/eoreader/products/optical/vis1_product.py index ba3f0fa7..27d0b3b8 100644 --- a/eoreader/products/optical/vis1_product.py +++ b/eoreader/products/optical/vis1_product.py @@ -346,11 +346,13 @@ def _to_reflectance( if original_dtype == "uint16": band_arr /= 100.0 + band_arr = self._toa_rad_to_toa_refl(band_arr, band, _VIS1_E0[band]) + # To float32 if band_arr.dtype != np.float32: band_arr = band_arr.astype(np.float32) - return self._toa_rad_to_toa_refl(band_arr, band, _VIS1_E0[band]) + return band_arr @cache def _read_mtd(self) -> (etree._Element, dict):