Skip to content

Commit

Permalink
Add new tables
Browse files Browse the repository at this point in the history
  • Loading branch information
ma-z-am committed Jul 20, 2023
1 parent bdd3383 commit 76ece60
Showing 1 changed file with 40 additions and 11 deletions.
51 changes: 40 additions & 11 deletions inst/extdata/scripts/check_scenario_overflows.R
Original file line number Diff line number Diff line change
@@ -1,30 +1,54 @@
library(dplyr)
if(FALSE){
s_a <- stat_summary(scenario = "S0")
s_a <- stat_summary(scenario = "S4")
s_b <- stat_summary(scenario = "S7", include_bsb = TRUE)

df <- merge(x = s_a, y = s_b, by = "RbId")

outlet_catch <- kwb.misa:::loadMisa_decouplingInfo()

df <- merge(x = df, y = outlet_catch, by.x = "RbId", by.y = "gerris_id")

df2 <- df %>%
mutate("diff_V" = tVol.x - tVol.y,
"red_V" = round(diff_V / tVol.x * 100, 0),
"diff_BSB" = tBSB.x - tBSB.y,
"red_BSB" = ifelse(
test = tBSB.x == 0,
yes = 0, no = round(diff_BSB / tBSB.x * 100, 0)))

# Regarding Volume
df2 <- df %>% mutate("diff" = tVol.x - tVol.y,
"removal" = round(diff / tVol.x * 100, 0))
df2 %>% group_by(surface_water.x) %>%
summarize("mean_removal" = mean(red_V),
"sum_absol" = sum(diff_V),
"mean_absol" = mean(diff_V))

View(df2 %>% group_by(catchment_arab) %>%
summarize("mean_removal" = mean(red_V),
"sum_removal" = sum(diff_V),
"n" = n(),
"mean_absolut" = sum_removal / n))

# Regarding BOD
df2 %>% group_by(surface_water.x) %>%
summarize("mean_removal" = mean(red_BSB),
"sum_absol" =sum(diff_BSB),
"mean_absol" = mean(diff_BSB))

View(df2 %>% group_by(catchment_arab) %>%
summarize("mean_removal" = mean(red_BSB),
"sum_removal" = sum(diff_BSB),
"n" = n(),
"mean_absolut" = sum_removal / n))

df2[df2$outlet_id.x == "16234002",]
hist(df2$removal[df2$removal > 0])
summary(df2$removal[df2$removal > 0])
summary(df2$diff[df2$removal > 0])
summary(df2$diff)
df3 <- df2 %>% group_by(surface_water.x) %>%
summarize("mean_removal" = mean(removal),
"mean_absol" = mean(diff))
df3 <-


df3 <- df2 %>% group_by(catchment_arab) %>%
summarize("mean_removal" = mean(removal),
"sum_removal" = sum(diff),
"n" = n(),
"mean_absolut" = sum_removal / n)

df2 %>% filter(removal > 0) %>%
group_by(surface_water.x) %>%
Expand Down Expand Up @@ -85,4 +109,9 @@ stat_summary <- function(scenario, include_bsb = TRUE){



df_stat %>%
group_by(RbId, outlet_id, upstream_link_id, surface_water) %>%
summarize("tVol" = sum(tVol_m3, na.rw = TRUE),
"tBSB" = sum(tBSB_g, na.rm = TRUE))


0 comments on commit 76ece60

Please sign in to comment.