aboutsummaryrefslogtreecommitdiff
path: root/R/PEC_sw_focus.R
diff options
context:
space:
mode:
authorJohannes Ranke <jranke@uni-bremen.de>2022-11-10 12:17:34 +0100
committerJohannes Ranke <jranke@uni-bremen.de>2022-11-10 12:17:34 +0100
commita0364c2561dda4c4b67e7e3b6830719b4ed60916 (patch)
tree2fef05a3297cf8a3643dfe0f2fac3a30fc2c2183 /R/PEC_sw_focus.R
parentaa0c59c7a3ede267730fe85f9e27b1814f9e897a (diff)
set_nd_nq is now in mkin, fix Steps12 bug
If a scenario with a slash "/" was selected in PEC_sw_focus(), the Step 2 file generated giving an error (path not found) in the Steps12 calculator, because the scenario name is part of the "compound" name in this implementation, in order to show it in the list that the calculator presents.
Diffstat (limited to 'R/PEC_sw_focus.R')
-rw-r--r--R/PEC_sw_focus.R19
1 files changed, 10 insertions, 9 deletions
diff --git a/R/PEC_sw_focus.R b/R/PEC_sw_focus.R
index c01dece..4d5139e 100644
--- a/R/PEC_sw_focus.R
+++ b/R/PEC_sw_focus.R
@@ -24,24 +24,24 @@
#' @note Step 2 is not implemented.
#' @export
#' @param parent A list containing substance specific parameters, e.g.
-#' conveniently generated by \code{\link{chent_focus_sw}}.
+#' conveniently generated by [chent_focus_sw].
#' @param rate The application rate in g/ha. Overriden when
#' applications are given explicitly
#' @param n The number of applications
#' @param i The application interval
#' @param comment A comment for the input file
#' @param met A list containing metabolite specific parameters. e.g.
-#' conveniently generated by \code{\link{chent_focus_sw}}. If not NULL,
+#' conveniently generated by [chent_focus_sw]. If not NULL,
#' the PEC is calculated for this compound, not the parent.
#' @param f_drift The fraction of the application rate reaching the waterbody
#' via drift. If NA, this is derived from the scenario name and the number
#' of applications via the drift data defined by the
-#' \code{\link{FOCUS_Step_12_scenarios}}
+#' [FOCUS_Step_12_scenarios]
#' @param f_rd The fraction of the amount applied reaching the waterbody via
#' runoff/drainage. At Step 1, it is assumed to be 10%, be it the
#' parent or a metabolite
#' @param scenario The name of the scenario. Must be one of the scenario
-#' names given in \code{\link{FOCUS_Step_12_scenarios}}
+#' names given in [FOCUS_Step_12_scenarios]
#' @param region 'n' for Northern Europe or 's' for Southern Europe. If NA, only
#' Step 1 PECsw are calculated
#' @param season 'of' for October to February, 'mm' for March to May, and 'js'
@@ -64,7 +64,7 @@
#'
#' # Metabolite
#' new_dummy <- chent_focus_sw("New Dummy", mw = 250, Koc = 100)
-#' M1 <- chent_focus_sw("M1", mw = 100, cwsat = 100, DT50_ws = 100, Koc = 50,
+#' M1 <- chent_focus_sw("M1", mw = 100, cwsat = 100, DT50_ws = 100, Koc = 50,
#' max_ws = 0, max_soil = 0.5)
#' PEC_sw_focus(new_dummy, 1000, scenario = "cereals, winter", met = M1)
PEC_sw_focus <- function(parent, rate, n = 1, i = NA,
@@ -81,8 +81,9 @@ PEC_sw_focus <- function(parent, rate, n = 1, i = NA,
{
if (n > 1 & is.na(i)) stop("Please specify the interval i if n > 1")
+ scenario = match.arg(scenario)
+
if (is.na(f_drift)) {
- scenario = match.arg(scenario)
f_drift = FOCUS_Step_12_scenarios$drift[scenario, "1"] / 100
# For Step 2 we would select the reduced percentiles for multiple apps:
if (n <= 8) {
@@ -128,7 +129,6 @@ PEC_sw_focus <- function(parent, rate, n = 1, i = NA,
}
on.exit(close(txt))
- scenario = match.arg(scenario)
region = match.arg(region)
season = match.arg(season)
interception = match.arg(interception)
@@ -179,10 +179,11 @@ PEC_sw_focus <- function(parent, rate, n = 1, i = NA,
reg_sea = reg_code + sea_code
}
+ scenario_safe <- sub(" /", " or", scenario)
if (is.null(met)) {
- name_input <- paste(parent$name, scenario, region, season)
+ name_input <- paste(parent$name, scenario_safe, region, season)
} else {
- name_input <- paste(met$name, scenario, region, season)
+ name_input <- paste(met$name, scenario_safe, region, season)
}
if (comment != "") name_input = paste(name_input, comment)

Contact - Imprint