Commit c40e9691 authored by Matteo DE FELICE's avatar Matteo DE FELICE

Added the possibility to focus only on the middle yeaR

parent c5b8330f
...@@ -6,23 +6,39 @@ shinyServer(function(input, output, session) { ...@@ -6,23 +6,39 @@ shinyServer(function(input, output, session) {
choices = zones[-1]) choices = zones[-1])
}) })
output$main_plot <- renderPlot({ output$main_plot <- renderPlot({
res = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Reservoirs') %>% res = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Reservoirs') %>%
mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n())) mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n()))
hrgen = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Hydro power generation') %>% hrgen = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Hydro power generation') %>%
mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n())) mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n()))
gen = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Generation') %>% gen = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Generation') %>%
mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n())) mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n()))
wv = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Water value') %>% wv = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Water value') %>%
mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n())) mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n()))
pf = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Power flow') %>% pf = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Power flow') %>%
mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n())) mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n()))
# Load ENTSOE Data # Load ENTSOE Data
entsoe_storage = read_rds('data/ENTSOE-Storage-2015-2018.rds') entsoe_storage = read_rds('data/ENTSOE-Storage-2015-2018.rds')
# Load WAPP demand data # Load WAPP demand data
wapp_demand = bind_rows(read_csv('data/demand.csv'), wapp_demand = bind_rows(read_csv('data/demand.csv'),
read_csv('data/demand.csv'), 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())) mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n()))
if (input$middle_year) {
res = filter(res, year(date) == 2017)
hrgen = filter(hrgen, year(date) == 2017)
gen = filter(gen, year(date) == 2017)
wv = filter(wv, year(date) == 2017)
pf = filter(pf, year(date) == 2017)
wapp_demand = filter(wapp_demand, year(date) == 2017)
}
# Average water value --------------------------------------------------------------------- # Average water value ---------------------------------------------------------------------
if (input$plot_type == 'awv') { if (input$plot_type == 'awv') {
sel <- sel <-
...@@ -235,12 +251,12 @@ shinyServer(function(input, output, session) { ...@@ -235,12 +251,12 @@ shinyServer(function(input, output, session) {
res_normalised = res_zone %>% group_by(area) %>% mutate(max_level = max(level)) %>% ungroup() %>% mutate(norm_level = level / max_level) %>% select(date, day_of_the_year, area, norm_level) res_normalised = res_zone %>% group_by(area) %>% mutate(max_level = max(level)) %>% ungroup() %>% mutate(norm_level = level / max_level) %>% select(date, day_of_the_year, area, norm_level)
merged = inner_join( merged = inner_join(
inner_join(
inner_join( inner_join(
inner_join( inner_join(
inner_join(inflows, res_zone), gen_zone), inner_join(
spillage), inner_join(inflows, res_zone), gen_zone),
pumping), spillage),
pumping),
res_normalised) %>% res_normalised) %>%
mutate(filling_rate = (inflow * 60 * 60 * 24 / 1e6) / level) %>% mutate(filling_rate = (inflow * 60 * 60 * 24 / 1e6) / level) %>%
gather(variable, output, -date, -day_of_the_year, -area) gather(variable, output, -date, -day_of_the_year, -area)
...@@ -286,8 +302,10 @@ shinyServer(function(input, output, session) { ...@@ -286,8 +302,10 @@ shinyServer(function(input, output, session) {
select(-X__1) %>% select(-X__1) %>%
gather(line, flow, -date) %>% gather(line, flow, -date) %>%
group_by(line) %>% group_by(line) %>%
mutate(all_zero = all(flow == 0)) %>%
filter(!all_zero) %>%
mutate(smooth_flow = zoo::rollmean(flow, 7, fill = NA)) mutate(smooth_flow = zoo::rollmean(flow, 7, fill = NA))
date_label = this_pf %>% group_by(date) %>% summarise(v = var(flow)) %>% arrange(-v) %>% pull(date) date_label = this_pf %>% group_by(date) %>% summarise(v = var(smooth_flow, na.rm = TRUE)) %>% arrange(-v) %>% pull(date)
g = ggplot(this_pf, aes(x = date, y = smooth_flow, color = line)) + geom_line() + g = ggplot(this_pf, aes(x = date, y = smooth_flow, color = line)) + geom_line() +
ggrepel::geom_label_repel(data = filter(this_pf, date == date_label[1]), ggrepel::geom_label_repel(data = filter(this_pf, date == date_label[1]),
......
...@@ -30,6 +30,7 @@ shinyUI( fluidPage( ...@@ -30,6 +30,7 @@ shinyUI( fluidPage(
'generation stacked' = 'gen_stacked', 'generation stacked' = 'gen_stacked',
'generation yearly' = 'gen_year', 'generation yearly' = 'gen_year',
'power flows' = 'pf')), 'power flows' = 'pf')),
checkboxInput('middle_year', 'Show only middle period', value = TRUE),
conditionalPanel( conditionalPanel(
condition = "input.plot_type == 'gen_mix' || input.plot_type == 'res_single'", condition = "input.plot_type == 'gen_mix' || input.plot_type == 'res_single'",
uiOutput("zone_selection") uiOutput("zone_selection")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment