...
 
Commits (3)
This diff is collapsed.
......@@ -18,6 +18,11 @@ shinyServer(function(input, output, session) {
mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n()))
# Load ENTSOE Data
entsoe_storage = read_rds('data/ENTSOE-Storage-2015-2018.rds')
# Load WAPP demand data
wapp_demand = bind_rows(read_csv('data/demand.csv'),
read_csv('data/demand.csv'),
read_csv('data/demand.csv')) %>%
mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n()))
# Average water value ---------------------------------------------------------------------
if (input$plot_type == 'awv') {
sel <-
......@@ -48,8 +53,8 @@ shinyServer(function(input, output, session) {
mutate(avg_cost = mean(value))
g = ggplot(sel,
aes(x = date, y = source, #y = fct_reorder(source, avg_cost),
fill = cut(value, right = FALSE, breaks = seq(0, max(sel$value)+0.1, length.out = 10)))) +
aes(x = date, y = source, #y = fct_reorder(source, avg_cost),
fill = cut(value, right = FALSE, breaks = seq(0, max(sel$value)+0.1, length.out = 10)))) +
geom_tile() +
scale_fill_brewer(palette = 'YlOrRd', name = 'water value', drop = FALSE) +
ylab('Zone') +
......@@ -62,6 +67,14 @@ shinyServer(function(input, output, session) {
sel_zone = select(gen, date, contains(paste0(input$zone, '_')))
print(names(sel_zone))
if (input$zone %in% names(wapp_demand)) {
demand_df = tibble(date = wapp_demand$date,
demand = wapp_demand[[input$zone]])
} else {
demand_df = NULL
}
color_palette = c('HPHS' = 'blue4',
'HDAM' = 'blue3',
'HROR' = 'cornflowerblue',
......@@ -89,11 +102,16 @@ shinyServer(function(input, output, session) {
mutate(variance = sd(generation)/mean(generation)) %>%
ungroup() %>%
mutate(source_type = fct_reorder(source_type, -variance)) %>%
ggplot(aes(x = date, y = generation, group = source_type,
fill = source_type)) +
ggplot(aes(x = date, y = generation)) +
scale_fill_manual(values = color_palette) +
geom_area() +
geom_area(aes(group = source_type,
fill = source_type)) +
theme_light()
if (!is.null(demand_df)) {
g = g + geom_line(data = demand_df,
aes(x = date, y = demand), color = 'black')
}
print(g)
}
......@@ -130,7 +148,7 @@ shinyServer(function(input, output, session) {
mutate(generation_fraction = generation / daily_total)
g = ggplot(gen_area, aes(x = date, y = generation_fraction, fill = type,
group = type)) +
group = type)) +
geom_area(size = 0.5, colour = 'black', alpha = 0.8) +
facet_wrap(~country) +
scale_fill_manual(values = color_palette) +
......@@ -197,6 +215,13 @@ shinyServer(function(input, output, session) {
mutate(day_of_the_year = yday(date)) %>%
gather(area, spillage, -date, -day_of_the_year)
pumping = readxl::read_xlsx(paste0('xls/', input$result_xls), sheet = 'Pumping') %>%
select(contains(paste0(input$zone, '_HPHS')),
contains(paste0(input$zone, '_HDAM'))) %>%
mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n())) %>%
mutate(day_of_the_year = yday(date)) %>%
gather(area, pumping, -date, -day_of_the_year)
res_zone = select(res, date, contains(paste0(input$zone, '_HPHS')),
contains(paste0(input$zone, '_HDAM'))) %>%
mutate(day_of_the_year = yday(date)) %>%
......@@ -210,16 +235,18 @@ shinyServer(function(input, output, session) {
merged = inner_join(
inner_join(
inner_join(inflows, res_zone), gen_zone),
spillage) %>%
inner_join(
inner_join(inflows, res_zone), gen_zone),
spillage),
pumping) %>%
gather(variable, output, -date, -day_of_the_year, -area)
entsoe_data = entsoe_storage %>%
filter(country == input$zone)
g = ggplot(merged, aes_string(x = ifelse(diff(range(res_zone$date)) > years(1),
"date",
"day_of_the_year"),
"date",
"day_of_the_year"),
y = "output", color = "area")) +
geom_line(size = 1) +
# ylab('GWh/day') +
......