Commit 7586a002 authored by Matteo DE FELICE's avatar Matteo DE FELICE

Now we show exactly each single reservoir

parent 1f046c2c
shinyServer(function(input, output, session) {
output$zone_selection <- renderUI({
zones = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'LMP') %>%
names()
names() %>% str_sort()
selectInput('zone', 'Choose the zone:',
choices = zones[-1])
})
output$hpp_selection <- renderUI({
zones = hrgen = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Hydro power generation') %>%
names() %>% str_sort()
selectInput('hpp', 'Choose the hydro-power plant:',
choices = hrgen[-1])
})
output$main_plot <- renderPlot({
res = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Reservoirs') %>%
......@@ -220,63 +226,52 @@ shinyServer(function(input, output, session) {
else if (input$plot_type == 'res_single') {
inflows = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Inflows') %>%
select(contains(paste0(input$zone, '_HPHS')),
contains(paste0(input$zone, '_HDAM'))) %>%
select(contains(input$hpp)) %>%
mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n())) %>%
mutate(day_of_the_year = yday(date)) %>%
gather(area, inflow, -date, -day_of_the_year)
spillage = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Spillage') %>%
select(contains(paste0(input$zone, '_HPHS')),
contains(paste0(input$zone, '_HDAM'))) %>%
select(contains(input$hpp)) %>%
mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n())) %>%
mutate(day_of_the_year = yday(date)) %>%
gather(area, spillage, -date, -day_of_the_year)
discharge = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Water discharge') %>%
select(contains(paste0(input$zone, '_HPHS')),
contains(paste0(input$zone, '_HDAM'))) %>%
select(contains(input$hpp)) %>%
mutate(date = seq(as_datetime('2016-01-01'), by = 'day', length.out = n())) %>%
mutate(day_of_the_year = yday(date)) %>%
gather(area, discharge, -date, -day_of_the_year)
pumping = readxl::read_xlsx(paste0('', input$result_xls), sheet = 'Pumping') %>%
select(contains(paste0(input$zone, '_HPHS')),
contains(paste0(input$zone, '_HDAM'))) %>%
select(contains(input$hpp)) %>%
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'))) %>%
res_zone = select(res, date, contains(input$hpp)) %>%
mutate(day_of_the_year = yday(date)) %>%
gather(area, level, -date, -day_of_the_year)
gen_zone = select(gen, date, contains(paste0(input$zone, '_HPHS')),
contains(paste0(input$zone, '_HDAM'))) %>%
gen_zone = select(gen, date, contains(input$hpp)) %>%
mutate(day_of_the_year = yday(date)) %>%
gather(area, generation, -date, -day_of_the_year)
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(
inner_join(
inner_join(
inner_join(
inner_join(
inner_join(inflows, res_zone), gen_zone),
spillage),
pumping),
discharge),
res_normalised) %>%
inner_join(inflows, res_zone), gen_zone),
spillage),
pumping),
discharge) %>%
# mutate(filling_rate = (inflow * 60 * 60 * 24 / 1e6) / level) %>%
mutate(diff_level = c(NA, diff(level))) %>%
mutate(outflow = discharge + spillage) %>%
gather(variable, output, -date, -day_of_the_year, -area)
if (length(unique(res_zone$area) < 2)) {
merged = merged %>% filter(variable != 'norm_level')
}
if (all(is.na(merged %>% filter(variable == 'pumping') %>% pull(output)))) {
merged = merged %>% filter(variable != 'pumping')
}
......
......@@ -36,13 +36,17 @@ shinyUI( fluidPage(
'power flows' = 'pf')),
checkboxInput('middle_year', 'Show only middle period', value = FALSE),
conditionalPanel(
condition = "input.plot_type == 'gen_mix' || input.plot_type == 'res_single'",
condition = "input.plot_type == 'gen_mix'",
uiOutput("zone_selection")
),
conditionalPanel(
condition = "input.plot_type == 'awv'",
checkboxInput("check_logscale", label = "Log10 y-axis", value = TRUE),
numericInput("num_maxhwm", label = h3("Max shown value"), value = 1000)
),
conditionalPanel(
condition = "input.plot_type == 'res_single'",
uiOutput("hpp_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