-
Notifications
You must be signed in to change notification settings - Fork 0
/
4. analysis.Rmd
142 lines (114 loc) · 3.34 KB
/
4. analysis.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
---
title: "Analysis"
output: html_document
---
```{r}
library(tidyverse)
library(lubridate)
library(ggplot2)
library(scales)
library(gridExtra)
source("./helper_functions.R")
```
The final step is going to be loading in the data, running through some analysis, and generating the plots necessary for the article. Note that the bulk of the heavy lifting for this step is in the separate `helper_functions.R` file.
Let's start by defining some helpful constants:
```{r}
###
# Constants
#
FUEL_COLUMNS <- c("dual_fuel", "hydro", "natural_gas", "nuclear", "other_fossil_fuels", "other_renewables", "wind")
DIRTY_FUELS <- c("dual_fuel", "natural_gas", "other_fossil_fuels")
CLEAN_FUELS <- c("hydro", "nuclear", "other_renewables", "wind")
HOT_MONTHS <- c(5, 6, 7, 8, 9, 10)
COLD_MONTHS <- c(11, 12, 1, 2, 3, 4)
CLEAN_GEN_COLOR <- "#5EBD3E"
DIRTY_GEN_COLOR <- "#766031"
```
Next up, load in the data we generated from the previous step.
```{r}
data <- read_csv("./derived_data/combined_gen_load.csv") %>%
categorize_fuels %>%
calculate_fuel_percs
head(data)
```
Looks good! Now let's start crunching numbers...
# Finding the top 10 Demand Days in 2019, 2020, 2021
```{r}
data %>%
rollup_daily() %>%
select(time_stamp, load) %>%
# Convert MW into GW
mutate(load = load / 1000) %>%
slice_max(load, n = 10)
```
# 2019 Peak Demand Event
## Range of dirty percentages for the peak
```{r}
peak_2019 <- data %>%
select_range("2019-07-19", "2019-07-20") %>%
select(time_stamp, dirty_perc, clean_perc)
range(peak_2019$dirty_perc) * 100
```
## Fuel mix breakdown
Although I didn't end up using this in the final post, it was helpful to compare how much of each fuel mix was being used while I was trying to gather data on what was going on.
```{r}
data %>%
select_range("2019-07-19", "2019-07-20") %>%
plot_line_per_fuel()
```
## Clean vs Dirty Chart
This is the chart I ended up using for the post, though I did some post-processing after generating it in R.
```{r}
data %>%
select_range("2019-07-19", "2019-07-20") %>%
plot_clean_dirty_mix() +
ggtitle("Hourly Generation Mix as % Clean vs Dirty")
```
## Fuel Mix Area Chart
This is half of the 2021 vs 2019 chart I stitched together in post-processing before adding to the post.
```{r}
data %>%
select_range("2019-07-19", "2019-07-20") %>%
plot_gen_area() +
ylim(0, 375)
```
# 2021 Peak Demand Event
## Dirty % Range
Calculating the range of dirty percentages during the 2 day period
```{r}
peak_2021 <- data %>%
select_range("2021-06-29", "2021-06-30") %>%
select(time_stamp, dirty_perc, clean_perc)
range(peak_2021$dirty_perc) * 100
```
## Clean vs Dirty Chart
```{r}
data %>%
select_range("2021-06-29", "2021-06-30") %>%
plot_clean_dirty_mix() +
ggtitle("Hourly Generation Mix as % Clean vs Dirty")
```
## Fuel Mix Area Chart
This is the other half of the 2021 vs 2019 chart.
```{r}
data %>%
select_range("2021-06-29", "2021-06-30") %>%
plot_gen_area() +
ylim(0, 375)
```
# Average Day
This section is for generating the charts I used on the average February days.
## Fuel Mix Area Chart
```{r}
data %>%
select_range("2021-02-02", "2021-02-03") %>%
plot_gen_area() +
ggtitle("Hourly Generation Fuel Mix")
```
## Average Day Clean vs Dirty Mix
```{r}
data %>%
select_range("2021-02-02", "2021-02-03") %>%
plot_clean_dirty_mix() +
ggtitle("Hourly Generation Mix as % Clean vs Dirty")
```