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

Implementation of single reservoirs comparison with ENTSO-E

parent 6d6a9c17
shinyServer(function(input, output, session) {
#
# # Combine the selected variables into a new data frame
# selectedData <- reactive({
#
# if (input$timescale == 'Yearly') {
# dd_m = dd_m %>% group_by(Date = year(Date), country, type) %>%
# dplyr::summarise(value = mean(value, na.rm = T))
# dd_m$Date = as.Date(as.yearmon(dd_m$Date))
# } else if (input$timescale == 'JFM') {
# dd_m = dd_m %>% dplyr::filter(month(Date) < 4) %>%
# group_by(Date = year(Date), country, type) %>%
# dplyr::summarise(value = mean(value, na.rm = T))
# dd_m$Date = as.Date(as.yearmon(dd_m$Date))
# } else if (input$timescale == 'JJA') {
# dd_m = dd_m %>% dplyr::filter(month(Date) >= 6 & month(Date) <= 8) %>%
# group_by(Date = year(Date), country, type) %>%
# dplyr::summarise(value = mean(value, na.rm = T))
# dd_m$Date = as.Date(as.yearmon(dd_m$Date))
# } else {
# dd_m$Date = as.Date(dd_m$Date)
# }
# if (input$norm) {
# dd_m = dd_m %>% group_by(country, type) %>%
# dplyr::mutate(value = (value - mean(value))/ sd(value))
# }
# dplyr::filter(dd_m, country %in% input$country,
# type %in% input$var, year(Date) %in% seq(input$years[1],
# input$years[2]))
#
# })
#
# selectedPCA <- reactive({
# if (input$PCvar == 't2m') {
# this_env = t2m_env
# } else {
# this_env = pp_env
# }
#
# if (input$timescale == 'Yearly') {
# selection = this_env$p_yrl
# timeindex = this_env$ti_yrl
# } else if (input$timescale == 'JFM') {
# selection = this_env$p_jfm
# timeindex = this_env$ti_jfm
# } else if (input$timescale == 'JJA') {
# selection = this_env$p_jja
# timeindex = this_env$ti_jja
# } else {
# selection = this_env$p_mon
# timeindex = this_env$ti_mon
# }
# selection$timeindex = timeindex
# selection
# })
#
output$zone_selection <- renderUI({
zones = readxl::read_xlsx(paste0('xls/', input$result_xls), sheet = 'LMP') %>%
names()
......@@ -70,6 +15,16 @@ shinyServer(function(input, output, session) {
mutate(date = seq(as_datetime('2016-01-01'), as_datetime('2016-12-31'), length.out = 366))
wv = readxl::read_xlsx(paste0('xls/', input$result_xls), sheet = 'Water value') %>%
mutate(date = seq(as_datetime('2016-01-01'), as_datetime('2016-12-31'), length.out = 366))
# Load ENTSOE Data
es_entsoe_2015_2017 <- read_excel("data/Copy of Water Reservoirs and Hydro Storage Plants_201412290000-201801010000.xlsx",
range = "A10:D61",
col_types = c("text", "numeric", "numeric",
"numeric"),
col_names = c('week','entsoe-2015', 'entsoe-2016', 'entsoe-2017')) %>%
mutate(date = seq(as_datetime('2016-01-01'), as_datetime('2016-12-31'), length.out = 52)) %>%
gather(variable, value, -week, -date) %>%
mutate(value = value / 1000) %>%
select(-week)
# Average water value ---------------------------------------------------------------------
if (input$plot_type == 'awv') {
sel <-
......@@ -139,8 +94,22 @@ shinyServer(function(input, output, session) {
print(g)
}
# Reservoir levels all ------------------------------------------------------------------
else if (input$plot_type == 'res_all') {
# Reservoir levels single ------------------------------------------------------------------
else if (input$plot_type == 'res_single') {
browser()
res_zone = select(res, date, contains(paste0(input$zone, '_')))
res_data = res %>% gather(zone, reservoir, -date, -X__1) %>%
select(-X__1)
g = ggplot(res_data, aes(x = date, y = reservoir, color = zone, group = zone)) +
geom_line(size = 0.5) +
scale_y_log10() +
ylab('GWh/day') +
theme(axis.text.x = element_text(size = 4, angle = 45, hjust = 1))
print(g)
# Reservoir levels all ------------------------------------------------------------------
} else if (input$plot_type == 'res_all') {
res_data = res %>% gather(zone, reservoir, -date, -X__1) %>%
select(-X__1)
......
library(shiny)
library(tidyverse)
library(readxl)
library(lubridate)
shinyUI( fluidPage(
......@@ -27,8 +28,6 @@ shinyUI( fluidPage(
numericInput("num_maxhwm", label = h3("Max shown value"), value = 1000)
)
),
......
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