Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TOA reflectance not between 0 and 1 #4

Open
zxdawn opened this issue May 2, 2023 · 2 comments
Open

TOA reflectance not between 0 and 1 #4

zxdawn opened this issue May 2, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@zxdawn
Copy link

zxdawn commented May 2, 2023

  • enpt version: 0.19.2
  • Python version: 3.10.10
  • Operating System: Mac OS M2

Description

The converted TOA reflectance is not between 0 and 1.

What I Did

config_minimal = dict(path_l1b_enmap_image=f_enmap)
CTR = EnPT_Controller(**config_minimal)
CTR.read_L1B_data()

# radiance
print(CTR.L1_obj.vnir.data[:, :, 0])

# reflectance
CTR.run_toaRad2toaRef()
print(CTR.L1_obj.vnir.data[:, :, 0])

Output

array([[75.735275, 75.68156 , 74.43002 , ..., 73.790054, 73.466194,
        74.22445 ],
       [76.41141 , 75.18983 , 74.571556, ..., 73.85979 , 73.63975 ,
        73.25236 ],
       [76.01936 , 75.75181 , 75.10099 , ..., 74.102554, 73.778694,
        73.7038  ],
       ...,
       [66.28344 , 68.94043 , 70.51789 , ..., 72.46776 , 73.046265,
        74.46463 ],
       [67.42289 , 67.8516  , 68.39808 , ..., 73.19657 , 73.11548 ,
        73.56175 ],
       [67.921844, 68.80148 , 67.12692 , ..., 73.925385, 73.25494 ,
        73.73582 ]], dtype=float32)


array([[2145, 2143, 2108, ..., 2090, 2081, 2102],
       [2164, 2130, 2112, ..., 2092, 2086, 2075],
       [2153, 2145, 2127, ..., 2099, 2090, 2087],
       ...,
       [1877, 1952, 1997, ..., 2052, 2069, 2109],
       [1909, 1922, 1937, ..., 2073, 2071, 2083],
       [1924, 1949, 1901, ..., 2094, 2075, 2088]], dtype=int16)
@danschef
Copy link
Collaborator

danschef commented May 8, 2023

The TOA reflectance is internally scaled between 0 and 10000 as this allows to store the data in integer values, which in turn reduces the memory footprint of the processing pipeline. Although there is a parameter to adjust the TOA reflectance scale factor (EnPT_Controller(scale_factor_toa_ref=1), documented here), I just noted that setting it to 1 does not change the data type of the TOA reflectance values to float. If needed, I could fix that. But you also just divide the TOA reflectance values by the scale factor.

@zxdawn
Copy link
Author

zxdawn commented May 9, 2023

Thanks for the info. If I add the scale_factor_toa_ref , the results are all 0. I guess that's the issue with data type (int)

import numpy as np
from enpt.execution.controller import EnPT_Controller

config_minimal = dict(path_l1b_enmap_image=filename, scale_factor_toa_ref=1)
CTR = EnPT_Controller(**config_minimal)
CTR.read_L1B_data()

CTR.run_toaRad2toaRef()
print(np.any(CTR.L1_obj.vnir.data))
# output: False

Anyway, dividing the TOA reflectance values by the default scale factor (10000) works well.

@danschef danschef added the enhancement New feature or request label Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants