Skip to content

Added check in calc_rdn for s_alb = 0#645

Merged
pgbrodrick merged 2 commits into
isofit:devfrom
evan-greenbrg:debug/s_alb_check
Mar 12, 2025
Merged

Added check in calc_rdn for s_alb = 0#645
pgbrodrick merged 2 commits into
isofit:devfrom
evan-greenbrg:debug/s_alb_check

Conversation

@evan-greenbrg

Copy link
Copy Markdown
Collaborator

Cases when the spherical albedo term in the lut table are 0 currently produce nan values, which leads exceptions when calculating inverse matrices.

When s_alb contains nans, calc_rdn returns a vector with partial nans (indexes where s_alb = 0). The resample function does not include a check for nans within the x vector (only H). When x contains partial nans, resample returns a vector of full nans.

As far as I can tell, this is only an issue with the 1c model. This fix adds a narrow check to the calc_rdn function within the 1c if statement for cases when s_alb = 0. I tried to make it verbose with a debug log, which could be warning if we want it to always be printed.

With how things are currently structured, the value we replace the nans with does not matter, as the 1c model will always return 0s where s_alb = 0. Potentially a behavior this doesn't share with Isofit 2.

Comment thread isofit/radiative_transfer/radiative_transfer.py Outdated
@unbohn

unbohn commented Mar 10, 2025

Copy link
Copy Markdown
Collaborator

@pgbrodrick I pushed a solution that handles both the 1c and 4c cases in one radiance equation, and at the same time, prevents zeros in the spherical albedo term to cause any issues down the line. Feel free to merge if you concur.

@pgbrodrick

Copy link
Copy Markdown
Collaborator

Nice algebraic trick @unbohn - this is also generally more numerically stable, so nothing but a win. I'll wait for the checks to complete for formality, and then merge. Thanks!

@pgbrodrick pgbrodrick merged commit c1cc4e2 into isofit:dev Mar 12, 2025
@evan-greenbrg evan-greenbrg deleted the debug/s_alb_check branch April 16, 2025 22:27
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.

3 participants