if (FALSE) {
# Select interactively a study. It only works on windows.
setSimulationPath()
# Specify path of the study. Note: if there are more than one simulation
# output in the study, the function will asks the user to interactively choose
# one simulation.
setSimulationPath("path_of_the_folder_of_the_study")
# Select the first simulation of a study
setSimulationPath("path_of_the_folder_of_the_study", 1)
# Select the last simulation of a study
setSimulationPath("path_of_the_folder_of_the_study", -1)
# Select a simulation by name
setSimulationPath("path_of_the_folder_of_the_study", "name of the simulation")
# Just need to read input data
setSimulationPath("path_of_the_folder_of_the_study", "input")
# or
setSimulationPath("path_of_the_folder_of_the_study", 0)
# Working with API
#--------------------------
setSimulationPathAPI(
host = "http://antares_api_adress",
study_id = "study_id_on_api",
token = "token"
)
## Custom httr options ?
# global using httr package
require(httr)
set_config(verbose())
setSimulationPathAPI(
host = "http://antares_api_adress",
study_id = "study_id_on_api",
token = "token"
)
reset_config()
# or in setSimulationPathAPI
setSimulationPathAPI(
host = "http://antares_api_adress",
study_id = "study_id_on_api",
token = "token",
httr_config = config(verbose = TRUE)
)
# disable ssl certificate checking ?
setSimulationPathAPI(
host = "http://antares_api_adress",
study_id = "study_id_on_api",
token = "token",
httr_config = config(ssl_verifypeer = FALSE)
)
# WORKING WITH MULTIPLE SIMULATIONS
#----------------------------------
# Let us assume ten simulations have been run and we want to collect the
# variable "LOAD" for each area. We can create a list containing options
# for each simulation and iterate through this list.
opts <- lapply(1:10, function(i) {
setSimulationPath("path_of_the_folder_of_the_study", i)
})
output <- lapply(opts, function(o) {
res <- readAntares(areas = "all", select = "LOAD", timeStep = "monthly", opts = o)
# Add a column "simulation" containing the name of the simulation
res$simulation <- o$name
res
})
# Concatenate all the tables in one super table
output <- rbindlist(output)
# Reshape output for easier comparisons: one line per timeId and one column
# per simulation
output <- dcast(output, timeId + areaId ~ simulation, value.var = "LOAD")
output
# Quick visualization
matplot(output[area == area[1], !c("area", "timeId"), with = FALSE],
type = "l")
}
Run the code above in your browser using DataLab