Fix Maritorena and Stumpf depth-correction formulas - #13
Open
ysims wants to merge 2 commits into
Open
Conversation
_maritorena_depth was previously a single-parameter exponential radiance scaler with no relation to any published Maritorena model. Replace it with the inverse of the Maritorena, Morel & Gentili (1994) two-flow shallow-water reflectance model: given known depth, deep-water reflectance (Rw_inf), and diffuse attenuation (K_d, repurposing the existing `attenuation` parameter), recover bottom reflectance Rb from measured water-leaving reflectance Rw via Rb = Rw_inf + (Rw - Rw_inf) / exp(-2 * K_d * depth), the algebraic inverse of the forward model Rw = Rw_inf + (Rb - Rw_inf) * exp(-2 * K_d * depth). Both Rw_inf and K_d now accept per-band mappings via the existing `_band_param` helper, matching the Lyzenga functions' convention. _stumpf_depth previously computed `m0 - m1 * ln(blue) / ln(green)` directly on raw reflectance, which both flips the sign convention of Stumpf, Holderied & Sinclair (2003) eq. (1) (`m1 * ratio - m0`, not `m0 - m1 * ratio`) and omits the paper's fixed scaling constant `n` (commonly 1000), which keeps `ln(n * Rw)` positive and away from the numerical instability of taking logs of small fractional reflectance values near zero. This is a genuine formula bug, not just a re-parameterisation: fix both the sign and add `n` (default 1000.0, matching the original paper) as a keyword. Behavioural change: existing callers of method="maritorena" or method="stumpf" with default parameters will see different numeric output, which is expected -- the old formulas did not implement the cited papers. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_maritorena_depth was previously a single-parameter exponential radiance scaler with no relation to any published Maritorena model. Replace it with the inverse of the Maritorena, Morel & Gentili (1994) two-flow shallow-water reflectance model: given known depth, deep-water reflectance (Rw_inf), and diffuse attenuation (K_d, repurposing the existing
attenuationparameter), recover bottom reflectance Rb from measured water-leaving reflectance Rw via Rb = Rw_inf + (Rw - Rw_inf) / exp(-2 * K_d * depth), the algebraic inverse of the forward model Rw = Rw_inf + (Rb - Rw_inf) * exp(-2 * K_d * depth). Both Rw_inf and K_d now accept per-band mappings via the existing_band_paramhelper, matching the Lyzenga functions' convention._stumpf_depth previously computed
m0 - m1 * ln(blue) / ln(green)directly on raw reflectance, which both flips the sign convention of Stumpf, Holderied & Sinclair (2003) eq. (1) (m1 * ratio - m0, notm0 - m1 * ratio) and omits the paper's fixed scaling constantn(commonly 1000), which keepsln(n * Rw)positive and away from the numerical instability of taking logs of small fractional reflectance values near zero. This is a genuine formula bug, not just a re-parameterisation: fix both the sign and addn(default 1000.0, matching the original paper) as a keyword.Behavioural change: existing callers of method="maritorena" or method="stumpf" with default parameters will see different numeric output, which is expected -- the old formulas did not implement the cited papers.