diff options
35 files changed, 2428 insertions, 8 deletions
@@ -1,3 +1,87 @@ +commit 15c1b8c5ddadf938ce13d3dd9da2a09d8749f740 +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2017-01-29 16:58:53 +0100 + + Setting up PELMO runs, execution and evaluation + + It all works! + +commit bc97a35a32c4f47e29364488a3601f94c6e68d45 +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2017-01-27 18:33:45 +0100 + + Really use all scenarios in test data + + Maize, that was used in the last commit, is not parameterised for + Jokioinen + +commit a4081ddfea726283874968c0b62a7f46e4fd1232 +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2017-01-27 18:23:35 +0100 + + Use all scenarios in the test data + +commit 3c82d26206e2f2e74600acd71a49c70eaed555c4 +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2017-01-27 08:17:08 +0100 + + Also test run with metabolites + +commit 8fd050e57b7babfbdb1ccfabb468a0398396d466 +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2017-01-27 07:54:53 +0100 + + Include a run with metabolites in PELMO test data + +commit b38055278d4a801598ece9d2c93716a9bf67134a +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2017-01-27 01:00:07 +0100 + + Set up FOCUS PELMO runs and run them in parallel + + - This works on Linux using wine + - PELMO runs (including pelmo.inp files) are correctly generated + - The PLM files for FOCUS Pesticide_D in the test data archive are + correctly reproduced + - The data files (including FOCUS groundwater scenario data) are now + created and documented in R files + +commit 40c2f387775a168df1be699813807586cf098648 +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2017-01-26 10:30:32 +0100 + + Improved test data with 'irrigation' + +commit 228ab628b407af4812a48f20693a9a3a6bba8af4 +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2017-01-25 16:45:24 +0100 + + More variable selection of test data + +commit bf6634b7d9a5033a217f04060f77e0c7d5b3046a +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2017-01-25 15:27:05 +0100 + + Use tar.bz2 to correctly transfer file names + +commit 476d556cb6a490b138e47d487dd732f298aa6c3d +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2017-01-25 14:29:41 +0100 + + Add FOCUS PELMO 5.5.3 output for dummy pesticide D + +commit 9f16be247e851c948edb30ac756550d89ba0af52 +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2017-01-19 11:44:22 +0100 + + Another correction of the docs + +commit 2ab822d51c4c7e29d62076336d7a3f02a46e41a5 +Author: Johannes Ranke <jranke@uni-bremen.de> +Date: 2017-01-19 11:41:19 +0100 + + Corrections in the documentation + commit 46883a0c3a3c00127a563a7befa0af440573baaa Author: Johannes Ranke <jranke@uni-bremen.de> Date: 2017-01-19 11:22:08 +0100 diff --git a/DESCRIPTION b/DESCRIPTION index 3c96ed5..97b5962 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Package: pfm Type: Package Title: Utilities for Pesticide Fate Modelling -Version: 0.4-1 -Date: 2017-01-19 +Version: 0.4-2 +Date: 2017-01-29 Authors@R: person("Johannes Ranke", email = "jranke@uni-bremen.de", role = c("aut", "cre", "cph")) Description: Utilities for simple calculations of predicted environmental @@ -18,7 +18,9 @@ Imports: Suggests: testthat, chents, - magrittr + magrittr, + R.utils, + PELMO.installeR License: GPL LazyLoad: yes LazyData: yes @@ -11,20 +11,29 @@ S3method(plot,TOXSWA_cwa) S3method(plot,one_box) S3method(print,GUS_result) S3method(twa,one_box) +export(FOCUS_GW_scenarios_2012) +export(FOCUS_PELMO_crop_sze_names) +export(FOCUS_PELMO_crops) +export(FOCUS_PELMO_location_codes) export(GUS) export(PEC_soil) export(PEC_sw_drainage_UK) export(PEC_sw_drift) export(PEC_sw_sed) +export(PELMO_path) +export(PELMO_runs) export(SFO_actual_twa) export(SSLRC_mobility_classification) export(TOXSWA_cwa) export(endpoint) +export(evaluate_PELMO) +export(focus_80th) export(geomean) export(max_twa) export(one_box) export(pfm_degradation) export(read.TOXSWA_cwa) +export(run_PELMO) export(sawtooth) export(soil_DT50) export(soil_Kfoc) @@ -36,6 +45,7 @@ import(mkin) importFrom(R6,R6Class) importFrom(methods,is) importFrom(mkin,mkinpredict) +importFrom(parallel,mclapply) importFrom(readr,fwf_empty) importFrom(readr,read_fwf) importFrom(stats,end) @@ -45,3 +55,4 @@ importFrom(stats,plot.ts) importFrom(stats,start) importFrom(stats,time) importFrom(stats,ts) +importFrom(utils,data) diff --git a/R/FOCUS_GW_scenarios_2012.R b/R/FOCUS_GW_scenarios_2012.R index 49cf7dd..e26ea50 100644 --- a/R/FOCUS_GW_scenarios_2012.R +++ b/R/FOCUS_GW_scenarios_2012.R @@ -1,11 +1,69 @@ #' A very small subset of the FOCUS Groundwater scenario defitions #' -#' Currently, only a small subset of the soil definitions are provided. +#' Currently, only scenario names with acronyms and a small subset of the soil definitions are provided. The +#' soil definitions are from page 46ff. from FOCUS (2012). #' #' @name FOCUS_GW_scenarios_2012 #' @references FOCUS (2012) Generic guidance for Tier 1 FOCUS ground water assessments. Version 2.1. #' FOrum for the Co-ordination of pesticde fate models and their USe. #' http://focus.jrc.ec.europa.eu/gw/docs/Generic_guidance_FOCV2_1.pdf +#' @export #' @examples #' FOCUS_GW_scenarios_2012 -NULL +FOCUS_GW_scenarios_2012 = list() + +n_layers = c(7, 6, 6, 5, 5, 6, 4, 6, 6) +acronyms = c("Cha", "Ham", "Jok", "Kre", "Oke", "Pia", "Por", "Sev", "Thi") +FOCUS_GW_scenarios_2012$names = c("Ch\u00e2teaudun", "Hamburg", "Jokioinen", + "Kremsm\u00fcnster", "Okehampton", + "Piacenza", "Porto", "Sevilla", "Thiva") + +names(FOCUS_GW_scenarios_2012$names) = acronyms +FOCUS_GW_scenarios_2012$soils <- data.frame( + location= rep(acronyms, times = n_layers), + horizon = c("Ap", "B1", "B2", "II C1", "II C1", "II C2", "M", + "Ap", "BvI", "BvII", "Bv/Cv", "Cv", "Cv", + "Ap", "Bs", "BC1", "BC2", "BC2", "Cg", + rep(NA, 5), + "A", "Bw1", "BC", "C", "C", + "Ap", "Ap", "Bw", "Bw", "2C", "2C", + rep(NA, 4), + rep(NA, 6), + "Ap1", "Ap2", "Bw", "Bw", "Ck1", "Ck1"), + number = unlist(sapply(n_layers, function(x) 1:x)), + pH_H2O = c(8.0, 8.1, 8.2, 8.5, 8.5, 8.5, 8.3, + 6.4, 5.6, 5.6, 5.7, 5.5, 5.5, + 6.2, 5.6, 5.4, 5.4, 5.4, 5.3, + 7.7, 7.0, 7.1, 7.1, 7.1, + 5.8, 6.3, 6.5, 6.6, 6.6, + 7, 7, 6.3, 6.3, 6.4, 6.4, + 4.9, 4.8, 4.8, 4.8, + 7.3, 7.3, 7.8, 8.1, 8.1, 8.2, + 7.7, 7.7, 7.8, 7.8, 7.8, 7.8), + perc_clay = c(30, 31, 25, 26, 26, 24, 31, + 7.2, 6.7, 0.9, 0, 0, 0, + 3.6, 1.8, 1.2, 1.7, 1.7, 1.9, + 14, 25, 27, 27, 27, + 18, 17, 14, 9, 9, + 15, 15, 7, 7, 0, 0, + 10, 8, 8, 8, + 14, 13, 15, 16, 16, 22, + 25.3, 25.3, 29.6, 31.9, 32.9, 32.9), + perc_oc = c(1.39, 0.93, 0.7, 0.3, 0.3, 0.27, 0.21, + 1.5, 1, 0.2, 0, 0, 0, + 4.06, 0.84, 0.36, 0.29, 0.29, 0.21, + 3.6, 1.0, 0.5, 0.5, 0.5, + 2.2, 0.7, 0.4, 0.1, 0.1, + 1.26, 1.26, 0.47, 0.47, 0, 0, + 1.42, 0.78, 0.78, 0.78, + 0.93, 0.93, 0.70, 0.58, 0.58, 0.49, + 0.74, 0.74, 0.57, 0.31, 0.18, 0.18), + rel_deg = c(1, 0.5, 0.5, 0.3, 0, 0, 0, + 1, 0.5, 0.3, 0.3, 0.3, 0, + 1, 0.5, 0.3, 0.3, 0, 0, + 1, 0.5, 0.5, 0.3, 0, + 1, 0.5, 0.3, 0.3, 0, + 1, 0.5, 0.5, 0.3, 0.3, 0, + 1, 0.5, 0.3, 0, + 1, 1, 0.5, 0.3, 0, 0, + 1, 0.5, 0.5, 0.3, 0.3, 0)) diff --git a/R/FOCUS_PELMO_data.R b/R/FOCUS_PELMO_data.R new file mode 100644 index 0000000..89fe5f6 --- /dev/null +++ b/R/FOCUS_PELMO_data.R @@ -0,0 +1,90 @@ +#' FOCUS PELMO crop names +#' +#' A named character vector with the crop names used in the PELMO 5.5.3 GUI. +#' For the names, three letter codes were constructed by generally taking the +#' first three letters in lower case. Only when there is an expression in +#' parentheses, the first letter of this expression becomes the first letter +#' in the three letter code, i.e. 'Peas (animals)' has the code \code{ape}. +#' +#' @docType data +#' @export +#' @examples +#' print(FOCUS_PELMO_crops) +FOCUS_PELMO_crops = c( + app = "Apples", + gra = "Grass and alfalfa", + pot = "Potatoes", + sug = "Sugar beets", + win = "Winter cereals", + fbe = "Beans (field)", + vbe = "Beans (vegetables)", + bus = "Bushberries", + cab = "Cabbage", + car = "Carrots", + cit = "Citrus", + cot = "Cotton", + lin = "Linseed", + mai = "Maize", + soi = "Oil seed rape (summer)", + woi = "Oil seed rape (winter)", + oni = "Onions", + ape = "Peas (animals)", + soy = "Soybeans", + spr = "Spring cereals", + str = "Strawberries", + sun = "Sunflower", + tob = "Tobacco", + tom = "Tomatoes", + vin = "Vines") + +#' FOCUS PELMO crop acronyms used for naming sceneario files +#' +#' A named character vector with the crop acronyms used in FOCUS PELMO 5.5.3 +#' for naming the .sze files located in the FOCUS directory. The crop acronyms +#' in the file names are sometimes capitalized, sometimes not. The scenario +#' files used for Beans (field) and Beans (vegetable) are the same. +#' +#' @docType data +#' @export +#' @examples +#' print(FOCUS_PELMO_crop_sze_names) +FOCUS_PELMO_crop_sze_names = c( + app = "apples", + gra = "grass", + pot = "potato", + sug = "sbeets", + win = "wcerea", + fbe = "beans", + vbe = "beans", # Same sze as for fbe is used, with 'irrigation' which has no effect on the run + bus = "bushb", + cab = "cabbag", + car = "carrot", + cit = "citrus", + cot = "cotton", + lin = "linse", + mai = "maize", + soi = "rapesu", + woi = "rapewi", + oni = "onions", + ape = "peas", + soy = "soyb", + spr = "scerea", + str = "strawb", + sun = "sunflo", + tob = "tobacc", + tom = "tomato", + vin = "vines") + +#' Location codes in FOCUS PELMO +#' +#' A named character vector of one letter location codes used in FOCUS PELMO, +#' indexed by three letter acronyms. + +#' @docType data +#' @export +#' @examples +#' print(FOCUS_PELMO_location_codes) +FOCUS_PELMO_location_codes = c( + Cha = "C", Ham = "H", Jok = "J", + Kre = "K", Oke = "N", Pia = "P", + Por = "O", Sev = "S", Thi = "T") diff --git a/R/PELMO_runs.R b/R/PELMO_runs.R new file mode 100644 index 0000000..5d401ea --- /dev/null +++ b/R/PELMO_runs.R @@ -0,0 +1,416 @@ +#' Set up runs for FOCUS PELMO +#' +#' Per default, the runs are also executed with FOCUS PELMO, and the results are processed +#' and returned. Currently, only FOCUS PELMO as installed on Linux (or other Unix systems) +#' using the \code{\link{install_PELMO}} from the \code{PELMO.installeR} package +#' maintained on github is supported. In such installations, FOCUS PELMO is installed into +#' package installation directory of \code{PELMO.installeR} and run with \code{wine}. +#' +#' @param runs A list of lists. Each inner lists has an element named 'psm' +#' that holds the psm string, and elements named using three letter crop acronyms, +#' as used in \code{\link{FOCUS_PELMO_crops}}, +#' that hold character vectors of three letter scenario acronyms +#' as used in \code{\link{FOCUS_GW_scenarios_2012}}. +#' @param psm_dir The directory where the psm files are located +#' @param version The FOCUS PELMO version +#' @param PELMO_base Where the FOCUS PELMO installation is located +#' @param execute Should PELMO be executed directly? +#' @param cores The number of cores to execute PELMO runs in parallel +#' @param evaluate Should the results be returned? +#' @param overwrite Should an existing run directories be overwritten +#' @references PELMO.installeR \url{https://jranke.github.io/PELMO.installeR} +#' +#' Wine \url{https://winehq.org} +#' @export +PELMO_runs <- function(runs, psm_dir = ".", version = "5.5.3", PELMO_base = "auto", + execute = TRUE, cores = getOption("mc.cores", 2L), + evaluate = TRUE, overwrite = FALSE) +{ + if (PELMO_base[1] == "auto") { + PELMO_base = file.path(system.file(package = "PELMO.installeR"), + paste0("FOCUSPELMO.", gsub("\\.", "", version))) + } + PELMO_exe = list.files(PELMO_base, "^pelmo.*.exe", full.names = TRUE) + if (length(PELMO_exe) == 0) { + stop("Could not find PELMO executable. Did you run PELMO.installeR::install_PELMO()?") + } + + run_list <- create_run_list(runs, psm_dir = psm_dir, check_psm_files = TRUE) + + setup_run <- function(x) { + psm <- x$psm + crop <- x$crop + scenario <- x$scenario + + location_code <- FOCUS_PELMO_location_codes[scenario] + + run_dir <- file.path(PELMO_base, "FOCUS", PELMO_path(psm, crop, scenario)) + + if (dir.exists(run_dir)) { + if (overwrite) { + unlink(run_dir, recursive = TRUE) + } else { + stop("Run directory for ", crop, " in ", scenario, "\n", run_dir, "\nalready exists") + } + } + + # Create the run directory + dir.create(run_dir, recursive = TRUE) + + # Copy the psm file + psm_file <- file.path(psm_dir, paste0(psm, ".psm")) + file.copy(psm_file, run_dir) + + # Copy Haude factors + file.copy(file.path(PELMO_base, "FOCUS", "HAUDE.DAT"), file.path(run_dir, "Haude.dat")) + + # Copy scenario file + sze_file_upper <- paste0(location_code, "_", + toupper(FOCUS_PELMO_crop_sze_names[crop]), ".sze") + sze_file_lower <- paste0(location_code, "_", + FOCUS_PELMO_crop_sze_names[crop], ".sze") + if (file.exists(file.path(PELMO_base, "FOCUS", sze_file_lower))) { + sze_file <- sze_file_lower + } else { + if (file.exists(file.path(PELMO_base, "FOCUS", sze_file_upper))) { + sze_file <- sze_file_upper + } else { + stop("Could not find szenario file for ", crop, " in ", scenario) + } + } + file.copy(file.path(PELMO_base, "FOCUS", sze_file), file.path(run_dir, sze_file_lower)) + + # Generate PELMO input file + input_file <- file(file.path(run_dir, "pelmo.inp"), encoding = "latin1", open = "w+") + on.exit(close(input_file)) + + add <- function(x) cat(paste0(x, "\r\n"), file = input_file, append = TRUE) + + interval <- get_interval(psm_file, location_code) + + n_years <- switch(as.character(interval), + "1" = 26, + "2" = 46, + "3" = 66) + + # First line with number of climate years + add(paste0(formatC(n_years, width = 3, flag = "0"), + " 01 01 31 12 Version ", substr(version, 1, 1))) + + # Second line with scenario file (why did we copy it, if this line refers to the FOCUS dir... + add(paste0("..\\..\\..\\", sze_file_lower)) + + # Third line with psm file + add(basename(psm_file)) + + # Lines with climate files + for (year in 1:n_years) { + add(paste0("..\\..\\..\\", location_code, "_", formatC(year, width = 2, flag = "0"), ".cli")) + } + + # Output control section + add("00000015 00.") + add(" PRSN TSER 000.0 1.0 00000001") + add(" TETD TSER 000.0 1.0 00000001") + add(" INFL TSER 100.0 1.0 00000001") + add(" RUNF TSER 000.0 1.0 00000001") + add(" THET TSER 000.0 1.0 00000001") + add(" THET TSER 030.0 1.0 00000001") + add(" TEMP TSER 000.0 1.0 00000001") + add(" TEMP TSER 030.0 1.0 00000001") + add(" TPAP TSER 000.0 1.0E05 00000001") + add(" TDKF TSER 000.0 1.0E05 00000001") + add(" TUPF TSER 000.0 1.0E05 00000001") + add(" TPST TSER 005.0 1.0E06 00000001") + add(" PFLX TSER 100.0 1.0E05 00000001") + add(" RFLX TSER 000.0 1.0E05 00000001") + add(" LEAC TSER 100.0 1.0E09 00000001") + + # Copy pelmo executable + file.copy(PELMO_exe, run_dir) + + # In addition to the files copied by the FOCUS PELMO GUI, we + # need the error file in the run directory, as we start + # the exe file from this directory + file.copy(file.path(PELMO_base, "lf90.eer"), run_dir) + } + run_list[[7]] + setup_run(run_list[[7]]) + + lapply(run_list, setup_run) + + if (execute) { + run_PELMO(runs, version = version, PELMO_base = PELMO_base) + } + + if (evaluate) { + evaluate_PELMO(runs, version = version, PELMO_base = PELMO_base) + } +} + +#' @inheritParams PELMO_runs +#' @importFrom parallel mclapply +#' @rdname PELMO_runs +#' @export +run_PELMO <- function(runs, version = "5.5.3", PELMO_base = "auto", + cores = getOption("mc.cores", 2L)) +{ + + if (PELMO_base[1] == "auto") { + PELMO_base = file.path(system.file(package = "PELMO.installeR"), + paste0("FOCUSPELMO.", gsub("\\.", "", version))) + } + + pelmo_exe = list.files(PELMO_base, "^pelmo.*.exe") + + # Create list of runs to traverse using mclapply + run_list <- create_run_list(runs, check_psm_files = FALSE) + + # In order to run in parallel, we need to make a directory tree starting + # from the base of the PELMO installation, as pelmo401.exe seems to look + # for ..\..\..\summary.PLM and does not start if this is in use by another + # instance + run_exe <- function(x) { + psm <- x$psm + crop <- x$crop + scenario <- x$scenario + run_dir <- file.path(PELMO_base, "FOCUS", PELMO_path(psm, crop, scenario)) + exe_dir <- file.path(PELMO_base, paste(sample(c(0:9, letters, LETTERS), + size = 8, replace = TRUE), + collapse = "")) + dir.create(exe_dir) + + # Fresh PELMO base directory for every run with random name + run_dir_exe <- file.path(exe_dir, "FOCUS", PELMO_path(psm, crop, scenario)) + dir.create(run_dir_exe, recursive = TRUE) + + # Copy the contents of the run directory + run_files <- list.files(run_dir, full.names = TRUE) + file.copy(run_files, run_dir_exe) + + # Copy FOCUS files + location_code <- FOCUS_PELMO_location_codes[x$scenario] + location_files <- list.files(file.path(PELMO_base, "FOCUS"), paste0("^", location_code), + full.names = TRUE) + focus_dir_exe <- file.path(exe_dir, "FOCUS") + file.copy(location_files, focus_dir_exe) + file.copy(file.path(PELMO_base, "FOCUS", "FOCUSCHECK.DAT"), focus_dir_exe) + + # We need to go the directory to simplify calling pelmo with wine + setwd(run_dir_exe) + psm_file <- paste0(psm, ".psm") + message("Starting ", pelmo_exe, " with ", psm_file) + system(paste("wine", pelmo_exe, psm_file), ignore.stdout = TRUE) + + # Copy the results to the original run directory + plm_files <- list.files(run_dir_exe, ".plm$", full.names = TRUE) + PLM_files <- list.files(run_dir_exe, ".PLM$", full.names = TRUE) + file.copy(c(plm_files, PLM_files), run_dir) + + # Clean up + unlink(exe_dir, recursive = TRUE) + } + + mclapply(run_list, run_exe, mc.cores = cores) +} + +#' Create a path of run directories as the PELMO GUI does +#' +#' @export +#' @importFrom utils data +#' @param psm The psm identifier +#' @param crop The PELMO crop acronym +#' @param scenario The scenario +PELMO_path <- function(psm, crop, scenario) { + if (crop %in% names(FOCUS_PELMO_crops)) { + crop <- FOCUS_PELMO_crops[crop] + } + if (!crop %in% FOCUS_PELMO_crops) stop(crop, " is not in FOCUS_PELMO_crops.") + psm_dir <- paste0(psm, ".run") + crop_dir <- paste0(gsub(" ", "_-_", crop), ".run") + + # Deal with 'irrigation'. It only affects the naming of the scenario directory, + # but it does not appear to affect the PELMO run. This can be seen when + # comparing runs set up for Beans (field) and Beans (vegetable) for the Porto + # scenario + irrigation_string <- "" + + # 'Irrigation' is only possible in the GUI for five scenarios + if (scenario %in% c("Cha", "Pia", "Por", "Sev", "Thi")) { + crop_acronyms <- names(FOCUS_PELMO_crops) + names(crop_acronyms) <- FOCUS_PELMO_crops + crop_acronym <- crop_acronyms[[crop]] + # Some crops are not 'irrigated' according to the GUI + if (crop_acronym %in% c("win", "fbe", "woi", "ape", "spr")) { + irrigation_string <- "--_-_no_-_irrigation" + } else { + irrigation_string <- "--_-_irrigated" + } + } + + scenario_dir <- paste0( + FOCUS_GW_scenarios_2012$names[scenario], "_-_(", FOCUS_PELMO_location_codes[scenario], ")", + irrigation_string, ".run") + + return(file.path(psm_dir, crop_dir, scenario_dir)) +} + +#' Create a list of runs that we can traverse +#' +#' @inheritParams PELMO_runs +#' @param check_psm_files Should we check if the psm file exists +create_run_list <- function(runs, psm_dir = ".", check_psm_files = FALSE) { + i <- 0 + run_list <- list() + for (run in runs) { + psm <- run$psm + if (check_psm_files) { + psm_file <- file.path(psm_dir, paste0(psm, ".psm")) + if (file.access(psm_file) == -1) { + stop(psm_file, " is not readable") + } + } + crops <- setdiff(names(run), "psm") + for (crop in crops) { + crop_acronyms <- names(FOCUS_PELMO_crops) + names(crop_acronyms) <- FOCUS_PELMO_crops + if (!crop %in% crop_acronyms) { + if (crop %in% FOCUS_PELMO_crops) { + crop <- crop_acronyms[crop] + } else { + stop("Invalid crop specification ", crop) + } + } + for (scenario in run[[crop]]) { + i <- i + 1 + run_list[[i]] <- list(psm = psm, crop = crop, scenario = scenario) + } + } + } + return(run_list) +} + +#' @rdname PELMO_runs +#' @inheritParams PELMO_runs +#' @importFrom parallel mclapply +#' @export +evaluate_PELMO <- function(runs, version = "5.5.3", PELMO_base = "auto") +{ + + if (PELMO_base[1] == "auto") { + PELMO_base = file.path(system.file(package = "PELMO.installeR"), + paste0("FOCUSPELMO.", gsub("\\.", "", version))) + } + + for (run in runs) { + psm <- run$psm + crops <- setdiff(names(run), "psm") + for (crop in crops) { + for (scenario in run[[crop]]) { + run_dir <- file.path(PELMO_base, "FOCUS", PELMO_path(psm, crop, scenario)) + echo_file <- readLines(file.path(run_dir, "ECHO.PLM"), encoding = "latin1") + parm_lines <- grep("\\*\\*\\* PARAMETERS OF", echo_file, value = TRUE) + acronyms <- gsub(".*\\((.*)\\).*", "\\1", parm_lines) + met_codes <- gsub(".*METABOLITE (..).*", "\\1", parm_lines) + met_codes[1] <- NA + names(met_codes) <- acronyms + + psm_file <- file.path(run_dir, paste0(psm, ".psm")) + location_code <- FOCUS_PELMO_location_codes[scenario] + interval <- get_interval(psm_file, location_code) + + # Get percolate for each period + wasser <- readLines(file.path(run_dir, "WASSER.PLM")) + percolate_lines <- grep("RECHARGE BELOW ROOT ZONE", wasser, value = TRUE) + percolate <- as.numeric(substr(percolate_lines, 40, 46)) + percolate_period <- sum_periods(percolate, interval) + + # Set up results that should match period.plm generated by the PELMO GUI + results_pfm <- list() + for (acronym in acronyms) { + results_pfm[[acronym]] <- list() + periods <- data.frame( + period = 1:20, + flux = NA, + percolate = 10 * percolate_period, + conc = NA) + + if (is.na(met_codes[acronym])) { + chem_file <- file.path(run_dir, "CHEM.PLM") + } else { + chem_file <- file.path(run_dir, paste0("CHEM_", met_codes[acronym], ".PLM")) + } + + annual_flux <- get_flux(chem_file) + periods$flux <- sum_periods(annual_flux, interval) * 1000 + + periods$conc <- 100 * periods$flux / periods$percolate + + results_pfm[[acronym]]$periods <- periods + results_pfm[[acronym]]$focus <- focus_80th(periods$conc) + } + save(results_pfm, file = file.path(run_dir, "period_pfm.rda")) + } + } + } +} + +#' Get the application interval in years from a psm file +get_interval <- function(psm_file, location_code) { + # How many years do we calculate (26, 46 or 66)? + psm <- readLines(psm_file, encoding = "latin1") + number_of_apps_lines <- grep("number of application location", psm) + absolute_apps_line <- grep(location_code, + psm[number_of_apps_lines]) + interval <- 1 # application every year + if (length(absolute_apps_line) == 1) { + apps_root <- number_of_apps_lines[absolute_apps_line] + } else { + apps_root <- number_of_apps_lines[1] + } + + number_of_apps <- as.integer(substr(psm[apps_root], 1, 3)) + last_app_line <- psm[apps_root + number_of_apps] + last_app_year <- as.integer(gsub("^.{2,3} .. (..) .*", "\\1", + last_app_line)) + if (last_app_year > 26) interval <- 2 + if (last_app_year > 46) interval <- 3 + return(interval) +} + +#' Sum up values according to FOCUS periods +sum_periods <- function(annual, interval) { + n_years <- switch(as.character(interval), + "1" = 26, + "2" = 46, + "3" = 66) + period_start_years <- seq(from = 7, to = n_years, by = interval) + sapply(1:20, function(x) { + years_i <- period_start_years[x] + (0 : (interval - 1)) + sum(annual[years_i]) + }) +} + +#' Get the flux of a chemical out of the FOCUS layer from a CHEM*.PLM file +get_flux <- function(chem_file) { + chem <- readLines(chem_file) + lowest_focus_comp_lines <- grep("^ . 21 ", chem, value = TRUE) + lowest_focus_comp <- read.table(text = lowest_focus_comp_lines) + return(lowest_focus_comp$V9) +} + +#' Calculate the 80th percentile according to FOCUS guidance +#' +#' This is nowadays defined as the mean of the 16th and the 17th +#' highest value. Previously, the 17th highest values was used (FOCUS 2014, p. +#' 18). NaN values need to be set to zero in order to reproduce the +#' values obtained by PELMO. +#' @param c_period A numeric vector of values to calculate the percentile from +#' @param old Should the old calculation method be used (the 17th highest value)? +#' @export +focus_80th <- function(c_period, old = FALSE) { + c_period <- ifelse(is.na(c_period), 0, c_period) + c_period_sorted <- sort(c_period) + if (old) return(c_period_sorted[17]) + else return(mean(c_period_sorted[c(16, 17)])) +} diff --git a/_pkgdown.yml b/_pkgdown.yml index ff5f43d..829ba48 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -17,6 +17,9 @@ reference: contents: - PEC_soil - soil_scenario_data_EFSA_2015 + - title: Predicted environmental concentrations in groundwater + contents: + - PELMO_runs - title: Predicted environmental concentrations in surface water contents: - PEC_sw_drift diff --git a/data/FOCUS_GW_scenarios_2012.RData b/data/FOCUS_GW_scenarios_2012.RData Binary files differdeleted file mode 100644 index 4b2622e..0000000 --- a/data/FOCUS_GW_scenarios_2012.RData +++ /dev/null diff --git a/docs/reference/FOCUS_GW_scenarios_2012.html b/docs/reference/FOCUS_GW_scenarios_2012.html index 64b42e9..fbc1649 100644 --- a/docs/reference/FOCUS_GW_scenarios_2012.html +++ b/docs/reference/FOCUS_GW_scenarios_2012.html @@ -70,10 +70,16 @@ </div> - <p>Currently, only a small subset of the soil definitions are provided.</p> + <p>Currently, only scenario names with acronyms and a small subset of the soil definitions are provided. The +soil definitions are from page 46ff. from FOCUS (2012).</p> + <pre><span class='no'>FOCUS_GW_scenarios_2012</span></pre> + <h2 class="hasAnchor" id="format"><a class="anchor" href="#format"></a>Format</h2> + + <p>An object of class <code>list</code> of length 2.</p> + <h2 class="hasAnchor" id="references"><a class="anchor" href="#references"></a>References</h2> <p>FOCUS (2012) Generic guidance for Tier 1 FOCUS ground water assessments. Version 2.1. @@ -147,6 +153,8 @@ <h2>Contents</h2> <ul class="nav nav-pills nav-stacked"> + <li><a href="#format">Format</a></li> + <li><a href="#references">References</a></li> <li><a href="#examples">Examples</a></li> diff --git a/docs/reference/FOCUS_PELMO_crop_sze_names.html b/docs/reference/FOCUS_PELMO_crop_sze_names.html new file mode 100644 index 0000000..5777868 --- /dev/null +++ b/docs/reference/FOCUS_PELMO_crop_sze_names.html @@ -0,0 +1,121 @@ +<!-- Generated by pkgdown: do not edit by hand --> +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta http-equiv="X-UA-Compatible" content="IE=edge"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> + +<title>FOCUS PELMO crop acronyms used for naming sceneario files — FOCUS_PELMO_crop_sze_names • pfm</title> + +<!-- jquery --> +<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script> +<!-- Bootstrap --> + +<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> +<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> + +<!-- Font Awesome icons --> +<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous"> + + +<!-- pkgdown --> +<link href="../pkgdown.css" rel="stylesheet"> +<script src="../jquery.sticky-kit.min.js"></script> +<script src="../pkgdown.js"></script> + +<!-- mathjax --> +<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> + +<!--[if lt IE 9]> +<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> +<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> +<![endif]--> + </head> + + <body> + <div class="container template-reference-topic"> + <header> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../index.html">pfm</a> + </div> + <div id="navbar" class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li> + <a href="../reference/index.html">Reference</a> +</li> + </ul> + + <ul class="nav navbar-nav navbar-right"> + + </ul> + </div><!--/.nav-collapse --> + </div><!--/.container --> +</div><!--/.navbar --> + + + </header> + + <div class="row"> + <div class="col-md-9 contents"> + <div class="page-header"> + <h1>FOCUS PELMO crop acronyms used for naming sceneario files</h1> + </div> + + + <p>A named character vector with the crop acronyms used in FOCUS PELMO 5.5.3 +for naming the .sze files located in the FOCUS directory. The crop acronyms +in the file names are sometimes capitalized, sometimes not. The scenario +files used for Beans (field) and Beans (vegetable) are the same.</p> + + + <pre><span class='no'>FOCUS_PELMO_crop_sze_names</span></pre> + + <h2 class="hasAnchor" id="format"><a class="anchor" href="#format"></a>Format</h2> + + <p>An object of class <code>character</code> of length 25.</p> + + + <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> + <pre class="examples"><div class='input'><span class='fu'>print</span>(<span class='no'>FOCUS_PELMO_crop_sze_names</span>)</div><div class='output co'>#> app gra pot sug win fbe vbe bus +#> "apples" "grass" "potato" "sbeets" "wcerea" "beans" "beans" "bushb" +#> cab car cit cot lin mai soi woi +#> "cabbag" "carrot" "citrus" "cotton" "linse" "maize" "rapesu" "rapewi" +#> oni ape soy spr str sun tob tom +#> "onions" "peas" "soyb" "scerea" "strawb" "sunflo" "tobacc" "tomato" +#> vin +#> "vines" </div></pre> + </div> + <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> + <h2>Contents</h2> + <ul class="nav nav-pills nav-stacked"> + + <li><a href="#format">Format</a></li> + + <li><a href="#examples">Examples</a></li> + </ul> + + </div> +</div> + + <footer> + <div class="copyright"> + <p>Developed by Johannes Ranke.</p> +</div> + +<div class="pkgdown"> + <p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p> +</div> + + </footer> + </div> + + </body> +</html> diff --git a/docs/reference/FOCUS_PELMO_crops.html b/docs/reference/FOCUS_PELMO_crops.html new file mode 100644 index 0000000..d9ad8d2 --- /dev/null +++ b/docs/reference/FOCUS_PELMO_crops.html @@ -0,0 +1,132 @@ +<!-- Generated by pkgdown: do not edit by hand --> +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta http-equiv="X-UA-Compatible" content="IE=edge"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> + +<title>FOCUS PELMO crop names — FOCUS_PELMO_crops • pfm</title> + +<!-- jquery --> +<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script> +<!-- Bootstrap --> + +<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> +<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> + +<!-- Font Awesome icons --> +<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous"> + + +<!-- pkgdown --> +<link href="../pkgdown.css" rel="stylesheet"> +<script src="../jquery.sticky-kit.min.js"></script> +<script src="../pkgdown.js"></script> + +<!-- mathjax --> +<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> + +<!--[if lt IE 9]> +<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> +<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> +<![endif]--> + </head> + + <body> + <div class="container template-reference-topic"> + <header> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../index.html">pfm</a> + </div> + <div id="navbar" class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li> + <a href="../reference/index.html">Reference</a> +</li> + </ul> + + <ul class="nav navbar-nav navbar-right"> + + </ul> + </div><!--/.nav-collapse --> + </div><!--/.container --> +</div><!--/.navbar --> + + + </header> + + <div class="row"> + <div class="col-md-9 contents"> + <div class="page-header"> + <h1>FOCUS PELMO crop names</h1> + </div> + + + <p>A named character vector with the crop names used in the PELMO 5.5.3 GUI. +For the names, three letter codes were constructed by generally taking the +first three letters in lower case. Only when there is an expression in +parentheses, the first letter of this expression becomes the first letter +in the three letter code, i.e. 'Peas (animals)' has the code <code>ape</code>.</p> + + + <pre><span class='no'>FOCUS_PELMO_crops</span></pre> + + <h2 class="hasAnchor" id="format"><a class="anchor" href="#format"></a>Format</h2> + + <p>An object of class <code>character</code> of length 25.</p> + + + <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> + <pre class="examples"><div class='input'><span class='fu'>print</span>(<span class='no'>FOCUS_PELMO_crops</span>)</div><div class='output co'>#> app gra pot +#> "Apples" "Grass and alfalfa" "Potatoes" +#> sug win fbe +#> "Sugar beets" "Winter cereals" "Beans (field)" +#> vbe bus cab +#> "Beans (vegetables)" "Bushberries" "Cabbage" +#> car cit cot +#> "Carrots" "Citrus" "Cotton" +#> lin mai soi +#> "Linseed" "Maize" "Oil seed rape (summer)" +#> woi oni ape +#> "Oil seed rape (winter)" "Onions" "Peas (animals)" +#> soy spr str +#> "Soybeans" "Spring cereals" "Strawberries" +#> sun tob tom +#> "Sunflower" "Tobacco" "Tomatoes" +#> vin +#> "Vines" </div></pre> + </div> + <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> + <h2>Contents</h2> + <ul class="nav nav-pills nav-stacked"> + + <li><a href="#format">Format</a></li> + + <li><a href="#examples">Examples</a></li> + </ul> + + </div> +</div> + + <footer> + <div class="copyright"> + <p>Developed by Johannes Ranke.</p> +</div> + +<div class="pkgdown"> + <p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p> +</div> + + </footer> + </div> + + </body> +</html> diff --git a/docs/reference/FOCUS_PELMO_location_codes.html b/docs/reference/FOCUS_PELMO_location_codes.html new file mode 100644 index 0000000..8051d42 --- /dev/null +++ b/docs/reference/FOCUS_PELMO_location_codes.html @@ -0,0 +1,113 @@ +<!-- Generated by pkgdown: do not edit by hand --> +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta http-equiv="X-UA-Compatible" content="IE=edge"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> + +<title>Location codes in FOCUS PELMO — FOCUS_PELMO_location_codes • pfm</title> + +<!-- jquery --> +<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script> +<!-- Bootstrap --> + +<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> +<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> + +<!-- Font Awesome icons --> +<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous"> + + +<!-- pkgdown --> +<link href="../pkgdown.css" rel="stylesheet"> +<script src="../jquery.sticky-kit.min.js"></script> +<script src="../pkgdown.js"></script> + +<!-- mathjax --> +<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> + +<!--[if lt IE 9]> +<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> +<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> +<![endif]--> + </head> + + <body> + <div class="container template-reference-topic"> + <header> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../index.html">pfm</a> + </div> + <div id="navbar" class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li> + <a href="../reference/index.html">Reference</a> +</li> + </ul> + + <ul class="nav navbar-nav navbar-right"> + + </ul> + </div><!--/.nav-collapse --> + </div><!--/.container --> +</div><!--/.navbar --> + + + </header> + + <div class="row"> + <div class="col-md-9 contents"> + <div class="page-header"> + <h1>Location codes in FOCUS PELMO</h1> + </div> + + + <p>A named character vector of one letter location codes used in FOCUS PELMO, +indexed by three letter acronyms.</p> + + + <pre><span class='no'>FOCUS_PELMO_location_codes</span></pre> + + <h2 class="hasAnchor" id="format"><a class="anchor" href="#format"></a>Format</h2> + + <p>An object of class <code>character</code> of length 9.</p> + + + <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2> + <pre class="examples"><div class='input'><span class='fu'>print</span>(<span class='no'>FOCUS_PELMO_location_codes</span>)</div><div class='output co'>#> Cha Ham Jok Kre Oke Pia Por Sev Thi +#> "C" "H" "J" "K" "N" "P" "O" "S" "T" </div></pre> + </div> + <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> + <h2>Contents</h2> + <ul class="nav nav-pills nav-stacked"> + + <li><a href="#format">Format</a></li> + + <li><a href="#examples">Examples</a></li> + </ul> + + </div> +</div> + + <footer> + <div class="copyright"> + <p>Developed by Johannes Ranke.</p> +</div> + +<div class="pkgdown"> + <p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p> +</div> + + </footer> + </div> + + </body> +</html> diff --git a/docs/reference/PELMO_path.html b/docs/reference/PELMO_path.html new file mode 100644 index 0000000..79aa89d --- /dev/null +++ b/docs/reference/PELMO_path.html @@ -0,0 +1,112 @@ +<!-- Generated by pkgdown: do not edit by hand --> +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta http-equiv="X-UA-Compatible" content="IE=edge"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> + +<title>Create a path of run directories as the PELMO GUI does — PELMO_path • pfm</title> + +<!-- jquery --> +<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script> +<!-- Bootstrap --> + +<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> +<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> + +<!-- Font Awesome icons --> +<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous"> + + +<!-- pkgdown --> +<link href="../pkgdown.css" rel="stylesheet"> +<script src="../jquery.sticky-kit.min.js"></script> +<script src="../pkgdown.js"></script> + +<!-- mathjax --> +<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> + +<!--[if lt IE 9]> +<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> +<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> +<![endif]--> + </head> + + <body> + <div class="container template-reference-topic"> + <header> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../index.html">pfm</a> + </div> + <div id="navbar" class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li> + <a href="../reference/index.html">Reference</a> +</li> + </ul> + + <ul class="nav navbar-nav navbar-right"> + + </ul> + </div><!--/.nav-collapse --> + </div><!--/.container --> +</div><!--/.navbar --> + + + </header> + + <div class="row"> + <div class="col-md-9 contents"> + <div class="page-header"> + <h1>Create a path of run directories as the PELMO GUI does</h1> + </div> + + + <p>Create a path of run directories as the PELMO GUI does</p> + + + <pre><span class='fu'>PELMO_path</span>(<span class='no'>psm</span>, <span class='no'>crop</span>, <span class='no'>scenario</span>)</pre> + + <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a> Arguments</h2> + <dl class="dl-horizontal"> + <dt>psm</dt> + <dd>The psm identifier</dd> + <dt>crop</dt> + <dd>The PELMO crop acronym</dd> + <dt>scenario</dt> + <dd>The scenario</dd> + </dl> + + + </div> + <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> + <h2>Contents</h2> + <ul class="nav nav-pills nav-stacked"> + <li><a href="#arguments">Arguments</a></li> + </ul> + + </div> +</div> + + <footer> + <div class="copyright"> + <p>Developed by Johannes Ranke.</p> +</div> + +<div class="pkgdown"> + <p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p> +</div> + + </footer> + </div> + + </body> +</html> diff --git a/docs/reference/PELMO_runs.html b/docs/reference/PELMO_runs.html new file mode 100644 index 0000000..e872196 --- /dev/null +++ b/docs/reference/PELMO_runs.html @@ -0,0 +1,144 @@ +<!-- Generated by pkgdown: do not edit by hand --> +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta http-equiv="X-UA-Compatible" content="IE=edge"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> + +<title>Set up runs for FOCUS PELMO — PELMO_runs • pfm</title> + +<!-- jquery --> +<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script> +<!-- Bootstrap --> + +<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> +<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> + +<!-- Font Awesome icons --> +<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous"> + + +<!-- pkgdown --> +<link href="../pkgdown.css" rel="stylesheet"> +<script src="../jquery.sticky-kit.min.js"></script> +<script src="../pkgdown.js"></script> + +<!-- mathjax --> +<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> + +<!--[if lt IE 9]> +<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> +<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> +<![endif]--> + </head> + + <body> + <div class="container template-reference-topic"> + <header> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../index.html">pfm</a> + </div> + <div id="navbar" class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li> + <a href="../reference/index.html">Reference</a> +</li> + </ul> + + <ul class="nav navbar-nav navbar-right"> + + </ul> + </div><!--/.nav-collapse --> + </div><!--/.container --> +</div><!--/.navbar --> + + + </header> + + <div class="row"> + <div class="col-md-9 contents"> + <div class="page-header"> + <h1>Set up runs for FOCUS PELMO</h1> + </div> + + + <p>Per default, the runs are also executed with FOCUS PELMO, and the results are processed +and returned. Currently, only FOCUS PELMO as installed on Linux (or other Unix systems) +using the <code>install_PELMO</code> from the <code>PELMO.installeR</code> package +maintained on github is supported. In such installations, FOCUS PELMO is installed into +package installation directory of <code>PELMO.installeR</code> and run with <code>wine</code>.</p> + + + <pre><span class='fu'>PELMO_runs</span>(<span class='no'>runs</span>, <span class='kw'>psm_dir</span> <span class='kw'>=</span> <span class='st'>"."</span>, <span class='kw'>version</span> <span class='kw'>=</span> <span class='st'>"5.5.3"</span>, <span class='kw'>PELMO_base</span> <span class='kw'>=</span> <span class='st'>"auto"</span>, + <span class='kw'>execute</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>cores</span> <span class='kw'>=</span> <span class='fu'>getOption</span>(<span class='st'>"mc.cores"</span>, <span class='fl'>2L</span>), <span class='kw'>evaluate</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, + <span class='kw'>overwrite</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>) + +<span class='fu'>run_PELMO</span>(<span class='no'>runs</span>, <span class='kw'>version</span> <span class='kw'>=</span> <span class='st'>"5.5.3"</span>, <span class='kw'>PELMO_base</span> <span class='kw'>=</span> <span class='st'>"auto"</span>, + <span class='kw'>cores</span> <span class='kw'>=</span> <span class='fu'>getOption</span>(<span class='st'>"mc.cores"</span>, <span class='fl'>2L</span>)) + +<span class='fu'>evaluate_PELMO</span>(<span class='no'>runs</span>, <span class='kw'>version</span> <span class='kw'>=</span> <span class='st'>"5.5.3"</span>, <span class='kw'>PELMO_base</span> <span class='kw'>=</span> <span class='st'>"auto"</span>)</pre> + + <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a> Arguments</h2> + <dl class="dl-horizontal"> + <dt>runs</dt> + <dd>A list of lists. Each inner lists has an element named 'psm' +that holds the psm string, and elements named using three letter crop acronyms, +as used in <code><a href='FOCUS_PELMO_crops.html'>FOCUS_PELMO_crops</a></code>, +that hold character vectors of three letter scenario acronyms +as used in <code><a href='FOCUS_GW_scenarios_2012.html'>FOCUS_GW_scenarios_2012</a></code>.</dd> + <dt>psm_dir</dt> + <dd>The directory where the psm files are located</dd> + <dt>version</dt> + <dd>The FOCUS PELMO version</dd> + <dt>PELMO_base</dt> + <dd>Where the FOCUS PELMO installation is located</dd> + <dt>execute</dt> + <dd>Should PELMO be executed directly?</dd> + <dt>cores</dt> + <dd>The number of cores to execute PELMO runs in parallel</dd> + <dt>evaluate</dt> + <dd>Should the results be returned?</dd> + <dt>overwrite</dt> + <dd>Should an existing run directories be overwritten</dd> + </dl> + + <h2 class="hasAnchor" id="references"><a class="anchor" href="#references"></a>References</h2> + + <p>PELMO.installeR <a href = 'https://jranke.github.io/PELMO.installeR'>https://jranke.github.io/PELMO.installeR</a></p> + <p>Wine <a href = 'https://winehq.org'>https://winehq.org</a></p> + + + </div> + <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> + <h2>Contents</h2> + <ul class="nav nav-pills nav-stacked"> + <li><a href="#arguments">Arguments</a></li> + + <li><a href="#references">References</a></li> + </ul> + + </div> +</div> + + <footer> + <div class="copyright"> + <p>Developed by Johannes Ranke.</p> +</div> + +<div class="pkgdown"> + <p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p> +</div> + + </footer> + </div> + + </body> +</html> diff --git a/docs/reference/create_run_list.html b/docs/reference/create_run_list.html new file mode 100644 index 0000000..b2c9798 --- /dev/null +++ b/docs/reference/create_run_list.html @@ -0,0 +1,116 @@ +<!-- Generated by pkgdown: do not edit by hand --> +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta http-equiv="X-UA-Compatible" content="IE=edge"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> + +<title>Create a list of runs that we can traverse — create_run_list • pfm</title> + +<!-- jquery --> +<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script> +<!-- Bootstrap --> + +<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> +<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> + +<!-- Font Awesome icons --> +<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous"> + + +<!-- pkgdown --> +<link href="../pkgdown.css" rel="stylesheet"> +<script src="../jquery.sticky-kit.min.js"></script> +<script src="../pkgdown.js"></script> + +<!-- mathjax --> +<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> + +<!--[if lt IE 9]> +<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> +<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> +<![endif]--> + </head> + + <body> + <div class="container template-reference-topic"> + <header> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../index.html">pfm</a> + </div> + <div id="navbar" class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li> + <a href="../reference/index.html">Reference</a> +</li> + </ul> + + <ul class="nav navbar-nav navbar-right"> + + </ul> + </div><!--/.nav-collapse --> + </div><!--/.container --> +</div><!--/.navbar --> + + + </header> + + <div class="row"> + <div class="col-md-9 contents"> + <div class="page-header"> + <h1>Create a list of runs that we can traverse</h1> + </div> + + + <p>Create a list of runs that we can traverse</p> + + + <pre><span class='fu'>create_run_list</span>(<span class='no'>runs</span>, <span class='kw'>psm_dir</span> <span class='kw'>=</span> <span class='st'>"."</span>, <span class='kw'>check_psm_files</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</pre> + + <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a> Arguments</h2> + <dl class="dl-horizontal"> + <dt>runs</dt> + <dd>A list of lists. Each inner lists has an element named 'psm' +that holds the psm string, and elements named using three letter crop acronyms, +as used in <code><a href='FOCUS_PELMO_crops.html'>FOCUS_PELMO_crops</a></code>, +that hold character vectors of three letter scenario acronyms +as used in <code><a href='FOCUS_GW_scenarios_2012.html'>FOCUS_GW_scenarios_2012</a></code>.</dd> + <dt>psm_dir</dt> + <dd>The directory where the psm files are located</dd> + <dt>check_psm_files</dt> + <dd>Should we check if the psm file exists</dd> + </dl> + + + </div> + <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> + <h2>Contents</h2> + <ul class="nav nav-pills nav-stacked"> + <li><a href="#arguments">Arguments</a></li> + </ul> + + </div> +</div> + + <footer> + <div class="copyright"> + <p>Developed by Johannes Ranke.</p> +</div> + +<div class="pkgdown"> + <p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p> +</div> + + </footer> + </div> + + </body> +</html> diff --git a/docs/reference/evaluate_PELMO.html b/docs/reference/evaluate_PELMO.html new file mode 100644 index 0000000..58e7843 --- /dev/null +++ b/docs/reference/evaluate_PELMO.html @@ -0,0 +1,116 @@ +<!-- Generated by pkgdown: do not edit by hand --> +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta http-equiv="X-UA-Compatible" content="IE=edge"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> + +<title>Evaluate PELMO runs — evaluate_PELMO • pfm</title> + +<!-- jquery --> +<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script> +<!-- Bootstrap --> + +<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> +<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> + +<!-- Font Awesome icons --> +<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous"> + + +<!-- pkgdown --> +<link href="../pkgdown.css" rel="stylesheet"> +<script src="../jquery.sticky-kit.min.js"></script> +<script src="../pkgdown.js"></script> + +<!-- mathjax --> +<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> + +<!--[if lt IE 9]> +<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> +<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> +<![endif]--> + </head> + + <body> + <div class="container template-reference-topic"> + <header> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../index.html">pfm</a> + </div> + <div id="navbar" class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li> + <a href="../reference/index.html">Reference</a> +</li> + </ul> + + <ul class="nav navbar-nav navbar-right"> + + </ul> + </div><!--/.nav-collapse --> + </div><!--/.container --> +</div><!--/.navbar --> + + + </header> + + <div class="row"> + <div class="col-md-9 contents"> + <div class="page-header"> + <h1>Evaluate PELMO runs</h1> + </div> + + + <p>Evaluate PELMO runs</p> + + + <pre><span class='fu'>evaluate_PELMO</span>(<span class='no'>runs</span>, <span class='kw'>version</span> <span class='kw'>=</span> <span class='st'>"5.5.3"</span>, <span class='kw'>PELMO_base</span> <span class='kw'>=</span> <span class='st'>"auto"</span>)</pre> + + <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a> Arguments</h2> + <dl class="dl-horizontal"> + <dt>runs</dt> + <dd>A list of lists. Each inner lists has an element named 'psm' +that holds the psm string, and elements named using three letter crop acronyms, +as used in <code><a href='FOCUS_PELMO_crops.html'>FOCUS_PELMO_crops</a></code>, +that hold character vectors of three letter scenario acronyms +as used in <code><a href='FOCUS_GW_scenarios_2012.html'>FOCUS_GW_scenarios_2012</a></code>.</dd> + <dt>version</dt> + <dd>The FOCUS PELMO version</dd> + <dt>PELMO_base</dt> + <dd>Where the FOCUS PELMO installation is located</dd> + </dl> + + + </div> + <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> + <h2>Contents</h2> + <ul class="nav nav-pills nav-stacked"> + <li><a href="#arguments">Arguments</a></li> + </ul> + + </div> +</div> + + <footer> + <div class="copyright"> + <p>Developed by Johannes Ranke.</p> +</div> + +<div class="pkgdown"> + <p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p> +</div> + + </footer> + </div> + + </body> +</html> diff --git a/docs/reference/focus_80th.html b/docs/reference/focus_80th.html new file mode 100644 index 0000000..8160746 --- /dev/null +++ b/docs/reference/focus_80th.html @@ -0,0 +1,113 @@ +<!-- Generated by pkgdown: do not edit by hand --> +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta http-equiv="X-UA-Compatible" content="IE=edge"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> + +<title>Calculate the 80th percentile according to FOCUS guidance — focus_80th • pfm</title> + +<!-- jquery --> +<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script> +<!-- Bootstrap --> + +<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> +<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> + +<!-- Font Awesome icons --> +<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous"> + + +<!-- pkgdown --> +<link href="../pkgdown.css" rel="stylesheet"> +<script src="../jquery.sticky-kit.min.js"></script> +<script src="../pkgdown.js"></script> + +<!-- mathjax --> +<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> + +<!--[if lt IE 9]> +<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> +<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> +<![endif]--> + </head> + + <body> + <div class="container template-reference-topic"> + <header> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../index.html">pfm</a> + </div> + <div id="navbar" class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li> + <a href="../reference/index.html">Reference</a> +</li> + </ul> + + <ul class="nav navbar-nav navbar-right"> + + </ul> + </div><!--/.nav-collapse --> + </div><!--/.container --> +</div><!--/.navbar --> + + + </header> + + <div class="row"> + <div class="col-md-9 contents"> + <div class="page-header"> + <h1>Calculate the 80th percentile according to FOCUS guidance</h1> + </div> + + + <p>This is nowadays defined as the mean of the 16th and the 17th +highest value. Previously, the 17th highest values was used (FOCUS 2014, p. +18). NaN values need to be set to zero in order to reproduce the +values obtained by PELMO.</p> + + + <pre><span class='fu'>focus_80th</span>(<span class='no'>c_period</span>, <span class='kw'>old</span> <span class='kw'>=</span> <span class='fl'>FALSE</span>)</pre> + + <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a> Arguments</h2> + <dl class="dl-horizontal"> + <dt>c_period</dt> + <dd>A numeric vector of values to calculate the percentile from</dd> + <dt>old</dt> + <dd>Should the old calculation method be used (the 17th highest value)?</dd> + </dl> + + + </div> + <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> + <h2>Contents</h2> + <ul class="nav nav-pills nav-stacked"> + <li><a href="#arguments">Arguments</a></li> + </ul> + + </div> +</div> + + <footer> + <div class="copyright"> + <p>Developed by Johannes Ranke.</p> +</div> + +<div class="pkgdown"> + <p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p> +</div> + + </footer> + </div> + + </body> +</html> diff --git a/docs/reference/get_flux.html b/docs/reference/get_flux.html new file mode 100644 index 0000000..64ea25e --- /dev/null +++ b/docs/reference/get_flux.html @@ -0,0 +1,101 @@ +<!-- Generated by pkgdown: do not edit by hand --> +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta http-equiv="X-UA-Compatible" content="IE=edge"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> + +<title>Get the flux of a chemical out of the FOCUS layer from a CHEM*.PLM file — get_flux • pfm</title> + +<!-- jquery --> +<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script> +<!-- Bootstrap --> + +<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> +<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> + +<!-- Font Awesome icons --> +<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous"> + + +<!-- pkgdown --> +<link href="../pkgdown.css" rel="stylesheet"> +<script src="../jquery.sticky-kit.min.js"></script> +<script src="../pkgdown.js"></script> + +<!-- mathjax --> +<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> + +<!--[if lt IE 9]> +<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> +<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> +<![endif]--> + </head> + + <body> + <div class="container template-reference-topic"> + <header> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../index.html">pfm</a> + </div> + <div id="navbar" class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li> + <a href="../reference/index.html">Reference</a> +</li> + </ul> + + <ul class="nav navbar-nav navbar-right"> + + </ul> + </div><!--/.nav-collapse --> + </div><!--/.container --> +</div><!--/.navbar --> + + + </header> + + <div class="row"> + <div class="col-md-9 contents"> + <div class="page-header"> + <h1>Get the flux of a chemical out of the FOCUS layer from a CHEM*.PLM file</h1> + </div> + + + <p>Get the flux of a chemical out of the FOCUS layer from a CHEM*.PLM file</p> + + + <pre><span class='fu'>get_flux</span>(<span class='no'>chem_file</span>)</pre> + + + </div> + <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> + <h2>Contents</h2> + <ul class="nav nav-pills nav-stacked"> + </ul> + + </div> +</div> + + <footer> + <div class="copyright"> + <p>Developed by Johannes Ranke.</p> +</div> + +<div class="pkgdown"> + <p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p> +</div> + + </footer> + </div> + + </body> +</html> diff --git a/docs/reference/get_interval.html b/docs/reference/get_interval.html new file mode 100644 index 0000000..13171c1 --- /dev/null +++ b/docs/reference/get_interval.html @@ -0,0 +1,101 @@ +<!-- Generated by pkgdown: do not edit by hand --> +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta http-equiv="X-UA-Compatible" content="IE=edge"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> + +<title>Get the application interval in years from a psm file — get_interval • pfm</title> + +<!-- jquery --> +<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script> +<!-- Bootstrap --> + +<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> +<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> + +<!-- Font Awesome icons --> +<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous"> + + +<!-- pkgdown --> +<link href="../pkgdown.css" rel="stylesheet"> +<script src="../jquery.sticky-kit.min.js"></script> +<script src="../pkgdown.js"></script> + +<!-- mathjax --> +<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> + +<!--[if lt IE 9]> +<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> +<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> +<![endif]--> + </head> + + <body> + <div class="container template-reference-topic"> + <header> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../index.html">pfm</a> + </div> + <div id="navbar" class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li> + <a href="../reference/index.html">Reference</a> +</li> + </ul> + + <ul class="nav navbar-nav navbar-right"> + + </ul> + </div><!--/.nav-collapse --> + </div><!--/.container --> +</div><!--/.navbar --> + + + </header> + + <div class="row"> + <div class="col-md-9 contents"> + <div class="page-header"> + <h1>Get the application interval in years from a psm file</h1> + </div> + + + <p>Get the application interval in years from a psm file</p> + + + <pre><span class='fu'>get_interval</span>(<span class='no'>psm_file</span>, <span class='no'>location_code</span>)</pre> + + + </div> + <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> + <h2>Contents</h2> + <ul class="nav nav-pills nav-stacked"> + </ul> + + </div> +</div> + + <footer> + <div class="copyright"> + <p>Developed by Johannes Ranke.</p> +</div> + +<div class="pkgdown"> + <p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p> +</div> + + </footer> + </div> + + </body> +</html> diff --git a/docs/reference/index.html b/docs/reference/index.html index 8f57cd2..33713b6 100644 --- a/docs/reference/index.html +++ b/docs/reference/index.html @@ -67,7 +67,7 @@ <div class="col-md-9"> <div class="page-header"> <h1>Function reference</h1> - <h4>version 0.4-1</h4> + <h4>version 0.4-2</h4> </div> <div class="contents"> @@ -117,6 +117,14 @@ <ul> <li><code><a href="soil_scenario_data_EFSA_2015.html">soil_scenario_data_EFSA_2015</a></code></li> </ul> + <h2 id="section-predicted-environmental-concentrations-in-groundwater" class="hasAnchor"><a href="#section-predicted-environmental-concentrations-in-groundwater" class="anchor"></a>Predicted environmental concentrations in groundwater</h2> + <p class="section-desc"></p> + + + <p><a href="PELMO_runs.html">Set up runs for FOCUS PELMO</a></p> + <ul> + <li><code><a href="PELMO_runs.html">PELMO_runs</a></code></li><li><code><a href="PELMO_runs.html">run_PELMO</a></code></li><li><code><a href="PELMO_runs.html">evaluate_PELMO</a></code></li> + </ul> <h2 id="section-predicted-environmental-concentrations-in-surface-water" class="hasAnchor"><a href="#section-predicted-environmental-concentrations-in-surface-water" class="anchor"></a>Predicted environmental concentrations in surface water</h2> <p class="section-desc"></p> @@ -173,6 +181,7 @@ <ul class="nav nav-pills nav-stacked"> <li><a href="#section-general-utility-functions">General utility functions</a></li> <li><a href="#section-predicted-environmental-concentrations-in-soil">Predicted environmental concentrations in soil</a></li> + <li><a href="#section-predicted-environmental-concentrations-in-groundwater">Predicted environmental concentrations in groundwater</a></li> <li><a href="#section-predicted-environmental-concentrations-in-surface-water">Predicted environmental concentrations in surface water</a></li> <li><a href="#section-classifications-and-indicators">Classifications and indicators</a></li> </ul> diff --git a/docs/reference/run_PELMO.html b/docs/reference/run_PELMO.html new file mode 100644 index 0000000..067d3c1 --- /dev/null +++ b/docs/reference/run_PELMO.html @@ -0,0 +1,119 @@ +<!-- Generated by pkgdown: do not edit by hand --> +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta http-equiv="X-UA-Compatible" content="IE=edge"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> + +<title>Run PELMO — run_PELMO • pfm</title> + +<!-- jquery --> +<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script> +<!-- Bootstrap --> + +<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> +<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> + +<!-- Font Awesome icons --> +<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous"> + + +<!-- pkgdown --> +<link href="../pkgdown.css" rel="stylesheet"> +<script src="../jquery.sticky-kit.min.js"></script> +<script src="../pkgdown.js"></script> + +<!-- mathjax --> +<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> + +<!--[if lt IE 9]> +<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> +<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> +<![endif]--> + </head> + + <body> + <div class="container template-reference-topic"> + <header> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../index.html">pfm</a> + </div> + <div id="navbar" class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li> + <a href="../reference/index.html">Reference</a> +</li> + </ul> + + <ul class="nav navbar-nav navbar-right"> + + </ul> + </div><!--/.nav-collapse --> + </div><!--/.container --> +</div><!--/.navbar --> + + + </header> + + <div class="row"> + <div class="col-md-9 contents"> + <div class="page-header"> + <h1>Run PELMO</h1> + </div> + + + <p>Run PELMO</p> + + + <pre><span class='fu'>run_PELMO</span>(<span class='no'>runs</span>, <span class='kw'>version</span> <span class='kw'>=</span> <span class='st'>"5.5.3"</span>, <span class='kw'>PELMO_base</span> <span class='kw'>=</span> <span class='st'>"auto"</span>, + <span class='kw'>cores</span> <span class='kw'>=</span> <span class='fu'>getOption</span>(<span class='st'>"mc.cores"</span>, <span class='fl'>2L</span>))</pre> + + <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a> Arguments</h2> + <dl class="dl-horizontal"> + <dt>runs</dt> + <dd>A list of lists. Each inner lists has an element named 'psm' +that holds the psm string, and elements named using three letter crop acronyms, +as used in <code><a href='FOCUS_PELMO_crops.html'>FOCUS_PELMO_crops</a></code>, +that hold character vectors of three letter scenario acronyms +as used in <code><a href='FOCUS_GW_scenarios_2012.html'>FOCUS_GW_scenarios_2012</a></code>.</dd> + <dt>version</dt> + <dd>The FOCUS PELMO version</dd> + <dt>PELMO_base</dt> + <dd>Where the FOCUS PELMO installation is located</dd> + <dt>cores</dt> + <dd>The number of cores to execute PELMO runs in parallel</dd> + </dl> + + + </div> + <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> + <h2>Contents</h2> + <ul class="nav nav-pills nav-stacked"> + <li><a href="#arguments">Arguments</a></li> + </ul> + + </div> +</div> + + <footer> + <div class="copyright"> + <p>Developed by Johannes Ranke.</p> +</div> + +<div class="pkgdown"> + <p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p> +</div> + + </footer> + </div> + + </body> +</html> diff --git a/docs/reference/sum_periods.html b/docs/reference/sum_periods.html new file mode 100644 index 0000000..66466ac --- /dev/null +++ b/docs/reference/sum_periods.html @@ -0,0 +1,101 @@ +<!-- Generated by pkgdown: do not edit by hand --> +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> +<meta http-equiv="X-UA-Compatible" content="IE=edge"> +<meta name="viewport" content="width=device-width, initial-scale=1.0"> + +<title>Sum up values according to FOCUS periods — sum_periods • pfm</title> + +<!-- jquery --> +<script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script> +<!-- Bootstrap --> + +<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> +<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> + +<!-- Font Awesome icons --> +<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous"> + + +<!-- pkgdown --> +<link href="../pkgdown.css" rel="stylesheet"> +<script src="../jquery.sticky-kit.min.js"></script> +<script src="../pkgdown.js"></script> + +<!-- mathjax --> +<script src='https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script> + +<!--[if lt IE 9]> +<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script> +<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> +<![endif]--> + </head> + + <body> + <div class="container template-reference-topic"> + <header> + <div class="navbar navbar-default navbar-fixed-top" role="navigation"> + <div class="container"> + <div class="navbar-header"> + <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar"> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + <span class="icon-bar"></span> + </button> + <a class="navbar-brand" href="../index.html">pfm</a> + </div> + <div id="navbar" class="navbar-collapse collapse"> + <ul class="nav navbar-nav"> + <li> + <a href="../reference/index.html">Reference</a> +</li> + </ul> + + <ul class="nav navbar-nav navbar-right"> + + </ul> + </div><!--/.nav-collapse --> + </div><!--/.container --> +</div><!--/.navbar --> + + + </header> + + <div class="row"> + <div class="col-md-9 contents"> + <div class="page-header"> + <h1>Sum up values according to FOCUS periods</h1> + </div> + + + <p>Sum up values according to FOCUS periods</p> + + + <pre><span class='fu'>sum_periods</span>(<span class='no'>annual</span>, <span class='no'>interval</span>)</pre> + + + </div> + <div class="col-md-3 hidden-xs hidden-sm" id="sidebar"> + <h2>Contents</h2> + <ul class="nav nav-pills nav-stacked"> + </ul> + + </div> +</div> + + <footer> + <div class="copyright"> + <p>Developed by Johannes Ranke.</p> +</div> + +<div class="pkgdown"> + <p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p> +</div> + + </footer> + </div> + + </body> +</html> diff --git a/man/FOCUS_GW_scenarios_2012.Rd b/man/FOCUS_GW_scenarios_2012.Rd index f2417d9..a19bbe5 100644 --- a/man/FOCUS_GW_scenarios_2012.Rd +++ b/man/FOCUS_GW_scenarios_2012.Rd @@ -1,10 +1,16 @@ % Generated by roxygen2: do not edit by hand % Please edit documentation in R/FOCUS_GW_scenarios_2012.R +\docType{data} \name{FOCUS_GW_scenarios_2012} \alias{FOCUS_GW_scenarios_2012} \title{A very small subset of the FOCUS Groundwater scenario defitions} +\format{An object of class \code{list} of length 2.} +\usage{ +FOCUS_GW_scenarios_2012 +} \description{ -Currently, only a small subset of the soil definitions are provided. +Currently, only scenario names with acronyms and a small subset of the soil definitions are provided. The +soil definitions are from page 46ff. from FOCUS (2012). } \examples{ FOCUS_GW_scenarios_2012 @@ -14,3 +20,4 @@ FOCUS (2012) Generic guidance for Tier 1 FOCUS ground water assessments. Version FOrum for the Co-ordination of pesticde fate models and their USe. http://focus.jrc.ec.europa.eu/gw/docs/Generic_guidance_FOCV2_1.pdf } +\keyword{datasets} diff --git a/man/FOCUS_PELMO_crop_sze_names.Rd b/man/FOCUS_PELMO_crop_sze_names.Rd new file mode 100644 index 0000000..180c011 --- /dev/null +++ b/man/FOCUS_PELMO_crop_sze_names.Rd @@ -0,0 +1,20 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/FOCUS_PELMO_data.R +\docType{data} +\name{FOCUS_PELMO_crop_sze_names} +\alias{FOCUS_PELMO_crop_sze_names} +\title{FOCUS PELMO crop acronyms used for naming sceneario files} +\format{An object of class \code{character} of length 25.} +\usage{ +FOCUS_PELMO_crop_sze_names +} +\description{ +A named character vector with the crop acronyms used in FOCUS PELMO 5.5.3 +for naming the .sze files located in the FOCUS directory. The crop acronyms +in the file names are sometimes capitalized, sometimes not. The scenario +files used for Beans (field) and Beans (vegetable) are the same. +} +\examples{ +print(FOCUS_PELMO_crop_sze_names) +} +\keyword{datasets} diff --git a/man/FOCUS_PELMO_crops.Rd b/man/FOCUS_PELMO_crops.Rd new file mode 100644 index 0000000..91a010a --- /dev/null +++ b/man/FOCUS_PELMO_crops.Rd @@ -0,0 +1,21 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/FOCUS_PELMO_data.R +\docType{data} +\name{FOCUS_PELMO_crops} +\alias{FOCUS_PELMO_crops} +\title{FOCUS PELMO crop names} +\format{An object of class \code{character} of length 25.} +\usage{ +FOCUS_PELMO_crops +} +\description{ +A named character vector with the crop names used in the PELMO 5.5.3 GUI. +For the names, three letter codes were constructed by generally taking the +first three letters in lower case. Only when there is an expression in +parentheses, the first letter of this expression becomes the first letter +in the three letter code, i.e. 'Peas (animals)' has the code \code{ape}. +} +\examples{ +print(FOCUS_PELMO_crops) +} +\keyword{datasets} diff --git a/man/FOCUS_PELMO_location_codes.Rd b/man/FOCUS_PELMO_location_codes.Rd new file mode 100644 index 0000000..961a840 --- /dev/null +++ b/man/FOCUS_PELMO_location_codes.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/FOCUS_PELMO_data.R +\docType{data} +\name{FOCUS_PELMO_location_codes} +\alias{FOCUS_PELMO_location_codes} +\title{Location codes in FOCUS PELMO} +\format{An object of class \code{character} of length 9.} +\usage{ +FOCUS_PELMO_location_codes +} +\description{ +A named character vector of one letter location codes used in FOCUS PELMO, +indexed by three letter acronyms. +} +\examples{ +print(FOCUS_PELMO_location_codes) +} +\keyword{datasets} diff --git a/man/PELMO_path.Rd b/man/PELMO_path.Rd new file mode 100644 index 0000000..e8ca50e --- /dev/null +++ b/man/PELMO_path.Rd @@ -0,0 +1,18 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/PELMO_runs.R +\name{PELMO_path} +\alias{PELMO_path} +\title{Create a path of run directories as the PELMO GUI does} +\usage{ +PELMO_path(psm, crop, scenario) +} +\arguments{ +\item{psm}{The psm identifier} + +\item{crop}{The PELMO crop acronym} + +\item{scenario}{The scenario} +} +\description{ +Create a path of run directories as the PELMO GUI does +} diff --git a/man/PELMO_runs.Rd b/man/PELMO_runs.Rd new file mode 100644 index 0000000..1d81e6d --- /dev/null +++ b/man/PELMO_runs.Rd @@ -0,0 +1,50 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/PELMO_runs.R +\name{PELMO_runs} +\alias{PELMO_runs} +\alias{run_PELMO} +\alias{evaluate_PELMO} +\title{Set up runs for FOCUS PELMO} +\usage{ +PELMO_runs(runs, psm_dir = ".", version = "5.5.3", PELMO_base = "auto", + execute = TRUE, cores = getOption("mc.cores", 2L), evaluate = TRUE, + overwrite = FALSE) + +run_PELMO(runs, version = "5.5.3", PELMO_base = "auto", + cores = getOption("mc.cores", 2L)) + +evaluate_PELMO(runs, version = "5.5.3", PELMO_base = "auto") +} +\arguments{ +\item{runs}{A list of lists. Each inner lists has an element named 'psm' +that holds the psm string, and elements named using three letter crop acronyms, +as used in \code{\link{FOCUS_PELMO_crops}}, +that hold character vectors of three letter scenario acronyms +as used in \code{\link{FOCUS_GW_scenarios_2012}}.} + +\item{psm_dir}{The directory where the psm files are located} + +\item{version}{The FOCUS PELMO version} + +\item{PELMO_base}{Where the FOCUS PELMO installation is located} + +\item{execute}{Should PELMO be executed directly?} + +\item{cores}{The number of cores to execute PELMO runs in parallel} + +\item{evaluate}{Should the results be returned?} + +\item{overwrite}{Should an existing run directories be overwritten} +} +\description{ +Per default, the runs are also executed with FOCUS PELMO, and the results are processed +and returned. Currently, only FOCUS PELMO as installed on Linux (or other Unix systems) +using the \code{\link{install_PELMO}} from the \code{PELMO.installeR} package +maintained on github is supported. In such installations, FOCUS PELMO is installed into +package installation directory of \code{PELMO.installeR} and run with \code{wine}. +} +\references{ +PELMO.installeR \url{https://jranke.github.io/PELMO.installeR} + +Wine \url{https://winehq.org} +} diff --git a/man/create_run_list.Rd b/man/create_run_list.Rd new file mode 100644 index 0000000..3151165 --- /dev/null +++ b/man/create_run_list.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/PELMO_runs.R +\name{create_run_list} +\alias{create_run_list} +\title{Create a list of runs that we can traverse} +\usage{ +create_run_list(runs, psm_dir = ".", check_psm_files = FALSE) +} +\arguments{ +\item{runs}{A list of lists. Each inner lists has an element named 'psm' +that holds the psm string, and elements named using three letter crop acronyms, +as used in \code{\link{FOCUS_PELMO_crops}}, +that hold character vectors of three letter scenario acronyms +as used in \code{\link{FOCUS_GW_scenarios_2012}}.} + +\item{psm_dir}{The directory where the psm files are located} + +\item{check_psm_files}{Should we check if the psm file exists} +} +\description{ +Create a list of runs that we can traverse +} diff --git a/man/focus_80th.Rd b/man/focus_80th.Rd new file mode 100644 index 0000000..8436791 --- /dev/null +++ b/man/focus_80th.Rd @@ -0,0 +1,19 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/PELMO_runs.R +\name{focus_80th} +\alias{focus_80th} +\title{Calculate the 80th percentile according to FOCUS guidance} +\usage{ +focus_80th(c_period, old = FALSE) +} +\arguments{ +\item{c_period}{A numeric vector of values to calculate the percentile from} + +\item{old}{Should the old calculation method be used (the 17th highest value)?} +} +\description{ +This is nowadays defined as the mean of the 16th and the 17th +highest value. Previously, the 17th highest values was used (FOCUS 2014, p. +18). NaN values need to be set to zero in order to reproduce the +values obtained by PELMO. +} diff --git a/man/get_flux.Rd b/man/get_flux.Rd new file mode 100644 index 0000000..93778cb --- /dev/null +++ b/man/get_flux.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/PELMO_runs.R +\name{get_flux} +\alias{get_flux} +\title{Get the flux of a chemical out of the FOCUS layer from a CHEM*.PLM file} +\usage{ +get_flux(chem_file) +} +\description{ +Get the flux of a chemical out of the FOCUS layer from a CHEM*.PLM file +} diff --git a/man/get_interval.Rd b/man/get_interval.Rd new file mode 100644 index 0000000..a751996 --- /dev/null +++ b/man/get_interval.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/PELMO_runs.R +\name{get_interval} +\alias{get_interval} +\title{Get the application interval in years from a psm file} +\usage{ +get_interval(psm_file, location_code) +} +\description{ +Get the application interval in years from a psm file +} diff --git a/man/sum_periods.Rd b/man/sum_periods.Rd new file mode 100644 index 0000000..5051af4 --- /dev/null +++ b/man/sum_periods.Rd @@ -0,0 +1,11 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/PELMO_runs.R +\name{sum_periods} +\alias{sum_periods} +\title{Sum up values according to FOCUS periods} +\usage{ +sum_periods(annual, interval) +} +\description{ +Sum up values according to FOCUS periods +} diff --git a/tests/testthat/test_PELMO.R b/tests/testthat/test_PELMO.R new file mode 100644 index 0000000..ab0e37a --- /dev/null +++ b/tests/testthat/test_PELMO.R @@ -0,0 +1,142 @@ +library(testthat) +library(pfm) +context("Create PELMO runs from psm files and execute them") +PELMO_base <- system.file("FOCUSPELMO.553", package = "PELMO.installeR") + +test_archive <- system.file("testdata/FOCUS_PELMO.tar.bz2", package = "pfm") +test_dir <- tempdir() +untar(test_archive, exdir = test_dir, compressed = "bzip2") + +runs <- list( + list( + psm = "Pesticide_D", + fbe = c("Por"), + vbe = c("Por")), + list( + psm = "Pesticide_D_1_day_pre_em_every_third_year", + pot = c("Cha", "Ham")), + list( + psm = "Pesticide_D_1_May_every_other_year_mets", + win = names(FOCUS_GW_scenarios_2012$names))) + +test_that("PELMO paths are correctly created", { + psm_paths = c( + PELMO_path(runs[[1]]$psm, "fbe", "Por"), + PELMO_path(runs[[2]]$psm, "pot", "Ham"), + PELMO_path(runs[[3]]$psm, "win", "Cha")) + + for (i in seq_along(psm_paths)) { + psm_file <- file.path(test_dir, psm_paths[i], paste0(runs[[i]]$psm, ".psm")) + expect_true(file.exists(psm_file)) + psm_new_location <- file.path(PELMO_base, basename(psm_file)) + file.copy(psm_file, psm_new_location, overwrite = TRUE) + } +}) + +test_that("PELMO runs are correctly set up", { + + # Prepare runs in analogy to the test archive + PELMO_runs(runs, psm_dir = PELMO_base, execute = FALSE, evaluate = FALSE, overwrite = TRUE) + + # Check that input files are correctly generated in the right location + for (run in runs) { + psm <- run$psm + crops <- setdiff(names(run), "psm") + for (crop in crops) { + for (scenario in run[[crop]]) { + pp <- PELMO_path(psm, crop, scenario) + + input_new <- readLines(file.path(PELMO_base, "FOCUS", pp, "pelmo.inp")) + input_test <- readLines(file.path(test_dir, pp, "pelmo.inp")) + + # Check if the input files are correctly reproduced + expect_identical(input_new, input_test) + } + } + } +}) + +test_that("PELMO runs can be run and give the expected result files", { + run_PELMO(runs, cores = 7) + + plm_files <- c("CHEM.PLM", "ECHO.PLM", + "KONZCHEM.PLM", "KONZC_A1", "KONZC_B1", + "PLNTPEST.plm", "PLOT.PLM", "WASSER.PLM") + + # Check that if output is the same as in the test archive + for (run in runs) { + psm <- run$psm + crops <- setdiff(names(run), "psm") + for (crop in crops) { + for (scenario in run[[crop]]) { + pp <- PELMO_path(psm, crop, scenario) + + for (plm in plm_files) { + if (file.exists(file.path(test_dir, pp, plm))) { + new <- readLines(file.path(PELMO_base, "FOCUS", pp, plm)) + test <- readLines(file.path(test_dir, pp, plm)) + + # Check if the ouput files are correctly reproduced + expect_identical(new, test) + } + } + } + } + } +}) + +test_that("PELMO runs are correctly evaluated", { + results <- evaluate_PELMO(runs) + + # Check that if output is the same as in the test archive + for (run in runs) { + psm <- run$psm + crops <- setdiff(names(run), "psm") + for (crop in crops) { + for (scenario in run[[crop]]) { + pp <- PELMO_path(psm, crop, scenario) + + period_file <- readLines(file.path(test_dir, pp, "period.plm"), encoding = "latin1") + + result_lines <- grep("^\tResults for.*in the percolate at 1 m soil depth$", period_file) + acronyms <- gsub(".*\\((.*)\\).*", "\\1", period_file[result_lines]) + names(result_lines) <- acronyms + + results <- list() + for (acronym in acronyms) { + results[[acronym]] <- list() + conc_lines <- result_lines[acronym] + 5:24 + tmp <- read.table(text = period_file[conc_lines], sep = "\t") + results[[acronym]]$periods <- data.frame( + period = as.integer(tmp$V2), + flux = tmp$V3, + percolate = tmp$V4, + conc = tmp$V5) + tmp80 <- read.table(text = period_file[result_lines[acronym] + 27], sep = "\t") + results[[acronym]]$focus <- tmp80[[1, "V5"]] + } + + period_pfm_file <- file.path(PELMO_base, "FOCUS", pp, "period_pfm.rda") + load(period_pfm_file) + + # Test for equality of all the components separately, + # as we need to adapt the tolerance + for (acronym in acronyms) { + p_pelmo <- results[[acronym]]$periods + p_test <- results_pfm[[acronym]]$periods + expect_equal(p_test$flux, p_pelmo$flux, tol = 1e-6, scale = 1) + expect_equal(p_test$percolate, p_pelmo$percolate) + # PELMO sets the concentration to 0 when the percolate is zero. + # We get NaN, which is more reasonable, but we need to + # take this into account for testing + p_test$conc <- ifelse(is.na(p_test$conc), 0, p_test$conc) + expect_equal(p_test$conc, p_pelmo$conc, tol = 1e-3, scale = 1) + + # FOCUS PEC + expect_equal(results_pfm[[acronym]]$focus, results[[acronym]]$focus, + tol = 1e-3, scale = 1) + } + } + } + } +}) diff --git a/tests/testthat/test_TOXSWA_cwa.R b/tests/testthat/test_TOXSWA.R index 7c9a73c..7c9a73c 100644 --- a/tests/testthat/test_TOXSWA_cwa.R +++ b/tests/testthat/test_TOXSWA.R |