Skip to content

Commit

Permalink
quantiles margin down 4/16h
Browse files Browse the repository at this point in the history
  • Loading branch information
pvictor committed Feb 26, 2019
1 parent 5b734af commit 62a4ec2
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 62 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: antaresWeeklyMargin
Title: Setup an 'Antares' Study for Weekly Margin Simulation
Version: 0.0.2.960
Version: 0.0.2.970
Authors@R: c(
person("Victor", "Perrier", email = "[email protected]", role = c("aut", "cre")),
person("Fabiola", "Aravena-Rojas", email = "[email protected]", role = c("aut")),
Expand Down
7 changes: 4 additions & 3 deletions R/margins_quantiles.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@


#' Compute margins' quantiles
#' Compute margins quantiles for a couple of hours
#'
#' @param margin a \code{data.table} containing margins.
#' @param hours Couple of hours.
#'
#' @return a \code{data.table}
#' @export
Expand All @@ -16,13 +17,13 @@
#'
#' @importFrom data.table copy melt %chin% :=
#' @importFrom stats median quantile
margins_quantiles <- function(margin) {
margins_quantiles <- function(margin, hours = c("09h", "19h")) {

margin <- copy(margin)
margin[, jour := format(datetime, format = "%A")]
margin[, date := format(datetime, format = "%Y-%m-%d")]
margin[, heure := format(datetime, format = "%Hh")]
margin <- margin[heure %chin% c("09h", "19h")]
margin <- margin[heure %chin% hours]

margin <- melt(
data = margin,
Expand Down
4 changes: 2 additions & 2 deletions inst/markdown/report/index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Legend:
Table of quantiles :

```{r down-quantiles-solo, echo=FALSE}
marg <- margins_quantiles(marges_down$margin_area_solo)
marg <- margins_quantiles(marges_down$margin_area_solo, hours = c("04h", "16h"))
ft_margins_quantiles(marg, layout = "horizontal", language = "en")
```

Expand Down Expand Up @@ -243,7 +243,7 @@ Legend:
Table of quantiles :

```{r down-quantiles-inter, echo=FALSE}
marg_i <- margins_quantiles(marges_down$margin_area_inter)
marg_i <- margins_quantiles(marges_down$margin_area_inter, hours = c("04h", "16h"))
ft_margins_quantiles(marg_i, layout = "horizontal", language = "en")
```

Expand Down
145 changes: 92 additions & 53 deletions inst/markdown/wmauto/index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ h1, h2, h3, h4 {

<br/>

```{r out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_series(marges$margin_area, "LOAD")
```{r series-load, out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_series(marges_up$margin_area, "LOAD")
```

<br/>
Expand All @@ -67,8 +67,8 @@ draw_series(marges$margin_area, "LOAD")

<br/>

```{r out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_series(marges$margin_area, "WIND")
```{r series-wind, out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_series(marges_up$margin_area, "WIND")
```

<br/>
Expand All @@ -82,8 +82,8 @@ draw_series(marges$margin_area, "WIND")

<br/>

```{r out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_series(marges$margin_area, "SOLAR")
```{r series-solar, out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_series(marges_up$margin_area, "SOLAR")
```

<br/>
Expand All @@ -93,22 +93,18 @@ draw_series(marges$margin_area, "SOLAR")

<br/>

# Results : margins analysis
# Results : upward margins analysis


<br/>

### Initial Remaining Capacity - <span style="font-size: 80%;"><img src="imgs/fr.svg" width="28" height="21" style="vertical-align: 0px;"/> FR</span>

<br/>

* A large number of scenarios with negative values of initial remaining capacity during peak-hours on weekdays
* Deterministic forecast is consistent with the results

<br/>

```{r out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_margins(data_margin = marges$margin_area_solo)
```{r up-margins-solo, out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_margins(data_margin = marges_up$margin_area_solo)
```
<br/>
Legend:
Expand All @@ -124,8 +120,8 @@ Legend:

Table of quantiles :

```{r, echo=FALSE}
marg <- margins_quantiles(marges$margin_area_solo)
```{r up-quantiles-solo, echo=FALSE}
marg <- margins_quantiles(marges_up$margin_area_solo)
ft_margins_quantiles(marg, layout = "horizontal", language = "en")
```

Expand All @@ -134,15 +130,11 @@ ft_margins_quantiles(marg, layout = "horizontal", language = "en")

### Final Remaining Capacity - <span style="font-size: 80%;"><img src="imgs/fr.svg" width="28" height="21" style="vertical-align: 0px;"/> FR</span>

<br/>

* Variability of final remaining capacity for France increases with time

<br/>


```{r out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_margins(data_margin = marges$margin_area_inter)
```{r up-margins-inter, out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_margins(data_margin = marges_up$margin_area_inter)
```
<br/>
Legend:
Expand All @@ -158,8 +150,8 @@ Legend:

Table of quantiles :

```{r, echo=FALSE}
marg_i <- margins_quantiles(marges$margin_area_inter)
```{r up-quantiles-inter, echo=FALSE}
marg_i <- margins_quantiles(marges_up$margin_area_inter)
ft_margins_quantiles(marg_i, layout = "horizontal", language = "en")
```

Expand All @@ -169,13 +161,9 @@ ft_margins_quantiles(marg_i, layout = "horizontal", language = "en")

<br/>

Risk of unserved energy in France.

<br/>


```{r out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_stack_hist(marges$margin_area_solo, marges$margin_area_inter, "fr")
```{r up-stack, out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_stack_hist(marges_up$margin_area_solo, marges_up$margin_area_inter, "fr")
```

<br/>
Expand All @@ -192,6 +180,75 @@ Legend:
<br/>



# Results : downward margins analysis


<br/>

### Initial Remaining Capacity - <span style="font-size: 80%;"><img src="imgs/fr.svg" width="28" height="21" style="vertical-align: 0px;"/> FR</span>


<br/>

```{r down-margins-solo, out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_margins(data_margin = marges_down$margin_area_solo)
```
<br/>
Legend:

* <span style="color: red;">1% of scenarii</span>
* <span style="color: orange;">4% of scenarii</span>
* <span style="color: blue;">10% of scenarii</span>
* <span style="color: green;">50% of scenarii</span>
* <span style="color: #A4A4A4">`r n_scenario` scenarii</span>

<br/>
<br/>

Table of quantiles :

```{r down-quantiles-solo, echo=FALSE}
marg <- margins_quantiles(marges_down$margin_area_solo, hours = c("04h", "16h"))
ft_margins_quantiles(marg, layout = "horizontal", language = "en")
```


<br/>

### Final Remaining Capacity - <span style="font-size: 80%;"><img src="imgs/fr.svg" width="28" height="21" style="vertical-align: 0px;"/> FR</span>

<br/>


```{r down-margins-inter, out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_margins(data_margin = marges_down$margin_area_inter)
```
<br/>
Legend:

* <span style="color: red;">1% of scenarii</span>
* <span style="color: orange;">4% of scenarii</span>
* <span style="color: blue;">10% of scenarii</span>
* <span style="color: green;">50% of scenarii</span>
* <span style="color: #A4A4A4">`r n_scenario` scenarii</span>

<br/>
<br/>

Table of quantiles :

```{r down-quantiles-inter, echo=FALSE}
marg_i <- margins_quantiles(marges_down$margin_area_inter, hours = c("04h", "16h"))
ft_margins_quantiles(marg_i, layout = "horizontal", language = "en")
```



<br/>
<br/>


# Detailed results : scenarii analysis


Expand All @@ -211,7 +268,7 @@ draw_scenario(mono$scenarii, var_value = "flux_total", var_date = "time", h = 60

<br/>

```{r out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
```{r mono-fr, out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_mono(mono$mono_france)
```

Expand All @@ -224,7 +281,7 @@ draw_mono(mono$mono_france)

<br/>

```{r out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
```{r mono-cwe, out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_mono(mono$mono_cwe)
```

Expand All @@ -243,19 +300,10 @@ draw_mono(mono$mono_cwe)

<br/>

```{r out.width='100%', fig.height=6, comment=NA, results='asis', eval=require('dygraphs'), echo=FALSE}
```{r exchanges, out.width='100%', fig.height=6, comment=NA, results='asis', eval=require('dygraphs'), echo=FALSE}
antaresViz::exchangesStack(marges_all$links, area = "fr", interactive = FALSE)
```

<br/>


<ul>
<li>France exports during the weekend.</li>
<li>During the weekdays France is a net importer.</li>
<li>During the day France exports to Belgium, except during hours of inadequacy as it was the case of 10 Nov 2016 17:00 UTC (no more flows between the 2 countries)</li>
</ul>



<br/>
Expand All @@ -267,19 +315,10 @@ antaresViz::exchangesStack(marges_all$links, area = "fr", interactive = FALSE)
<br/>


```{r out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_prod_MC(marges$margin_area, date_i = date_study, mc_year = year_mc)#$widgets[[1]]$widget[[1]]
```{r prod-mc, out.width='100%', fig.height=6, eval=require('dygraphs'), echo=FALSE}
draw_prod_MC(marges_up$margin_area, date_i = date_debut, mc_year = year_mc)#$widgets[[1]]$widget[[1]]
```

<br/>

<ul>
<li>In France, thermal production is low because of unavailability of nuclear plants.</li>
<li>Because of that, France is a net importer during the weekdays.</li>
<li>We can also observe time steps where there are unsupplied energy.</li>
<li>Water is pumped during off-peak hours but it is not enough to avoid inadequacy.</li>
</ul>


<br/>
<br/>
Expand All @@ -288,7 +327,7 @@ draw_prod_MC(marges$margin_area, date_i = date_study, mc_year = year_mc)#$widget

<br/>

```{r out.width='100%', fig.height=6, eval=require('leaflet'), echo=FALSE}
```{r map, out.width='100%', fig.height=6, eval=require('leaflet'), echo=FALSE}
plotMap(
x = marges_all, mapLayout = ml, interactive = FALSE,
colLinkVar = "abs_loadFactor", sizeLinkVar = "FLOW LIN.",
Expand Down
8 changes: 5 additions & 3 deletions man/margins_quantiles.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 62a4ec2

Please sign in to comment.