Skip to content

Commit

Permalink
Add emission load names with unit to columns
Browse files Browse the repository at this point in the history
  • Loading branch information
mrustl committed Mar 23, 2021
1 parent b5c1976 commit 6651f2e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions vignettes/workflow_beijing.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -325,16 +325,24 @@ heavy_metals <- c("Abfiltrierbare Stoffe",
# average across catchment types
c_heavy_metals_means <- x_conc %>%
dplyr::filter(VariableName %in% heavy_metals) %>%
dplyr::mutate(unit_load = kwb.utils::substSpecialChars(.data$UnitsAbbreviation) %>%
stringr::str_replace("L", "m2_year"),
label_load = sprintf("%s.%s",
.data$VariableName,
.data$unit_load)) %>%
dplyr::rowwise(VariableID) %>%
dplyr::mutate(conc_mean = mean(dplyr::c_across(tidyselect::all_of(structures))))
# annual load = V * c
# for heavy metals -> l/m2-year * ug/l = ug/m2-year
# for TSS -> l/m2-year * mg/l = mg/m2-year
loads <- sapply(X = c_heavy_metals_means$conc_mean,
loads <- dplyr::bind_rows(
setNames(lapply(X = c_heavy_metals_means$conc_mean,
FUN = function(a){
abimo_inpout$ROW*a/1e3
})
}),
nm = c_heavy_metals_means$label_load)
)
# add computed loads to ABIMO dataset
abimo_inpout_emissions <- cbind(abimo_inpout, loads)
Expand Down

0 comments on commit 6651f2e

Please sign in to comment.