Title: | Import, Manipulate and Explore the Results of an 'Antares' Simulation |
---|---|
Description: | Import, manipulate and explore results generated by 'Antares', a powerful open source software developed by RTE (Réseau de Transport d’Électricité) to simulate and study electric power systems (more information about 'Antares' here : <https://antares-simulator.org/>). |
Authors: | Tatiana Vargas [aut, cre], Jalal-Edine ZAWAM [aut], Frederic Breant [ctb], Francois Guillem [aut], Benoit Thieurmel [aut], Titouan Robert [aut], Victor Perrier [ctb], Etienne Sanchez [ctb], Assil Mansouri [ctb], Clement Berthet [ctb], Kamel Kemiha [ctb], Abdallah Mahoudi [ctb], Nicolas Boitard [ctb], RTE [cph] |
Maintainer: | Tatiana Vargas <[email protected]> |
License: | GPL (>= 2) | file LICENSE |
Version: | 2.9.0 |
Built: | 2025-02-13 09:29:32 UTC |
Source: | https://github.com/rte-antares-rpackage/antaresread |
API methods
api_get( opts, endpoint, ..., default_endpoint = "v1/studies", parse_result = NULL, encoding = NULL ) api_post(opts, endpoint, ..., default_endpoint = "v1/studies") api_put(opts, endpoint, ..., default_endpoint = "v1/studies") api_delete(opts, endpoint, ..., default_endpoint = "v1/studies")
api_get( opts, endpoint, ..., default_endpoint = "v1/studies", parse_result = NULL, encoding = NULL ) api_post(opts, endpoint, ..., default_endpoint = "v1/studies") api_put(opts, endpoint, ..., default_endpoint = "v1/studies") api_delete(opts, endpoint, ..., default_endpoint = "v1/studies")
opts |
Antares simulation options or a |
endpoint |
API endpoint to interrogate, it will be added after |
... |
Additional arguments passed to API method. |
default_endpoint |
Default endpoint to use. |
parse_result |
|
encoding |
argument to pass as argument to the function |
Response from the API.
## Not run: # List studies with local API # default result content in R object (auto parsed) api_get(opts = list(host = "http://0.0.0.0:8080"), endpoint = NULL, parse_result = NULL) # you can force parse options as text and encoding to UTF-8 api_get(opts = list(host = "http://0.0.0.0:8080"), endpoint = NULL, parse_result = "text", encoding = "UTF-8") ## End(Not run)
## Not run: # List studies with local API # default result content in R object (auto parsed) api_get(opts = list(host = "http://0.0.0.0:8080"), endpoint = NULL, parse_result = NULL) # you can force parse options as text and encoding to UTF-8 api_get(opts = list(host = "http://0.0.0.0:8080"), endpoint = NULL, parse_result = "text", encoding = "UTF-8") ## End(Not run)
This function converts a list of tables or table into an
antaresDataList
object.
An antaresDataList
is a list of tables of classantaresDataTable
.
It also has attributes that store the time step, the type of data and the
simulation options.
as.antaresDataList(x, ...) ## S3 method for class 'antaresDataTable' as.antaresDataList(x, name = NULL, ...) ## S3 method for class 'data.frame' as.antaresDataList( x, synthesis, timeStep, type, opts = simOptions(), name = type, ... )
as.antaresDataList(x, ...) ## S3 method for class 'antaresDataTable' as.antaresDataList(x, name = NULL, ...) ## S3 method for class 'data.frame' as.antaresDataList( x, synthesis, timeStep, type, opts = simOptions(), name = type, ... )
x |
Data.frame or data.table to convert to a an antaresDataTable. |
... |
Arguments to be passed to methods. |
name |
name of the table in the final object. If |
synthesis |
Does the table contain synthetic results ? |
timeStep |
Time step of the data. One of "hourly", "daily", "weekly", "monthly" or "annual". |
type |
type of data: for instance "areas", "links", "clusters", etc. |
opts |
Simulation options. |
antaresDataList
object.
This function converts a data.frame
or a data.table
into an
antaresDataTable
object.
An antaresDataTable
is simply a data.table
with additional
attributes recording the time step, the type of data and the simulation
options.
as.antaresDataTable(x, ...) ## S3 method for class 'data.frame' as.antaresDataTable(x, synthesis, timeStep, type, opts = simOptions(), ...)
as.antaresDataTable(x, ...) ## S3 method for class 'data.frame' as.antaresDataTable(x, synthesis, timeStep, type, opts = simOptions(), ...)
x |
object to convert to a an |
... |
Arguments to be passed to methods. |
synthesis |
Does the table contain synthetic results ? |
timeStep |
Time step of the data. One of "hourly", "daily", "weekly", "monthly" or "annual". |
type |
type of data: for instance "areas", "links", "clusters", etc. |
opts |
Simulation options. |
antaresDataTable
object.
This function changes the timestep of a table or an antaresData
object
and performs the required aggregation or desaggregation. We can specify
(des)aggregate functions by columns, see the param fun
.
changeTimeStep(x, newTimeStep, oldTimeStep, fun = "sum", opts = simOptions())
changeTimeStep(x, newTimeStep, oldTimeStep, fun = "sum", opts = simOptions())
x |
data.table with a column "timeId" or an object of class "antaresDataList" |
newTimeStep |
Desired time step.The possible values are hourly, daily, weekly, monthly and annual. |
oldTimeStep |
Current time step of the data. This argument is optional for an object of
class |
fun |
Character vector with one element per column to (des)aggregate indicating the function to use ("sum", "mean", "min" or "max") for this column. It can be a single element, in that case the same function is applied to every columns. |
opts |
list of simulation parameters returned by the function
|
Either a data.table or an object of class "antaresDataList" depending on the
class of x
## Not run: setSimulationPath() areasH <- readAntares(select = "LOAD", synthesis = FALSE, mcYears = 1) areasD <- readAntares(select = "LOAD", synthesis = FALSE, mcYears = 1, timeStep ="daily") areasDAgg <- changeTimeStep(areasH, "daily", "hourly") all.equal(areasDAgg$LOAD, areasD$LOAD) # Use different aggregation functions mydata <- readAntares(select = c("LOAD", "MRG. PRICE"), timeStep = "monthly") changeTimeStep(mydata, "annual", fun = c("sum", "mean")) ## End(Not run)
## Not run: setSimulationPath() areasH <- readAntares(select = "LOAD", synthesis = FALSE, mcYears = 1) areasD <- readAntares(select = "LOAD", synthesis = FALSE, mcYears = 1, timeStep ="daily") areasDAgg <- changeTimeStep(areasH, "daily", "hourly") all.equal(areasDAgg$LOAD, areasD$LOAD) # Use different aggregation functions mydata <- readAntares(select = c("LOAD", "MRG. PRICE"), timeStep = "monthly") changeTimeStep(mydata, "annual", fun = c("sum", "mean")) ## End(Not run)
copyToClipboard
is a utility function that copies data to the
clipboard. The data can then be copied in another program like excel.
copyToClipboard(x, ...) ## S3 method for class 'antaresDataList' copyToClipboard(x, what, ...)
copyToClipboard(x, ...) ## S3 method for class 'antaresDataList' copyToClipboard(x, what, ...)
x |
an object used to select a method. |
... |
arguments passed to |
what |
character or numeric indicating which element to copy to clipboard (areas, links, clusters or districts) |
The function does not return anything. It is only used to interact with the clipboard
The function is useful only for small data objects: for a table,
only the 50000 rows are copied to clipboard. If the table to copy
is longer, either use filters to reduce the number of rows or write the
table in text file with write.table
# This only works on Windows systems ## Not run: x <- data.frame(a = sample(10), b = sample(10)) copyToClipboard(x) # Try to open excel and use CTRL + V to copy the data in a spreadsheet. ## End(Not run)
# This only works on Windows systems ## Not run: x <- data.frame(a = sample(10), b = sample(10)) copyToClipboard(x) # Try to open excel and use CTRL + V to copy the data in a spreadsheet. ## End(Not run)
This function converts an "readAntares" object in the data structure used by PPSE : instead of having one table for areas, one for links and one for clusters, the function creates a list with one element per area. Each element is a data.table containing the data about the area and one column per cluster of the area containing the production of this cluster.
extractDataList(x, areas = NULL)
extractDataList(x, areas = NULL)
x |
object of class "antaresData" or "antaresTable" created by the function
|
areas |
character vector containing the name of areas to keep in the
final object. If |
a list of data.tables with one element per area. The list also contains an element named "areaList" containing the name of areas in the object and a table called "infos" that contains for each area the number of variables of different type (values, details, link).
getAreas
and getDistricts
are utility functions that builds
list of areas or districts by using regular expressions to select and/or
exclude areas/districts
getAreas( select = NULL, exclude = NULL, withClustersOnly = FALSE, regexpSelect = TRUE, regexpExclude = TRUE, opts = simOptions(), ignore.case = TRUE, districts = NULL ) getDistricts( select = NULL, exclude = NULL, regexpSelect = TRUE, regexpExclude = TRUE, opts = simOptions(), ignore.case = TRUE )
getAreas( select = NULL, exclude = NULL, withClustersOnly = FALSE, regexpSelect = TRUE, regexpExclude = TRUE, opts = simOptions(), ignore.case = TRUE, districts = NULL ) getDistricts( select = NULL, exclude = NULL, regexpSelect = TRUE, regexpExclude = TRUE, opts = simOptions(), ignore.case = TRUE )
select |
Character vector. If |
exclude |
Character vector. If |
withClustersOnly |
Should the function return only nodes containing clusters ? |
regexpSelect |
Is |
regexpExclude |
Is |
opts |
list of simulation parameters returned by the function
|
ignore.case |
Should the case be ignored when evaluating the regular expressions ? |
districts |
Names of districts. If this argument is not null, only areas belonging to the specified districts are returned. |
A character vector containing the name of the areas/districts satisfying the rules defined by the parameters.
Read geographic trimming (filtering) options
getGeographicTrimming(areas = NULL, links = TRUE, opts = simOptions())
getGeographicTrimming(areas = NULL, links = TRUE, opts = simOptions())
areas |
Character. vector of areas |
links |
Logical. if TRUE, return filtering options for all links starting from selected areas |
opts |
List. simulation options |
list of filtering options for areas and links
getIdCols
return the id columns of an AntaresDataTable
getIdCols(x = NULL)
getIdCols(x = NULL)
x |
an AntaresDataTable. |
A character vector containing the name of the id columns of an antaresDataTable
This function finds the names of the links connected to a set of areas.
getLinks( areas = NULL, exclude = NULL, opts = simOptions(), internalOnly = FALSE, namesOnly = TRUE, withDirection = FALSE, withTransmission = FALSE )
getLinks( areas = NULL, exclude = NULL, opts = simOptions(), internalOnly = FALSE, namesOnly = TRUE, withDirection = FALSE, withTransmission = FALSE )
areas |
Vector containing area names. It represents the set of areas we are interested
in. If |
exclude |
Vector containing area names. If not |
opts |
list of simulation parameters returned by the function
|
internalOnly |
If |
namesOnly |
If |
withDirection |
Used only if |
withTransmission |
Used only if |
If namesOnly = TRUE
the function returns a vector containing link names
If namesOnly = FALSE
and withDirection = FALSE
, it returns a
data.table
with exactly one line per link and with three columns:
link |
Link name |
from |
First area connected to the link |
to |
Second area connected to the link |
If namesOnly = FALSE
and withDirection = TRUE
, it returns a
data.table
with one or two lines per link and with four columns:
area |
Area name |
link |
Link name |
to |
Area connected to |
direction |
1 if the link connects |
## Not run: # Get all links of a study getLinks() # Get all links with their origins and destinations getLinks(namesOnly = FALSE) # Get all links connected to French areas (assuming their names contain "fr") getLinks(getAreas("fr")) # Same but with only links connecting two French areas getLinks(getAreas("fr"), internalOnly = TRUE) # Exclude links connecting real areas with pumped storage virtual areas # (assuming their names contain "psp") getLinks(getAreas("fr"), exclude = getAreas("psp")) ## End(Not run)
## Not run: # Get all links of a study getLinks() # Get all links with their origins and destinations getLinks(namesOnly = FALSE) # Get all links connected to French areas (assuming their names contain "fr") getLinks(getAreas("fr")) # Same but with only links connecting two French areas getLinks(getAreas("fr"), internalOnly = TRUE) # Exclude links connecting real areas with pumped storage virtual areas # (assuming their names contain "psp") getLinks(getAreas("fr"), exclude = getAreas("psp")) ## End(Not run)
usage for hvdc
hvdcModification(data, removeHvdcAreas = TRUE, reafectLinks = FALSE)
hvdcModification(data, removeHvdcAreas = TRUE, reafectLinks = FALSE)
data |
|
removeHvdcAreas |
|
reafectLinks |
|
Object of class "antaresDataList" is returned. It is a list of data.tables, each element representing one type of element (areas, links, clusters)
## Not run: data <- readAntares(areas = 'all', links = 'all') data <- setHvdcAreas(data, "psp in") data <- hvdcModification(data) ## End(Not run)
## Not run: data <- readAntares(areas = 'all', links = 'all') data <- setHvdcAreas(data, "psp in") data <- hvdcModification(data) ## End(Not run)
Merge two digests
mergeDigests(digest_new, digest_ori)
mergeDigests(digest_new, digest_ori)
digest_new |
new digest with missing lines |
digest_ori |
original digest with all lines |
updated digest list of 5 tables (begin, areas, middle, links lin., links quad.)
Creation of Mc_all new (only antares > V6)
parAggregateMCall( opts, nbcl = 8, verbose = 2, timestep = c("annual", "daily", "hourly", "monthly", "weekly"), writeOutput = TRUE, mcWeights = NULL, mcYears = NULL, filtering = FALSE, selected = NULL, legacy = FALSE ) aggregateResult( opts, verbose = 2, timestep = c("annual", "daily", "hourly", "monthly", "weekly"), writeOutput = TRUE, mcWeights = NULL, mcYears = NULL, filtering = FALSE, selected = NULL, legacy = FALSE )
parAggregateMCall( opts, nbcl = 8, verbose = 2, timestep = c("annual", "daily", "hourly", "monthly", "weekly"), writeOutput = TRUE, mcWeights = NULL, mcYears = NULL, filtering = FALSE, selected = NULL, legacy = FALSE ) aggregateResult( opts, verbose = 2, timestep = c("annual", "daily", "hourly", "monthly", "weekly"), writeOutput = TRUE, mcWeights = NULL, mcYears = NULL, filtering = FALSE, selected = NULL, legacy = FALSE )
opts |
|
nbcl |
|
verbose |
|
timestep |
|
writeOutput |
|
mcWeights |
|
mcYears |
|
filtering |
|
selected |
|
legacy |
|
Object list
of data.tables, each element representing one type
of element (areas, links, clusters)
Mcyear aggregation weigthed by wd
ponderateMcAggregation(x, fun = weighted.mean, ...)
ponderateMcAggregation(x, fun = weighted.mean, ...)
x |
|
fun |
|
... |
|
Object of class "antaresDataTable".
## Not run: data <- readAntares(areas = 'all', mcYears = 'all') ponderateMcAggregation(data, fun = weighted.mean, w = c(.1, .9)) ## End(Not run)
## Not run: data <- readAntares(areas = 'all', mcYears = 'all') ponderateMcAggregation(data, fun = weighted.mean, w = c(.1, .9)) ## End(Not run)
Read configuration options from file or API
readIni(pathIni, opts = antaresRead::simOptions(), default_ext = ".ini") readIniFile(file, stringsAsFactors = FALSE) readIniAPI(study_id, path, host, token = NULL)
readIni(pathIni, opts = antaresRead::simOptions(), default_ext = ".ini") readIniFile(file, stringsAsFactors = FALSE) readIniAPI(study_id, path, host, token = NULL)
pathIni |
Path to config/ini file to read. |
opts |
List of simulation parameters returned by the function
|
default_ext |
Default extension used for config files. |
file |
File path. |
stringsAsFactors |
logical: should character vectors be converted to factors? |
study_id |
Study's identifier. |
path |
Path of configuration object to read. |
host |
Host of AntaREST server API. |
token |
API personnal access token. |
A list with an element for each section of the .ini file.
## Not run: library(antaresRead) library(antaresEditObject) # With physical study: setSimulationPath("../tests-studies/Study_V8.2/", simulation = "input") readIni("settings/generaldata") # With API setSimulationPathAPI( host = "http://localhost:8080", study_id = "73427ae1-be83-44e0-b04f-d5127e53424c", token = NULL, simulation = "input" ) readIni("settings/generaldata") ## End(Not run)
## Not run: library(antaresRead) library(antaresEditObject) # With physical study: setSimulationPath("../tests-studies/Study_V8.2/", simulation = "input") readIni("settings/generaldata") # With API setSimulationPathAPI( host = "http://localhost:8080", study_id = "73427ae1-be83-44e0-b04f-d5127e53424c", token = NULL, simulation = "input" ) readIni("settings/generaldata") ## End(Not run)
readAntares
is a swiss-army-knife function used to read almost every
possible time series of an antares Project at any desired time resolution
(hourly, daily, weekly, monthly or annual).
It was first designed to read
output time series, but it can also read input time series. The input time
series are processed by the function to fit the query of the user (timeStep,
synthetic results or Monte-Carlo simulation, etc.). The few data that are not
read by readAntares
can generally by read with other functions of the
package starting with "read" (readClusterDesc
,
readLayout
, readBindingConstraints
)
readAntares( areas = NULL, links = NULL, clusters = NULL, districts = NULL, clustersRes = NULL, clustersST = NULL, bindingConstraints = FALSE, misc = FALSE, thermalAvailabilities = FALSE, hydroStorage = FALSE, hydroStorageMaxPower = FALSE, reserve = FALSE, linkCapacity = FALSE, mustRun = FALSE, thermalModulation = FALSE, select = NULL, mcYears = NULL, timeStep = c("hourly", "daily", "weekly", "monthly", "annual"), mcWeights = NULL, opts = simOptions(), parallel = FALSE, simplify = TRUE, showProgress = TRUE )
readAntares( areas = NULL, links = NULL, clusters = NULL, districts = NULL, clustersRes = NULL, clustersST = NULL, bindingConstraints = FALSE, misc = FALSE, thermalAvailabilities = FALSE, hydroStorage = FALSE, hydroStorageMaxPower = FALSE, reserve = FALSE, linkCapacity = FALSE, mustRun = FALSE, thermalModulation = FALSE, select = NULL, mcYears = NULL, timeStep = c("hourly", "daily", "weekly", "monthly", "annual"), mcWeights = NULL, opts = simOptions(), parallel = FALSE, simplify = TRUE, showProgress = TRUE )
areas |
Vector containing the names of the areas to import. If
|
links |
Vector containing the name of links to import. If |
clusters |
Vector containing the name of the areas for which you want to
import results at thermal cluster level. If |
districts |
Vector containing the names of the districts to import. If |
clustersRes |
Vector containing the name of the areas for which you want to
import results at renewable cluster level. If |
clustersST |
Vector containing the name of the areas for which you want to
import results at short-term cluster level. If |
bindingConstraints |
Should binding constraints be imported (v8.4+)? |
misc |
Vector containing the name of the areas for which you want to import misc. |
thermalAvailabilities |
Should thermal availabilities of clusters be imported ? If TRUE, the column "thermalAvailability" is added to the result and a new column "availableUnits" containing the number of available units in a cluster is created.If synthesis is set to TRUE then "availableUnits" contain the mean of avaible units on all MC Years. |
hydroStorage |
Should hydro storage be imported ? |
hydroStorageMaxPower |
Should hydro storage maximum power be imported ? |
reserve |
Should reserve be imported ? |
linkCapacity |
Should link capacities be imported ? |
mustRun |
Should must run productions be added to the result? If TRUE,
then four columns are added: |
thermalModulation |
Should thermal modulation time series be imported ? If |
select |
Character vector containing the name of the columns to import. If this
argument is |
mcYears |
Index of the Monte-Carlo years to import. If |
timeStep |
Resolution of the data to import: hourly (default), daily, weekly, monthly or annual. |
mcWeights |
Vector of weights to apply to the specified mcYears. If not |
opts |
list of simulation parameters returned by the function
|
parallel |
Should the importation be parallelized ? (See details) |
simplify |
If TRUE and only one type of output is imported then a data.table is returned. If FALSE, the result will always be a list of class "antaresData". |
showProgress |
If TRUE the function displays information about the progress of the importation. |
If parameters areas
, links
, clusters
and districts
are all NULL
, readAntares
will read output for all areas.
By default the function reads synthetic results if they are available.
readAntares
is able to read input time series, but when they are not
stored in output, these time series may have changed since a simulation has
been run. In such a case the function will remind you this danger with a
warning.
When individual Monte-Carlo simulations are read, the function may crash because of insufficient memory. In such a case, it is necessary to reduce size of the output. Different strategies are available depending on your objective:
Use a larger time step (parameter timeStep
)
Filter the elements to import (parameters areas
,links
,
clusters
and districts
)
Select only a few columns (parameter select
)
read only a subset of Monte-Carlo simulations (parameter
mcYears
). For instance one can import a random sample of
100 simulations with mcYears = sample(simOptions()$mcYears, 100)
If simplify = TRUE
and only one type of output is imported
then the result is a data.table.
Else an object of class "antaresDataList" is returned. It is a list of data.tables, each element representing one type of element (areas, links, clusters)
If you import several elements of the same type (areas, links, clusters), you
can use parallelized importation to improve performance. Setting the
parameter parallel = TRUE
is not enough to parallelize the
importation, you also have to install the package
foreach
and a package that provides a parallel backend (for instance the package
doParallel).
Before running the function with argument parallel=TRUE
, you need to
register your parallel backend. For instance, if you use package "doParallel"
you need to use the function registerDoParallel
once per
session.
setSimulationPath
, getAreas
,
getLinks
, getDistricts
## Not run: # Import areas and links separately areas <- readAntares() # equivalent to readAntares(areas="all") links <- readAntares(links="all") # Import areas and links at same time output <- readAntares(areas = "all", links = "all") # Add input time series to the object returned by the function areas <- readAntares(areas = "all", misc = TRUE, reserve = TRUE) # Get all output for one area myArea <- sample(simOptions()$areaList, 1) myArea myAreaOutput <- readAntares(area = myArea, links = getLinks(myArea, regexpSelect=FALSE), clusters = myArea) # Or equivalently: myAreaOutput <- readAntaresAreas(myArea) # Use parameter "select" to read only some columns. areas <- readAntares(select = c("LOAD", "OV. COST")) # Aliases can be used to select frequent groups of columns. use showAliases() # to view a list of available aliases areas <- readAntares(select="economy") ## End(Not run)
## Not run: # Import areas and links separately areas <- readAntares() # equivalent to readAntares(areas="all") links <- readAntares(links="all") # Import areas and links at same time output <- readAntares(areas = "all", links = "all") # Add input time series to the object returned by the function areas <- readAntares(areas = "all", misc = TRUE, reserve = TRUE) # Get all output for one area myArea <- sample(simOptions()$areaList, 1) myArea myAreaOutput <- readAntares(area = myArea, links = getLinks(myArea, regexpSelect=FALSE), clusters = myArea) # Or equivalently: myAreaOutput <- readAntaresAreas(myArea) # Use parameter "select" to read only some columns. areas <- readAntares(select = c("LOAD", "OV. COST")) # Aliases can be used to select frequent groups of columns. use showAliases() # to view a list of available aliases areas <- readAntares(select="economy") ## End(Not run)
This a function is a wrapper for "antaresData" that reads all data for a list of areas.
readAntaresAreas( areas, links = TRUE, clusters = TRUE, clustersRes = TRUE, internalOnly = FALSE, opts = simOptions(), ... )
readAntaresAreas( areas, links = TRUE, clusters = TRUE, clustersRes = TRUE, internalOnly = FALSE, opts = simOptions(), ... )
areas |
Vector containing area names. It represents the set of areas we are interested
in. If |
links |
should links connected to the areas be imported ? |
clusters |
should the thermal clusters of the areas be imported ? |
clustersRes |
should the renewable clusters of the areas be imported ? |
internalOnly |
If |
opts |
list of simulation parameters returned by the function
|
... |
Other arguments passed to the function |
If simplify = TRUE
and only one type of output is imported
then the result is a data.table.
Else an object of class "antaresData" is returned. It is a list of data.tables, each element representing one type of element (areas, links, clusters)
## Not run: myarea <- simOptions()$areaList[1] data <- readAntaresAreas(myarea) # Equivalent but more concise than: data2 <- readAntares(myarea, links = getLinks(myarea), clusters = myarea) all.equal(data, data2) ## End(Not run)
## Not run: myarea <- simOptions()$areaList[1] data <- readAntaresAreas(myarea) # Equivalent but more concise than: data2 <- readAntares(myarea, links = getLinks(myarea), clusters = myarea) all.equal(data, data2) ## End(Not run)
Read output for a list of clusters
readAntaresClusters( clusters, selected = c("production", "NP Cost", "NODU", "profit"), timeStep = c("hourly", "daily", "weekly", "monthly", "annual"), opts = simOptions(), parallel = FALSE, showProgress = TRUE )
readAntaresClusters( clusters, selected = c("production", "NP Cost", "NODU", "profit"), timeStep = c("hourly", "daily", "weekly", "monthly", "annual"), opts = simOptions(), parallel = FALSE, showProgress = TRUE )
clusters |
vector of thermal clusters to be imported |
selected |
vector of thematic trimming |
timeStep |
Resolution of the data to import: hourly (default), daily, weekly, monthly or annual. |
opts |
list of simulation parameters returned by the function
|
parallel |
Should the importation be parallelized ? (See details) |
showProgress |
If TRUE the function displays information about the progress of the importation. |
data.table of results for thermal clusters
Read output for a list of short-term storage clusters
readAntaresSTClusters( clustersST, selected = c("P.injection", "levels", "P.withdrawal"), timeStep = c("hourly", "daily", "weekly", "monthly", "annual"), opts = simOptions(), parallel = FALSE, showProgress = TRUE )
readAntaresSTClusters( clustersST, selected = c("P.injection", "levels", "P.withdrawal"), timeStep = c("hourly", "daily", "weekly", "monthly", "annual"), opts = simOptions(), parallel = FALSE, showProgress = TRUE )
clustersST |
vector of short-term storage clusters to be imported |
selected |
vector of thematic trimming |
timeStep |
Resolution of the data to import: hourly (default), daily, weekly, monthly or annual. |
opts |
list of simulation parameters returned by the function
|
parallel |
Should the importation be parallelized ? (See details) |
showProgress |
If TRUE the function displays information about the progress of the importation. |
data.table of results for short-term storage clusters
This function reads the binding constraints of an Antares project.
Be aware that binding constraints are read in the input files of a study. So they may have changed since a simulation has been run.
readBindingConstraints(opts = simOptions())
readBindingConstraints(opts = simOptions())
opts |
list of simulation parameters returned by the function
|
An object of class bindingConstraints
. This object is also a named
list with 3 sections per read constraint.
Since release 2.7.0
the structure of the returned object has evolved for
all versions of study Antares:
.ini parameters are in section properties
Coeffcients links or thermal are in section coefs
Values are already in section values
For an study Antares version >=8.7.0. Now contains data.frame
with
one line per time step and colums according to "scenarized RHS".
For "both" case, you will find in section values
two data.frame
:
One data.frame
for less
One data.frame
for greater
For an study Antares version <8.7.0.
Section values
contains one line
per time step and three columns "less", "greater" and "equal"
## Not run: setSimulationPath() constraints <- readBindingConstraints() # read properties constraints$properties # read coefs constraints$coefs # read values constraints$values # both case ( study Antares >=8.7.0) constraints$values$less constraints$values$greater # display equation (only for study Antares <8.7.0) summary(constraints) ## End(Not run)
## Not run: setSimulationPath() constraints <- readBindingConstraints() # read properties constraints$properties # read coefs constraints$coefs # read values constraints$values # both case ( study Antares >=8.7.0) constraints$values$less constraints$values$greater # display equation (only for study Antares <8.7.0) summary(constraints) ## End(Not run)
This function reads in the input files of an antares study the characteristics of each cluster.
Be aware that clusters descriptions are read in the input files so they may have changed since a simulation has been run.
readClusterDesc(opts = simOptions(), dot_format = TRUE) readClusterResDesc(opts = simOptions(), dot_format = TRUE) readClusterSTDesc(opts = simOptions(), dot_format = TRUE)
readClusterDesc(opts = simOptions(), dot_format = TRUE) readClusterResDesc(opts = simOptions(), dot_format = TRUE) readClusterSTDesc(opts = simOptions(), dot_format = TRUE)
opts |
list of simulation parameters returned by the function
|
dot_format |
|
A data.table with one line per cluster. The columns of the data.table may change between different projects, but there will always be the following columns:
area |
Name of the area containing the cluster |
cluster |
Name of the cluster |
group |
Type of cluster (gaz, nuclear, etc.) |
unitcount |
number of production units |
nominalcapacity |
production capacity of each unit |
The other present columns depends on the version of antares and the options that have been set: if an option is unset for all clusters, it will not appear in the table.
By default, the function reads the cluster description of the default antares
study. You can use the argument opts
to specify another study.
readClusterDesc
: read thermal clusters
readClusterResDesc
: read renewable clusters (Antares >= V8.1)
readClusterSTDesc
: read st-storage clusters (Antares >= V8.6)
If you have no clusters properties, Null data.table (0 rows and 0 cols)
is returned.
You have now two format output to display input properties.
Default is format uses by operating team, eg min.down.time
.
Other format is according to antares simulator, eg min-down-time
.
All properties are returned with default values according to Antares Study version.
## Not run: # Default format with "dot separator" # thermal readClusterDesc() # renewable readClusterResDesc() # st-storage readClusterSTDesc() # Antares Simulator format #' # thermal readClusterDesc(dot_format = FALSE) # renewable readClusterResDesc(dot_format = FALSE) # st-storage readClusterSTDesc(dot_format = FALSE) # By default, the function reads cluster descriptions for the default study, # but it is possible to specify another study with parameter "opts" sim1 <- setSimulationPath() #[... code that modifies the default antares study] readClusterDesc(sim1) ## End(Not run)
## Not run: # Default format with "dot separator" # thermal readClusterDesc() # renewable readClusterResDesc() # st-storage readClusterSTDesc() # Antares Simulator format #' # thermal readClusterDesc(dot_format = FALSE) # renewable readClusterResDesc(dot_format = FALSE) # st-storage readClusterSTDesc(dot_format = FALSE) # By default, the function reads cluster descriptions for the default study, # but it is possible to specify another study with parameter "opts" sim1 <- setSimulationPath() #[... code that modifies the default antares study] readClusterDesc(sim1) ## End(Not run)
Read digest file
readDigestFile(opts, endpoint = "mc-all/grid/digest.txt")
readDigestFile(opts, endpoint = "mc-all/grid/digest.txt")
opts |
simulation options |
endpoint |
Suffix of path for digest file Default is : "mc-all/grid/digest.txt" added to opts$simDataPath |
list of 5 tables (begin, areas, middle, links lin., links quad.)
readInputRes
is a function that reads renewable time series from an antares
project. But contrary to readAntares
, it only reads time series
stored in the input folder, so it can work in "input" mode.
readInputRES( areas = "all", clusters, opts = simOptions(), timeStep = c("hourly", "daily", "weekly", "monthly", "annual"), simplify = TRUE, parallel = FALSE, showProgress = TRUE )
readInputRES( areas = "all", clusters, opts = simOptions(), timeStep = c("hourly", "daily", "weekly", "monthly", "annual"), simplify = TRUE, parallel = FALSE, showProgress = TRUE )
areas |
vector of RES areas names for which renewable time series must be read. |
clusters |
vector of RES clusters names for which renewable time series must be read. |
opts |
list of simulation parameters returned by the function
|
timeStep |
Resolution of the data to import: hourly (default), daily, weekly, monthly or annual. |
simplify |
If TRUE and only one type of output is imported then a data.table is returned. If FALSE, the result will always be a list of class "antaresData". |
parallel |
Should the importation be parallelized ? (See details) |
showProgress |
If TRUE the function displays information about the progress of the importation. |
data.table with class "antaresDataTable".
setSimulationPath
, readAntares
,
getAreas
, getLinks
readInputThermal
is a function that reads thermal time series from an antares
project. But contrary to readAntares
, it only reads time series
stored in the input folder, so it can work in "input" mode.
readInputThermal( areas = "all", clusters, thermalAvailabilities = TRUE, thermalModulation = FALSE, thermalData = FALSE, opts = simOptions(), timeStep = c("hourly", "daily", "weekly", "monthly", "annual"), simplify = TRUE, parallel = FALSE, showProgress = TRUE )
readInputThermal( areas = "all", clusters, thermalAvailabilities = TRUE, thermalModulation = FALSE, thermalData = FALSE, opts = simOptions(), timeStep = c("hourly", "daily", "weekly", "monthly", "annual"), simplify = TRUE, parallel = FALSE, showProgress = TRUE )
areas |
vector of areas names for which thermal time series must be read. |
clusters |
vector of clusters names for which thermal time series must be read. |
thermalAvailabilities |
if TRUE, return thermalAvailabilities data |
thermalModulation |
if TRUE, return thermalModulation data |
thermalData |
if TRUE, return thermalData from prepro |
opts |
list of simulation parameters returned by the function
|
timeStep |
Resolution of the data to import: hourly (default), daily, weekly, monthly or annual. |
simplify |
If TRUE and only one type of output is imported then a data.table is returned. If FALSE, the result will always be a list of class "antaresData". |
parallel |
Should the importation be parallelized ? (See details) |
showProgress |
If TRUE the function displays information about the progress of the importation. |
If thermalModulation or thermalData is TRUE, an object of class "antaresDataList" is returned. It is a list of data.tables for selected input
Else the result is a data.table with class "antaresDataTable".
the clusters parameter can also accept the special value "all". It indicates the function to read the desired time series for all clusters.
setSimulationPath
, readAntares
,
getAreas
, getLinks
readInputTS
is a function that reads time series from an antares
project. But contrary to readAntares
, it only reads time series
stored in the input folder, so it can work in "input" mode.
readInputTS( load = NULL, thermalAvailabilities = NULL, ror = NULL, mingen = NULL, hydroStorage = NULL, hydroStorageMaxPower = NULL, wind = NULL, solar = NULL, misc = NULL, reserve = NULL, linkCapacity = NULL, resProduction = NULL, st_storage = NULL, opts = simOptions(), timeStep = c("hourly", "daily", "weekly", "monthly", "annual"), simplify = TRUE, parallel = FALSE, showProgress = TRUE )
readInputTS( load = NULL, thermalAvailabilities = NULL, ror = NULL, mingen = NULL, hydroStorage = NULL, hydroStorageMaxPower = NULL, wind = NULL, solar = NULL, misc = NULL, reserve = NULL, linkCapacity = NULL, resProduction = NULL, st_storage = NULL, opts = simOptions(), timeStep = c("hourly", "daily", "weekly", "monthly", "annual"), simplify = TRUE, parallel = FALSE, showProgress = TRUE )
load |
vector of areas names for which load time series must be read. |
thermalAvailabilities |
vector of areas names for which thermal availabilities of clusters must be read. |
ror |
vector of areas names for which run of river time series must be read. |
mingen |
vector of areas names for which Hydro Pmin time series must be read. (only for Antares version >= 860) |
hydroStorage |
vector of areas names for which hydrolic storage time series must be read. |
hydroStorageMaxPower |
vector of areas names for which hydrolic storage maximum power time series must be read. |
wind |
vector of areas names for which wind time series must be read |
solar |
vector of areas names for which solar time series must be read |
misc |
vector of areas names for which misc time series must be read |
reserve |
vector of areas names for which reserve time series must be read |
linkCapacity |
vector of links names for which links characteristics time series must be read |
resProduction |
vector of areas names for which renewables clusters production time series must be read. |
st_storage |
vector of areas names for which st-storage clusters production time series must be read. |
opts |
list of simulation parameters returned by the function
|
timeStep |
Resolution of the data to import: hourly (default), daily, weekly, monthly or annual. |
simplify |
If TRUE and only one type of output is imported then a data.table is returned. If FALSE, the result will always be a list of class "antaresData". |
parallel |
Should the importation be parallelized ? (See details) |
showProgress |
If TRUE the function displays information about the progress of the importation. |
If simplify = TRUE
and only one type of input is imported
then the result is a data.table with class "antaresDataTable".
Else an object of class "antaresDataList" is returned. It is a list of data.tables, each element representing one type of element (load, wind, solar, etc.).
All parameters expecting a vector of areas or links names also accept the special value "all". It indicates the function to read the desired time series for all areas or links.
setSimulationPath
, readAntares
,
getAreas
, getLinks
## Not run: # Set an antares study in "input" mode. This is useful when one want to # inspect input time series before running a simulation. # Note that readAntares do not function in input mode, but readInputTS # works with any mode. setSimulationPath("path_to_the_study", "input") # Read load time series readInputTS(load = "all") # Read hydrolic storage and maximum power in the same call: readInputTS(hydroStorage = "all", hydroStorageMaxPower = "all") # Use a different time step myArea <- readInputTS(load= "myArea", timeStep = "monthly") # Quick plot to visualize the variability of the series matplot(myArea[, - (1:2), with = FALSE], type = "l") ## End(Not run)
## Not run: # Set an antares study in "input" mode. This is useful when one want to # inspect input time series before running a simulation. # Note that readAntares do not function in input mode, but readInputTS # works with any mode. setSimulationPath("path_to_the_study", "input") # Read load time series readInputTS(load = "all") # Read hydrolic storage and maximum power in the same call: readInputTS(hydroStorage = "all", hydroStorageMaxPower = "all") # Use a different time step myArea <- readInputTS(load= "myArea", timeStep = "monthly") # Quick plot to visualize the variability of the series matplot(myArea[, - (1:2), with = FALSE], type = "l") ## End(Not run)
This function reads in the input files of an antares study the current areas layout, ie. the position of the areas It may be useful for plotting the network.
Be aware that the layout is read in the input files so they may have changed since a simulation has been run.
readLayout(opts = simOptions(), xyCompare = c("union", "intersect"))
readLayout(opts = simOptions(), xyCompare = c("union", "intersect"))
opts |
list of simulation parameters returned by the function
|
xyCompare |
Use when passing multiple opts, can be "union" or "intersect". |
A list with three elements:
areas: |
A data.frame containing the name, the color and the coordinate of each area |
district: |
A data.frame containing the name, the color and the coordinate of each district |
links: |
A data.frame containing the name, the coordinates of the origin and the destination of each link |
By default, readLayout
reads the layout for the current default
antares study. It is possible to specify another study with the parameter
opts
. And we can pass multiple studies using a list
of opts.
## Not run: readLayout() # By default, the function reads layout for the default study, # but it is possible to specify another study with parameter "opts" sim1 <- setSimulationPath() #[... code that modifies the default antares study] readLayout(sim1) ## End(Not run)
## Not run: readLayout() # By default, the function reads layout for the default study, # but it is possible to specify another study with parameter "opts" sim1 <- setSimulationPath() #[... code that modifies the default antares study] readLayout(sim1) ## End(Not run)
This function can be used to read the value of the criteria optimized by ANTARES. Notice that these values are only available in "Xpansion" mode or when option "Export mps" is turned on.
readOptimCriteria(opts = simOptions())
readOptimCriteria(opts = simOptions())
opts |
list of simulation parameters returned by the function
|
A table of class antaresDataTable
. It contains the usual columns
timeID
, mcYear
, time
and two columns "criterion1" and
"criterion2" containing the values of the criteria. Time step can be daily
or weekly depending on the optimization options.
## Not run: setSimulationPath() optimCriteria <- readOptimCriteria() ## End(Not run)
## Not run: setSimulationPath() optimCriteria <- readOptimCriteria() ## End(Not run)
This function removes virtual areas from an antaresDataList
object and
corrects the data for the real areas. The antaresDataList
object
should contain area and link data to function correctly.
removeVirtualAreas( x, storageFlexibility = NULL, production = NULL, reassignCosts = FALSE, newCols = TRUE, rowBal = TRUE, prodVars = getAlias("rmVA_production"), costsVars = c("OV. COST", "OP. COST", "CO2 EMIS.", "NP COST"), costsOn = c("both", "storageFlexibility", "production") )
removeVirtualAreas( x, storageFlexibility = NULL, production = NULL, reassignCosts = FALSE, newCols = TRUE, rowBal = TRUE, prodVars = getAlias("rmVA_production"), costsVars = c("OV. COST", "OP. COST", "CO2 EMIS.", "NP COST"), costsOn = c("both", "storageFlexibility", "production") )
x |
An object of class |
storageFlexibility |
A vector containing the names of the virtual storage/flexibility areas. Can also be a named list. Names are columns to add and elements the virtual areas to group. |
production |
A vector containing the names of the virtual production areas. |
reassignCosts |
If TRUE, the production costs of the virtual areas are reallocated to the real areas they are connected to. If the virtual areas are connected to a virtual hub, their costs are first reallocated to the hub and then the costs of the hub are reallocated to the real areas. |
newCols |
If |
rowBal |
If |
prodVars |
Virtual productions columns to add to real area.
Default to |
costsVars |
If parameter |
costsOn |
If parameter |
Two types of virtual areas have been defined corresponding to different types of modeling in Antares and different types of post-treatment to do:
Flexibility/storage areas are areas created to model pumping unit or any other flexibility that behave as a storage. For those virtual areas, the important results are flows on the links.
Production areas are areas created to isolate some generation from the "real" areas. They can be isolate for several reasons: to distinguish time-series (for example wind onshore/offshore), to select some specific unit to participate to day-ahead reserve, etc.
removeVirtualAreas
performs different corrections:
Correct the balance of the real areas (and districts) by removing the flows to or from virtual areas.
If parameter reassignCosts
is TRUE, then the costs of the
virtual areas are reassigned to the real areas they are connected to. The
default affected columns are OV. COST
, OP. COST
, CO2 EMIS.
and NP COST
. If a virtual area is connected to a single real area,
all its costs are attributed to the real area. If it is connected to
several real areas, then costs at a given time step are divided between
them proportionally to the flows between them and the virtual area.
An aggregation is done at the end to correct districts costs.
For each storage/flexibility area, a column named like the area is
created. It contains the values of the flow between the virtual area and
the real areas. This column is interpreted as a production of
electricity: it is positive if the flow from the virtual area to the real
area is positive and negative otherwise. If parameter newCols
is
FALSE
, the values are added to the variable PSP
and the
columns is removed.
An aggregation is done at the end to add virtual storage/flexibility to districts.
If the parameter production
is specified, then the non null
productions of the virtual areas are either added to the ones of the real
areas they are connected to if newCols = FALSE
or put in new
columns if newCols = TRUE
. In the second case the columns are
named *_virtual
where "*
" is a type of
production (wind, solar, nuclear, ...). Productions that are zero for
all virtual areas are omited.
If virtual production areas contains clusters then they will be move to the
real area.
An aggregation is done at the end to add virtual production to districts.
Finally, virtual areas and the links connected to them are removed from the data.
The functions makes a few assumptions about the network. If they are violated it will not act correctly:
storage/flexibility areas can be connected to other storage/flexibility areas (hubs), but at least one of them is connected to a real area. That means that there is no group of virtual areas disconnected from the real network. If such a group exists, you can either remove them manually or simply not import them.
production areas are connected to one and only one real area. They cannot be connected to virtual areas. But a real area may by connected to several production areas.
An antaresDataList
object in which virtual areas have been removed and
data of the real has been corrected. See details for an explanation of the
corrections.
## Not run: # Assume we have a network with two virtual areas acting as pump storage and # an area representing offshore production # # offshore # | # real area - psp in # \ # psp out # data <- readAntares(areas="all", links="all") # Remove pump storage virtual areas correctedData <- removeVirtualAreas( x = data, storageFlexibility = c("psp in", "psp out"), production = "offshore" ) correctedData_list <- removeVirtualAreas( x = data, storageFlexibility = list(PSP = c("psp in", "psp out")), production = "offshore" ) correctedData_details <- removeVirtualAreas( x = data, storageFlexibility = list(PSP_IN = "psp in", PSP_OUT = "psp out"), production = "offshore" ) ## End(Not run)
## Not run: # Assume we have a network with two virtual areas acting as pump storage and # an area representing offshore production # # offshore # | # real area - psp in # \ # psp out # data <- readAntares(areas="all", links="all") # Remove pump storage virtual areas correctedData <- removeVirtualAreas( x = data, storageFlexibility = c("psp in", "psp out"), production = "offshore" ) correctedData_list <- removeVirtualAreas( x = data, storageFlexibility = list(PSP = c("psp in", "psp out")), production = "offshore" ) correctedData_details <- removeVirtualAreas( x = data, storageFlexibility = list(PSP_IN = "psp in", PSP_OUT = "psp out"), production = "offshore" ) ## End(Not run)
This function add hvdc attribute
setHvdcAreas(data, areas)
setHvdcAreas(data, areas)
data |
|
areas |
|
Object of class "antaresDataList" is returned. It is a list of data.tables, each element representing one type of element (areas, links, clusters)
## Not run: library(antaresRead) opts <- setSimulationPath('mypath', 1) myAreaOutput <- readAntares(areas = "all", links = "all") myAreaOutput <- setHvdcAreas(myAreaOutput, "y_dsr") ## End(Not run)
## Not run: library(antaresRead) opts <- setSimulationPath('mypath', 1) myAreaOutput <- readAntares(areas = "all", links = "all") myAreaOutput <- setHvdcAreas(myAreaOutput, "y_dsr") ## End(Not run)
This function specify RAM limit (in Go) of the value returned by readAntares.
setRam(x)
setRam(x)
x |
|
list
(returned by options()
)
## Not run: #Set maximum ram to used to 50 Go setRam(50) ## End(Not run)
## Not run: #Set maximum ram to used to 50 Go setRam(50) ## End(Not run)
This function has to be used before the read
functions. It sets the path to
the Antares simulation to work on and other useful options (list of areas,
links, areas with clusters, variables, etc.). On local disk with setSimulationPath
or
on an AntaREST API with setSimulationPathAPI
setSimulationPath(path, simulation = NULL) setSimulationPathAPI( host, study_id, token, simulation = NULL, timeout = 60, httr_config = list() )
setSimulationPath(path, simulation = NULL) setSimulationPathAPI( host, study_id, token, simulation = NULL, timeout = 60, httr_config = list() )
path |
(optional)
Path to the simulation. It can either be the path to a directory containing
an antares project or directly to the directory containing the output of a
simulation. If missing, a window opens and lets the user choose the
directory of the simulation interactively. Can also choose .h5 file, if |
simulation |
(optional) Only used if "path" represents the path of a study and not of the
output of a simulation. It can be either the name of the simulation or a
number indicating which simulation to use. It is possible to use negative
values to select a simulation from the last one: for instance -1 will
select the most recent simulation, -2 will the penultimate one, etc. There
are two special values 0 and "input" that tells the function that the user
is not interested by the results of any simulation, but only by the inputs.
In such a case, the function |
host |
|
study_id |
|
token |
|
timeout |
|
httr_config |
API httr configuration. See |
The simulation chosen with setSimulationPath
or setSimulationPathAPI
becomes the default
simulation for all functions of the package. This behavior is fine when
working on only one simulation, but it may become problematic when working
on multiple simulations at same time.
In such case, you can store the object returned by the function in a variable and pass this variable to the functions of the package (see examples).
A list containing various information about the simulation, in particular:
studyPath |
path of the Antares study |
simPath |
path of the simulation |
inputPath |
path of the input folder of the study |
studyName |
Name of the study |
simDataPath |
path of the folder containing the data of the simulation |
name |
name of the simulation |
mode |
type of simulation: economy, adequacy, draft or input |
synthesis |
Are synthetic results available ? |
yearByYear |
Are the results for each Monte Carlo simulation available ? |
scenarios |
Are the Monte-Carlo scenarii stored in output ? This is important to reconstruct some input time series that have been used in each Monte-Carlo simulation. |
mcYears |
Vector containing the number of the exported Monte-Carlo scenarios |
antaresVersion |
Version of Antares used to run the simulation. |
areaList |
Vector of the available areas. |
districtList |
Vector of the available districts. |
linkList |
Vector of the available links. |
areasWithClusters |
Vector of areas containing clusters. |
areasWithResClusters |
Vector of areas containing clusters renewable. |
areasWithSTClusters |
Vector of areas containing clusters storage (>=v8.6.0). |
variables |
Available variables for areas, districts and links. |
parameters |
Other parameters of the simulation. |
binding |
Table of time series dimensions for each group (>=v8.7.0). |
timeIdMin |
Minimum time id of the simulation. It is generally equal to one but can be higher if working on a subperiod. |
timeIdMax |
maximum time id of the simulation. |
start |
Date of the first day of the year in the simulation. This date corresponds to timeId = 1. |
firstWeekday |
First day of the week. |
districtsDef |
data.table containing the specification of the districts. |
energyCosts |
list containing the cost of spilled and unsupplied energy. |
verbose |
|
sleep |
timer for api commande execute |
simOptions
, readAntares
, readLayout
,
readClusterDesc
, readBindingConstraints
## Not run: # 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") ## End(Not run)
## Not run: # 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") ## End(Not run)
Change API Timeout
setTimeoutAPI(opts, timeout)
setTimeoutAPI(opts, timeout)
opts |
list of simulation parameters returned by the function
|
timeout |
|
Object of class simOptions
, list of options used to read the data contained in the last
simulation read by setTimeoutAPI
.
## Not run: opts <- setTimeoutAPI(opts, timeout = 45) ## End(Not run)
## Not run: opts <- setTimeoutAPI(opts, timeout = 45) ## End(Not run)
Aliases are short names that can be used in the select
parameter in
function readAntares
to tell the function which columns and/or
type of data to import.
setAlias
can be used to create a new alias. It can be especially
useful for package developers to help their users select the data required
by their packages.
getAlias
return character vector containing columns and/or types of data
showAliases
lists available aliases
showAliases(names = NULL) setAlias(name, desc, select) getAlias(name)
showAliases(names = NULL) setAlias(name, desc, select) getAlias(name)
names |
optional vector of alias names. If provided, the full list of columns selected by these aliases is displayed. Else only the name and a short description of all aliases is displayed. |
name |
Alias name |
desc |
Short description indicating why the new alias is interesting |
select |
character vector containing columns and/or types of data to import. |
setAlias
is only used for its side effects. A data.frame with columns
'name', 'desc' and 'select'. showAliases
invisibly returns a
data.frame with columns "name", "desc" and "select".
# Display the short description of an alias showAliases() # Display the full description of an alias showAliases("renewable") getAlias("renewable") ## Not run: # Create a new alias that imports flows setAlias("test", "short description", c("links", "FLOW LIN.")) showAliases() ## End(Not run)
# Display the short description of an alias showAliases() # Display the full description of an alias showAliases("renewable") getAlias("renewable") ## Not run: # Create a new alias that imports flows setAlias("test", "short description", c("links", "FLOW LIN.")) showAliases() ## End(Not run)
The function readAntares
stores in its output the options used
to read some data (path of the study, area list, link list, start date,
etc.).
simOptions(x = NULL)
simOptions(x = NULL)
x |
object of class |
simOptions
extracts these options from an object of class
antaresTable
or antaresOutput
. It can be useful when working on
multiple simulations, either to check how some object has been created or to
use it in some functions like getAreas
or
getLinks
If the parameter of the function is NULL
, it returns the default
simulation options, that is the options set by setSimulationPath
the last time it was run.
list of options used to read the data contained in an object or the last
simulation options read by setSimulationPath
if x
is
NULL
## Not run: setSimulationPath(study1) simOptions() # returns the options for study 1 data <- readAntares() # Choose a different study setSimulationPath(study2) simOptions() # returns the options for study 2 getAreas() # returns the areas of the secund study getAreas(opts = simOptions(data)) # returns the areas of the first study ## End(Not run)
## Not run: setSimulationPath(study1) simOptions() # returns the options for study 1 data <- readAntares() # Choose a different study setSimulationPath(study2) simOptions() # returns the options for study 2 getAreas() # returns the areas of the secund study getAreas(opts = simOptions(data)) # returns the areas of the first study ## End(Not run)
Subset method for antaresDataList
.
## S3 method for class 'antaresDataList' subset(x, y = NULL, areas = NULL, timeIds = NULL, mcYears = NULL, ...)
## S3 method for class 'antaresDataList' subset(x, y = NULL, areas = NULL, timeIds = NULL, mcYears = NULL, ...)
x |
Object of class |
y |
A table containing at least one of the columns "area", "timeId" or
"mcYear". If it is not |
areas |
Vector of area names to keep in the result. If |
timeIds |
Vector of time ids to keep. If |
mcYears |
Vector of monte-carlo years to keep. If |
... |
Currently unused. |
A filtered antaresDataList
.
## Not run: #keep only the first year mydata <- readAntares(areas = "all", links = "all", mcYears = "all") mySubset<-subset(mydata, mcYears = 1) #keep only the first year for areas a and b mydata <- readAntares(areas = "all", links = "all", mcYears = "all") mySubset<-subset(mydata, mcYears = 1, areas=c("a", "b")) #' #keep only the first year for areas a and b and timeIds include in 5:16 mydata <- readAntares(areas = "all", links = "all", mcYears = "all") mySubset<-subset(mydata, mcYears = 1, areas=c("a", "b"), timeIds=5:16) ## End(Not run)
## Not run: #keep only the first year mydata <- readAntares(areas = "all", links = "all", mcYears = "all") mySubset<-subset(mydata, mcYears = 1) #keep only the first year for areas a and b mydata <- readAntares(areas = "all", links = "all", mcYears = "all") mySubset<-subset(mydata, mcYears = 1, areas=c("a", "b")) #' #keep only the first year for areas a and b and timeIds include in 5:16 mydata <- readAntares(areas = "all", links = "all", mcYears = "all") mySubset<-subset(mydata, mcYears = 1, areas=c("a", "b"), timeIds=5:16) ## End(Not run)
This function cannot be used for a study
>= 8.7.0
## S3 method for class 'bindingConstraints' summary(object, ...)
## S3 method for class 'bindingConstraints' summary(object, ...)
object |
Object returned by readBindingConstraints |
... |
Unused |
A data.frame with one line per constraint.
This function displays each element of an antaresData
object in a
spreadsheet-like viewer.
viewAntares(x, ...)
viewAntares(x, ...)
x |
An object of class |
... |
Currently unused |
Invisible NULL.
## Not run: setSimulationPath() areas <-readAntares() viewAntares(areas) output <- studyAntares(areas="all", links = "all", clusters = "all") viewAntares(output) # Opens three data viewers for each element of output ## End(Not run)
## Not run: setSimulationPath() areas <-readAntares() viewAntares(areas) output <- studyAntares(areas="all", links = "all", clusters = "all") viewAntares(output) # Opens three data viewers for each element of output ## End(Not run)
Write digest file
writeDigest(digest, opts = simOptions())
writeDigest(digest, opts = simOptions())
digest |
list of 5 elements similar to what is returned by |
opts |
simulation options |
updated digest list of 5 tables (begin, areas, middle, links lin., links quad.)