|
1 |
| -[](https://travis-ci.org/rte-antares-rpackage/antaresRead) |
2 |
| -[](https://ci.appveyor.com/project/rte-antares-rpackage/antaresread) |
3 |
| -[](https://codecov.io/gh/rte-antares-rpackage/antaresRead/branch/master) |
4 |
| -[](https://cran.r-project.org/package=antaresRead) |
5 |
| - |
6 |
| - |
7 |
| -# Read data from an Antares study with R package 'antaresRead' |
8 |
| - |
9 |
| - |
10 |
| -## Installation |
11 |
| - |
12 |
| -You can install the package from CRAN: |
13 |
| -```r |
14 |
| -install.packages("antaresRead") |
15 |
| -``` |
16 |
| - |
17 |
| -You can also install the last development version from Github: |
18 |
| -```r |
19 |
| -devtools::install_github("rte-antares-rpackage/antaresRead", ref ="develop") |
20 |
| -``` |
21 |
| - |
22 |
| -To display the help of the package and see all the functions it provides, type: |
23 |
| -```r |
24 |
| -help(package="antaresRead") |
25 |
| -``` |
26 |
| - |
27 |
| -To see a practical example of use of the package, look at the vignette : |
28 |
| -```r |
29 |
| -vignette("antares") |
30 |
| -``` |
31 |
| - |
32 |
| -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 . |
33 |
| - |
34 |
| - |
35 |
| -## Initialisation |
36 |
| - |
37 |
| -Load the package |
38 |
| - |
39 |
| -```r |
40 |
| -library(antaresRead) |
41 |
| -``` |
42 |
| - |
43 |
| -Select an Antares simulation interactively. |
44 |
| - |
45 |
| -```r |
46 |
| -setSimulationPath() |
47 |
| -``` |
48 |
| - |
49 |
| -You can also select it programmatically: |
50 |
| - |
51 |
| -```r |
52 |
| -setsimulationPath("study_path", simulation) |
53 |
| -``` |
54 |
| - |
55 |
| -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. |
56 |
| - |
57 |
| - |
58 |
| -## Read data from a simulation |
59 |
| - |
60 |
| -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: |
61 |
| - |
62 |
| -```r |
63 |
| -# Read synthetic results of all areas of a study with hourly time step. |
64 |
| -areaData <- readAntares(areas = "all") |
65 |
| - |
66 |
| -# Same but with a daily time step: |
67 |
| -areaData <- readAntares(areas = "all", timeStep = "daily") |
68 |
| - |
69 |
| -# Read all Monte Carlo scenarios for a given area. |
70 |
| -myArea <- readAntares(areas = "my_area", mcYears = "all") |
71 |
| - |
72 |
| -# Same but add miscelaneous production time series to the result |
73 |
| -myArea <- readAntares(areas = "my_area", mcYears = "all", misc = TRUE) |
74 |
| - |
75 |
| -# Read only columns "LOAD" and "MRG. PRICE" |
76 |
| -areaData <- readAntares(areas = "all", select = c("LOAD", "MRG. PRICE")) |
77 |
| -``` |
78 |
| - |
79 |
| -Functions `getAreas` and `getLinks` are helpful to create a selection of areas or links of interest. Here are a few examples: |
80 |
| - |
81 |
| -```r |
82 |
| -# select areas containing "fr" |
83 |
| -myareas <- getAreas("fr") |
84 |
| - |
85 |
| -# Same but remove areas containing "hvdc" |
86 |
| -myareas <- getAreas("fr", exclude = "hvdc") |
87 |
| - |
88 |
| -# Get the links that connect two of the previous areas |
89 |
| -mylinks <- getLinks(myareas, internalOnly = FALSE) |
90 |
| - |
91 |
| -# Get the results for these areas and links |
92 |
| -mydata <- readAntares(areas = myareas, links = mylinks) |
93 |
| -``` |
94 |
| - |
95 |
| -## Work with the imported data |
96 |
| - |
97 |
| -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: |
98 |
| - |
99 |
| -```r |
100 |
| -name_of_the_table[filter_rows, select_columns, group_by] |
101 |
| -``` |
102 |
| - |
103 |
| -Here are some examples: |
104 |
| - |
105 |
| -```r |
106 |
| -# Select lines based on some criteria |
107 |
| -mydata[area == "fr" & month == "JUL"] |
108 |
| - |
109 |
| -# Select columns, and compute new ones |
110 |
| -mydata[, .(area, month, load2 = LOAD^2)] |
111 |
| - |
112 |
| -# Aggregate data by some variables |
113 |
| -mydata[, .(total = sum(LOAD)), by = .(month)] |
114 |
| - |
115 |
| -# All three operations can be done with a single line of code |
116 |
| -mydata[area == "fr", .(total = sum(LOAD)), by = .(month)] |
117 |
| - |
118 |
| -help(package = "data.table") |
119 |
| -``` |
120 |
| - |
121 |
| -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: |
122 |
| - |
123 |
| -```r |
124 |
| -help(package="data.table") |
125 |
| -vignette("datatable-intro") |
126 |
| -``` |
127 |
| -## Contributing: |
128 |
| - |
129 |
| -Contributions to the library are welcome and can be submitted in the form of pull requests to this repository. |
130 |
| - |
131 |
| -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: |
132 |
| - |
133 |
| -```r |
134 |
| -saveWd<-getwd() |
135 |
| -setwd('inst/testdata/') |
136 |
| -tar( |
137 |
| - tarfile = "antares-test-study.tar.gz", |
138 |
| - files = "test_case", |
139 |
| - compression = "gzip" |
140 |
| -) |
141 |
| - |
142 |
| -setwd(saveWd) |
143 |
| -``` |
144 |
| - |
145 |
| -You must also change the h5 file [here](https://github.com/rte-antares-rpackage/antaresRead/blob/master/tests/testthat/helper_init.R#L35). |
146 |
| - |
147 |
| -## ANTARES : |
148 |
| - Antares is a powerful software developed by RTE to simulate and study electric power systems (more information about Antares here : <https://antares.rte-france.com>). |
149 |
| - |
150 |
| -ANTARES is now an open-source project (since 2018), you can download the sources [here](https://github.com/AntaresSimulatorTeam/Antares_Simulator) if you want to use this package. |
151 |
| - |
152 |
| -## License Information: |
153 |
| - |
154 |
| -Copyright 2015-2016 RTE (France) |
155 |
| - |
156 |
| -* RTE: http://www.rte-france.com |
157 |
| - |
158 |
| -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. |
| 1 | +# antaresRead |
| 2 | + |
| 3 | +> Read data from an Antares study with R package 'antaresRead' |
| 4 | +
|
| 5 | +[](https://travis-ci.org/rte-antares-rpackage/antaresRead) |
| 6 | +[](https://ci.appveyor.com/project/rte-antares-rpackage/antaresread) |
| 7 | +[](https://codecov.io/gh/rte-antares-rpackage/antaresRead/branch/master) |
| 8 | +[](https://cran.r-project.org/package=antaresRead) |
| 9 | +[](https://www.tidyverse.org/lifecycle/#stable) |
| 10 | +[](https://www.repostatus.org/#active) |
| 11 | + |
| 12 | + |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +You can install the package from CRAN: |
| 17 | +```r |
| 18 | +install.packages("antaresRead") |
| 19 | +``` |
| 20 | + |
| 21 | +You can also install the last development version from Github: |
| 22 | +```r |
| 23 | +devtools::install_github("rte-antares-rpackage/antaresRead") |
| 24 | +``` |
| 25 | + |
| 26 | +To display the help of the package and see all the functions it provides, type: |
| 27 | +```r |
| 28 | +help(package="antaresRead") |
| 29 | +``` |
| 30 | + |
| 31 | +To see a practical example of use of the package, look at the vignette : |
| 32 | +```r |
| 33 | +vignette("antares") |
| 34 | +``` |
| 35 | + |
| 36 | +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 . |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | + |
| 41 | +## Initialisation |
| 42 | + |
| 43 | +Load the package |
| 44 | + |
| 45 | +```r |
| 46 | +library(antaresRead) |
| 47 | +``` |
| 48 | + |
| 49 | +Select an Antares simulation interactively. |
| 50 | + |
| 51 | +```r |
| 52 | +setSimulationPath() |
| 53 | +``` |
| 54 | + |
| 55 | +You can also select it programmatically: |
| 56 | + |
| 57 | +```r |
| 58 | +setsimulationPath("study_path", simulation) |
| 59 | +``` |
| 60 | + |
| 61 | +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. |
| 62 | + |
| 63 | + |
| 64 | +## Read data from a simulation |
| 65 | + |
| 66 | +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: |
| 67 | + |
| 68 | +```r |
| 69 | +# Read synthetic results of all areas of a study with hourly time step. |
| 70 | +areaData <- readAntares(areas = "all") |
| 71 | + |
| 72 | +# Same but with a daily time step: |
| 73 | +areaData <- readAntares(areas = "all", timeStep = "daily") |
| 74 | + |
| 75 | +# Read all Monte Carlo scenarios for a given area. |
| 76 | +myArea <- readAntares(areas = "my_area", mcYears = "all") |
| 77 | + |
| 78 | +# Same but add miscelaneous production time series to the result |
| 79 | +myArea <- readAntares(areas = "my_area", mcYears = "all", misc = TRUE) |
| 80 | + |
| 81 | +# Read only columns "LOAD" and "MRG. PRICE" |
| 82 | +areaData <- readAntares(areas = "all", select = c("LOAD", "MRG. PRICE")) |
| 83 | +``` |
| 84 | + |
| 85 | +Functions `getAreas` and `getLinks` are helpful to create a selection of areas or links of interest. Here are a few examples: |
| 86 | + |
| 87 | +```r |
| 88 | +# select areas containing "fr" |
| 89 | +myareas <- getAreas("fr") |
| 90 | + |
| 91 | +# Same but remove areas containing "hvdc" |
| 92 | +myareas <- getAreas("fr", exclude = "hvdc") |
| 93 | + |
| 94 | +# Get the links that connect two of the previous areas |
| 95 | +mylinks <- getLinks(myareas, internalOnly = FALSE) |
| 96 | + |
| 97 | +# Get the results for these areas and links |
| 98 | +mydata <- readAntares(areas = myareas, links = mylinks) |
| 99 | +``` |
| 100 | + |
| 101 | +## Work with the imported data |
| 102 | + |
| 103 | +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: |
| 104 | + |
| 105 | +```r |
| 106 | +name_of_the_table[filter_rows, select_columns, group_by] |
| 107 | +``` |
| 108 | + |
| 109 | +Here are some examples: |
| 110 | + |
| 111 | +```r |
| 112 | +# Select lines based on some criteria |
| 113 | +mydata[area == "fr" & month == "JUL"] |
| 114 | + |
| 115 | +# Select columns, and compute new ones |
| 116 | +mydata[, .(area, month, load2 = LOAD^2)] |
| 117 | + |
| 118 | +# Aggregate data by some variables |
| 119 | +mydata[, .(total = sum(LOAD)), by = .(month)] |
| 120 | + |
| 121 | +# All three operations can be done with a single line of code |
| 122 | +mydata[area == "fr", .(total = sum(LOAD)), by = .(month)] |
| 123 | + |
| 124 | +help(package = "data.table") |
| 125 | +``` |
| 126 | + |
| 127 | +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: |
| 128 | + |
| 129 | +```r |
| 130 | +help(package="data.table") |
| 131 | +vignette("datatable-intro") |
| 132 | +``` |
| 133 | +## Contributing: |
| 134 | + |
| 135 | +Contributions to the library are welcome and can be submitted in the form of pull requests to this repository. |
| 136 | + |
| 137 | +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: |
| 138 | + |
| 139 | +```r |
| 140 | +saveWd<-getwd() |
| 141 | +setwd('inst/testdata/') |
| 142 | +tar( |
| 143 | + tarfile = "antares-test-study.tar.gz", |
| 144 | + files = "test_case", |
| 145 | + compression = "gzip" |
| 146 | +) |
| 147 | + |
| 148 | +setwd(saveWd) |
| 149 | +``` |
| 150 | + |
| 151 | +You must also change the h5 file [here](https://github.com/rte-antares-rpackage/antaresRead/blob/master/tests/testthat/helper_init.R#L35). |
| 152 | + |
| 153 | +## ANTARES : |
| 154 | + Antares is a powerful software developed by RTE to simulate and study electric power systems (more information about Antares here : <https://antares.rte-france.com>). |
| 155 | + |
| 156 | +ANTARES is now an open-source project (since 2018), you can download the sources [here](https://github.com/AntaresSimulatorTeam/Antares_Simulator) if you want to use this package. |
| 157 | + |
| 158 | +## License Information: |
| 159 | + |
| 160 | +Copyright 2015-2016 RTE (France) |
| 161 | + |
| 162 | +* RTE: http://www.rte-france.com |
| 163 | + |
| 164 | +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. |
0 commit comments