From 8e34aec7f1c59c4579d8c6ba6ca99a2bb4beb159 Mon Sep 17 00:00:00 2001 From: Dorchies David <david.dorchies@inrae.fr> Date: Wed, 31 Mar 2021 16:36:11 +0200 Subject: [PATCH] feat: export data in the package --- .Rbuildignore | 1 + DESCRIPTION | 2 + NAMESPACE | 4 +- R/get_objectives.R | 60 ------------------ R/get_vobj_ts.R | 8 +-- R/lakes.R | 11 ++++ R/objectives.R | 12 ++++ R/plot_isofrequency.R | 2 +- R/rulesets.R | 10 +++ R/sysdata.rda | Bin 0 -> 1242 bytes R/vgest_cost.R | 14 ++-- R/vgest_read.R | 8 +-- R/vgest_read_chrono.R | 2 +- R/vgest_run_store.R | 6 +- {inst/seine => data-raw}/lakes.txt | 0 .../objective_description.txt | 0 .../objective_stations.json | 0 .../objective_thresholds.txt | 0 data-raw/rulesets.txt | 0 data-raw/seine_grands_lacs.R | 58 +++++++++++++++++ man/get_objectives.Rd | 40 ------------ man/get_vobj_ts.Rd | 8 +-- man/lakes.Rd | 24 +++++++ man/objectives.Rd | 25 ++++++++ man/plot_isofrequency_lake.Rd | 2 +- man/rulesets.Rd | 23 +++++++ man/vgest_cost.Rd | 8 +-- man/vgest_cost_lakes.Rd | 2 +- man/vgest_read_all.Rd | 4 +- man/vgest_read_chrono.Rd | 2 +- man/vgest_read_one.Rd | 4 +- man/vgest_run_store.Rd | 6 +- 32 files changed, 207 insertions(+), 139 deletions(-) delete mode 100644 R/get_objectives.R create mode 100644 R/lakes.R create mode 100644 R/objectives.R create mode 100644 R/rulesets.R create mode 100644 R/sysdata.rda rename {inst/seine => data-raw}/lakes.txt (100%) rename {inst/seine => data-raw}/objective_description.txt (100%) rename {inst/seine => data-raw}/objective_stations.json (100%) rename {inst/seine => data-raw}/objective_thresholds.txt (100%) create mode 100644 data-raw/rulesets.txt create mode 100644 data-raw/seine_grands_lacs.R delete mode 100644 man/get_objectives.Rd create mode 100644 man/lakes.Rd create mode 100644 man/objectives.Rd create mode 100644 man/rulesets.Rd diff --git a/.Rbuildignore b/.Rbuildignore index 58e9550..019fe14 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -1,3 +1,4 @@ ^rvgest\.Rproj$ ^\.Rproj\.user$ ^LICENSE\.md$ +^data-raw$ diff --git a/DESCRIPTION b/DESCRIPTION index 30551c5..ac7d075 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -19,3 +19,5 @@ Imports: lubridate, TSstudio VignetteBuilder: knitr +Depends: + R (>= 2.10) diff --git a/NAMESPACE b/NAMESPACE index 2936386..55588b0 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,10 +9,12 @@ S3method(vgest_read_chrono,Objectives) S3method(vgest_read_chrono,default) S3method(vgest_run_store,Objectives) S3method(vgest_run_store,character) -export(get_objectives) export(get_vobj_ts) +export(lakes) +export(objectives) export(plot_isofrequency) export(plot_isofrequency_lake) +export(rulesets) export(vgest_cost) export(vgest_read) export(vgest_read_all) diff --git a/R/get_objectives.R b/R/get_objectives.R deleted file mode 100644 index cb2f1a9..0000000 --- a/R/get_objectives.R +++ /dev/null @@ -1,60 +0,0 @@ -#' Load objective data for \code{\link{vgest_run}} -#' -#' @param objective_thresholds File location of threshold table -#' @param objective_stations File location of objective station table -#' @param lakes File location of lake table -#' -#' @return A dataframe containing one line by objective and the following columns: -#' -#' - station (character): identifier of the objective station -#' - flood (boolean): TRUE for high flow mitigation objective, and FALSE for low flow support -#' - level (character): code composed with "l" for low-flow and "h" for high flow followed by the number of the level -#' - threshold (numeric): value of the threshold in m3/s -#' - lakes (dataframe): Dataframe containing lake details (name, min storage, max storage) -#' -#' @export -#' -#' @examples -#' # Get objectives stored in IRMaRA package -#' df <- get_objectives() -#' # Objectives at Paris -#' df[df[,"station"] == "PARIS_05",] -#' # Lake details concerning the 40th objective in the table -#' df[57, "lakes"] -get_objectives <- function( - objective_thresholds = app_sys("seine", "objective_thresholds.txt"), - objective_stations = app_sys("seine", "objective_stations.json"), - lakes = app_sys("seine", "lakes.txt") -) { - thresholds <- read.delim(objective_thresholds) - stations <- jsonlite::fromJSON( - readLines(objective_stations) - ) - dfLakes <- read.delim(lakes) - row.names(dfLakes) <- dfLakes$name - bFirst = TRUE - for(iStation in 1:nrow(thresholds)) { - station <- thresholds[iStation, 1] - for(type in c("l", "h")) { - bFlood = (type == "h") - for(level in grep(paste0(type, ".*"), names(thresholds))) { - threshold <- thresholds[iStation, level] - df1 <- data.frame( - station = station, - flood = bFlood, - level = names(thresholds)[level], - threshold = threshold - ) - df1$lakes <- list(dfLakes[stations[[station]]$lakes,]) - if(bFirst) { - df <- df1 - bFirst <- FALSE - } else { - df <- rbind(df, df1) - } - } - } - } - class(df) <- c("Objectives", class(df)) - return(df) -} \ No newline at end of file diff --git a/R/get_vobj_ts.R b/R/get_vobj_ts.R index 2da9741..ee34693 100644 --- a/R/get_vobj_ts.R +++ b/R/get_vobj_ts.R @@ -10,7 +10,7 @@ #' #' @examples #' \dontrun{ -#' dfTs <- get_vobj_ts(vgest_read_all(get_objectives()[1,], "./database")) +#' dfTs <- get_vobj_ts(vgest_read_all(objectives[1,], "./database")) #' } get_vobj_ts <- function(x) { UseMethod("get_vobj_ts", x) @@ -27,9 +27,9 @@ get_vobj_ts <- function(x) { #' @examples #' \dontrun{ #' # Get the first lake of the first objective -#' dfTs <- get_vobj_ts(vgest_read_all(get_objectives()[1,], "./database")[[1]]) +#' dfTs <- get_vobj_ts(vgest_read_all(objectives[1,], "./database")[[1]]) #' # Can also be done by -#' dfTs <- get_vobj_ts(vgest_read_one(1, get_objectives()[1,], "./database")) +#' dfTs <- get_vobj_ts(vgest_read_one(1, objectives[1,], "./database")) #' } get_vobj_ts.Vobj <- function(x) { # Build the date vector @@ -57,7 +57,7 @@ get_vobj_ts.Vobj <- function(x) { #' #' @examples #' \dontrun{ -#' dfTs <- get_vobj_ts(vgest_read_all(get_objectives()[1,], "./database")) +#' dfTs <- get_vobj_ts(vgest_read_all(objectives[1,], "./database")) #' } get_vobj_ts.ListVobj <-function(x) { lVobjTs <- lapply(x, get_vobj_ts.Vobj) diff --git a/R/lakes.R b/R/lakes.R new file mode 100644 index 0000000..2d47ab2 --- /dev/null +++ b/R/lakes.R @@ -0,0 +1,11 @@ +#' Characteristics of the 4 lakes managed by Seine Grands Lacs +#' +#' @format a [data.frame] with 3 columns: +#' +#' - "name" the name of the river on which the lake is implemented ([character]) +#' - "min" the minimum lake storage in Mm3 ([numeric]) +#' - "max" the maximum lake storage in Mm3 ([numeric]) +#' +#' @source \url{https://www.seinegrandslacs.fr/quatre-lacs-reservoirs-au-coeur-dun-bassin} +#' @export +"lakes" diff --git a/R/objectives.R b/R/objectives.R new file mode 100644 index 0000000..778f263 --- /dev/null +++ b/R/objectives.R @@ -0,0 +1,12 @@ +#' Objectives of reservoir management on the Seine River +#' +#' @format a [data.frame] with 5 columns: +#' +#' - "station" the id of the station ([character]) +#' - "flood" a [logical] which is `TRUE` for a flood objective and `FALSE` for a drought objective +#' - "level" a [character] representing the severity of the threshold: "l1" to "l4" for low flow thresholds and "h1" to "h3" for high flow thresholds +#' - "lakes" a [list] which contains a [data.frame] with informations concerning the lakes (See [lakes]) +#' +#' @source Dorchies, D., Thirel, G., Jay-Allemand, M., Chauveau, M., Dehay, F., Bourgin, P.-Y., Perrin, C., Jost, C., Rizzoli, J.-L., Demerliac, S., Thépot, R., 2014. Climate change impacts on multi-objective reservoir management: case study on the Seine River basin, France. International Journal of River Basin Management 12, 265–283. \url{https://doi.org/10.1080/15715124.2013.865636} +#' @export +"objectives" diff --git a/R/plot_isofrequency.R b/R/plot_isofrequency.R index 8b4d744..263e9cd 100644 --- a/R/plot_isofrequency.R +++ b/R/plot_isofrequency.R @@ -27,7 +27,7 @@ plot_isofrequency <- function(x, freq, result.dir = "database") { #' #' @param vObj dataframe produced by [vgest_read_one()] and stored in a list by [vgest_read_all()] #' @param frequencies vector of frequencies to plot -#' @param lake lake data extract from column `lakes` of objective data given by [get_objectives()] +#' @param lake lake data extract from column `lakes` of objective data given by [objectives] #' @param top.margin top margin applied on the plot for the title #' #' @return [NULL] diff --git a/R/rulesets.R b/R/rulesets.R new file mode 100644 index 0000000..194df1d --- /dev/null +++ b/R/rulesets.R @@ -0,0 +1,10 @@ +#' Rule sets used in the reservoir managements +#' +#' @format a [list] with 2 items: +#' +#' - "constraints" [character] description of the constraints apply on the management of the reservoir +#' - "rules" [character] description of rule set selections depending on which constraints are applied +#' +#' @source Dehay, F., 2012. Etude de l’impact du changement climatique sur la gestion des lacs-réservoirs de la Seine (other). Diplôme d’ingénieur de l’ENGEES ,Strasbourg. \url{https://hal.inrae.fr/hal-02597326} +#' @export +"rulesets" diff --git a/R/sysdata.rda b/R/sysdata.rda new file mode 100644 index 0000000000000000000000000000000000000000..81ac5e9c93fdbc396cb616681a4e8a7327842a33 GIT binary patch literal 1242 zcmV<01SR`IT4*^jL0KkKS&kG4#Q+)O|NZ~}+`4^#|E2%u{&>It|M2D(QXs$pKmcGs zKmb4i&;`f6LMaxlpa`Hg87NH&=rsVy^dK=B0MIl5XaS%GfB?v7XwwOyzyJUM00000 z000000000CgMa`400000000000000083JmQflSJ3VvlMQ$p!?%dLUy^0BsS3FeYkY z4G&Xdj1WCQsVEakrXxW$JrSm!gaM(Zni>W})YC?Q8UO$Rp{9USj*|k7X{*!;6bULC zfCb8p)>L3BwE9$+XhIicpJ<n&HTC`rIZ^Tig;;u$U+hH{jWEuQ7zES=!X^+UP)eW& zz|ML{OMw%$A~`WYS1}RF6q2D)h{G8f7uxD<s?@cZD-2ygo(=$Bk{1DbOTbzk<)LZ@ z&34LGp-W5^UCy+Z9ASnSWm^@@I~yjEk%k!=8elXrT3|FV%CTEKE!A-2<G1T^e*kdK z=TnkIwqy<pt07K)$TixbR=Nrdmpb<7w+p0+mZZTXmH%W!7=cM5LBqqj&bysaBqFe| zJLq>1;f5n-*jo!>_kpAg(rHOaRZ%AREh9x_VUfJjtTHVq)f_6c!oGEC)2-<yjVWf7 zxiraFSe7MQ%uPvJ&%0*Cl55nni8>W^G*z3BBsC!<DTP3apsLF=3ZIQwBDGKDMw%+7 zC9fKy%I>U_O0b!W?V}Y{uL_E}a<CW_S6?oM6<aJN!6hW5ltP6f#RwQ-0cEOCB%)GD z!TZKO5v3GWH#+48!2%<N0yu6U*o6b>>$jXU9Nqd~G~IqnIagm*ubVB?9DK;tB%5@J z<H)Q2+;NP#SZOY1O$ej1h}s>pLx|5OnJyl>VbTx)4>?`SmqN69f>3*_>MO-PuD;Xg z;nTx%w=2&%huGOh-KyFzlYUJvf0bdM;?JvLtqo~1X_GWBRF!VGqRSnRA6LoK`M(!) ze^mRlehm#Od1sqesMTa)W?72MGc0LVqe#_eVpbU$mS$xcjK!UE)iCu>?M1pr!N=N> zwCtE>uUPg<vN2d<W=zD%nK33+WIIwj2O04jdnXaZbi7TSgZ0SVZ8aOsoru<X^jv4( z-?y@Jqjf7uqGoAUlv+c4jnTl>9a$Zdkmnx1`r*WMD(9cOyEHJ$E@{Yp2^{0Mk<s4` z(mS(p$=m3hayA@`my4orIZk2CI2~CxB*IPP*Xh7;^r_920n|X*e>Yhdz+pQXJTN&G ze&0pc^>(dwcl!D{t&DXsKWsSg71Q;bFb>WsjBRS{w<h;zd!gzzy_uc2qb*jlTU5TI z*dvw8q(_*1#zsYzcKTiC)v~>%Rl1T{go&?uTF=Ph>1}nkz_zkEI5Ngose^VcT=tkv zDJJG^f*Sgs-hVxq*<XUs3wb!%9Z!#>2JWc=U>0COojkxex-v7y8&qVH%NrcKws`Z` z!EH|xHylm&>h?&;m&N=J2$Olm!#b?WwXrPlHd){<=cY48-hPf}1LfZGvmCl;sZ~;` zPO_sn@y1>6UfnRh%OVVS7OFMwjrGRX3~{AX7ZKV!rVXhVW0NB!xgzm=W<a#FYKqx~ zhHQnuT7yPRXCMk_1fol{1l0bU6cQ@cfR9Kz#aERj<bw?Es;fbqR=@r(<ce^iAsi?X EiV;pVV*mgE literal 0 HcmV?d00001 diff --git a/R/vgest_cost.R b/R/vgest_cost.R index 4b1cc29..a95c000 100644 --- a/R/vgest_cost.R +++ b/R/vgest_cost.R @@ -3,7 +3,7 @@ #' Uses ouput of PaChrono.txt or VObj\[1-4\].dat for the calculation. #' #' @param data Data source, see details -#' @param objective one row of the dataframe given by [get_objectives()] +#' @param objective one row of the dataframe given by [objectives] #' #' @return the total cost for one objective at one station in m3/day #' @rdname vgest_cost @@ -19,7 +19,7 @@ vgest_cost <- function(data, objective) { #' For each lake, it's the mean daily storage for a low-flow support objective and the mean daily available storage capacity for a high flow mitigation objective. #' #' @param Vobj A [matrix] or a [data.frame] with one column by lake, in the same order as `objective$lakes` -#' @param objective one row of the dataframe given by [get_objectives()] +#' @param objective one row of the dataframe given by [objectives] #' #' @return total cost of all the lakes in m3/day #' @@ -39,7 +39,7 @@ vgest_cost_lakes <- function(Vobj, objective) { } -#' @param objective one row of the dataframe given by [get_objectives()] +#' @param objective one row of the dataframe given by [objectives] #' #' @rdname vgest_cost #' @export @@ -47,7 +47,7 @@ vgest_cost_lakes <- function(Vobj, objective) { #' @examples #' \dontrun{ #' # This should be done after the execution of vgest for the concerned objective -#' objective <- get_objectives()[1,] +#' objective <- objectives[1,] #' lResultVobj <- vgest_read_all(objective) #' vgest_cost(lResultVobj, objective) #' } @@ -67,7 +67,7 @@ vgest_cost.ListVobj <- function(data, objective) { #' @examples #' \dontrun{ #' # This should be done after the execution of vgest for the concerned objective -#' objective <- get_objectives()[1,] +#' objective <- objectives[1,] #' lChrono <- vgest_read_chrono(objective) #' vgest_cost(lChrono[[1]], objective) #' } @@ -78,7 +78,7 @@ vgest_cost.Chrono <- function(data, objective) { #' #' @param data the [list] given by [vgest_read_chrono()] -#' @param objective [data.frame] given by [get_objectives()] +#' @param objective [data.frame] given by [objectives] #' #' @return A list with items named \[station\]_\[high/low\]_\[threshold\] containing the total cost for a list of objectives and stations in m3/day #' @rdname vgest_cost @@ -87,7 +87,7 @@ vgest_cost.Chrono <- function(data, objective) { #' @examples #' \dontrun{ #' # This should be done after the execution of vgest for the concerned objective -#' objective <- get_objectives()[1,] +#' objective <- objectives[1,] #' lChronos <- vgest_read_chrono(objective, distributionType = 2) #' vgest_cost(lChronos, objective) #' } diff --git a/R/vgest_read.R b/R/vgest_read.R index 17903df..5efe471 100644 --- a/R/vgest_read.R +++ b/R/vgest_read.R @@ -48,7 +48,7 @@ vgest_read <- function(file, bFlood) { #' This function is preferred to [vgest_read()] because it builds the path for the file to read. #' #' @param iLake Lake number for the current station -#' @param x one line of the dataframe produced by [get_objectives()] +#' @param x one line of the dataframe produced by [objectives] #' @param result.dir path where results of VGEST runs are stored (See [vgest_run_store()]) #' #' @return dataframe with the content of the `VOBJi.DAT` file @@ -56,7 +56,7 @@ vgest_read <- function(file, bFlood) { #' #' @examples #' \dontrun{ -#' vgest_read_one(1, get_objectives()[1,], "./database") +#' vgest_read_one(1, objectives[1,], "./database") #' } vgest_read_one <- function(iLake, x, result.dir) { sLowHigh <- c("low", "high") @@ -72,7 +72,7 @@ vgest_read_one <- function(iLake, x, result.dir) { #' Read all result files `VOBJi.DAT` for all the lakes of one objective at one station #' -#' @param x one line of the dataframe produced by [get_objectives()] +#' @param x one line of the dataframe produced by [objectives] #' @param result.dir path where results of VGEST runs are stored (See [vgest_run_store()]) #' #' @return list with dataframes produced by @@ -80,7 +80,7 @@ vgest_read_one <- function(iLake, x, result.dir) { #' #' @examples #' \dontrun{ -#' vgest_read_all(get_objectives()[1,], "./database") +#' vgest_read_all(objectives[1,], "./database") #' } vgest_read_all <- function(x, result.dir = "database") { lObj <- lapply(1:nrow(x$lakes[[1]]), vgest_read_one, x, result.dir) diff --git a/R/vgest_read_chrono.R b/R/vgest_read_chrono.R index 462a682..07ebe73 100644 --- a/R/vgest_read_chrono.R +++ b/R/vgest_read_chrono.R @@ -89,7 +89,7 @@ vgest_read_chrono.default <- function(x, nLakes, distributionType, ...) { #' #' @examples #' \dontrun{ -#' objective <- get_objectives()[1,] +#' objective <- objectives[1,] #' distributionType <- 2 #' vgest_run_store(objective, #' 1, 1, "Q_NAT_1900-2009.txt", diff --git a/R/vgest_run_store.R b/R/vgest_run_store.R index 99a4d69..866c7b7 100644 --- a/R/vgest_run_store.R +++ b/R/vgest_run_store.R @@ -45,7 +45,7 @@ vgest_run_store.character <- function(x, reservoirRuleSet, networkSet, cat(" - OK\n") } -#' @param x row(s) of a [data.frame] provided by [get_objectives()] +#' @param x row(s) of a [data.frame] provided by [objectives] #' #' @export #' @rdname vgest_run_store @@ -54,13 +54,13 @@ vgest_run_store.character <- function(x, reservoirRuleSet, networkSet, #' \dontrun{ #' # Example with `vgest_run_store.Objectives` #' # Running vgest for: -#' # - the first objective returned by `get_objectives()` +#' # - the first objective returned by `objectives` #' # - the first configuration of reservoir rules #' # - the first configuration of network #' # - the naturalized hydrological flows of the file located in DONNEES/Q_NAT_1900-2009.txt #' # - doing the optimization on the period between 01/01/1900 and 31/12/2009 #' # - a task distribution function of present volumes and maximum usable volume replenishment times from the start of time steps -#' vgest_run_store(get_objectives()[1,], +#' vgest_run_store(objectives[1,], #' 1, 1, "Q_NAT_1900-2009.txt", #' "01/01/1900", "31/12/2009", 2) #' diff --git a/inst/seine/lakes.txt b/data-raw/lakes.txt similarity index 100% rename from inst/seine/lakes.txt rename to data-raw/lakes.txt diff --git a/inst/seine/objective_description.txt b/data-raw/objective_description.txt similarity index 100% rename from inst/seine/objective_description.txt rename to data-raw/objective_description.txt diff --git a/inst/seine/objective_stations.json b/data-raw/objective_stations.json similarity index 100% rename from inst/seine/objective_stations.json rename to data-raw/objective_stations.json diff --git a/inst/seine/objective_thresholds.txt b/data-raw/objective_thresholds.txt similarity index 100% rename from inst/seine/objective_thresholds.txt rename to data-raw/objective_thresholds.txt diff --git a/data-raw/rulesets.txt b/data-raw/rulesets.txt new file mode 100644 index 0000000..e69de29 diff --git a/data-raw/seine_grands_lacs.R b/data-raw/seine_grands_lacs.R new file mode 100644 index 0000000..d623aa3 --- /dev/null +++ b/data-raw/seine_grands_lacs.R @@ -0,0 +1,58 @@ +## code to prepare `seine_grands_lacs` dataset goes here + + +# *** lakes *** +lakes <- read.delim("data-raw/lakes.txt") +row.names(lakes) <- lakes$name + +# *** objectives *** +thresholds <- read.delim("data-raw/objective_thresholds.txt") +stations <- jsonlite::fromJSON( + readLines("data-raw/objective_stations.json") +) +bFirst = TRUE +for(iStation in 1:nrow(thresholds)) { + station <- thresholds[iStation, 1] + for(type in c("l", "h")) { + bFlood = (type == "h") + for(level in grep(paste0(type, ".*"), names(thresholds))) { + threshold <- thresholds[iStation, level] + df1 <- data.frame( + station = station, + flood = bFlood, + level = names(thresholds)[level], + threshold = threshold + ) + df1$lakes <- list(lakes[stations[[station]]$lakes,]) + if(bFirst) { + objectives <- df1 + bFirst <- FALSE + } else { + objectives <- rbind(objectives, df1) + } + } + } +} +class(objectives) <- c("Objectives", class(objectives)) + +# *** rulesets *** +constraints <- c( + "a. Qres (minimum flow) at inlets and at Yonne outlet (inline reservoir)", + "b. Qres at outlets", + "c. Qref (maximum flow) at inlets and outlets", + "d. Priority to hydropower generation on Yonne reservoir (Max outflow of 16m<sup>3</sup>/s)", + "e. QST Gradient flow daily limitation for Yonne reservoir (+/- 2m3/s per day)" +) + +rules <- c( + "All constraints (a+b+c+d+e)", + "1, without Qref (a+b+d+e)", + "1, without Qres at outlet (a+c+d+e)", + "3, without Qref (a+d+e)", + "4, without hydropower priority for Yonne lake (a+e)", + "5, without Yonne outflow variation limitation (a)" +) +rulesets <- list(constraints = constraints, rules = rules) + +# Record data in the package +usethis::use_data(objectives, lakes, rulesets, internal = TRUE, overwrite = TRUE) diff --git a/man/get_objectives.Rd b/man/get_objectives.Rd deleted file mode 100644 index a3b705b..0000000 --- a/man/get_objectives.Rd +++ /dev/null @@ -1,40 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/get_objectives.R -\name{get_objectives} -\alias{get_objectives} -\title{Load objective data for \code{\link{vgest_run}}} -\usage{ -get_objectives( - objective_thresholds = app_sys("seine", "objective_thresholds.txt"), - objective_stations = app_sys("seine", "objective_stations.json"), - lakes = app_sys("seine", "lakes.txt") -) -} -\arguments{ -\item{objective_thresholds}{File location of threshold table} - -\item{objective_stations}{File location of objective station table} - -\item{lakes}{File location of lake table} -} -\value{ -A dataframe containing one line by objective and the following columns: -\itemize{ -\item station (character): identifier of the objective station -\item flood (boolean): TRUE for high flow mitigation objective, and FALSE for low flow support -\item level (character): code composed with "l" for low-flow and "h" for high flow followed by the number of the level -\item threshold (numeric): value of the threshold in m3/s -\item lakes (dataframe): Dataframe containing lake details (name, min storage, max storage) -} -} -\description{ -Load objective data for \code{\link{vgest_run}} -} -\examples{ -# Get objectives stored in IRMaRA package -df <- get_objectives() -# Objectives at Paris -df[df[,"station"] == "PARIS_05",] -# Lake details concerning the 40th objective in the table -df[57, "lakes"] -} diff --git a/man/get_vobj_ts.Rd b/man/get_vobj_ts.Rd index 0531eae..e44ae2d 100644 --- a/man/get_vobj_ts.Rd +++ b/man/get_vobj_ts.Rd @@ -29,15 +29,15 @@ Use for binding results of several lakes for one objective at one station. } \examples{ \dontrun{ -dfTs <- get_vobj_ts(vgest_read_all(get_objectives()[1,], "./database")) +dfTs <- get_vobj_ts(vgest_read_all(objectives[1,], "./database")) } \dontrun{ # Get the first lake of the first objective -dfTs <- get_vobj_ts(vgest_read_all(get_objectives()[1,], "./database")[[1]]) +dfTs <- get_vobj_ts(vgest_read_all(objectives[1,], "./database")[[1]]) # Can also be done by -dfTs <- get_vobj_ts(vgest_read_one(1, get_objectives()[1,], "./database")) +dfTs <- get_vobj_ts(vgest_read_one(1, objectives[1,], "./database")) } \dontrun{ -dfTs <- get_vobj_ts(vgest_read_all(get_objectives()[1,], "./database")) +dfTs <- get_vobj_ts(vgest_read_all(objectives[1,], "./database")) } } diff --git a/man/lakes.Rd b/man/lakes.Rd new file mode 100644 index 0000000..ad5aebf --- /dev/null +++ b/man/lakes.Rd @@ -0,0 +1,24 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/lakes.R +\docType{data} +\name{lakes} +\alias{lakes} +\title{Characteristics of the 4 lakes managed by Seine Grands Lacs} +\format{ +a \link{data.frame} with 3 columns: +\itemize{ +\item "name" the name of the river on which the lake is implemented (\link{character}) +\item "min" the minimum lake storage in Mm3 (\link{numeric}) +\item "max" the maximum lake storage in Mm3 (\link{numeric}) +} +} +\source{ +\url{https://www.seinegrandslacs.fr/quatre-lacs-reservoirs-au-coeur-dun-bassin} +} +\usage{ +lakes +} +\description{ +Characteristics of the 4 lakes managed by Seine Grands Lacs +} +\keyword{datasets} diff --git a/man/objectives.Rd b/man/objectives.Rd new file mode 100644 index 0000000..bc23e53 --- /dev/null +++ b/man/objectives.Rd @@ -0,0 +1,25 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/objectives.R +\docType{data} +\name{objectives} +\alias{objectives} +\title{Objectives of reservoir management on the Seine River} +\format{ +a \link{data.frame} with 5 columns: +\itemize{ +\item "station" the id of the station (\link{character}) +\item "flood" a \link{logical} which is \code{TRUE} for a flood objective and \code{FALSE} for a drought objective +\item "level" a \link{character} representing the severity of the threshold: "l1" to "l4" for low flow thresholds and "h1" to "h3" for high flow thresholds +\item "lakes" a \link{list} which contains a \link{data.frame} with informations concerning the lakes (See \link{lakes}) +} +} +\source{ +Dorchies, D., Thirel, G., Jay-Allemand, M., Chauveau, M., Dehay, F., Bourgin, P.-Y., Perrin, C., Jost, C., Rizzoli, J.-L., Demerliac, S., Thépot, R., 2014. Climate change impacts on multi-objective reservoir management: case study on the Seine River basin, France. International Journal of River Basin Management 12, 265–283. \url{https://doi.org/10.1080/15715124.2013.865636} +} +\usage{ +objectives +} +\description{ +Objectives of reservoir management on the Seine River +} +\keyword{datasets} diff --git a/man/plot_isofrequency_lake.Rd b/man/plot_isofrequency_lake.Rd index be63a95..0856f91 100644 --- a/man/plot_isofrequency_lake.Rd +++ b/man/plot_isofrequency_lake.Rd @@ -11,7 +11,7 @@ plot_isofrequency_lake(vObj, frequencies, lake, top.margin) \item{frequencies}{vector of frequencies to plot} -\item{lake}{lake data extract from column \code{lakes} of objective data given by \code{\link[=get_objectives]{get_objectives()}}} +\item{lake}{lake data extract from column \code{lakes} of objective data given by \link{objectives}} \item{top.margin}{top margin applied on the plot for the title} } diff --git a/man/rulesets.Rd b/man/rulesets.Rd new file mode 100644 index 0000000..a0d24d0 --- /dev/null +++ b/man/rulesets.Rd @@ -0,0 +1,23 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/rulesets.R +\docType{data} +\name{rulesets} +\alias{rulesets} +\title{Rule sets used in the reservoir managements} +\format{ +a \link{list} with 2 items: +\itemize{ +\item "constraints" \link{character} description of the constraints apply on the management of the reservoir +\item "rules" \link{character} description of rule set selections depending on which constraints are applied +} +} +\source{ +Dehay, F., 2012. Etude de l’impact du changement climatique sur la gestion des lacs-réservoirs de la Seine (other). Diplôme d’ingénieur de l’ENGEES ,Strasbourg. \url{https://hal.inrae.fr/hal-02597326} +} +\usage{ +rulesets +} +\description{ +Rule sets used in the reservoir managements +} +\keyword{datasets} diff --git a/man/vgest_cost.Rd b/man/vgest_cost.Rd index 00f2b7d..f2b6bf5 100644 --- a/man/vgest_cost.Rd +++ b/man/vgest_cost.Rd @@ -18,7 +18,7 @@ vgest_cost(data, objective) \arguments{ \item{data}{the \link{list} given by \code{\link[=vgest_read_chrono]{vgest_read_chrono()}}} -\item{objective}{\link{data.frame} given by \code{\link[=get_objectives]{get_objectives()}}} +\item{objective}{\link{data.frame} given by \link{objectives}} } \value{ the total cost for one objective at one station in m3/day @@ -33,19 +33,19 @@ Uses ouput of PaChrono.txt or VObj[1-4].dat for the calculation. \examples{ \dontrun{ # This should be done after the execution of vgest for the concerned objective -objective <- get_objectives()[1,] +objective <- objectives[1,] lResultVobj <- vgest_read_all(objective) vgest_cost(lResultVobj, objective) } \dontrun{ # This should be done after the execution of vgest for the concerned objective -objective <- get_objectives()[1,] +objective <- objectives[1,] lChrono <- vgest_read_chrono(objective) vgest_cost(lChrono[[1]], objective) } \dontrun{ # This should be done after the execution of vgest for the concerned objective -objective <- get_objectives()[1,] +objective <- objectives[1,] lChronos <- vgest_read_chrono(objective, distributionType = 2) vgest_cost(lChronos, objective) } diff --git a/man/vgest_cost_lakes.Rd b/man/vgest_cost_lakes.Rd index a1f97c8..bfd1c79 100644 --- a/man/vgest_cost_lakes.Rd +++ b/man/vgest_cost_lakes.Rd @@ -9,7 +9,7 @@ vgest_cost_lakes(Vobj, objective) \arguments{ \item{Vobj}{A \link{matrix} or a \link{data.frame} with one column by lake, in the same order as \code{objective$lakes}} -\item{objective}{one row of the dataframe given by \code{\link[=get_objectives]{get_objectives()}}} +\item{objective}{one row of the dataframe given by \link{objectives}} } \value{ total cost of all the lakes in m3/day diff --git a/man/vgest_read_all.Rd b/man/vgest_read_all.Rd index 367cd4e..a2d529a 100644 --- a/man/vgest_read_all.Rd +++ b/man/vgest_read_all.Rd @@ -7,7 +7,7 @@ vgest_read_all(x, result.dir = "database") } \arguments{ -\item{x}{one line of the dataframe produced by \code{\link[=get_objectives]{get_objectives()}}} +\item{x}{one line of the dataframe produced by \link{objectives}} \item{result.dir}{path where results of VGEST runs are stored (See \code{\link[=vgest_run_store]{vgest_run_store()}})} } @@ -19,6 +19,6 @@ Read all result files \code{VOBJi.DAT} for all the lakes of one objective at one } \examples{ \dontrun{ -vgest_read_all(get_objectives()[1,], "./database") +vgest_read_all(objectives[1,], "./database") } } diff --git a/man/vgest_read_chrono.Rd b/man/vgest_read_chrono.Rd index 4e681c5..af892d5 100644 --- a/man/vgest_read_chrono.Rd +++ b/man/vgest_read_chrono.Rd @@ -67,7 +67,7 @@ The file is saved in RDS format for quicker reading the next time. } \examples{ \dontrun{ -objective <- get_objectives()[1,] +objective <- objectives[1,] distributionType <- 2 vgest_run_store(objective, 1, 1, "Q_NAT_1900-2009.txt", diff --git a/man/vgest_read_one.Rd b/man/vgest_read_one.Rd index 79aff6f..a53cd47 100644 --- a/man/vgest_read_one.Rd +++ b/man/vgest_read_one.Rd @@ -9,7 +9,7 @@ vgest_read_one(iLake, x, result.dir) \arguments{ \item{iLake}{Lake number for the current station} -\item{x}{one line of the dataframe produced by \code{\link[=get_objectives]{get_objectives()}}} +\item{x}{one line of the dataframe produced by \link{objectives}} \item{result.dir}{path where results of VGEST runs are stored (See \code{\link[=vgest_run_store]{vgest_run_store()}})} } @@ -21,6 +21,6 @@ This function is preferred to \code{\link[=vgest_read]{vgest_read()}} because it } \examples{ \dontrun{ -vgest_read_one(1, get_objectives()[1,], "./database") +vgest_read_one(1, objectives[1,], "./database") } } diff --git a/man/vgest_run_store.Rd b/man/vgest_run_store.Rd index 8642fe4..237bf01 100644 --- a/man/vgest_run_store.Rd +++ b/man/vgest_run_store.Rd @@ -37,7 +37,7 @@ vgest_run_store(x, ...) ) } \arguments{ -\item{x}{row(s) of a \link{data.frame} provided by \code{\link[=get_objectives]{get_objectives()}}} +\item{x}{row(s) of a \link{data.frame} provided by \link{objectives}} \item{...}{other parameter passed to the method \link{vgest_run_store.character}} @@ -77,13 +77,13 @@ Prepare, run and store results of one or several VGEST instances \dontrun{ # Example with `vgest_run_store.Objectives` # Running vgest for: -# - the first objective returned by `get_objectives()` +# - the first objective returned by `objectives` # - the first configuration of reservoir rules # - the first configuration of network # - the naturalized hydrological flows of the file located in DONNEES/Q_NAT_1900-2009.txt # - doing the optimization on the period between 01/01/1900 and 31/12/2009 # - a task distribution function of present volumes and maximum usable volume replenishment times from the start of time steps -vgest_run_store(get_objectives()[1,], +vgest_run_store(objectives[1,], 1, 1, "Q_NAT_1900-2009.txt", "01/01/1900", "31/12/2009", 2) -- GitLab