Commit 48800268 authored by David's avatar David
Browse files

fix(getNodeRanking): case with 2 parallel upstream ungauged nodes

Refs #130
2 merge requests!93Draft: Version 0.7.0,!77Resolve "Ungauged node: Diversion to Reservoir crashes Calibration"
Pipeline #54534 passed with stage
in 7 minutes and 7 seconds
Showing with 5 additions and 2 deletions
+5 -2
...@@ -146,11 +146,14 @@ getNodeRanking <- function(griwrm) { ...@@ -146,11 +146,14 @@ getNodeRanking <- function(griwrm) {
g <- g[!g$id %in% upIds, ] g <- g[!g$id %in% upIds, ]
#Search for ungauged ids #Search for ungauged ids
upIds <- unique(g$id[!g$id %in% g$down & g$id != g$donor]) upIds <- unique(g$id[!g$id %in% g$down & g$id != g$donor])
for(upId in upIds) { while(length(upIds) > 0) {
upId <- upIds[1]
#Browse the ungauged sub-network until the donor #Browse the ungauged sub-network until the donor
g2 <- g %>% filter(donor == g$donor[g$id == upId]) upDonor <- g$donor[g$id == upId]
g2 <- g %>% filter(donor == upDonor)
g2$donor <- g2$id g2$donor <- g2$id
ungaugedIds <- getNodeRanking(g2) ungaugedIds <- getNodeRanking(g2)
upIds <- upIds[!upIds %in% ungaugedIds]
r <- c(r, ungaugedIds) r <- c(r, ungaugedIds)
g <- g[!g$id %in% ungaugedIds, ] g <- g[!g$id %in% ungaugedIds, ]
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment