diff --git a/dev/.nojekyll b/dev/.nojekyll new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/dev/.nojekyll @@ -0,0 +1 @@ + diff --git a/dev/LICENSE-text.html b/dev/LICENSE-text.html new file mode 100644 index 00000000..f763d7a6 --- /dev/null +++ b/dev/LICENSE-text.html @@ -0,0 +1,81 @@ + +
COPYRIGHT HOLDER: RTE Réseau de transport d’électricité ++ +
vignettes/antaresRead.Rmd
+ antaresRead.Rmd
This document describes a typical use of the antaresRead
+package.
This package has been designed to read the results of an Antares +simulation in an easy and convivial way. It can of course read any +output files of a simulation at any desired time step, read synthetic +results or detailed Monte Carlo scenarios but it can also add input time +series to the results and perform some basic treatments like removing +virtual areas.
+The antaresRead
package depends on the packages
+data.table
, plyr
and lubridate
.
+If you have not already got them you can install them with the following
+command:
+install.packages(c("data.table", "plyr", "lubridate"))
Then you can install the antaresRead
package either with
+the Rstudio assistant in the “Packages” tab or with the following
+command:
+install.packages("path_to_the_package/antaresRead_***.zip")
First, when you start a new R session, you need to load the +package:
+ +To display the list of all the functions of the package and access +their help pages, type in the R console:
+
+help(package = "antaresRead")
Then you can start using the package. The first function to use is
+setSimulationPath
.
This function needs to be called at least once during each R session. +It stores important informations that are used by most of the functions +of the package. While it has not been run, these functions will not +work.
+Without any argument, setSimulationPath
asks
+interactively to choose a directory containing an antares study. If the
+study contains multiple simulation results, it will also asks the user
+to choose one of them. This function stores the path to the output and
+reads some useful information about the simulation: type of output
+available, list of areas, links and clusters in the simulation,
+variables present in the output files, etc.
setSimulationPath
can also be used in a non-interactive
+way with one of these syntaxes:
+# Specify full path
+setSimulationPath("study_path/output/simulation_name")
+
+# Specify the name of the simulation
+setSimulationPath("study_path", simulation_name)
+
+# Select a simulation by order
+setSimulationPath("study_path", 1) # first simulation
+
+# Select a simulation by reverse order
+setSimulationPath("study_path", -1) # last simulation
+
+# It is possible to store in a variable the result of the function
+opts <- setSimulationPath("study_path", 1)
The function returns an object containing informations about the +selected simulation. You can store this object in a variable for later +use but this is not necessary because at any moment you can retrieve +these informations.
+Once setSimulationPath
has been run, you can start
+reading data. Function readAntares
is there for that !
readAntares
is the main function of the package. It is
+used to read every possible time series and it performs a few treatments
+on them to make your life easier. The result of the function will have
+the simplest structure possible: either a simple table or a list of
+tables if you asks data for differents elements (for instance links and
+areas)
It has a huge number of parameters to control exactly what you get, +but all of them are optional. Without any argument the function will +still works and it will read the synthetic results for all the areas. +But you can import other kind of output. here are some examples:
+
+# Synthetic results for all links
+readAntares(links="all")
+
+#Synthetic results for all clusters
+readAntares(clusters="all")
+
+# Areas and links at the same time
+readAntares(areas="all", links="all")
+
+# Select only a few columns.
+readAntares(select = c("OV. COST", "OP. COST", "LOAD"))
You can also choose what elements to import and what level of details +you want. For instance, the following command reads the first 10 +Monte-Carlo scenarii data at monthly time step for the areas named +“area1”, “area2” and “area3”.
+
+readAntares(areas=c("area1", "area2", "area3"), timeStep="monthly",
+ synthesis=FALSE, mcYears = 1:10)
Finally many arguments of readAntares
can be used to add
+input time series to the object returned by the function. For instance,
+misc=TRUE
will add columns containing miscelaneous
+productions for the imported areas.
readAntares
returns either a single table or a list of
+tables depending on the query of the user. More precisely the tables are
+data.table
objects. It is then possible to use the powerful
+syntax offered by the package data.table
.
The general syntax is like:
+
+name_of_the_table[filter_rows, select_columns, group_by]
For instance, areas[area == "08_fr", .(timeId, LOAD)]
+will return a table containing columns timeId
and
+LOAD
for the area names “08_fr”. In the select statement,
+it is also possible to calculate new columns. For instance, one can
+compute the net load like this:
One can also compute aggregated statistics. For instance, the
+following code will compute the total load of all areas per
+timeId
:
+areas[, .(totalLoad = sum(LOAD)), by = .(timeId)]
Of course, aggregation also works with filters. For instance to +compute the total load only for french areas (assuming their names +contain “fr”):
+ +If you are not familiar with package data.table
, you
+should have a look at the documentation and especially at the vignettes
+of the package:
+help(package="data.table")
readAntares
can import almost everything but not
+everything because some data is not time series. Other functions exist
+to read this specific data: readBindingConstraints
to read
+binding constraints, readClusterDesc
to read cluster
+characteristics and readLayout
to get the coordinates of
+the areas in the user interface of Antares.
Some parameters in readAntares
and other functions wait
+for vectors of area names or link names. On large projects with lots of
+areas. It may be painful to specify by hand a long list of areas or
+links. Hopefully, the functions getAreas
and
+getLinks
can be used to select or exclude areas using
+regular expressions. For instance, let us assume that the name of all
+areas located in France start with the characters”fr”, then the
+following command returns the list of all french areas:
+getAreas("fr")
To exclude offshore production areas (assuming their name contains +the word “offshore”) one can use:
+
+getAreas("fr", exclude="offshore")
A few other functions are provided by the package. To see a list of +them, type in the console:
+
+help(package = "antaresRead")
++ + +Read data from an Antares study with R package ‘antaresRead’
+
You can install the package from CRAN:
+
+install.packages("antaresRead")
You can also install the last development version from Github:
+
+devtools::install_github("rte-antares-rpackage/antaresRead")
To display the help of the package and see all the functions it provides, type:
+
+help(package="antaresRead")
To see a practical example of use of the package, look at the vignette :
+
+vignette("antares")
Finally, you can download a cheatsheet that summarize in a single page how to use the package: https://github.com/rte-antares-rpackage/antaresRead/raw/master/cheat_sheet/antares_cheat_sheet_en.pdf .
+See website for more documentation: https://rte-antares-rpackage.github.io/antaresRead/
+Load the package
+ +Select an Antares simulation interactively.
+ +You can also select it programmatically:
+
+setsimulationPath("study_path", simulation)
The parameter simulation
can be the name of a simulation, the name of the folder containing the simulation results, or the index of the simulation. 1
corresponds to the oldest simulation, -1
to the newest one, 0 to the inputs.
Most data from a simulation can be imported in the R session with function readAntares()
. It has many parameters that control what data is imported. Here are a few examples:
+# Read synthetic results of all areas of a study with hourly time step.
+areaData <- readAntares(areas = "all")
+
+# Same but with a daily time step:
+areaData <- readAntares(areas = "all", timeStep = "daily")
+
+# Read all Monte Carlo scenarios for a given area.
+myArea <- readAntares(areas = "my_area", mcYears = "all")
+
+# Same but add miscelaneous production time series to the result
+myArea <- readAntares(areas = "my_area", mcYears = "all", misc = TRUE)
+
+# Read only columns "LOAD" and "MRG. PRICE"
+areaData <- readAntares(areas = "all", select = c("LOAD", "MRG. PRICE"))
Functions getAreas
and getLinks
are helpful to create a selection of areas or links of interest. Here are a few examples:
+# select areas containing "fr"
+myareas <- getAreas("fr")
+
+# Same but remove areas containing "hvdc"
+myareas <- getAreas("fr", exclude = "hvdc")
+
+# Get the links that connect two of the previous areas
+mylinks <- getLinks(myareas, internalOnly = FALSE)
+
+# Get the results for these areas and links
+mydata <- readAntares(areas = myareas, links = mylinks)
When only one type of elements is imported (only areas or only links, etc.) readAntares()
read antares returns a data.table
with some extra attributes. A data.table
is a table with some enhanced capacities offered by package data.table
. In particular it provides a special syntax to manipulate its content:
+name_of_the_table[filter_rows, select_columns, group_by]
Here are some examples:
+
+# Select lines based on some criteria
+mydata[area == "fr" & month == "JUL"]
+
+# Select columns, and compute new ones
+mydata[, .(area, month, load2 = LOAD^2)]
+
+# Aggregate data by some variables
+mydata[, .(total = sum(LOAD)), by = .(month)]
+
+# All three operations can be done with a single line of code
+mydata[area == "fr", .(total = sum(LOAD)), by = .(month)]
+
+help(package = "data.table")
If you are not familiar with package data.table
, you should have a look at the documentation and especially at the vignettes of the package:
Contributions to the library are welcome and can be submitted in the form of pull requests to this repository.
+The folder test_case contains a test Antares study used to run automatic tests. If you modifies it, you need to run the following command to include the modifications in the tests:
+ +Antares is a powerful software developed by RTE to simulate and study electric power systems (more information about Antares here : https://antares-simulator.org/).
+ANTARES is now an open-source project (since 2018), you can download the sources here if you want to use this package.
+Copyright 2015-2016 RTE (France)
+This Source Code is subject to the terms of the GNU General Public License, version 2 or any higher version. If a copy of the GPL-v2 was not distributed with this file, You can obtain one at https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html.
+NEWS.md
+ NEW FEATURES:
+readAntaresSTClusters()
+fread_antares()
shiny compatible with a conditional processing of the error messagesBREAKING CHANGES :
+readClusterDesc()
/ readClusterResDesc()
/ readClusterSTDesc()
are updated with new endpoint “table mode”.
+BUGFIXES :
+setSimulationPathAPI()
: control the existence of the output folder links or areas before reading the data (upgrade Antares Web)readClusterDesc()
/ readClusterResDesc()
/ readClusterSTDesc()
return a data.table in API modeNEW FEATURES:
+readInputThermal()
:
+readInputRES()
new parameter areas to get desired clusters from selected areas.setSimulationPath()
return a new parameter binding
(for studies >= v8.7.0). It contains a table with group dimensions of time series for binding constraints.readAntares()
new parameter clustersST to read (output simulation) short-term clustersBREAKING CHANGES :
+readInputThermal()
/ readInputRES()
default value when no time series in the selected clusters.BUGFIXES :
+readInputThermal()
return data from file data.txt with thermalData
parametersetSimulationPath()
has also the parameter areasWithSTClusters in ‘output’ modereadBindingConstraints()
read now Scenarized RHS for binding constraints (cf. Antares v8.7 changelog)
+fread_antares()
no longer returns warningsapi_put()/api_delete()
return a server error messageBUGFIXES :
+readBindingConstraints()
read well study >= v8.3.2DATA :
+Dependencies :
+lifecycle
to manage functions status/package statusBUGFIXES : * readIniFile()
: avoid utils::type.convert
on specific cases (ex : 789e or 123i) * api_get()
add encoding argument to pass to httr::content()
BUGFIXES :
+setSimulationPathAPI()
:
+simulation
the simulation parameter works with negative values within the limit of the number of simulationsreadClusterDesc()
calls to add “opts”readAntares()
:
+.formatlist()
, read N-level list instead of 2.BREAKING CHANGES :
+api_get()
has a new parameter to control JSON file parsingreadInputThermal()
default value when no time series in the selected clusters.readInputRES()
default value when no time series in the selected clustersreadClusterDesc()
/ readClusterRESDesc()
/ readClusterSTDesc()
return empty dataTable and warning if no cluster in Antares study.NEW FEATURES (Antares v8.6, cf. Antares v8.6 changelog) :
+readClusterSTDesc()
read “short-term storage” clusters parameters (input files of an antares study)BREAKING CHANGES (Antares v8.6) :
+readInputTS()
is now compatible to read time series with :
+setSimulationPath()
has new parameter areasWithSTClusters (name of area with “st-storage” cluster)BUGFIXES :
+setSimulationPathAPI
generate new global parameter sleep
to add timer to API request.importOutput()
to use readAntares()
with parallel == TRUE
in shiny applicationsetSimulationPathAPI()
delete a redundant API requestreadClusterDesc()
minor fix in API mode + fix if no cluster exists => return specific error messagereadIniAPI()
read well file generaldata
for sections “playlist” and “variables selection”DATA :
+v8.6.0
+BUGFIXES:
+setSimulationPath()
(mc-all/mc-ind) (#199)DEV:
+NEW FEATURES:
+readAntares()
has new argument for binding constraints output (v8.4+) (#173)readDigestFile()
, mergeDigests()
and writeDigest()
to manipulate digest file.digest.txt
with the one createdthermal.txt
+BUGFIXES:
+NEW FEATURES:
+getGeographicTrimming()
returns filtering options for selected areas (links optional).readInputRes()
for reading renewable clusters input datagetLinks()
now has a new argument withTransmission. if TRUE, return additional column with type of transmission capacities.readInputThermal()
: added new argument for thermalDataNEW FEATURES:
+Added new functions readInputThermal()
and readAntaresClusters()
: Both functions take a vector of clusters instead of areas * readInputThermal()
: read thermal TS (availabilities) and modulation in Input mode * readAntaresClusters()
: read output data for clusters only with thematic trimming
NEW FEATURES:
+Major upgrade to aggregateResult()
and parAggregateMCall()
: * Faster & memory efficient * Support for Antares studies up to v8.3 (v8.4 experimental) * Dynamic timestep detection * Creation of grid folder * Recycling of original mc-all data
NEW FEATURES:
+added “profit by cluster” when reading cluster data.
+BUGFIXES:
+Fix for 404 error when some output is missing in API mode(#188).
+api_get()
, api_post()
, api_put()
, api_delete()
.readIni()
.FEATURES:
+BUGFIXES:
+FEATURES:
+BUGFIXES:
+FEATURES:
+readInputTS()
for hydroStorage
+hvdcModification()
functionFEATURES:
+removeVirtualAreas()
in getLinks()
+BREAKING CHANGES:
+NEW FEATURES:
+BUGFIXES:
+BUGFIXES:
+NEW FEATURES:
+BUGFIXES:
+BUGFIXES:
+BUGFIXES:
+NEW FEATURES:
+BUGFIXES:
+BUGFIXES:
+BUGFIXES:
+BUGFIXES:
+NEW FEATURES:
+BUGFIXES:
+BUGFIXES:
+BREAKING CHANGES:
+NEW FEATURES:
+BUGFIXES:
+NEW FEATURES:
+BREAKING CHANGES:
+BREAKING CHANGES:
+NEW FEATURES:
+BUGFIXES:
+BREAKING CHANGES:
+BUGFIXES:
+BREAKING CHANGES: * Variable mustRunModuction has been renamed minGenModulation for consistency with Antares * Similarly in the object returned by setSimulationPath and simOptions, “setList” has been renamed “districtList”
+NEW FEATURES: * Now, when one filters, add, remove or update columns of an object of class ‘antaresDataTable’, the result is still of class ‘antaresDataTable’.
+BUGFIXES:
+BREAKING CHANGES:
+NEW FEATURES:
+NEW FEATURES:
+BUGFIXES:
+BREAKING CHANGES:
+NEW FEATURES:
+BUGFIXES:
+NEW FEATURES:
+BUGFIXES:
+BREAKING CHANGES:
+NEW FEATURES:
+BUGFIXES:
+BREAKING CHANGES:
+NEW FEATURES:
+NEW FEATURES:
+BREAKING CHANGES:
+NEW FEATURES:
+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")
Antares simulation options or a list
with an host =
slot.
API endpoint to interrogate, it will be added after default_endpoint
.
+Can be a full URL (by wrapping ìn I()
), in that case default_endpoint
is ignored.
Additional arguments passed to API method.
Default endpoint to use.
character
options for parameter as
of function httr::content()
argument to pass as argument to the function httr::content()
Response from the API.
+if (FALSE) { # \dontrun{
+
+# 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")
+
+} # }
+
R/aggregateResult.R
+ aggregatate_mc_all.Rd
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
+)
list
of simulation parameters returned by the function setSimulationPath
numeric
Number of parralel process
numeric
show log in console. Defaut to 1
0 : No log
1 : Short log
2 : Long log
character
antares timestep
boolean
write result or not.
numeric
vector of weigth for mcYears.
numeric
mcYears to load.
boolean
filtering control
list
named list (pass to antaresRead) : list(areas = 'a', links = 'a - e')
boolean
run old version of the function
Object list
of data.tables, each element representing one type
+of element (areas, links, clusters)
R/antaresRead-package.R
+ antaresRead-package.Rd
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/).
+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,
+ ...
+)
Data.frame or data.table to convert to a an antaresDataTable.
Arguments to be passed to methods.
name of the table in the final object. If NULL
, the type of the data
+is used.
Does the table contain synthetic results ?
Time step of the data. One of "hourly", "daily", "weekly", "monthly" or "annual".
type of data: for instance "areas", "links", "clusters", etc.
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(), ...)
object to convert to a an antaresDataList
.
Arguments to be passed to methods.
Does the table contain synthetic results ?
Time step of the data. One of "hourly", "daily", "weekly", "monthly" or "annual".
type of data: for instance "areas", "links", "clusters", etc.
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())
data.table with a column "timeId" or an object of class "antaresDataList"
Desired time step.The possible values are hourly, daily, weekly, +monthly and annual.
Current time step of the data. This argument is optional for an object of
+class antaresData
because the time step of the data is stored inside
+the object
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.
list of simulation parameters returned by the function
+setSimulationPath
Either a data.table or an object of class "antaresDataList" depending on the
+class of x
if (FALSE) { # \dontrun{
+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"))
+} # }
+
+
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, ...)
an object used to select a method.
arguments passed to write.table
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
+if (FALSE) { # \dontrun{
+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.
+} # }
+
+
R/aggregateResult.R
+ dot-writeIni.Rd
Write ini file from list obtain by antaresRead::readIniFile and modify by user
+.writeIni(listData, pathIni, overwrite = FALSE)
+if (FALSE) { # \dontrun{
+pathIni <- "D:/exemple_test/settings/generaldata.ini"
+generalSetting <- antaresRead::readIniFile(pathIni)
+generalSetting$output$synthesis <- FALSE
+writeIni(generalSetting, pathIni)
+} # }
+
+
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)
object of class "antaresData" or "antaresTable" created by the function
+readAntares
character vector containing the name of areas to keep in the
+final object. If NULL
, all areas are kept in the final object.
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
+)
Character vector. If regexpSelect
is TRUE, this vector is
+interpreted as a list of regular expressions. Else it is interpreted as a
+list of area names. If NULL
, all areas are selected
Character vector. If regexpExclude
is TRUE, this vector is
+interpreted as a list of regular expressions and each area validating one
+of them is excluded. Else it is interpreted as list of area names to
+exclude. If NULL
, not any area is excluded.
Should the function return only nodes containing clusters ?
Is select
a list of regular expressions ?
Is exclude
a list of regular expressions ?
list of simulation parameters returned by the function
+setSimulationPath
Should the case be ignored when evaluating the regular +expressions ?
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.
+R/getGeographicTrimming.R
+ getGeographicTrimming.Rd
Read geographic trimming (filtering) options
+getGeographicTrimming(areas = NULL, links = TRUE, opts = simOptions())
list of filtering options for areas and links
+getIdCols
return the id columns of an AntaresDataTable
getIdCols(x = NULL)
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
+)
Vector containing area names. It represents the set of areas we are interested
+in. If NULL
, all areas of the study are used.
Vector containing area names. If not NULL
, all links connected to
+one of these areas are omitted.
list of simulation parameters returned by the function
+setSimulationPath
If TRUE
, only links that connect two areas from parameter areas
are returned.
+If not, the function also returns all the links that connect an area from the list with
+an area outside the list.
If TRUE
, the function returns a vector with link names, else it
+returns a table containing the name, the origin and the destination of each
+selected link.
Used only if namesOnly = FALSE
. If FALSE
, then the function
+returns a table with one line per link, containing the link name, the
+origin and the destination of the link. If TRUE
, then it returns a
+table with columns area
, link
, to
and direction
+which is equal is equal to
+1 if the link connects area
to to
and -1 if it connects
+to
to area
.
+The column area
contains only areas that are compatible with parameters
+areas
and exclude
. Note that the same link can appear twice
+in the table with different directions.
Used only if namesOnly = FALSE
. If TRUE
, a column is added to indicate
+type of transmission capacities for links.
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 name
First area connected to the link
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 name
Link name
Area connected to area
by link
1 if the link connects area
to to
else -1
if (FALSE) { # \dontrun{
+
+# 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"))
+
+} # }
+
+
usage for hvdc
+hvdcModification(data, removeHvdcAreas = TRUE, reafectLinks = FALSE)
Object of class "antaresDataList" is returned. +It is a list of data.tables, each element representing one type of element (areas, links, clusters)
+if (FALSE) { # \dontrun{
+
+data <- readAntares(areas = 'all', links = 'all')
+data <- setHvdcAreas(data, "psp in")
+data <- hvdcModification(data)
+
+} # }
+
+
+ All functions+ + |
+ |
---|---|
+ + | +API methods |
+
+ + | +Creation of Mc_all new (only antares > V6) |
+
+ + | +Convert objects to antaresDataTable |
+
+ + | +Convert objects to antaresDataTable |
+
+ + | +Change the timestep of an output |
+
+ + | +Copy data to the clipboard |
+
+ + | +Format data PPSE-style |
+
+ + | +Select and exclude areas |
+
+ + | +Read geographic trimming (filtering) options |
+
+ + | +get Id columns |
+
+ + | +Retrieve links connected to a set of areas |
+
+ + | +hvdc straitement |
+
+ + | +Merge two digests |
+
+ + | +Mcyear aggregation weigthed by wd |
+
+ + | +Read configuration options from file or API |
+
+ + | +Read the data of an Antares simulation |
+
+ + | +Read output for a list of areas |
+
+ + | +Read output for a list of clusters |
+
+ + | +Read output for a list of short-term storage clusters |
+
+ + | +Read binding constraints |
+
+ + | +Import clusters description |
+
+ + | +Read digest file |
+
+ + | +Read Input RES time series |
+
+ + | +Read Input time series |
+
+ + | +Read Input thermal time series |
+
+ + | +Read areas layout |
+
+ + | +Read Optimization Criteria |
+
+ + | +Remove virtual areas |
+
+ + | +show aliases for variables |
+
+ + | +Set hvdc areas |
+
+ + | +Specify RAM limit |
+
+ + | +Set Path to an Antares simulation |
+
+ + | +Change API Timeout |
+
+ + | +Extract simulation options |
+
+ + | +Subset an antaresDataList |
+
+ + | +Display equation of binding constraint |
+
+ + | +View the content of an antares output |
+
+ + | +Write digest file |
+
Merge two digests
+mergeDigests(digest_new, digest_ori)
updated digest +list of 5 tables (begin, areas, middle, links lin., links quad.)
+R/ponderateMcAggregation.R
+ ponderateMcAggregation.Rd
Mcyear aggregation weigthed by wd
+ponderateMcAggregation(x, fun = weighted.mean, ...)
Object of class "antaresDataTable".
+if (FALSE) { # \dontrun{
+ data <- readAntares(areas = 'all', mcYears = 'all')
+ ponderateMcAggregation(data, fun = weighted.mean, w = c(.1, .9))
+
+
+} # }
+
+
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)
Path to config/ini file to read.
List of simulation parameters returned by the function
+setSimulationPath()
Default extension used for config files.
File path.
logical: should character vectors be converted to factors?
Study's identifier.
Path of configuration object to read.
Host of AntaREST server API.
API personnal access token.
A list with an element for each section of the .ini file.
+if (FALSE) { # \dontrun{
+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")
+
+} # }
+
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
+)
Vector containing the names of the areas to import. If
+NULL
no area is imported. The special value "all"
tells the
+function to import all areas. By default, the value is "all" when no other argument is enter and "NULL" when other arguments are enter.
Vector containing the name of links to import. If NULL
no
+area is imported. The special value "all"
tells the function to
+import all areas. Use function getLinks
to import all links
+connected to some areas.
Vector containing the name of the areas for which you want to
+import results at thermal cluster level. If NULL
no cluster is imported. The
+special value "all"
tells the function to import thermal clusters from all
+areas.
Vector containing the names of the districts to import. If NULL
,
+no district is imported. The special value "all"
tells the function to import all
+districts.
Vector containing the name of the areas for which you want to
+import results at renewable cluster level. If NULL
no cluster is imported. The
+special value "all"
tells the function to import renewable clusters from all
+areas.
Vector containing the name of the areas for which you want to
+import results at short-term cluster level. If NULL
no cluster is imported. The
+special value "all"
tells the function to import short-term clusters from all
+areas.
Should binding constraints be imported (v8.4+)?
Vector containing the name of the areas for which you want to +import misc.
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.
Should hydro storage be imported ?
Should hydro storage maximum power be imported ?
Should reserve be imported ?
Should link capacities be imported ?
Should must run productions be added to the result? If TRUE,
+then four columns are added: mustRun
contains the production of
+clusters that are in complete must run mode; mustRunPartial
+contains the partial must run production of clusters; mustRunTotal
+is the sum of the two previous columns. Finally thermalPmin
is
+similar to mustRunTotal except it also takes into account the production
+induced by the minimum stable power of the units of a cluster. More
+precisely, for a given cluster and a given time step, it is equal to
+min(NODU x min-stable-power, mustRunTotal)
.
Should thermal modulation time series be imported ? If TRUE
, the
+columns "marginalCostModulation", "marketBidModulation", "capacityModulation"
+and "minGenModulation" are added to the cluster data.
Character vector containing the name of the columns to import. If this
+argument is NULL
, all variables are imported. Special names
+"allAreas"
and "allLinks"
indicate to the function to import
+all variables for areas or for links. Since version 1.0, values "misc",
+"thermalAvailabilities", "hydroStorage", "hydroStorageMaxPower", "reserve",
+"linkCapacity", "mustRun", "thermalModulation" are also accepted and can
+replace the corresponding arguments. The list of available variables can be
+seen with the command simOptions()$variables
. Id variables like
+area
, link
or timeId
are automatically imported.
+Note that select
is not taken into account when importing cluster
+data.
Index of the Monte-Carlo years to import. If NULL
, synthetic results
+are read, else the specified Monte-Carlo simulations are imported. The
+special value all
tells the function to import all Monte-Carlo
+simulations.
Resolution of the data to import: hourly (default), daily, +weekly, monthly or annual.
Vector of weights to apply to the specified mcYears. If not NULL
, the vector must
+be the same length as the vector provided in the mcYear
parameter. The function
+readAntares
will then return the weighted synthetic results for the specified years,
+with the specified weights.
list of simulation parameters returned by the function
+setSimulationPath
Should the importation be parallelized ? (See details)
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".
If TRUE the function displays information about the progress of the +importation.
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 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 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.
if (FALSE) { # \dontrun{
+# 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")
+
+} # }
+
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(),
+ ...
+)
Vector containing area names. It represents the set of areas we are interested
+in. If NULL
, all areas of the study are used.
should links connected to the areas be imported ?
should the thermal clusters of the areas be imported ?
should the renewable clusters of the areas be imported ?
If TRUE
, only links that connect two areas from parameter areas
are returned.
+If not, the function also returns all the links that connect an area from the list with
+an area outside the list.
list of simulation parameters returned by the function
+setSimulationPath
Other arguments passed to the function readAntares
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)
+if (FALSE) { # \dontrun{
+myarea <- simOptions()$areaList[1]
+data <- readAntaresAreas(myarea)
+
+# Equivalent but more concise than:
+data2 <- readAntares(myarea, links = getLinks(myarea), clusters = myarea)
+
+all.equal(data, data2)
+} # }
+
+
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
+)
vector of thermal clusters to be imported
vector of thematic trimming
Resolution of the data to import: hourly (default), daily, +weekly, monthly or annual.
list of simulation parameters returned by the function
+setSimulationPath
Should the importation be parallelized ? (See details)
If TRUE the function displays information about the progress of the +importation.
data.table of results for thermal clusters
+R/readAntaresClusters.R
+ readAntaresSTClusters.Rd
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
+)
vector of short-term storage clusters to be imported
vector of thematic trimming
Resolution of the data to import: hourly (default), daily, +weekly, monthly or annual.
list of simulation parameters returned by the function
+setSimulationPath
Should the importation be parallelized ? (See details)
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())
list of simulation parameters returned by the function
+setSimulationPath
An object of class bindingConstraints
. This object is also a named
+list with 3 sections per read constraint.
For an study Antares version >=8.7.0. Now contains data.frame
with
+one line per time step and \(p\) 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"
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
if (FALSE) { # \dontrun{
+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)
+
+} # }
+
+
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())
+
+readClusterResDesc(opts = simOptions())
+
+readClusterSTDesc(opts = simOptions())
list of simulation parameters returned by the function
+setSimulationPath
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:
+Name of the area containing the cluster
Name of the cluster
Type of cluster (gaz, nuclear, etc.)
number of production units
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.
+if (FALSE) { # \dontrun{
+
+# thermal
+readClusterDesc()
+
+# renewable
+readClusterResDesc()
+
+# st-storage
+readClusterSTDesc()
+
+# 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)
+
+} # }
+
+
Read digest file
+readDigestFile(opts, endpoint = "mc-all/grid/digest.txt")
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
+)
vector of RES areas names for which renewable time series must be read.
vector of RES clusters names for which renewable time series must be read.
list of simulation parameters returned by the function
+setSimulationPath
Resolution of the data to import: hourly (default), daily, +weekly, monthly or annual.
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".
Should the importation be parallelized ? (See details)
If TRUE the function displays information about the progress of the +importation.
data.table with class "antaresDataTable".
+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
+)
vector of areas names for which load time series must be read.
vector of areas names for which thermal availabilities of clusters must be read.
vector of areas names for which run of river time series must be read.
vector of areas names for which Hydro Pmin time series must be read. +(only for Antares version >= 860)
vector of areas names for which hydrolic storage time series must be read.
vector of areas names for which hydrolic storage maximum power time series must be read.
vector of areas names for which wind time series must be read
vector of areas names for which solar time series must be read
vector of areas names for which misc time series must be read
vector of areas names for which reserve time series must be read
vector of links names for which links characteristics time series must be read
vector of areas names for which renewables clusters production time series must be read.
vector of areas names for which st-storage clusters production time series must be read.
list of simulation parameters returned by the function
+setSimulationPath
Resolution of the data to import: hourly (default), daily, +weekly, monthly or annual.
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".
Should the importation be parallelized ? (See details)
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.
+if (FALSE) { # \dontrun{
+# 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")
+} # }
+
+
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
+)
vector of areas names for which thermal time series must be read.
vector of clusters names for which thermal time series must be read.
if TRUE, return thermalAvailabilities data
if TRUE, return thermalModulation data
if TRUE, return thermalData from prepro
list of simulation parameters returned by the function
+setSimulationPath
Resolution of the data to import: hourly (default), daily, +weekly, monthly or annual.
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".
Should the importation be parallelized ? (See details)
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.
+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"))
list of simulation parameters returned by the function
+setSimulationPath
Use when passing multiple opts, can be "union" or "intersect".
A list with three elements:
+A data.frame containing the name, the color and the coordinate +of each area
A data.frame containing the name, the color and the coordinate +of each district
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.
if (FALSE) { # \dontrun{
+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)
+
+} # }
+
+
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())
list of simulation parameters returned by the function
+setSimulationPath
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.
if (FALSE) { # \dontrun{
+setSimulationPath()
+
+optimCriteria <- readOptimCriteria()
+} # }
+
+
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")
+)
An object of class antaresDataList
with at least components
+areas
and links
.
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.
A vector containing the names of the virtual production +areas.
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.
If TRUE
, new columns containing the production of the virtual
+areas are added. If FALSE their production is added to the production of
+the real areas they are connected to.
If TRUE
, then BALANCE will be corrected by ROW. BAL:
+BALANCE := BALANCE - "ROW. BAL"
Virtual productions columns to add to real area.
+Default to getAlias("rmVA_production")
If parameter reassignCosts
is TRUE, affected columns.
+Default to OV. COST
, OP. COST
, CO2 EMIS.
and NP COST
If parameter reassignCosts
is TRUE, then the costs of the
+virtual areas are reassigned to the real areas they are connected to.
+You can choose to reassigned production & storageFlexibility virtuals areas
+("both", default), or only "production" or "storageFlexibility" virtuals 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.
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.
if (FALSE) { # \dontrun{
+
+# 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"
+)
+
+} # }
+
+
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)
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.
Alias name
Short description indicating why the new alias is interesting
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()
+#> name desc
+#> 1 economy Production costs, prices, exchanges and spilled energy
+#> 2 adequacy Adequacy variables
+#> 3 generation Production that can be controlled: thermal and hydrostorage
+#> 4 renewable Renewable productions
+#> 5 thermal Thermal productions
+#> 6 netLoad Variables used to compute net load
+#> 7 rmVA_production removeVirtualAreas production varaibles
+#> 8 nostat All variables except summary variable (MIN, MAX and STD)
+
+# Display the full description of an alias
+showAliases("renewable")
+#> name desc
+#> 4 renewable Renewable productions
+#> select
+#> 4 WIND, WIND OFFSHORE, WIND ONSHORE, SOLAR, SOLAR CONCRT., SOLAR PV, SOLAR ROOFT, RENW. 1, RENW. 2, RENW. 3, RENW. 4, H. ROR, H. STOR, MISC. DTG, MISC. DTG 2, MISC. DTG 3, MISC. DTG 4
+
+getAlias("renewable")
+#> [1] "WIND" "WIND OFFSHORE" "WIND ONSHORE" "SOLAR"
+#> [5] "SOLAR CONCRT." "SOLAR PV" "SOLAR ROOFT" "RENW. 1"
+#> [9] "RENW. 2" "RENW. 3" "RENW. 4" "H. ROR"
+#> [13] "H. STOR" "MISC. DTG" "MISC. DTG 2" "MISC. DTG 3"
+#> [17] "MISC. DTG 4"
+
+if (FALSE) { # \dontrun{
+# Create a new alias that imports flows
+setAlias("test", "short description", c("links", "FLOW LIN."))
+showAliases()
+} # }
+
+
This function add hvdc attribute
+setHvdcAreas(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)
+if (FALSE) { # \dontrun{
+
+library(antaresRead)
+opts <- setSimulationPath('mypath', 1)
+myAreaOutput <- readAntares(areas = "all", links = "all")
+myAreaOutput <- setHvdcAreas(myAreaOutput, "y_dsr")
+
+
+} # }
+
+
This function specify RAM limit (in Go) of the value returned by readAntares.
+setRam(x)
list
(returned by options()
)
if (FALSE) { # \dontrun{
+#Set maximum ram to used to 50 Go
+setRam(50)
+} # }
+
+
R/setSimulationPath.R
, R/setSimulationPathAPI.R
+ setSimulationPath.Rd
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()
+)
(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 rhdf5
is installed.
(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 readAntares
is unavailable.
character
host of AntaREST server API
character
id of the target study on the API
character
API personnal access token
numeric
API timeout (seconds). Default to 60. See also setTimeoutAPI
API httr configuration. See config
A list containing various information about the simulation, in particular:
+path of the Antares study
path of the simulation
path of the input folder of the study
Name of the study
path of the folder containing the data of the simulation
name of the simulation
type of simulation: economy, adequacy, draft or input
Are synthetic results available ?
Are the results for each Monte Carlo simulation available ?
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.
Vector containing the number of the exported Monte-Carlo scenarios
Version of Antares used to run the simulation.
Vector of the available areas.
Vector of the available districts.
Vector of the available links.
Vector of areas containing clusters.
Vector of areas containing clusters renewable.
Vector of areas containing clusters storage (>=v8.6.0).
Available variables for areas, districts and links.
Other parameters of the simulation.
Table of time series dimensions for each group (>=v8.7.0).
Minimum time id of the simulation. It is generally equal to one but can +be higher if working on a subperiod.
maximum time id of the simulation.
Date of the first day of the year in the simulation. This date corresponds +to timeId = 1.
First day of the week.
data.table containing the specification of the districts.
list containing the cost of spilled and unsupplied energy.
timer for api commande execute
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).
+
+if (FALSE) { # \dontrun{
+# 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")
+} # }
+
+
Change API Timeout
+setTimeoutAPI(opts, timeout)
list of simulation parameters returned by the function
+setSimulationPathAPI
numeric
API timeout (seconds). Default to 60.
Object of class simOptions
, list of options used to read the data contained in the last
+simulation read by setTimeoutAPI
.
if (FALSE) { # \dontrun{
+opts <- setTimeoutAPI(opts, timeout = 45)
+} # }
+
+
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)
list of options used to read the data contained in an object or the last
+simulation options read by setSimulationPath
if x
is
+NULL
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.
if (FALSE) { # \dontrun{
+ 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
+
+} # }
+
+
Subset method for antaresDataList
.
# S3 method for class 'antaresDataList'
+subset(x, y = NULL, areas = NULL, timeIds = NULL, mcYears = NULL, ...)
Object of class antaresDataList
created with
+readAntares
.
A table containing at least one of the columns "area", "timeId" or
+"mcYear". If it is not NULL
, then only tuples (area, timeId,
+ mcYear)
present in this table are kept.
Vector of area names to keep in the result. If NULL
, all
+areas are kept.
Vector of time ids to keep. If NULL
, all time ids are
+kept.
Vector of monte-carlo years to keep. If NULL
, all time
+ids are kept.
Currently unused.
A filtered antaresDataList
.
if (FALSE) { # \dontrun{
+#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)
+
+} # }
+
+
R/readBindingConstraints.R
+ summary.bindingConstraints.Rd
# S3 method for class 'bindingConstraints'
+summary(object, ...)
A data.frame with one line per constraint.
+This function displays each element of an antaresData
object in a
+spreadsheet-like viewer.
viewAntares(x, ...)
An object of class antaresData
, generated by the function
+readAntares
.
Currently unused
Invisible NULL.
+if (FALSE) { # \dontrun{
+setSimulationPath()
+
+areas <-readAntares()
+viewAntares(areas)
+
+output <- studyAntares(areas="all", links = "all", clusters = "all")
+viewAntares(output) # Opens three data viewers for each element of output
+} # }
+
+
Write digest file
+writeDigest(digest, opts = simOptions())
list of 5 elements similar to what is returned by readDigestFile
simulation options
updated digest +list of 5 tables (begin, areas, middle, links lin., links quad.)
+