From de469bc5c47b664343f181cbeaa7f89c768bc76a Mon Sep 17 00:00:00 2001 From: Dorchies David <david.dorchies@inrae.fr> Date: Tue, 27 Apr 2021 14:15:32 +0200 Subject: [PATCH] feat: add station names - also reduce discretisation of prob to 5% Refs #14, #15 --- R/calcInstantRisk.R | 2 +- R/calcRiskHeatMap.R | 2 +- R/mod_one_objective_focus.R | 3 +-- R/station_names.R | 10 ++++++++++ 4 files changed, 13 insertions(+), 4 deletions(-) create mode 100644 R/station_names.R diff --git a/R/calcInstantRisk.R b/R/calcInstantRisk.R index 15628a0..d03bd95 100644 --- a/R/calcInstantRisk.R +++ b/R/calcInstantRisk.R @@ -49,7 +49,7 @@ calcInstantRisk <- function(con, ruleset, date, storages, n = 10L) { NULL } }) - names(l) <- paste(objectives$station, objectives$level, "Q", + names(l) <- paste(station_names[objectives$station], objectives$level, "Q", ifelse(objectives$flood, "<", ">"), objectives$threshold, "m3/s") df <- data.frame(id_objective = seq.int(nrow(objectives)), diff --git a/R/calcRiskHeatMap.R b/R/calcRiskHeatMap.R index 35a5b79..044b878 100644 --- a/R/calcRiskHeatMap.R +++ b/R/calcRiskHeatMap.R @@ -17,7 +17,7 @@ calcRiskHeatMap <- function(con, ruleset, station, level, lake) { dataLength <- length(which(cdf$id_cal_day == calday)) if(dataLength > 1) { l <- approx(cdf$V[cdf$id_cal_day == calday], cdf$prob[cdf$id_cal_day == calday], discretStorage, rule = 2) - data.frame(julian = i, day = calday, V = l$x, prob = round(l$y, digits = 1)) + data.frame(julian = i, day = calday, V = l$x, prob = round(l$y *20)/20) } else if(dataLength == 1){ data.frame(julian = i, day = calday, V = discretStorage, prob = 0) } else { diff --git a/R/mod_one_objective_focus.R b/R/mod_one_objective_focus.R index 07047e9..e105eac 100644 --- a/R/mod_one_objective_focus.R +++ b/R/mod_one_objective_focus.R @@ -13,7 +13,7 @@ mod_one_objective_focus_ui <- function(id){ rulesets <- seq(length(rvgest::rulesets$rules)) names(rulesets) <- paste0(rulesets, ". ", rvgest::rulesets$rules) stations <- unique(rvgest::objectives$station) - names(stations) <- stations + names(stations) <- station_names levels <- unique(rvgest::objectives$level) names(levels) <- levels tagList( @@ -67,7 +67,6 @@ mod_one_objective_focus_server <- function(id, con, SGL_RT_storage){ names(levels) <- paste(objectives$level, "Q", ifelse(objectives$flood, "<", ">"), objectives$threshold, "m3/s") - golem::print_dev(levels) updateSelectInput(session, inputId = "level", choices = levels) }) diff --git a/R/station_names.R b/R/station_names.R new file mode 100644 index 0000000..84db6f9 --- /dev/null +++ b/R/station_names.R @@ -0,0 +1,10 @@ +station_names <- strsplit("Arcis-sur-Aube +Mery-sur-Seine +Nogent-sur-Seine +Gurgy (Yonne) +Courlon-sur-Yonne +Alfortville (Seine) +Chalons-sur-Marne +Noisiel (Marne) +Paris (Seine)", "\n")[[1]] +names(station_names) <- unique(rvgest::objectives$station) -- GitLab