GeoscienceAustralia / dea-notebooks

Repository for Digital Earth Australia Jupyter Notebooks: tools and workflows for geospatial analysis with Open Data Cube and Xarray
https://docs.dea.ga.gov.au/notebooks/
Apache License 2.0
441 stars 128 forks source link

Excessive warnings from `calculate_indices` function on normalised data #1072

Open robbibt opened 1 year ago

robbibt commented 1 year ago

Describe the bug/issue The calculate_indices function currently provides a warning if normalise is set to False, but an index is requested that needs normalisation. This prevents users from running an index that assumes values in the range of 0-1 on data with values in the range of 0-10,000. https://github.com/GeoscienceAustralia/dea-notebooks/blob/develop/Tools/dea_tools/bandindices.py#L316-L324

However, sometimes a user may wish to pass in data that is already normalised between 0-1, and therefore set normalise to False. However, this still raises the warning, which can produce a lot of spammy messages.

Solution This line should include a check to see if values are not in the range 0-1, and only raise the warning if that is the case. https://github.com/GeoscienceAustralia/dea-notebooks/blob/develop/Tools/dea_tools/bandindices.py#L316-L324

robbibt commented 1 year ago

Hmm, this is complicated by the fact that ds can be Dask, and we don't want to trigger computation early to work out if its values are outside the 0-1.0 range...