Skip to content

Commit

Permalink
tweaks based on review suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Moodie committed Feb 15, 2021
1 parent 1e75e28 commit ff4de5c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
35 changes: 32 additions & 3 deletions pyDeltaRCM/sed_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,10 @@ def _compute_Vp_ero(self, Vp_sed, U_loc, U_ero, beta):
Function is used by both sand and mud pathways, but the input value of
U_ero depends on the pathway.
.. note::
The volume returned is *always* a positive value.
Parameters
----------
Vp_sed : :obj:`float`
Expand All @@ -382,10 +386,35 @@ def _compute_Vp_ero(self, Vp_sed, U_loc, U_ero, beta):
def _limit_Vp_change(self, Vp, stage, eta, dx, dep_ero):
"""Limit change in volume to 1/4 of a cell volume.
Function is used by multiple pathways in `mud_dep_ero` and `sand_dep_ero`
but with different inputs for the sediment volume (:obj:`Vp`).
Function is used by multiple pathways in `mud_dep_ero` and
`sand_dep_ero` but with different inputs for the sediment volume
(:obj:`Vp`).
.. note::
The input volume should be positive, and the volume returned is
*always* a positive value. If needed, a Router-specific
*implementation of :obj:`_deposit_or_erode` should make the value
*negative _after_ it has been limited here.
Parameters
----------
Vp
Input sediment volume, positive value.
stage
Stage at cell.
eta
Bed elevation at cell.
dx
Cell dimension (meters).
dep_ero indicates which pathway we are in, dep==0, ero==1
dep_ero
Flag indicating whether the call to this method has been made by a
depositional calculation (`dep_ero == 0`) or an erosional
calculation (`dep_ero == 1`).
"""
depth = stage - eta
if depth < 0:
Expand Down
6 changes: 5 additions & 1 deletion pyDeltaRCM/water_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def _get_weight_at_cell_water(ind, weight_sfc, weight_int, depth_nbrs, ct_nbrs,
weight = weight / np.sum(weight)

elif np.sum(weight) == 0:
# if all weights are zeros/nan
# if all weights are zeros
if wall[4] == True: # noqa: E712
# if current cell is wall cell
# just set to zero and pass
Expand All @@ -510,6 +510,10 @@ def _get_weight_at_cell_water(ind, weight_sfc, weight_int, depth_nbrs, ct_nbrs,

weight = weight / np.sum(weight)

elif np.isnan(np.sum(weight)):
raise RuntimeError('NaN encountered in summing water weights. '
'Please report error.')

else:
raise RuntimeError('Water sum(weight) less than 0. '
'Please report error.')
Expand Down

0 comments on commit ff4de5c

Please sign in to comment.