Skip to content

Fix Maritorena and Stumpf depth-correction formulas - #13

Open
ysims wants to merge 2 commits into
mainfrom
feature/maritorena-stumpf-literature-accuracy
Open

Fix Maritorena and Stumpf depth-correction formulas#13
ysims wants to merge 2 commits into
mainfrom
feature/maritorena-stumpf-literature-accuracy

Conversation

@ysims

@ysims ysims commented Aug 4, 2026

Copy link
Copy Markdown
Owner

_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.

ysims and others added 2 commits July 28, 2026 20:52
_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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant