Skip to content
Snippets Groups Projects
Commit 13ac6827 authored by Marianna Rottoli's avatar Marianna Rottoli
Browse files

Reporting: vintages plot for EU does not repeat historical values. Name of...

Reporting: vintages plot for EU  does not repeat historical values. Name of output folder without special characters. Saved info of run names in output folder.
parent 5e4962f5
No related branches found
No related tags found
1 merge request!194Updates to EDGE-Transport
......@@ -484,11 +484,15 @@ for (outputdir in outputdirs) {
emipSource_all = rbind(emipSource_all, emipSource)
}
outdir = paste0("output/comparerunEDGE", gsub(" | ^([[:alpha:]]*).*","", Sys.time()))
## create string with date and time
time = gsub(":",".",gsub(" ","_",Sys.time()))
## create output folder
outdir = paste0("output/comparerunEDGE", time)
dir.create(outdir)
## names of the output files
md_template = "EDGETransportComparison.Rmd"
dash_template = "EDGEdashboard.Rmd"
## save RDS files
saveRDS(EJmode_all, paste0(outdir, "/EJmode_all.RDS"))
saveRDS(salescomp_all, paste0(outdir, "/salescomp_all.RDS"))
saveRDS(fleet_all, paste0(outdir, "/fleet_all.RDS"))
......@@ -503,6 +507,10 @@ saveRDS(emipSource_all, paste0(outdir, "/emipSource_all.RDS"))
file.copy(file.path("./scripts/output/comparison/notebook_templates", md_template), outdir)
rmarkdown::render(path(outdir, md_template), output_format="pdf_document")
## create a txt file containing the run names
write.table(outputdirs, paste0(outdir, "/run_names.txt"), append = FALSE, sep = " ", quote = FALSE,
row.names = FALSE, col.names = FALSE)
## if it's a 5 scenarios comparison across ConvCase, SynSurge, ElecEra, and HydrHype (with an extra baseline for ConvCase and 4 budgets Budg1100). run the dashboard
if (length(outputdirs) == 5 &
isTRUE(any(grepl("Budg1100_SynSurge", outputdirs))) &
......
......@@ -19,6 +19,7 @@ require(quitte)
library(lucode)
library(magpie)
library(quitte)
library(cowplot)
```
```{r, echo=FALSE, message=FALSE, warning=FALSE}
......@@ -460,16 +461,32 @@ emidem_pf(emidem_all)
```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width=14, fig.height=12}
vintcomparison_regi_pf = function(dt, rp){
dt = dt[year %in% c(2015, 2030, 2050, 2100) & region == rp]
plot = ggplot()+
geom_bar(data = dt,
aes(x=scenario, y=value, group=interaction(variable, technology),
fill = technology, width=.75), alpha = 0.5, position="stack", stat = "identity", width = 0.5)+
geom_bar(data = dt,
dt = dt[year %in% c(2020, 2030, 2050) & region == rp]
p1 = ggplot()+
geom_bar(data = dt[year == 2020 & scenario == unique(dt$scenario)[1]][, scenario := "Historical"],
aes(x=scenario, y=value, group= technology,
fill = technology, width=.75), position="stack", stat = "identity", width = 0.5)+
theme_minimal()+
ylim(0,500)+
facet_wrap(~ year, nrow = 1)+
theme(axis.text.x = element_text(angle = 90, size=14, vjust=0.5, hjust=1),
axis.text.y = element_text(size=14),
axis.title.y = element_text(size=14),
title = element_text(size=14),
axis.line = element_line(size = 0.5, colour = "grey"),
legend.text = element_text(size=14),
strip.text = element_text(size=14),
strip.background = element_rect(color = "grey"),
legend.position = "none")+
scale_fill_manual(values = cols)+
labs(y = "[million Veh]", x="")
p2 = ggplot()+
geom_bar(data = dt[year != 2020],
aes(x=scenario, y=value, group=interaction(variable, technology),
fill = technology, alpha = factor(alphaval), width=.75), position="stack", stat = "identity", width = 0.5, color = "black", size=0.05)+
guides(fill = guide_legend(reverse=TRUE))+
fill = technology, width=.75), position="stack", stat = "identity", width = 0.5)+
theme_minimal()+
ylim(0,500)+
facet_wrap(~ year, nrow = 1)+
theme(axis.text.x = element_text(angle = 90, size=14, vjust=0.5, hjust=1),
axis.text.y = element_text(size=14),
......@@ -479,12 +496,13 @@ vintcomparison_regi_pf = function(dt, rp){
legend.text = element_text(size=14),
strip.text = element_text(size=14),
strip.background = element_rect(color = "grey"))+
scale_alpha_discrete(breaks = c(1,0), name = "Status", labels = c("Vintages","New additions")) +
guides(linetype=FALSE,
fill=guide_legend(reverse=FALSE, title="Transport mode"))+
guides(fill=guide_legend(title="Transport mode"))+
scale_fill_manual(values = cols)+
labs(y = "[million Veh]", x="", title = "LDV fleet")
return(plot)
labs(y = "", x="")
plot = plot_grid(p1, p2, align = "h", ncol = 2, rel_widths = c(0.15,0.85))
return(plot)
}
p = vintcomparison_regi_pf(fleet_all, rp = regionplot)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment