Skip to content

Commit 7820542

Browse files
committed
add antaresViz examples
1 parent 9fcdb76 commit 7820542

File tree

2 files changed

+505
-0
lines changed

2 files changed

+505
-0
lines changed

antaresViz.Rmd

+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
---
2+
title: "antaresViz"
3+
author: "Jalal-Edine ZAWAM"
4+
date: "20 juillet 2018"
5+
output:
6+
html_document:
7+
number_sections: yes
8+
toc: yes
9+
---
10+
11+
```{r param, echo=FALSE}
12+
13+
#param of all examples
14+
pathStudy <- "E:\\ANTARES\\Exemple_antares\\2_exemple_etudes_importantes\\TYNDP\\ST2030\\ST2030"
15+
16+
pathStudyL <- "E:\\ANTARES\\Exemple_antares\\3_petit_exemple\\PackagesR\\Test_packages_R_602"
17+
18+
```
19+
20+
21+
# Introduction
22+
23+
`antaresViz` is on [CRAN](https://cran.r-project.org/web/packages/antaresViz/index.html). This package can help you to visualize results from the open source software ANTARES, more information about ANTARES [here](https://github.com/AntaresSimulatorTeam/Antares_Simulator).
24+
25+
This documentation will present some new examples for `antaresViz` and also how to use R, data.table and RStudio.
26+
27+
# How to represent the generation mix for each country?
28+
29+
Here we have to use the `prodStack` function.
30+
31+
```{r prodStackHelp, eval=FALSE}
32+
#you can visualize prodStack help with this command on RStudio
33+
#you will find some examples
34+
??prodStack
35+
36+
```
37+
38+
## Generation mix for hourly data
39+
40+
```{r importHourlyData, echo=TRUE}
41+
suppressMessages(library(antaresViz))
42+
#pathStudy : path to my study
43+
suppressWarnings(opts <- setSimulationPath(pathStudy,-1))
44+
myData <- suppressWarnings(readAntares(areas = "fr", showProgress = FALSE))
45+
46+
prodStack(myData, interactive = FALSE, areas = "fr", dateRange = c("2018-07-01", "2018-07-05"))
47+
48+
#prodStack can also be an interactive application, a user can set this behaviour in two ways:
49+
#1. do not set the "interactive" parameter (by default, interactive is set to TRUE)
50+
#2. set "interactive" parameter to TRUE
51+
52+
#run it in your console
53+
#prodStack(myData, areas = "fr", dateRange = c("2018-07-01", "2018-07-05"))
54+
55+
#run it in your console
56+
#prodStack(myData, interactive = TRUE, areas = "fr", dateRange = c("2018-07-01", "2018-07-05"))
57+
58+
```
59+
60+
61+
One can also include `prodStack` in a shiny app like for the adequacy French report
62+
[bpnumerique](http://bpnumerique.rte-france.com/), tab "Analyse detaillee".
63+
64+
## Generation mix for daily, weekly or monthly data
65+
```{r importDWMData, echo=TRUE}
66+
suppressMessages(library(antaresViz))
67+
#pathStudy : path to my study
68+
suppressWarnings(opts <- setSimulationPath(pathStudy,-1))
69+
myDataD <- suppressWarnings(readAntares(areas = "fr", showProgress = FALSE, timeStep = "daily"))
70+
myDataW <- suppressWarnings(readAntares(areas = "fr", showProgress = FALSE, timeStep = "weekly"))
71+
myDataM <- suppressWarnings(readAntares(areas = "fr", showProgress = FALSE, timeStep = "monthly"))
72+
73+
dataRangeEx <- c("2018-06-25", "2018-07-05")
74+
prodStack(myDataD, interactive = FALSE, areas = "fr", dateRange = dataRangeEx)
75+
prodStack(myDataW, interactive = FALSE, areas = "fr", dateRange = dataRangeEx)
76+
prodStack(myDataM, interactive = FALSE, areas = "fr", dateRange = c("2018-05-01", "2018-09-30"))
77+
78+
#try to plot weekly data for one week in your console
79+
#try to plot monthly data for one month in your console
80+
#prodStack(myDataW, interactive = FALSE, areas = "fr", dateRange = c("2018-07-01", "2018-07-05"))
81+
#prodStack(myDataM, interactive = FALSE, areas = "fr", dateRange = c("2018-05-01", "2018-05-30"))
82+
83+
```
84+
85+
## Generation mix for annual data
86+
```{r importAnnualData, echo=TRUE}
87+
suppressMessages(library(antaresViz))
88+
#pathStudy : path to my study
89+
suppressWarnings(opts <- setSimulationPath(pathStudy,-1))
90+
myDataA <- suppressWarnings(readAntares(areas = "fr", showProgress = FALSE, timeStep = "annual"))
91+
92+
prodStack(myDataA, interactive = FALSE, areas = "fr")
93+
```
94+
95+
# How to represent LOLD and ENS for each country?
96+
97+
## With plot it's easy
98+
`plot` help you to visualize a time series and can also help you to visualize LOLE and ENS.
99+
100+
```{r plotLOLE, echo=TRUE}
101+
suppressMessages(library(antaresViz))
102+
#pathStudy : path to my study
103+
suppressWarnings(opts <- setSimulationPath(pathStudy,-1))
104+
#get only some areas
105+
myAreas <- c("fr", "fi", "be")
106+
myDataH <- suppressWarnings(readAntares(areas = myAreas, showProgress = FALSE))
107+
108+
#one country and one variable
109+
plot(myDataH, interactive = FALSE, elements = "fr", variable = "UNSP. ENRG")
110+
#one country and several variables
111+
plot(myDataH, interactive = FALSE, elements = "fr", variable = c("UNSP. ENRG", "LOLD", "LOLP"))
112+
#several countries and one variable
113+
plot(myDataH, interactive = FALSE, elements = c("fr", "fi", "be"), variable = c("UNSP. ENRG"))
114+
#several countries and several variables
115+
plot(myDataH, interactive = FALSE, elements = c("fr", "fi", "be"), variable = c("UNSP. ENRG", "LOLD", "LOLP"))
116+
#one country and several variables but with monotone
117+
plot(myDataH, interactive = FALSE, elements = "be", variable = c("WIND", "SOLAR"), type = "monotone")
118+
119+
```
120+
121+
## Other possibilities
122+
123+
`plot` can be used with `type` "barplot", "density", "cdf" or "heatmap" to visualize some variables like "LOLD".
124+
125+
`prodStack` can also be used to visualize a lack of production.
126+
127+
128+
```{r prodStackLOLE, echo=TRUE}
129+
suppressMessages(library(antaresViz))
130+
#pathStudy : path to my study
131+
suppressWarnings(opts <- setSimulationPath(pathStudy,-1))
132+
#get only some areas
133+
myAreas <- c("fr", "fi", "be")
134+
myDataH <- suppressWarnings(readAntares(areas = myAreas, showProgress = FALSE))
135+
136+
dateWithENS <- myDataH[LOLD >0 , time][1]
137+
dateWithENS
138+
firstDate <- dateWithENS - 60*60*24
139+
lastDate <- dateWithENS + 60*60*24
140+
prodStack(myDataH, interactive = FALSE, areas = "fr", dateRange = c(firstDate, lastDate))
141+
142+
```
143+
144+
## For several simulations
145+
```{r plotLoleSims, echo=TRUE}
146+
suppressMessages(library(antaresViz))
147+
#pathStudy : path to my study
148+
suppressWarnings(opts <- setSimulationPath(pathStudy,-1))
149+
#only some variables
150+
varToGet <- c("UNSP. ENRG", "LOLD", "LOLP")
151+
myDataS1 <- suppressWarnings(readAntares(areas = "fr", showProgress = FALSE, select = varToGet))
152+
suppressWarnings(opts <- setSimulationPath(pathStudy,-2))
153+
myDataS2 <- suppressWarnings(readAntares(areas = "fr", showProgress = FALSE, select = varToGet))
154+
155+
#one simulation and one variable
156+
plot(myDataS1, interactive = FALSE, elements = "fr", variable = "UNSP. ENRG")
157+
plot(myDataS2, interactive = FALSE, elements = "fr", variable = "UNSP. ENRG")
158+
159+
#plot in the same graph the two variables
160+
myDataS1[, unspEnrgS1 := `UNSP. ENRG`]
161+
myDataS1[, unspEnrgS2 := myDataS2$`UNSP. ENRG`]
162+
plot(myDataS1, interactive = FALSE, elements = "fr", variable = c("unspEnrgS1", "unspEnrgS2"))
163+
164+
```

antaresViz.html

+341
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)