Skip to content

Commit

Permalink
prevent infinite loop stemming from divide by zero
Browse files Browse the repository at this point in the history
  • Loading branch information
thurber committed Jan 4, 2024
1 parent a654bea commit 28cfaac
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions mosartwmpy/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def __init__(self, config: Benedict = None, parameters: Parameters = None, empty
# parameter for calculating number of main channel iterations needed
# phi_r
phi_main = np.where(
(self.mosart_mask > 0) & (self.channel_length > 0),
(self.mosart_mask > 0) & (self.channel_length > 0) & (self.channel_width > 0),
self.total_drainage_area_single * np.sqrt(self.channel_slope) / (self.channel_length * self.channel_width),
0
)
Expand Down Expand Up @@ -352,7 +352,7 @@ def __init__(self, config: Benedict = None, parameters: Parameters = None, empty
# parameter for calculating number of subnetwork iterations needed
# phi_t
phi_sub = np.where(
self.subnetwork_length > 0,
(self.mosart_mask > 0) & (self.subnetwork_length > 0) & (self.subnetwork_width > 0),
(self.area * np.sqrt(self.subnetwork_slope)) / (self.subnetwork_length * self.subnetwork_width),
0,
)
Expand Down

0 comments on commit 28cfaac

Please sign in to comment.