Skip to content

Commit

Permalink
FIX: Force the loading of DimapV1 bands in float32
Browse files Browse the repository at this point in the history
  • Loading branch information
remi-braun committed Jul 22, 2024
1 parent b677300 commit eda09a1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
11 changes: 5 additions & 6 deletions eoreader/products/optical/gs2_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 3 additions & 1 deletion eoreader/products/optical/vis1_product.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit eda09a1

Please sign in to comment.