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

update SDR variable names and correct typo in docstring #1629 #1638

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/natcap/invest/sdr/sdr_core.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,13 @@ def calculate_sediment_deposition(

This algorithm outputs both sediment deposition (t_i) and flux (f_i)::

t_i = dr_i * (sum over j ∈ J of f_j * p(i,j)) + E'_i
t_i = dt_i * (sum over j ∈ J of f_j * p(j,i))

f_i = (1 - dr_i) * (sum over j ∈ J of f_j * p(i,j)) + E'_i
f_i = (1 - dt_i) * (sum over j ∈ J of f_j * p(j,i)) + E'_i


(sum over k ∈ K of SDR_k * p(i,k)) - SDR_i
dr_i = --------------------------------------------
dt_i = --------------------------------------------
(1 - SDR_i)

where:
Expand Down Expand Up @@ -645,21 +645,21 @@ def calculate_sediment_deposition(
if sdr_i == 1:
# This reflects property B in the user's guide and is
# an edge case to avoid division-by-zero.
dr_i = 1
dt_i = 1
else:
dr_i = (downslope_sdr_weighted_sum - sdr_i) / (1 - sdr_i)
dt_i = (downslope_sdr_weighted_sum - sdr_i) / (1 - sdr_i)

# Lisa's modified equations
t_i = dr_i * f_j_weighted_sum # deposition, a.k.a trapped sediment
f_i = (1 - dr_i) * f_j_weighted_sum + e_prime_i # flux
t_i = dt_i * f_j_weighted_sum # deposition, a.k.a trapped sediment
f_i = (1 - dt_i) * f_j_weighted_sum + e_prime_i # flux

# On large flow paths, it's possible for dr_i, f_i and t_i
# On large flow paths, it's possible for dt_i, f_i and t_i
# to have very small negative values that are numerically
# equivalent to 0. These negative values were raising
# questions on the forums and it's easier to clamp the
# values here than to explain IEEE 754.
if dr_i < 0:
dr_i = 0
if dt_i < 0:
dt_i = 0
if t_i < 0:
t_i = 0
if f_i < 0:
Expand Down
Loading