-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAEMO-constraints.Rmd
68 lines (55 loc) · 2.42 KB
/
AEMO-constraints.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
title: "AEMO-constraints"
author: "GeoffRussell"
date: "2/5/2023"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(tidyverse)
library(readxl)
confile<-"/home/geoff/ARTICLES/GRID/NEM_Constraint_Report_2021_summary_data.xlsx"
sheets<-excel_sheets(confile)
print(sheets)
```
## NEM Constraint
```{r functions}
getSheet<-function(sheetname) {
read_excel(confile,sheet=sheetname,na='n/a',col_types=c('text',
rep('numeric',2),
'text',
'text',
'text',
'text'
))
}
dffcas<-read_excel(confile,sheet="Binding FCAS",na='n/a',col_types=c('text',
rep('numeric',2),
'text',
'text'
)) %>%
mutate("2020"=`2020 Hours`,"2021"=`2021 Hours`) %>%
select(-`2020 Hours`,-`2021 Hours`)
df<-getSheet("Binding") %>% mutate("2020"=`2020 Hours`,"2021"=`2021 Hours`) %>% select(-`2020 Hours`,-`2021 Hours`)
show<-function(.data,txt) {
cat(txt,.data$n,"\n")
}
docounts<-function(df,type) {
cat(type," ",nrow(df),"\n")
df %>% filter(`2020`>0) %>% summarise(n=n()) %>% show("Binding>0 2020: ")
df %>% filter(`2020`>24) %>% summarise(n=n()) %>% show("2020 >24 hrs: ")
df %>% filter(`2021`>24) %>% summarise(n=n()) %>% show("2021 >24 hrs: ")
df %>% filter(`2020`>0&`2021`==0.0) %>% summarise(n=n()) %>% show("Better in 2021: ")
df %>% filter(`2020`==0.0 & `2021`>0) %>% summarise(n=n()) %>% show("Worse in 2021: ")
}
docounts(df,"NEM Bindings 2021")
docounts(dffcas,"FCAS Bindings 2021")
dfl<-df %>% filter(`2020`==0&`2021`>100) %>%
pivot_longer(cols=c("2020","2021"),names_to="Year",values_to="Hours") %>%
select(`Constraint Equation ID`,`Hours`,`Year`,`Region`)
p<-dfl %>% ggplot() + geom_col(aes(x=`Constraint Equation ID`,y=`Hours`,fill=`Year`),position="dodge") + facet_wrap(~Region)+coord_flip()
p
png("constraints20-21.png",width=2000,height=3000,units="px",res=300,type="cairo-png")
print(p)
dev.off()
```