From cf3a096828f96eb6215376bbd5679f67c64e9f68 Mon Sep 17 00:00:00 2001 From: pvictor Date: Wed, 25 Apr 2018 15:51:30 +0200 Subject: [PATCH] minor changes --- .gitignore | 1 + R/create_wm_cluster.R | 7 +++++-- R/create_wm_hydro_areas.R | 17 ++++++++++------- R/create_wm_misc.R | 2 +- R/create_wm_ror.R | 4 ++-- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index 46e8d83..a9b056a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ .Ruserdata *.Rproj test_case/ +test_output/ diff --git a/R/create_wm_cluster.R b/R/create_wm_cluster.R index 9b3c7cd..4b06e4d 100644 --- a/R/create_wm_cluster.R +++ b/R/create_wm_cluster.R @@ -37,8 +37,10 @@ create_wm_cluster <- function(data, start = NULL, rm_prev_clus = TRUE, sort_othe if (!is.null(start)) { start <- as.Date(start) data <- copy(data) - data <- data[as.Date(datetime, tz = "Europe/Paris") >= start] - data <- data[as.Date(datetime) < start + 7] + # data <- data[as.Date(datetime, tz = "Europe/Paris") >= start] + # data <- data[as.Date(datetime) < start + 7] + data <- data[format(datetime, format = "%Y-%m-%d") >= format(start)] + data <- data[format(datetime, format = "%Y-%m-%d") < format(start + 7)] } n_168 <- data[, .N, by = code_groupe] @@ -123,6 +125,7 @@ create_wm_cluster <- function(data, start = NULL, rm_prev_clus = TRUE, sort_othe tryCreateCluster <- function(args) { # Sys.sleep(0.1) # try(stop("erreur"), silent = TRUE) + args <- args[!duplicated(names(args))] try(do.call(createCluster, args), silent = TRUE) } diff --git a/R/create_wm_hydro_areas.R b/R/create_wm_hydro_areas.R index 709e2ed..84602c4 100644 --- a/R/create_wm_hydro_areas.R +++ b/R/create_wm_hydro_areas.R @@ -55,7 +55,8 @@ create_wm_hydro_areas <- function(start, # Configuration des liens areas/lac for (i in areas) { - print(i) + # print(i) + cat(format(sprintf("Creating links for %s...\n", i), width = getOption("width"))) links_etude <- antaresRead::getLinks(opts = opts) if (paste0(i, " - lac") %in% links_etude || paste0("lac - ", i) %in% links_etude) { @@ -106,7 +107,7 @@ create_wm_hydro_areas <- function(start, max_lac <- max_lac_area + max_lac } - print(max_lac) + # print(max_lac) # Changement de nominal capacity du lac_generator if (nrow(readClusterDesc(opts = opts)[area == "lac", ]) != 0 ) { cluster_lac <- readClusterDesc(opts = opts)[area == "lac", ] @@ -114,8 +115,8 @@ create_wm_hydro_areas <- function(start, # Test avec capa_lac_autres qui reste a determiner - capa_cluster_lac <- capa_lac_fr+max_lac - print(capa_cluster_lac) + capa_cluster_lac <- capa_lac_fr + max_lac + # print(capa_cluster_lac) opts <- createCluster( area = "lac", @@ -137,7 +138,8 @@ create_wm_hydro_areas <- function(start, # Creation des binding constraints pour l'energie turbine par le noeud lac for (i in areas) { - print(i) + # print(i) + cat(format(sprintf("Creating binding constraints for %s...\n", i), width = getOption("width"))) energy_lac <- readEnergy(area = i, opts = input_pdh) energy_lac <- energy_lac[date >= date_i & date < date_f]$expectation @@ -175,10 +177,11 @@ create_wm_hydro_areas <- function(start, } } - print(i) + # print(i) + cat(format(sprintf("Reset hydro storage for %s...\n", i), width = getOption("width"))) # antaresWaterValues::resetHydroStorage(i, opts = opts) matrix_null <- NULL - print("reset hydro storage") + # print("reset hydro storage") write.table( x = matrix_null, diff --git a/R/create_wm_misc.R b/R/create_wm_misc.R index 26826e1..df02bd3 100644 --- a/R/create_wm_misc.R +++ b/R/create_wm_misc.R @@ -71,7 +71,7 @@ create_wm_misc <- function(data, start = NULL, sort_misc = TRUE, opts = antaresR start_sim = opts$start ) } - cat("\nReordering Misc - Done!\n") + cat(format("\nReordering Misc - Done!\n", width = getOption("width"))) } diff --git a/R/create_wm_ror.R b/R/create_wm_ror.R index bbeb7e1..0cb4b28 100644 --- a/R/create_wm_ror.R +++ b/R/create_wm_ror.R @@ -80,14 +80,14 @@ create_wm_ror <- function(data, start = NULL, startday = "samedi", sort_areas = if (sort_areas) { areas <- getAreas(exclude = "fr") for (a in areas) { - cat(sprintf("\rReordering ROR for %s...", a)) + cat(format(sprintf("\rReordering ROR for %s...", a), width = getOption("width"))) reorder_hourly( path = file.path(inputPath, "hydro", "series", a, "ror.txt"), start_wm = start, start_sim = opts$start ) } - cat("\rReordering ROR - Done!\n") + cat(format("\rReordering ROR - Done!\n", width = getOption("width"))) } }