Skip to content

Commit

Permalink
Merge branch 'main' of github.com:natcap/invest into bugfix/1600-ufrm…
Browse files Browse the repository at this point in the history
…-preserve-source-aoi-fields
  • Loading branch information
emilyanndavis committed Oct 8, 2024
2 parents 5458781 + 91e10fb commit b131848
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
3 changes: 3 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ Unreleased Changes
* Fixed a bug that, in certain scenarios, caused a datastack to be saved
with relative paths when the Relative Paths checkbox was left unchecked
(https://github.com/natcap/invest/issues/1609)
* Habitat Quality
* Access raster is now generated from the reprojected access vector.
(https://github.com/natcap/invest/issues/1615)
* Urban Flood Risk
* Fields present on the input AOI vector are now retained in the output.
(https://github.com/natcap/invest/issues/1600)
Expand Down
2 changes: 1 addition & 1 deletion src/natcap/invest/habitat_quality.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ def execute(args):

rasterize_access_task = task_graph.add_task(
func=pygeoprocessing.rasterize,
args=(args['access_vector_path'], access_raster_path),
args=(reprojected_access_path, access_raster_path),
kwargs={
'option_list': ['ATTRIBUTE=ACCESS'],
'burn_values': None
Expand Down
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

0 comments on commit b131848

Please sign in to comment.