From 4415c63d2d50c353e8241eb46caea8e353086f01 Mon Sep 17 00:00:00 2001 From: Marianna Rottoli <marianna.rottoli@mail.polimi.it> Date: Wed, 20 May 2020 18:05:44 +0200 Subject: [PATCH] Reporting improvemente: dashboard new plots, loadFactor is loaded, emissions. --- scripts/output/comparison/EDGEcomparison.R | 196 +++++++++++-- .../EDGETransportComparison.Rmd | 235 ++++++++++++++- .../notebook_templates/EDGEdashboard.Rmd | 247 ++++++++-------- .../notebook_templates/helper_dashboard.R | 272 ++++++++++++++++-- .../EDGETransportReport.Rmd | 10 +- 5 files changed, 787 insertions(+), 173 deletions(-) diff --git a/scripts/output/comparison/EDGEcomparison.R b/scripts/output/comparison/EDGEcomparison.R index 7ec13ed..e0361a1 100644 --- a/scripts/output/comparison/EDGEcomparison.R +++ b/scripts/output/comparison/EDGEcomparison.R @@ -12,6 +12,8 @@ require(data.table) require(rmndt) require(moinput) require(edgeTrpLib) +require(gdx) +require(gdxdt) setConfig(forcecache = TRUE) if(!exists("source_include")) { @@ -43,7 +45,8 @@ CO2km_int_newsales_all = NULL emidem_all = NULL EJfuelsPass_all = NULL EJfuelsFrgt_all = NULL -emidemPass_all = NULL +emipdem_all = NULL +emipUp_all = NULL scenNames <- getScenNames(outputdirs) EDGEdata_path <- path(outputdirs, paste("EDGE-T/")) @@ -58,7 +61,7 @@ REMIND2ISO_MAPPING <- fread("config/regionmappingH12.csv")[, .(iso = CountryCode SalesFun = function(shares_LDV, newcomp, sharesVS1){ - ## I need the total demand for each region to get the average composition in Europe (sales are on a country level) + ## I need the total demand for each region to get the average composition in the region (sales are on a country level) ## First I calculate the total demand for new sales using the shares on FV level (in newcomp) and on VS1 level newcomp = merge(newcomp, sharesVS1[,.(shareVS1 = share, iso, year, vehicle_type, subsector_L1)], all.x=TRUE, by = c("iso", "year", "vehicle_type", "subsector_L1")) newcomp[, newdem := totdem*sharetech_new*shareVS1] @@ -90,7 +93,7 @@ SalesFun = function(shares_LDV, newcomp, sharesVS1){ } -fleetFun = function(vintcomp, newcomp, sharesVS1){ +fleetFun = function(vintcomp, newcomp, sharesVS1, loadFactor){ vintcomp = vintcomp[,.(totdem, iso, subsector_L1, year, technology,vehicle_type, sector, sharetech_vint)] newcomp = newcomp[,.(iso, subsector_L1, year, technology,vehicle_type, sector, sharetech_new)] @@ -102,9 +105,9 @@ fleetFun = function(vintcomp, newcomp, sharesVS1){ "year"), measure.vars = c("vintdem", "newdem")) allfleet[,alpha:=ifelse(variable == "vintdem", 0, 1)] - load_factor = 1.5 + allfleet = merge(allfleet, loadFactor, all.x = TRUE, by = c("iso", "vehicle_type", "year")) annual_mileage = 15000 - allfleet = allfleet[,.(value = sum(value/load_factor/annual_mileage)), by = c("iso", "technology", "variable", "year")] + allfleet = allfleet[,.(value = sum(value/loadFactor/annual_mileage)), by = c("iso", "technology", "variable", "year")] allfleet = merge(allfleet, REMIND2ISO_MAPPING, by = "iso") allfleet = allfleet[,.(value = sum(value)), by = c("region", "technology", "variable", "year")] @@ -165,8 +168,8 @@ EJmodeFun = function(demandEJ){ ESmodeFun = function(demandkm, POP){ ## REMIND-EDGE results demandkm <- demandkm[,c("sector","subsector_L3","subsector_L2", - "subsector_L1","vehicle_type","technology", "iso","year","demand_F")] - + "subsector_L1","vehicle_type","technology", "iso","year","demand_F")] + ## attribute aggregated mode and vehicle names for plotting purposes, and aggregate demandkm[, aggr_mode := ifelse(subsector_L1 %in% c("Three-Wheeler", "trn_pass_road_LDV_4W"), "LDV", NA)] demandkm[, aggr_mode := ifelse(sector %in% c("trn_freight", "trn_shipping_intl"), "Freight", aggr_mode)] @@ -191,9 +194,9 @@ ESmodeFun = function(demandkm, POP){ demandkm[, vehicle_type_plot := factor(vehicle_type, levels = c("LDV","Freight Rail", "Truck", "Domestic Ship", "International Ship", - "Motorbikes", "Small Cars", "Large Cars", "Van", - "Domestic Aviation", "International Aviation","Bus", "Passenger Rail", - "Freight", "Non motorized", "Shipping"))] + "Motorbikes", "Small Cars", "Large Cars", "Van", + "Domestic Aviation", "International Aviation","Bus", "Passenger Rail", + "Freight", "Non motorized", "Shipping"))] ## attribute aggregate mode (passenger, freight) demandkm[, mode := ifelse(vehicle_type %in% c("Freight", "Freight Rail", "Truck", "Shipping") ,"freight", "pass")] @@ -224,7 +227,7 @@ ESmodeFun = function(demandkm, POP){ } FEliq_sourceFun = function(FEliq_source, gdp){ - ## Attribute oil and biodiesel (TODO Coal2Liquids is accounted for as Oil! + ## Attribute oil and biodiesel (TODO Coal2Liquids is accounted for as Oil! FEliq_source[, technology := ifelse(variable %in% c("FE|Transport|Liquids|Oil", "FE|Transport|Liquids|Coal"), "Oil", NA)] FEliq_source[, technology := ifelse(variable %in% c("FE|Transport|Liquids|Biomass"), "Biodiesel", technology)] FEliq_source[, technology := ifelse(variable %in% c("FE|Transport|Liquids|Hydrogen"), "Synfuel", technology)] @@ -233,15 +236,16 @@ FEliq_sourceFun = function(FEliq_source, gdp){ FEliq_sourceR = FEliq_source[][, shareliq := value/sum(value),by=c("region", "year")] ## to ISO level FEliq_sourceISO <- disaggregate_dt(FEliq_source, REMIND2ISO_MAPPING, - valuecol="value", - datacols=c("model","scenario", "unit","technology"), - weights=gdp) + valuecol="value", + datacols=c("model","scenario", "unit","technology"), + weights=gdp) ## calculate share FEliq_sourceISO[, shareliq := value/sum(value),by=c("iso", "year")] - + return(list(FEliq_sourceISO = FEliq_sourceISO, FEliq_sourceR = FEliq_sourceR)) } + CO2km_int_newsales_Fun = function(shares_LDV, mj_km_data, sharesVS1, FEliq_source, gdp){ ## energy intensity https://en.wikipedia.org/wiki/Energy_density # emi_petrol = 45 ## MJ/gFUEL @@ -331,19 +335,139 @@ emidemFun = function(emidem){ emidemPassFun = function(emidemPass){ emidemPass = emidemPass[region!="World" & year >= 2015 & year <= 2100] emidemPass[, variable := as.character(variable)] + emidemPass[, c("model", "scenario", "variable", "unit") := NULL] + setnames(emidemPass, old = "value", new = "emi_sum") + emidemPass[, type := "Demand"] return(emidemPass) } +emipUpFun = function(prodSe, prodFe, vemi, pemi, pass_sm_el_emi){ + prodSe <- readgdx(gdx, "vm_prodSe")[ + tall >= minyr & tall <= maxyr] + prodFe <- readgdx(gdx, "vm_prodFe")[ + ttot >= minyr & ttot <= maxyr] + + prodFefos <- prodFe[all_te %in% c("tdfosdie", "tdfospet")] + TWa_2_EJ <- 31.536 + GtC_2_MtCO2 <- 44 / 12 * 1000 + + prodSe[, value := value*TWa_2_EJ] + prodFe[, value := value*TWa_2_EJ] + + setnames(prodFe, c("year", "region", "se", "fe", "te", "value")) + setnames(prodFefos, c("year", "region", "se", "fe", "te", "value")) + setnames(prodSe, c("year", "region", "pe", "se", "te", "value")) + + ## Fe + + prodFe <- prodFe[fe %in% c("fepet", "fedie")] + prodFe[, all_liq := sum(value), by=.(year, region)] + prodFe[, liq_val := sum(value), by=.(year, region, se)] + + prodFe[, c("fe", "te", "value") := NULL] + prodFe <- unique(prodFe) + + prodSyn <- prodSe[te == "MeOH"] + + prodSyn[, se := "synliq"] + prodSyn[, c("pe", "te") := NULL] + setnames(prodSyn, "value", "syn_val") + prodSyn <- rbind(prodSyn, + CJ(year=c(2020), region = unique(prodFe$region), se="synliq", syn_val=0)) + + + allLiq <- merge(prodSyn, prodFe, all=T) + allLiq[is.na(syn_val), syn_val := 0] + allLiq[, all_liq := max(all_liq, na.rm=T), by=.(year, region)] + allLiq[, syn_val := max(syn_val, na.rm=T), by=.(year, region)] + ## separate synthetic fuels + allLiq[se == "synliq", liq_val := syn_val] + allLiq[se == "seliqfos", liq_val := liq_val - syn_val] + + allLiq <- allLiq[ + data.table(se=c("seliqbio", "seliqfos", "synliq"), + lname=c("biofuels", "fossil fuels", "synfuels")), + on="se"] + + ## Electricity production - not really important but interesting + prodEl <- prodSe[se == "seel"] + + ## Electricity consumption for H2 production + prodEl[, allEl := sum(value), by=.(year, region)][ + , c("pe", "se", "te", "value") := NULL + ] + prodEl <- unique(prodEl) + + prodElH2 <- prodSe[pe == "seel" & se == "seh2"] + prodElH2[, elh2 := sum(value), by=.(year, region)] + prodElH2[, c("pe", "se", "te", "value") := NULL] + prodElH2 <- unique(prodElH2) + + prodShare <- merge(prodEl, prodElH2, all=T) + prodShare[, netProd := allEl - elh2] + prodVert <- melt(prodShare, id.vars = c("year", "region"))[ + data.table(variable=c("elh2", "netProd"), + label=c("Electricity for H2", "Other Demands")), + on="variable" + ] + + setnames(vemi, c("year", "region", "pe", "se", "te", "emi", "val")) + emico2 <- vemi[se == "seel" & emi == "co2"][ + , co2val := sum(val) * GtC_2_MtCO2, by=.(year, region)][ + , c("pe", "se", "te", "emi", "val") := NULL + ] + emico2 <- unique(emico2) + + emico2 <- merge(emico2, prodShare, by=c("year", "region")) + emico2[, int := co2val/allEl] # MtCO2/EJ -> tCO2/MJ + ## emissions from electricity for hydrogen production + emisyn <- emico2[, .(se="seh2", co2 = int * elh2), by=.(year, region)] # MtCO2 + + ## synfuel share + syn_fos <- allLiq[se != "seliqbio"][ + , .(syn_share = syn_val/sum(liq_val)), by=.(year, region)] + syn_fos <- unique(syn_fos) + + ## final energy from prodFefos + setnames(prodFefos, c("year", "region", "se", "fe", "te", "prodFE")) + prodFefos <- prodFefos[syn_fos, on=.(year, region)] + ## substract synfuels + prodFefos[, no_syn := prodFE * (1-syn_share)] + + + setnames(pemi, c("fe", "emi_fac")) + + prodFefos <- pemi[prodFefos, on="fe"] + prodFefos[, co2 := emi_fac * no_syn * TWa_2_EJ] + + + ## add synthetic fuel/ upstream emissions + emi_all <- merge(emisyn, prodFefos[, .(year, region, se=fe, co2)], by=c("year", "region", "se", "co2"), all=T) + + ## add emissions from electricity + pass_sm_el_emi[, c("model", "scenario", "variable", "unit") := NULL] + pass_sm_el_emi[, se := "electricity"] + pass_sm_el_emi = pass_sm_el_emi[year %in% unique(emi_all$year)] + setnames(pass_sm_el_emi, c("region", "co2", "year", "se")) + emi_all = rbind(emi_all, pass_sm_el_emi) + emi_all = emi_all[, .(emi_upstr = sum(co2)), by=.(year, region)] + emi_all[, type := "Upstream"] + return(emi_all) +} + for (outputdir in outputdirs) { ## load mif file name_mif = list.files(path = outputdir, pattern = "REMIND_generic", full.names = F) name_mif = name_mif[!grepl("withoutPlu", name_mif)] miffile <- as.data.table(read.quitte(paste0(outputdir, "/", name_mif))) - miffile[, region:=as.character(region)] + miffile[, region := as.character(region)] miffile[, year := period] - miffile[, period:=NULL] + miffile[, period := NULL] miffile = miffile[region != "World"] + ## load gdx file + gdx = paste0(outputdir, "/fulldata.gdx") + ## load RDS files sharesVS1 = readRDS(paste0(outputdir, "/EDGE-T/", "shares.RDS"))[["VS1_shares"]] newcomp = readRDS(paste0(outputdir, "/EDGE-T/", "newcomp.RDS")) @@ -352,25 +476,34 @@ for (outputdir in outputdirs) { demandEJ = readRDS(paste0(outputdir, "/EDGE-T/", "demandF_plot_EJ.RDS")) demandkm = readRDS(paste0(outputdir, "/EDGE-T/", "demandF_plot_pkm.RDS")) mj_km_data = readRDS(paste0(outputdir, "/EDGE-T/", "mj_km_data.RDS")) - + loadFactor = readRDS(paste0(outputdir, "/EDGE-T/", "loadFactor.RDS")) + + ## load data from gdx file + minyr <- 2020 + maxyr <- 2100 + prodSe <- readgdx(gdx, "vm_prodSe")[tall >= minyr & tall <= maxyr] + prodFe <- readgdx(gdx, "vm_prodFe")[ttot >= minyr & ttot <= maxyr] + vemi <- readgdx(gdx, "vm_emiTeDetail")[ttot >= minyr & ttot <= maxyr] + pemi <- readgdx(gdx, "p_ef_dem") ## emission factors ## load population and GDP POP_country=calcOutput("Population", aggregate = F)[,, "pop_SSP2"] POP <- magpie2dt(POP_country, regioncol = "iso", - yearcol = "year", datacols = "POP") + yearcol = "year", datacols = "POP") gdp <- getRMNDGDP(scenario = "gdp_SSP2", usecache = T) ## select useful entries from mif file FEliq_source = miffile[variable %in% c("FE|Transport|Liquids|Biomass", "FE|Transport|Liquids|Hydrogen", "FE|Transport|Liquids|Coal", "FE|Transport|Liquids|Oil"),] emidem = miffile[variable %in% c("Emi|CO2|Transport|Demand"),] emidemPass = miffile[variable %in% c("Emi|CO2|Transport|Pass|Short-Medium Distance|Demand"),] + pass_sm_el_emi = miffile[variable %in% c("Emi|CO2|Transport|Pass|Short-Medium Distance|Electricity")] ## modify mif file entries to be used in the functions FEliq_source = FEliq_sourceFun(FEliq_source, gdp) - - + + ## calculate sales salescomp = SalesFun(shares_LDV, newcomp, sharesVS1) ## calculate fleet compositons - fleet = fleetFun(vintcomp, newcomp, sharesVS1) + fleet = fleetFun(vintcomp, newcomp, sharesVS1, loadFactor) ## calculate EJ from LDVs by technology EJroad = EJroadFun(demandEJ) ## calculate FE demand by mode @@ -388,7 +521,9 @@ for (outputdir in outputdirs) { ## calculate demand emissions emidem = emidemFun(emidem) ## calculate emissions from passenger demand SM - emidemPass = emidemPassFun(emidemPass) + emipdem = emidemPassFun(emidemPass) + ## calculate upstream emissions (accounting for synfuels, hydrogen and electricity production) + emipUp = emipUpFun(prodSe, prodFe, vemi, pemi, pass_sm_el_emi) ## add scenario dimension to the results fleet[, scenario := as.character(unique(miffile$scenario))] salescomp[, scenario := unique(miffile$scenario)] @@ -400,7 +535,8 @@ for (outputdir in outputdirs) { emidem[, scenario := as.character(unique(miffile$scenario))] EJfuelsPass[, scenario := as.character(unique(miffile$scenario))] EJfuelsFrgt[, scenario := as.character(unique(miffile$scenario))] - emidemPass[, scenario := as.character(unique(miffile$scenario))] + emipdem[, scenario := as.character(unique(miffile$scenario))] + emipUp[, scenario := as.character(unique(miffile$scenario))] ## rbind scenarios salescomp_all = rbind(salescomp_all, salescomp) fleet_all = rbind(fleet_all, fleet) @@ -412,7 +548,8 @@ for (outputdir in outputdirs) { emidem_all = rbind(emidem_all, emidem) EJfuelsPass_all = rbind(EJfuelsPass_all, EJfuelsPass) EJfuelsFrgt_all = rbind(EJfuelsFrgt_all, EJfuelsFrgt) - emidemPass_all = rbind(emidemPass_all, emidemPass) + emipdem_all = rbind(emipdem_all, emipdem) + emipUp_all = rbind(emipUp_all, emipUp) } outdir = paste0("output/comparerunEDGE", gsub(" | ^([[:alpha:]]*).*","", Sys.time())) @@ -430,7 +567,8 @@ saveRDS(CO2km_int_newsales_all, paste0(outdir, "/CO2km_int_newsales_all.RDS")) saveRDS(emidem_all, paste0(outdir, "/emidem_all.RDS")) saveRDS(EJfuelsPass_all, paste0(outdir, "/EJfuelsPass_all.RDS")) saveRDS(EJfuelsFrgt_all, paste0(outdir, "/EJfuelsFrgt_all.RDS")) -saveRDS(emidemPass_all, paste0(outdir, "/emidemPass_all.RDS")) +saveRDS(emipdem_all, paste0(outdir, "/emipdem_all.RDS")) +saveRDS(emipUp_all, paste0(outdir, "/emipUp_all.RDS")) file.copy(file.path("./scripts/output/comparison/notebook_templates", md_template), outdir) rmarkdown::render(path(outdir, md_template), output_format="pdf_document") @@ -441,8 +579,8 @@ if (length(outputdirs) == 5 & isTRUE(any(grepl("Budg1100_ElecEra", outputdirs))) & isTRUE(any(grepl("Budg1100_HydrHype", outputdirs))) & isTRUE(any(grepl("Base_ConvCase", outputdirs)))){ - file.copy(file.path("./scripts/output/comparison/notebook_templates/helper_dashboard.R"), outdir) - file.copy(file.path("./scripts/output/comparison/notebook_templates", dash_template), outdir) - rmarkdown::render(path(outdir, dash_template)) + file.copy(file.path("./scripts/output/comparison/notebook_templates/helper_dashboard.R"), outdir) + file.copy(file.path("./scripts/output/comparison/notebook_templates", dash_template), outdir) + rmarkdown::render(path(outdir, dash_template)) } diff --git a/scripts/output/comparison/notebook_templates/EDGETransportComparison.Rmd b/scripts/output/comparison/notebook_templates/EDGETransportComparison.Rmd index 2470681..cfb560b 100644 --- a/scripts/output/comparison/notebook_templates/EDGETransportComparison.Rmd +++ b/scripts/output/comparison/notebook_templates/EDGETransportComparison.Rmd @@ -117,7 +117,7 @@ legend_ord = c(legend_ord_modes, legend_ord_fuels, legend_ord_costs) - +regionplot = "EUR" ``` ```{r, echo=FALSE, message=FALSE, warning=FALSE} @@ -155,11 +155,10 @@ vintcomparisonpf = function(dt){ } vintcomparisonpf(fleet_all) -## Sales composition - ``` +## Sales composition ```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width=14, fig.height=12} salescompf = function(dt){ @@ -230,7 +229,7 @@ EJroadpf = function(dt){ strip.background = element_rect(color = "grey")) - plotTrucks = ggplot()+ + plotTruck = ggplot()+ geom_area(data = dt[subsector_L1 %in% c("trn_freight_road_tmp_subsector_L1")], aes(x=year, y=demand_EJ, group = technology, fill = technology), color = "black", size=0.05, position= position_stack())+ labs(x = "", y = "[EJ]", title = "Trucks Final Energy demand")+ theme_minimal()+ @@ -248,7 +247,7 @@ EJroadpf = function(dt){ strip.text = element_text(size = 14), strip.background = element_rect(color = "grey")) - return(plotlist = list(plotLDV = plotLDV, plotBus = plotBus, plotTrucks = plotTrucks)) + return(plotlist = list(plotLDV = plotLDV, plotBus = plotBus, plotTruck = plotTruck)) } EJroadpf(EJroad_all) @@ -452,3 +451,229 @@ emidem_pf = function(dt){ emidem_pf(emidem_all) ``` + + + +## Focus on slected region + +## vintages +```{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, + 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))+ + theme_minimal()+ + 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"))+ + 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"))+ + scale_fill_manual(values = cols)+ + labs(y = "[million Veh]", x="", title = "LDV fleet") + return(plot) +} + +p = vintcomparison_regi_pf(fleet_all, rp = regionplot) + +p + +aspect_ratio <- 1.5 +height <- 6 +ggsave("pvint.png", p, dpi=500, height = height , width = height * aspect_ratio) +``` + + +## Sales composition + +```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width=14, fig.height=12} +salescom_regi_pf = function(dt, rp){ + + plot = ggplot()+ + geom_area(data = dt[region == rp], aes(x=as.numeric(as.character(year)), y = shareFS1, group = technology, fill = technology), position = position_fill())+ + theme_minimal()+ + facet_wrap( ~ scenario, nrow = 1)+ + scale_fill_manual("Technology", values = cols)+ + expand_limits(y = c(0,1))+ + scale_x_continuous(breaks = c(2015,2030,2050, 2100))+ + scale_y_continuous(labels = scales::percent)+ + theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1, size = 14), + axis.text.y = element_text(size = 14), + axis.line = element_line(size = 0.5, colour = "grey"), + axis.title = element_text(size = 14), + title = element_text(size = 14), + legend.text = element_text(size = 14), + legend.title = element_text(size = 14), + strip.text = element_text(size = 14), + strip.background = element_rect(color = "grey"))+ + labs(x = "", y = "[%]", title = "Market share of new LDV sales") + return(plot) +} + +p = salescom_regi_pf(salescomp_all, rp = regionplot) + +p + +aspect_ratio <- 2 +height <- 5 +ggsave("psales.png", p, dpi=500, height = height , width = height * aspect_ratio) + + +``` + +```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width=14, fig.height=12} +CO2km_int_regi_newsalespf = function(dt, rp){ + dt = dt[!is.na(gCO2_km_ave)] + if (rp == "EUR"){ + ## add historical values + historical_values = data.table(year = c(2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018), emi = c(159, 157, 145, 140, 137, 132, 128, 124, 120, 119, 119, 120)) + + targets = data.table(name = c("2021 target", "2025 target", "2030 target"), value = c(95, 95*(1-0.15), 95*(1-0.37))) + + plot = ggplot()+ + geom_line(data = dt[year >= 2020 & region == rp], aes(x = year, y = gCO2_km_ave, group = scenario, color = scenario))+ + geom_point(data = historical_values, aes(x = year, y = emi), color = "grey20")+ + geom_hline(data = targets, aes(yintercept = value, linetype = name), color = "grey20", size=0.1)+ + geom_text(data = targets, aes(y = value+5, x = c(2025, 2030, 2035), label = name), size = 5)+ + labs(title = expression(paste(CO["2"], " intensity of LDVs new additions")), y = expression(paste("[", gCO["2"], "/km]")), x = "")+ + expand_limits(y = c(0,1))+ + scale_x_continuous(breaks = c(2020, 2030, 2050, 2100))+ + theme_minimal()+ + theme(axis.text.x = element_text(angle = 90, size = 14, vjust=0.5, hjust=1), + axis.text.y = element_text(size = 14), + axis.title = element_text(size = 14), + title = element_text(size = 14), + legend.text = element_text(size = 14), + legend.title = element_text(size = 14), + strip.text = element_text(size = 14), + strip.background = element_rect(color = "grey"), + axis.line = element_line(size = 0.5, colour = "grey"))+ + guides(linetype = FALSE) + + } else { + ## historical values are not available + plot = ggplot()+ + geom_line(data = dt[year >= 2020 & region == rp], aes(x = year, y = gCO2_km_ave, group = scenario, color = scenario))+ + labs(title = expression(paste(CO["2"], " intensity of LDVs new additions")), y = expression(paste("[", gCO["2"], "/km]")), x = "")+ + expand_limits(y = c(0,1))+ + scale_x_continuous(breaks = c(2020, 2030, 2050, 2100))+ + theme_minimal()+ + theme(axis.text.x = element_text(angle = 90, size = 14, vjust=0.5, hjust=1), + axis.text.y = element_text(size = 14), + axis.title = element_text(size = 14), + title = element_text(size = 14), + legend.text = element_text(size = 14), + legend.title = element_text(size = 14), + strip.text = element_text(size = 14), + strip.background = element_rect(color = "grey"), + axis.line = element_line(size = 0.5, colour = "grey"))+ + guides(linetype = FALSE) + + } + return(plot) +} + +p = CO2km_int_regi_newsalespf(CO2km_int_newsales_all, rp = regionplot) + +p + +aspect_ratio <- 1.5 +height <- 6 +ggsave("pCO2int.png", p, dpi=500, height = height , width = height * aspect_ratio) +``` + +```{r, echo=FALSE, message=FALSE, warning=FALSE, fig.width=14, fig.height=12} +EJroad_regi_pf = function(dt, rp){ + dt[, technology := factor(technology, levels = legend_ord)] + dt = dt[year >= 2020] + plotLDV = ggplot()+ + geom_area(data = dt[subsector_L1 == "trn_pass_road_LDV_4W" & region == rp], aes(x=year, y=demand_EJ, group = technology, fill = technology), color = "black", size=0.05, position= position_stack())+ + labs(x = "", y = "[EJ]", title = "LDV Final Energy demand")+ + theme_minimal()+ + facet_wrap(~scenario, nrow = 1)+ + scale_fill_manual("Technology", values = cols, breaks=legend_ord)+ + expand_limits(y = c(0,1))+ + scale_x_continuous(breaks = c(2020, 2030,2050, 2100))+ + theme(axis.text.x = element_text(angle = 90, size = 14, vjust=0.5, hjust=1), + axis.text.y = element_text(size = 14), + axis.title = element_text(size = 14), + axis.line = element_line(size = 0.5, colour = "grey"), + title = element_text(size = 14), + legend.text = element_text(size = 14), + legend.title = element_text(size = 14), + strip.text = element_text(size = 14), + strip.background = element_rect(color = "grey")) + + + plotBus = ggplot()+ + geom_area(data = dt[subsector_L1 %in% c("trn_pass_road_bus_tmp_subsector_L1", "Bus_tmp_subsector_L1") & region == rp], aes(x=year, y=demand_EJ, group = technology, fill = technology), color = "black", size=0.05, position= position_stack())+ + labs(x = "", y = "[EJ]", title = "Buses Final Energy demand")+ + theme_minimal()+ + facet_wrap(~scenario, nrow = 1)+ + scale_fill_manual("Technology", values = cols, breaks=legend_ord)+ + expand_limits(y = c(0,1))+ + scale_x_continuous(breaks = c(2020, 2030,2050, 2100))+ + theme(axis.text.x = element_text(angle = 90, size = 14, vjust=0.5, hjust=1), + axis.text.y = element_text(size = 14), + axis.title = element_text(size = 14), + axis.line = element_line(size = 0.5, colour = "grey"), + title = element_text(size = 14), + legend.text = element_text(size = 14), + legend.title = element_text(size = 14), + strip.text = element_text(size = 14), + strip.background = element_rect(color = "grey")) + + + plotTruck = ggplot()+ + geom_area(data = dt[subsector_L1 %in% c("trn_freight_road_tmp_subsector_L1") & region == rp], aes(x=year, y=demand_EJ, group = technology, fill = technology), color = "black", size=0.05, position= position_stack())+ + labs(x = "", y = "[EJ]", title = "Trucks Final Energy demand")+ + theme_minimal()+ + facet_wrap(~scenario, nrow = 1)+ + scale_fill_manual("Technology", values = cols, breaks=legend_ord)+ + expand_limits(y = c(0,1))+ + scale_x_continuous(breaks = c(2020, 2030,2050, 2100))+ + theme(axis.text.x = element_text(angle = 90, size = 14, vjust=0.5, hjust=1), + axis.text.y = element_text(size = 14), + axis.title = element_text(size = 14), + axis.line = element_line(size = 0.5, colour = "grey"), + title = element_text(size = 14), + legend.text = element_text(size = 14), + legend.title = element_text(size = 14), + strip.text = element_text(size = 14), + strip.background = element_rect(color = "grey")) + + return(plotlist = list(plotLDV = plotLDV, plotBus = plotBus, plotTruck = plotTruck)) +} + +plist = EJroad_regi_pf(EJroad_all, rp = regionplot) + +plist + +pLDV = plist[["plotLDV"]] + +pBus = plist[["plotBus"]] + +pTruck = plist[["plotTruck"]] + +aspect_ratio <- 1.5 +height <- 6 +ggsave("pLDV.png", pLDV, dpi=500, height = height , width = height * aspect_ratio) +ggsave("pBus.png", pBus, dpi=500, height = height , width = height * aspect_ratio) +ggsave("pTruck.png", pTruck, dpi=500, height = height , width = height * aspect_ratio) + +``` + + diff --git a/scripts/output/comparison/notebook_templates/EDGEdashboard.Rmd b/scripts/output/comparison/notebook_templates/EDGEdashboard.Rmd index 92ec8cb..d7a8233 100644 --- a/scripts/output/comparison/notebook_templates/EDGEdashboard.Rmd +++ b/scripts/output/comparison/notebook_templates/EDGEdashboard.Rmd @@ -38,8 +38,8 @@ legend=plotlist$legend #data frame with help tooltips helpTooltip_df <- data.frame( - title=c("Per capita Passenger Transport Energy Services Demand", "Total Passenger Transport Energy Services Demand", "Sales composition", "Final energy LDVs by fuel","Transport Passenger Final Energy Demand", "Fleet composition", "Fleet composition comparison", "Emission intensity, new sales comparison", "Comparison of passenger final energy demand", "Emissions passenger transport demand", "Emission intensity of new sales"), - placement=c("right", "left", "right", "left", "left", "left", "right", "left", "left", "left", "left")) + title=c("Per capita Passenger Transport Energy Services Demand", "Total Passenger Transport Energy Services Demand", "Sales composition", "Final energy LDVs by fuel","Transport Passenger Final Energy Demand", "Fleet composition", "Fleet composition comparison", "Emission intensity, new sales comparison", "Comparison of passenger final energy demand", "Emissions passenger transport", "Emission intensity of new sales", "Comparison of sales composition", "Comparison of passenger demand emissions", "Comparison of passenger upstream emissions"), + placement=c("right", "left", "right", "left", "left", "left", "right", "left", "right", "left", "left", "left", "left", "left")) helpTooltip = function(tooltipdf){ @@ -95,21 +95,21 @@ helpTooltip = function(tooltipdf){ <!--Creating First Page - LDV Page--> Overview {data-icon="glyphicon glyphicon-scale"} ===================================== -Side Navigation {.sidebar .sidebarOverview data-width=60} +Side Navigation {.sidebar .sidebarOverview data-width=160} ------------------------------------- -[](#overview){class="fas fa-thermometer-three-quarters sidebar-button selected"} -[](#overview-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"} -[](#overview-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"} -[](#overview-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"} -[](#overview-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"} +[Baseline](#overview){class="sidebar-button selected"} +[Conventional Case](#overview-conv-scenario){class="sidebar-button"} +[Hydrogen Hype](#overview-fcev-scenario){class="sidebar-button"} +[Electric Era](#overview-bev-scenario){class="sidebar-button"} +[Synfuel Surge](#overview-synfuel-scenario){class="sidebar-button"} Row {data-height=300} ----------------------------------------------------------------------- ### Transport scenario {data-width=100} ```{r} -valueBox("Conventional Case NoTax", icon = "fa-thermometer-three-quarters") +valueBox("Conventional Case NoTax") ``` @@ -148,23 +148,23 @@ Row {data-heigth=500} plotlist$`ConvCase NoTax`$plot$EJpassfuels ``` -### Emissions passenger transport demand +### Emissions passenger transport ```{r} -plotlist$`ConvCase NoTax`$plot$emipdem +plotlist$`ConvCase NoTax`$plot$emip ``` -Overview Conv scenario {.hidden data-icon="glyphicon glyphicon-tint"} -===================================== +Overview Conv scenario {.hidden} +===================================== -Side Navigation {.sidebar .sidebarOverview data-width=60} +Side Navigation {.sidebar .sidebarOverview data-width=160} ------------------------------------- -[](#overview){class="fas fa-thermometer-three-quarters sidebar-button"} -[](#overview-conv-scenario){class="glyphicon glyphicon-oil sidebar-button selected"} -[](#overview-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"} -[](#overview-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"} -[](#overview-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"} +[Baseline](#overview){class="sidebar-button"} +[Conventional Case](#overview-conv-scenario){class="sidebar-button selected"} +[Hydrogen Hype](#overview-fcev-scenario){class="sidebar-button"} +[Electric Era](#overview-bev-scenario){class="sidebar-button"} +[Synfuel Surge](#overview-synfuel-scenario){class="sidebar-button"} <!-- Dividing the page in two rows--> @@ -173,7 +173,7 @@ Row {data-height=300} ### Transport scenario {data-width=100} ```{r} -valueBox("Conventional Case", icon = "glyphicon-oil") +valueBox("Conventional Case") ``` @@ -185,7 +185,7 @@ valueBox(plotlist$ConvCase$emiscen, icon = "fa-cloud") ### Scenario description {data-width=200} -Absence of policies oriented to promote alternative vehicles. Internal combustion engines lead the market. +Absence of policies oriented to promote alternative vehicles. Internal combustion engines lead the market. More information can be found in the [Assumptions]. <!-- Dividing the page in two columns--> Row {data-heigth=500} @@ -211,24 +211,24 @@ Row {data-heigth=500} plotlist$ConvCase$plot$EJpassfuels ``` -### Emissions passenger transport demand +### Emissions passenger transport ```{r} -plotlist$ConvCase$plot$emipdem +plotlist$ConvCase$plot$emip ``` -Overview FCEV scenario {.hidden data-icon="glyphicon glyphicon-tint"} +Overview FCEV scenario {.hidden} ===================================== -Side Navigation {.sidebar .sidebarOverview data-width=60} +Side Navigation {.sidebar .sidebarOverview data-width=160} ------------------------------------- -[](#overview){class="fas fa-thermometer-three-quarters sidebar-button"} -[](#overview-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"} -[](#overview-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button selected"} -[](#overview-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"} -[](#overview-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"} +[Baseline](#overview){class="sidebar-button"} +[Conventional Case](#overview-conv-scenario){class="sidebar-button"} +[Hydrogen Hype](#overview-fcev-scenario){class="sidebar-button selected"} +[Electric Era](#overview-bev-scenario){class="sidebar-button"} +[Synfuel Surge](#overview-synfuel-scenario){class="sidebar-button"} <!-- Dividing the page in two rows--> @@ -237,7 +237,7 @@ Row {data-height=300} ### Transport scenario {data-width=100} ```{r} -valueBox("Hydrogen Hype", icon = "glyphicon-tint") +valueBox("Hydrogen Hype") ``` @@ -276,30 +276,30 @@ Row {data-heigth=500} plotlist$HydrHype$plot$EJpassfuels ``` -### Emissions passenger transport demand +### Emissions passenger transport ```{r} -plotlist$HydrHype$plot$emipdem +plotlist$HydrHype$plot$emip ``` -Overview BEV scenario { .hidden data-icon="glyphicon glyphicon-flash"} +Overview BEV scenario {.hidden} ===================================== -Side Navigation {.sidebar .sidebarOverview data-width=60} +Side Navigation {.sidebar .sidebarOverview data-width=160} ------------------------------------- -[](#overview){class="fas fa-thermometer-three-quarters sidebar-button"} -[](#overview-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"} -[](#overview-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"} -[](#overview-bev-scenario){class="glyphicon glyphicon-flash sidebar-button selected"} -[](#overview-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"} +[Baseline](#overview){class="sidebar-button"} +[Conventional Case](#overview-conv-scenario){class="sidebar-button"} +[Hydrogen Hype](#overview-fcev-scenario){class="sidebar-button"} +[Electric Era](#overview-bev-scenario){class="sidebar-button selected"} +[Synfuel Surge](#overview-synfuel-scenario){class="sidebar-button"} Row {data-height=300} ----------------------------------------------------------------------- ### Transport scenario {data-width=100} ```{r} -valueBox("Electric Era", icon = "glyphicon-flash") +valueBox("Electric Era") ``` @@ -339,30 +339,30 @@ Row {data-heigth=500} plotlist$ElecEra$plot$EJpassfuels ``` -### Emissions passenger transport demand +### Emissions passenger transport ```{r} -plotlist$ElecEra$plot$emipdem +plotlist$ElecEra$plot$emip ``` -Overview Synfuel scenario {.hidden data-icon="glyphicon glyphicon-random"} +Overview Synfuel scenario {.hidden} ===================================== -Side Navigation {.sidebar .sidebarOverview data-width=60} +Side Navigation {.sidebar .sidebarOverview data-width=160} ------------------------------------- -[](#overview){class="fas fa-thermometer-three-quarters sidebar-button"} -[](#overview-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"} -[](#overview-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"} -[](#overview-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"} -[](#overview-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button selected"} +[Baseline](#overview){class="sidebar-button"} +[Conventional Case](#overview-conv-scenario){class="sidebar-button"} +[Hydrogen Hype](#overview-fcev-scenario){class="sidebar-button"} +[Electric Era](#overview-bev-scenario){class="sidebar-button"} +[Synfuel Surge](#overview-synfuel-scenario){class="sidebar-button selected"} Row {data-height=300} ----------------------------------------------------------------------- ### Transport scenario {data-width=100} ```{r} -valueBox("Synfuel Surge", icon = "glyphicon-random") +valueBox("Synfuel Surge") ``` @@ -401,24 +401,23 @@ Row {data-heigth=500} plotlist$SynSurge$plot$EJpassfuels ``` -### Emissions passenger transport demand +### Emissions passenger transport ```{r} -plotlist$SynSurge$plot$emipdem +plotlist$SynSurge$plot$emip ``` - LDVs {data-icon="fa-car"} -===================================== +===================================== -Side Navigation {.sidebar .sidebarLDV data-width=60} +Side Navigation {.sidebar .sidebarLDV data-width=160} ------------------------------------- -[](#ldvs){class="fas fa-thermometer-three-quarters sidebar-button selected"} -[](#ldvs-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"} -[](#ldvs-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"} -[](#ldvs-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"} -[](#ldvs-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"} +[Baseline](#ldvs){class="sidebar-button selected"} +[Conventional Case](#ldvs-conv-scenario){class="sidebar-button"} +[Hydrogen Hype](#ldvs-fcev-scenario){class="sidebar-button"} +[Electric Era](#ldvs-bev-scenario){class="sidebar-button"} +[Synfuel Surge](#ldvs-synfuel-scenario){class="sidebar-button"} <!-- Dividing the page in two rows--> Row {data-height=300} @@ -426,7 +425,7 @@ Row {data-height=300} ### Transport scenario {data-width=100} ```{r} -valueBox("Conventional Case NoTax", icon = "fa-thermometer-three-quarters") +valueBox("Conventional Case NoTax") ``` @@ -472,17 +471,17 @@ plotlist$`ConvCase NoTax`$plot$EJLDV plotlist$`ConvCase NoTax`$plot$vintcomp ``` -LDVs Conv scenario { .hidden data-icon="glyphicon glyphicon-flash"} +LDVs Conv scenario {.hidden} ===================================== -Side Navigation {.sidebar .sidebarLDV data-width=60} +Side Navigation {.sidebar .sidebarLDV data-width=160} ------------------------------------- -[](#ldvs){class="fas fa-thermometer-three-quarters sidebar-button"} -[](#ldvs-conv-scenario){class="glyphicon glyphicon-oil sidebar-button selected"} -[](#ldvs-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"} -[](#ldvs-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"} -[](#ldvs-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"} +[Baseline](#ldvs){class="sidebar-button"} +[Conventional Case](#ldvs-conv-scenario){class="sidebar-button selected"} +[Hydrogen Hype](#ldvs-fcev-scenario){class="sidebar-button"} +[Electric Era](#ldvs-bev-scenario){class="sidebar-button"} +[Synfuel Surge](#ldvs-synfuel-scenario){class="sidebar-button"} <!-- Dividing the page in two rows--> @@ -491,7 +490,7 @@ Row {data-height=300} ### Transport scenario {data-width=100} ```{r} -valueBox("Conventional Case", icon = "glyphicon-oil") +valueBox("Conventional Case") ``` @@ -538,17 +537,18 @@ plotlist$ConvCase$plot$vintcomp ``` -LDVs FCEV scenario {.hidden data-icon="glyphicon glyphicon-tint"} +LDVs FCEV scenario {.hidden} ===================================== -Side Navigation {.sidebar .sidebarLDV data-width=60} +Side Navigation {.sidebar .sidebarLDV data-width=160} ------------------------------------- -[](#ldvs){class="fas fa-thermometer-three-quarters sidebar-button"} -[](#ldvs-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"} -[](#ldvs-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button selected"} -[](#ldvs-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"} -[](#ldvs-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"} +[Baseline](#ldvs){class="sidebar-button"} +[Conventional Case](#ldvs-conv-scenario){class="sidebar-button"} +[Hydrogen Hype](#ldvs-fcev-scenario){class="sidebar-button selected"} +[Electric Era](#ldvs-bev-scenario){class="sidebar-button"} +[Synfuel Surge](#ldvs-synfuel-scenario){class="sidebar-button"} + <!-- Dividing the page in two rows--> @@ -557,7 +557,7 @@ Row {data-height=300} ### Transport scenario {data-width=100} ```{r} -valueBox("Hydrogen Hype", icon = "glyphicon-tint") +valueBox("Hydrogen Hype") ``` @@ -605,18 +605,19 @@ plotlist$HydrHype$plot$vintcomp ``` -LDVs BEV scenario { .hidden data-icon="glyphicon glyphicon-flash"} +LDVs BEV scenario {.hidden} ===================================== -Side Navigation {.sidebar .sidebarLDV data-width=60} +Side Navigation {.sidebar .sidebarLDV data-width=160} ------------------------------------- -[](#ldvs){class="fas fa-thermometer-three-quarters sidebar-button"} -[](#ldvs-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"} -[](#ldvs-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"} -[](#ldvs-bev-scenario){class="glyphicon glyphicon-flash sidebar-button selected"} -[](#ldvs-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button"} +[Baseline](#ldvs){class="sidebar-button"} +[Conventional Case](#ldvs-conv-scenario){class="sidebar-button"} +[Hydrogen Hype](#ldvs-fcev-scenario){class="sidebar-button"} +[Electric Era](#ldvs-bev-scenario){class="sidebar-button selected"} +[Synfuel Surge](#ldvs-synfuel-scenario){class="sidebar-button"} + <!-- Dividing the page in two rows--> @@ -625,7 +626,7 @@ Row {data-height=300} ### Transport scenario {data-width=100} ```{r} -valueBox("Electric Era", icon = "glyphicon-flash") +valueBox("Electric Era") ``` @@ -637,7 +638,7 @@ valueBox(plotlist$ElecEra$emiscen, icon = "fa-cloud") ### Scenario description {data-width=200} -Electric vehicles gain an important share of the mix thanks to policies oriented at promoting them. +Electric vehicles gain an important share of the mix thanks to policies oriented at promoting them. More information can be found in the [Assumptions]. <!-- Dividing the page in two rows--> @@ -672,17 +673,18 @@ plotlist$ElecEra$plot$vintcomp ``` -LDVs Synfuel scenario {.hidden data-icon="glyphicon glyphicon-random"} +LDVs Synfuel scenario {.hidden} ===================================== -Side Navigation {.sidebar .sidebarLDV data-width=60} +Side Navigation {.sidebar .sidebarLDV data-width=160} ------------------------------------- -[](#ldvs){class="fas fa-thermometer-three-quarters sidebar-button"} -[](#ldvs-conv-scenario){class="glyphicon glyphicon-oil sidebar-button"} -[](#ldvs-fcev-scenario){class="glyphicon glyphicon-tint sidebar-button"} -[](#ldvs-bev-scenario){class="glyphicon glyphicon-flash sidebar-button"} -[](#ldvs-synfuel-scenario){class="glyphicon glyphicon-random sidebar-button selected"} +[Baseline](#ldvs){class="sidebar-button"} +[Conventional Case](#ldvs-conv-scenario){class="sidebar-button"} +[Hydrogen Hype](#ldvs-fcev-scenario){class="sidebar-button"} +[Electric Era](#ldvs-bev-scenario){class="sidebar-button"} +[Synfuel Surge](#ldvs-synfuel-scenario){class="sidebar-button selected"} + <!-- Dividing the page in two rows--> Row {data-height=300} @@ -690,7 +692,7 @@ Row {data-height=300} ### Transport scenario {data-width=100} ```{r} -valueBox("Synfuel Surge", icon = "glyphicon-random") +valueBox("Synfuel Surge") ``` @@ -740,7 +742,8 @@ plotlist$SynSurge$plot$vintcomp Comparison {data-icon="fa-exchange-alt"} ===================================== -Row {data-height=300} + +Row {data-height = 450} ----------------------------------------------------------------------- ### Fleet composition comparison @@ -753,12 +756,32 @@ plotlist$comparison$plot$vintscen plotlist$comparison$plot$CO2km_intensity_newsales_scen ``` +### Comparison of passenger demand emissions + +```{r} +plotlist$comparison$plot$emipdem_scen +``` + +Row {data-height = 450} +----------------------------------------------------------------------- + ### Comparison of passenger final energy demand ```{r} plotlist$comparison$plot$EJpassfuels_scen ``` -Assumptions {data-icon="fa-comment"} +### Comparison of sales composition +```{r} +plotlist$comparison$plot$salescom_scen +``` + +### Comparison of passenger upstream emissions +```{r} +plotlist$comparison$plot$emipup_scen +``` + + +Assumptions {data-icon="glyphicon glyphicon-th-list"} ===================================== Column {data-width= 450} @@ -768,11 +791,10 @@ Column {data-width= 450} <!--An overview of the passenger transport sector is provided in [Overview], while a detailed results about light duty vehicles projections are in [LDVs]. --> -Main scenario assumptions: - * Conventional consumers patterns * No policies to promote alternative vehicles -* Learning rate on BEVs and FCEVs +* Pessimistic trend of electric recharging stations +* Learning-by-doing on BEVs and FCEVs * Market-driven behavior of light duty vehicles powertrain choice @@ -780,28 +802,31 @@ Main scenario assumptions: * Conventional consumers patterns * No policies to promote alternative vehicles -* Learning rate on BEVs and FCEVs +* Pessimistic trend of electric recharging stations +* Learning-by-doing on BEVs and FCEVs * Market-driven behavior of light duty vehicles powertrain choice ### Hydrogen Hype {data-height=200} -* Learning rate on BEVs and FCEVs +* Learning-by-doing on BEVs and FCEVs * Optimistic trend of hydrogen refuelling stations -* Rebates-feebates scheme: FCEVs receive 5000\euro subsidies for purchases in 2020, around 3300\euro in 2025 and 1700\euro in 2030. 1000\euro mark-up cost on internal combustion engines are applied in 2020, 700\euro in 2025 and 300\euro in 2030 +* Rebates-feebates scheme: FCEVs receive 5000&euro subsidies for purchases in 2020, around 3300&euro in 2025 and 1700&euro in 2030. 1000&euro mark-up cost on internal combustion engines are applied in 2020, 700&euro in 2025 and 300&euro in 2030 +* Mark-up costs applied to internal combustion engines (both conventional and hybrid) * Market-driven behavior of light duty vehicles powertrain choice * Policy push of FCEVs: policy-driven decrease of the perceived inconvenience cost associated to the purchase of hydrogen vehicles * Hydrogen from renewable resources (green hydrogen) is at least 95\% of the total hydrogen ### Electric Era {data-height=200} -* Learning rate on BEVs and FCEVs -* Rebates-feebates scheme: FCEVs receive 5000\euro subsidies for purchases in 2020, around 3300\euro in 2025 and 1700\euro in 2030. 1000\euro mark-up cost on internal combustion engines are applied in 2020, 700\euro in 2025 and 300\euro in 2030 +* Learning-by-doing on BEVs and FCEVs +* Rebates-feebates scheme: BEVs receive 5000&euro subsidies for purchases in 2020, around 3300&euro in 2025 and 1700&euro in 2030. 1000&euro mark-up cost on internal combustion engines are applied in 2020, 700&euro in 2025 and 300&euro in 2030 +* Mark-up costs applied to internal combustion engines (both conventional and hybrid) * Market-driven behavior of light duty vehicles powertrain choice ### Synfuel Surge {data-height=200} * Conventional consumers patterns -* Learning rate on BEVs and FCEVs +* Learning-by-doing on BEVs and FCEVs * Market-driven behavior of light duty vehicles powertrain choice * Synfuels are forced in the liquids mix reaching 10\% of liquids fuels in transportation by 2035 * Hydrogen from renewable resources (green hydrogen) is at least 95% of the total hydrogen @@ -855,8 +880,8 @@ navBarMemory = function(topMenuLabel, sideBarClass){ .sidebar-button { /* sidebar size */ display: inline-block; - font-size: 40px; - height: 80px; + font-size: 20px; + height: 30px; padding-top: 20px } @@ -964,10 +989,6 @@ navBarMemory = function(topMenuLabel, sideBarClass){ -ms-user-select: none; user-select: none; } + </style> - - - - - diff --git a/scripts/output/comparison/notebook_templates/helper_dashboard.R b/scripts/output/comparison/notebook_templates/helper_dashboard.R index 28af747..8b83121 100644 --- a/scripts/output/comparison/notebook_templates/helper_dashboard.R +++ b/scripts/output/comparison/notebook_templates/helper_dashboard.R @@ -69,7 +69,10 @@ cols <- c("NG" = "#d11141", "ConvCase" = "#113245", "ConvCaseNoTax" = "#d11141", "ConvCaseWise" = "#d11141", - "SynSurge" = "orchid") + "SynSurge" = "orchid", + "Tailpipe" = "#113245", + "Tailpipe+Energy system" = "#f37735", + "Energy system" = "#6495ed") legend_ord_modes <- c("Freight Rail", "Truck", "Shipping", "International Shipping", "Domestic Shipping", "Trucks", "Motorbikes", "Small Cars", "Large Cars", "Van", @@ -93,7 +96,8 @@ ESmodecap_all = readRDS("ESmodecap_all.RDS") ESmodeabs_all = readRDS("ESmodeabs_all.RDS") CO2km_int_newsales_all = readRDS("CO2km_int_newsales_all.RDS") EJpass_all = readRDS("EJfuelsPass_all.RDS") -emipdem_all = readRDS("emidemPass_all.RDS") +emipdem_all = readRDS("emipdem_all.RDS") +emipUp_all = readRDS("emipUp_all.RDS") ## scenarios scens = unique(EJmode_all$scenario) @@ -147,8 +151,29 @@ vintscen_dash = function(dt){ dt[, scenario := gsub(".*_", "", scenario)] dt[, scenario := factor(scenario, levels = c("ConvCaseNoTax", "ConvCase", "HydrHype", "ElecEra", "SynSurge"))] dt[, details := paste0("Vehicles: ", round(value, 0), " [million]", "<br>", "Technology: ", technology, "<br>", "Region: ", region," <br>", "Year: ", year) ] - plot = ggplot()+ - geom_bar(data = dt, + g1 = ggplot()+ + geom_bar(data = dt[year %in% c(2030, 2050)], + aes(x = scenario, y = value, group = technology, text = details, fill = technology, width=.75), position="stack", stat = "identity", width = 0.5)+ + guides(fill = guide_legend(reverse=TRUE))+ + facet_wrap(~year, nrow = 1)+ + theme_minimal()+ + theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1, size = 8), + axis.text.y = element_blank(), + axis.line = element_line(size = 0.5, colour = "grey"), + axis.title = element_text(size = 8), + title = element_text(size = 8), + strip.text = element_text(size=8), + strip.background = element_rect(color = "grey"), + legend.position = "none")+ + 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"))+ + scale_fill_manual(values = cols)+ + ylim(0, 650)+ + labs(x = "", y = "") + + g2 = ggplot()+ + geom_bar(data = dt[year == 2015 & scenario == "ConvCase"][, scenario := "Historical"], aes(x = scenario, y = value, group = technology, text = details, fill = technology, width=.75), position="stack", stat = "identity", width = 0.5)+ guides(fill = guide_legend(reverse=TRUE))+ facet_wrap(~year, nrow = 1)+ @@ -169,7 +194,10 @@ vintscen_dash = function(dt){ labs(x = "", y = "") - plot = ggplotly(plot, tooltip = c("text")) %>% + plot = subplot(ggplotly(g2, tooltip = c("text")), ggplotly(g1, tooltip = c("text")), nrows = 1, widths = c(0.12,0.88)) + + + plot = ggplotly(plot) %>% config(modeBarButtonsToRemove=plotlyButtonsToHide, displaylogo=FALSE)%>% layout(yaxis=list(title='[million veh]', titlefont = list(size = 10))) @@ -186,8 +214,11 @@ salescomdash = function(dt, scen){ dt = dt[region == region_plot & scenario == scen & year <=2050] dt[, year := as.numeric(as.character(year))] dt[, details := paste0("Share: ", round(shareFS1*100, digits = 0), " %", "<br>", "Technology: ", technology, "<br>", "Region: ", region," <br>", "Year: ", year) ] + ## normalize shares so to have sum to 1 + dt[, shareFS1 := round(shareFS1*100, digits = 0)] + dt[, shareFS1 := shareFS1/sum(shareFS1), by = c("region", "year")] plot = ggplot()+ - geom_bar(data = dt, aes(x = year,y = round(shareFS1*100, digits = 0), group = technology, fill = technology, text = details), position = position_stack(), stat = "identity")+ + geom_bar(data = dt, aes(x = year,y = shareFS1, group = technology, fill = technology, text = details), position = position_stack(), stat = "identity")+ theme_minimal()+ scale_fill_manual("Technology", values = cols)+ expand_limits(y = c(0,1))+ @@ -342,13 +373,14 @@ EJpass_dash = function(dt, scen){ EJpass_scen_dash = function(dt){ dt[, scenario := ifelse(scenario == "Base_ConvCase", "ConvCaseNoTax", scenario)] + dt[, subtech := factor(subtech, levels = legend_ord)] dt = dt[region == region_plot & year %in% c(2015, 2030, 2050) & sector == "trn_pass"] dt[, details := paste0("Demand: ", round(demand_EJ, digits = 0), " [EJ]","<br>", "Technology: ", subtech, "<br>", "Region: ", region," <br>", "Year: ", year) ] dt[, scenario := gsub(".*_", "", scenario)] dt[, scenario := factor(scenario, levels = c("ConvCaseNoTax", "ConvCase", "HydrHype", "ElecEra", "SynSurge"))] - plot = ggplot()+ - geom_bar(data = dt, aes(x = scenario, y = demand_EJ, group = subtech, + g1 = ggplot()+ + geom_bar(data = dt[year %in% c(2030, 2050)], aes(x = scenario, y = demand_EJ, group = subtech, fill = subtech, text = details, width=.75), position="stack", stat = "identity", width = 0.5)+ @@ -358,6 +390,27 @@ EJpass_scen_dash = function(dt){ expand_limits(y = c(0,1))+ ylim(0, 25)+ labs(x = "", y = "")+ + theme(axis.text.x = element_text(angle = 90, size = 8, vjust=0.5, hjust=1), + axis.text.y = element_blank(), + axis.title = element_text(size = 8), + title = element_text(size = 8), + legend.position = "none", + strip.text = element_text(size = 8), + strip.background = element_rect(color = "grey"), + axis.line = element_line(size = 0.5, colour = "grey")) + + + g2 = ggplot()+ + geom_bar(data = dt[year == 2015 & scenario == "ConvCase"][, scenario := "Historical"], aes(x = scenario, y = demand_EJ, group = subtech, + fill = subtech, + text = details, width=.75), + position="stack", stat = "identity", width = 0.5)+ + facet_wrap(~year, nrow = 1)+ + theme_minimal()+ + scale_fill_manual("Technology",values = cols, breaks=legend_ord)+ + expand_limits(y = c(0,1))+ + ylim(0, 25)+ + labs(x = "", y = "")+ theme(axis.text.x = element_text(angle = 90, size = 8, vjust=0.5, hjust=1), axis.text.y = element_text(size = 8), axis.title = element_text(size = 8), @@ -367,7 +420,10 @@ EJpass_scen_dash = function(dt){ strip.background = element_rect(color = "grey"), axis.line = element_line(size = 0.5, colour = "grey")) - plot = ggplotly(plot, tooltip = c("text")) %>% + + plot = subplot(ggplotly(g2, tooltip = c("text")), ggplotly(g1, tooltip = c("text")), nrows = 1, widths = c(0.12,0.88)) + + plot = ggplotly(plot) %>% config(modeBarButtonsToRemove=plotlyButtonsToHide, displaylogo=FALSE) %>% layout(yaxis=list(title='[EJ]', titlefont = list(size = 10))) @@ -471,7 +527,7 @@ EJLDVdash <- function(dt, scen){ theme_minimal()+ scale_fill_manual("Technology", values = cols, breaks=legend_ord)+ expand_limits(y = c(0,1))+ - ylim(0, 13)+ + ylim(0, 16)+ scale_x_continuous(breaks = c(2015, 2030, 2050))+ theme(axis.text.x = element_text(angle = 90, size = 8, vjust=0.5, hjust=1), axis.text.y = element_text(size = 8), @@ -495,15 +551,33 @@ EJLDVdash <- function(dt, scen){ } -emipdem_dash = function(dt, scen){ - dt = dt[region == region_plot & scenario == scen & year <= 2050] +emip_dash = function(dt1, dt_upstr1, scen){ + dt = copy(dt1) + dt_upstr = copy(dt_upstr1) + setnames(dt, old = "emi_sum", new = "value") + setnames(dt_upstr, old = "emi_upstr", new = "value") + dt = rbind(dt, dt_upstr) + dt[, year:= as.numeric(year)] + dt = dt[region == region_plot & scenario == scen & year <= 2050 & year >= 2020] + dt = dcast(dt, region + year + scenario ~ type, value.var = "value") + + dt[, diff := Upstream - Demand] + dt = melt(dt, id.vars = c("region", "year", "scenario")) + setnames(dt, old = "variable", new = "type") + dt[type == "diff", type := "Energy system"] + dt[type == "Upstream", type := "Tailpipe+Energy system"] + dt[type == "Demand", type := "Tailpipe"] + + dt[, details := paste0("Emissions: ", round(value, digits = 0), " [MtCO<sub>2</sub>]", "<br>", "Type: ", type, "<br>", "Region: ", region," <br>", "Year: ", year) ] + plot = ggplot()+ - geom_line(data = dt, aes(x = year, y = value, text = ""))+ + geom_area(data = dt[year >= 2020 & type == "Tailpipe+Energy system"], aes(x = year, y = value, text = details, fill =type, group = type), alpha = 0.4, position = position_stack())+ + geom_line(data = dt[year >= 2020 & type != "Tailpipe+Energy system"], aes(x = year, y = value, text = details, group = type, color = type))+ labs(x = "", y = "")+ theme_minimal()+ expand_limits(y = c(0,1))+ - ylim(0,1250)+ + # ylim(0,1400)+ scale_x_continuous(breaks = c(2015, 2030, 2050))+ theme(axis.text.x = element_text(angle = 90, size = 8, vjust=0.5, hjust=1), axis.text.y = element_text(size = 8), @@ -512,16 +586,149 @@ emipdem_dash = function(dt, scen){ title = element_text(size = 8), legend.position = "none", strip.text = element_text(size=8), - strip.background = element_rect(color = "grey")) - + strip.background = element_rect(color = "grey"))+ + scale_color_manual(values = cols)+ + scale_fill_manual(values = cols) + plot = ggplotly(plot, tooltip = c("text")) %>% config(modeBarButtonsToRemove=plotlyButtonsToHide, displaylogo=FALSE) %>% layout(yaxis=list(title='[MtCO<sub>2</sub>]', titlefont = list(size = 10))) + vars = as.character(unique(dt$type)) + + return(plot) + +} + +emipcom_dash = function(dt1, dt_upstr1){ + dt = copy(dt1) + dt_upstr = copy(dt_upstr1) + setnames(dt, old = "emi_sum", new = "value") + setnames(dt_upstr, old = "emi_upstr", new = "value") + dt = rbind(dt, dt_upstr) + + dt = dt[region == region_plot & year <= 2050 & year >= 2020] + dt[, year := as.numeric(year)] + + dt[, scenario := ifelse(scenario == "Base_ConvCase", "ConvCaseNoTax", scenario)] + dt[, scenario := gsub(".*_", "", scenario)] + + dt[, details := scenario ] + + + + pdem = ggplot()+ + geom_line(data = dt[type == "Demand"], aes(x = year, y = value, text = details, group = scenario, color = scenario))+ + labs(x = "", y = "")+ + theme_minimal()+ + expand_limits(y = c(0,1))+ + ylim(0,1400)+ + scale_x_continuous(breaks = c(2015, 2030, 2050))+ + theme(axis.text.x = element_text(angle = 90, size = 8, vjust=0.5, hjust=1), + axis.text.y = element_text(size = 8), + axis.title = element_text(size = 8), + axis.line = element_line(size = 0.5, colour = "grey"), + title = element_text(size = 8), + legend.position = "none", + strip.text = element_text(size=8), + strip.background = element_rect(color = "grey"))+ + scale_color_manual(values = cols) + + pdem = ggplotly(pdem, tooltip = c("text")) %>% + config(modeBarButtonsToRemove=plotlyButtonsToHide, displaylogo=FALSE) %>% + layout(yaxis=list(title='[MtCO<sub>2</sub>]', titlefont = list(size = 10))) + + vars = as.character(unique(dt$scenario)) + + + pup = ggplot()+ + geom_line(data = dt[type == "Upstream"], aes(x = year, y = value, text = scenario, group = scenario, color = scenario))+ + labs(x = "", y = "")+ + theme_minimal()+ + expand_limits(y = c(0,1))+ + # ylim(0,1400)+ + scale_x_continuous(breaks = c(2015, 2030, 2050))+ + theme(axis.text.x = element_text(angle = 90, size = 8, vjust=0.5, hjust=1), + axis.text.y = element_text(size = 8), + axis.title = element_text(size = 8), + axis.line = element_line(size = 0.5, colour = "grey"), + title = element_text(size = 8), + legend.position = "none", + strip.text = element_text(size=8), + strip.background = element_rect(color = "grey"))+ + scale_color_manual(values = cols) + + pup = ggplotly(pup, tooltip = c("text")) %>% + config(modeBarButtonsToRemove=plotlyButtonsToHide, displaylogo=FALSE) %>% + layout(yaxis=list(title='[MtCO<sub>2</sub>]', titlefont = list(size = 10))) + + plot = list(pdem = pdem, pup = pup, vars = vars) + return(plot) } + +salescom_scen_dash = function(dt){ + dt[, scenario := as.character(scenario)] + dt[, scenario := ifelse(scenario == "Base_ConvCase", "ConvCaseNoTax", scenario)] + dt = dt[region == region_plot & year %in% c(2020, 2030, 2050)] + dt[, year := as.numeric(as.character(year))] + dt[, scenario := gsub(".*_", "", scenario)] + dt[, scenario := factor(scenario, levels = c("ConvCaseNoTax", "ConvCase", "HydrHype", "ElecEra", "SynSurge"))] + ## normalize shares so to have sum to 1 + dt[, shareFS1 := round(shareFS1*100, digits = 0)] + dt[, shareFS1 := shareFS1/sum(shareFS1), by = c("region", "year", "scenario")] + dt[, details := paste0("Share: ", round(shareFS1*100, 0), " %", "<br>", "Technology: ", technology, "<br>", "Region: ", region," <br>", "Year: ", year) ] + g1 = ggplot()+ + geom_bar(data = dt[year %in% c(2030, 2050)], aes(x = scenario,y = shareFS1, group = technology, fill = technology, text = details), position = position_stack(), stat = "identity")+ + theme_minimal()+ + scale_fill_manual("Technology", values = cols)+ + expand_limits(y = c(0,1))+ + facet_wrap(~year, nrow = 1)+ + theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1, size = 8), + axis.text.y = element_blank(), + axis.line = element_line(size = 0.5, colour = "grey"), + axis.title = element_text(size = 8), + title = element_text(size = 8), + strip.text = element_text(size=8), + strip.background = element_rect(color = "grey"), + legend.position = "none")+ + labs(x = "", y = "") + + + g2 = ggplot()+ + geom_bar(data = dt[year == 2020 & scenario == "ConvCase"][, scenario := "Historical"], aes(x = scenario,y = round(shareFS1*100, digits = 0), group = technology, fill = technology, text = details), position = position_stack(), stat = "identity")+ + theme_minimal()+ + scale_fill_manual("Technology", values = cols)+ + expand_limits(y = c(0,1))+ + facet_wrap(~year, nrow = 1)+ + theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1, size = 8), + axis.text.y = element_text(size=8), + axis.line = element_line(size = 0.5, colour = "grey"), + axis.title = element_text(size = 8), + title = element_text(size = 8), + strip.text = element_text(size=8), + strip.background = element_rect(color = "grey"), + legend.position = "none")+ + labs(x = "", y = "") + + + plot = subplot(ggplotly(g2, tooltip = c("text")), ggplotly(g1, tooltip = c("text")), nrows = 1, widths = c(0.12,0.88)) + + plot = ggplotly(plot) %>% + config(modeBarButtonsToRemove=plotlyButtonsToHide, displaylogo=FALSE)%>% + layout(yaxis=list(title='[%]', titlefont = list(size = 10))) + + ## vars used for creating the legend in the dashboard + vars = as.character(unique(dt$technology)) + + output = list(plot = plot, + vars = vars) + + return(output) +} + legend = list() create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfuels_all, CO2km_int_newsales_all, EJLDV_all){ @@ -563,9 +770,9 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue CO2km_int_newsales = CO2km_intensity_newsalesdash(CO2km_int_newsales_all, scen) ## final energy LDVs by fuel EJLDV = EJLDVdash(EJroad_all, scen) - ## emissions passenger transport demand - emipdem = emipdem_dash(emipdem_all, scen) - + ## emissions passenger transport demand and upstream emissions + emip = emip_dash(emipdem_all, emipUp_all, scen) + ## collect plots output[[scenname]]$plot$vintcomp = vintcomp$plot output[[scenname]]$plot$salescomp = salescomp$plot @@ -575,7 +782,7 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue output[[scenname]]$plot$EJpassfuels = EJpassfuels$plot output[[scenname]]$plot$CO2km_int_newsales = CO2km_int_newsales output[[scenname]]$plot$EJLDV = EJLDV$plot - output[[scenname]]$plot$emipdem = emipdem + output[[scenname]]$plot$emip = emip output[[scenname]]$emiscen = emiscen } @@ -586,11 +793,19 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue CO2km_intensity_newsales_scen = CO2km_intensity_newsales_scen_dash(CO2km_int_newsales_all) ## Final energy demand EJpassfuels_scen = EJpass_scen_dash(EJpass_all) + ## sales + salescom_scen = salescom_scen_dash(salescomp_all) + ## emissions + emip_scen = emipcom_dash(emipdem_all, emipUp_all) output[["comparison"]]$plot$vintscen = vintscen$plot output[["comparison"]]$plot$CO2km_intensity_newsales_scen = CO2km_intensity_newsales_scen$plot output[["comparison"]]$plot$EJpassfuels_scen = EJpassfuels_scen$plot + output[["comparison"]]$plot$salescom_scen = salescom_scen$plot + output[["comparison"]]$plot$emipdem_scen = emip_scen$pdem + output[["comparison"]]$plot$emipup_scen = emip_scen$pup + legend$'Sales composition'$contents <- lapply(salescomp$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) }) @@ -605,8 +820,11 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue names(legend$'Total Passenger Transport Energy Services Demand'$contents) <- ESmodeabs$vars legend$'Total Passenger Transport Energy Services Demand'$description <- "<p>Energy services demand in the passenger transport sector, in kilometers driven</p>" + legend$'Emissions passenger transport'$contents <- lapply(emip$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) }) + names(legend$'Emissions passenger transport'$contents) <- emip$vars + legend$'Emissions passenger transport'$description <- "<p>Emissions from the passenger transport sector, excluding international aviation<p>" + - legend$'Emissions passenger transport demand'$description <- "<p>Emissions from the passenger transport sector, including international aviation<p>" legend$'Emission intensity of new sales'$description <- "CO<sub>2</sub> intensity of new light duty vehicles" legend$'Per capita Freight Transport Energy Services Demand'$contents <- lapply(ESmodecap$vars$vars_frgt, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) }) @@ -639,6 +857,18 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue names(legend$'Comparison of passenger final energy demand'$contents) <- EJpassfuels_scen$vars legend$'Comparison of passenger final energy demand'$description <- "<p>Final energy demand for the passenger transport sector (bunkers excluded), compared across scenarios</p>" + legend$'Comparison of sales composition'$contents <- lapply(salescom_scen$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) }) + names(legend$'Comparison of sales composition'$contents) <- salescom_scen$vars + legend$'Comparison of sales composition'$description <- "<p>Composition of sales of light duty vehicles in selected years, in percentage</p>" + + legend$'Comparison of passenger demand emissions'$contents <- lapply(emip_scen$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) }) + names(legend$'Comparison of passenger demand emissions'$contents) <- emip_scen$vars + legend$'Comparison of passenger demand emissions'$description <- "<p>Comparison of emissions from passenger transport demand across scenarios</p>" + + legend$'Comparison of passenger upstream emissions'$contents <- lapply(emip_scen$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) }) + names(legend$'Comparison of passenger upstream emissions'$contents) <- emip_scen$vars + legend$'Comparison of passenger upstream emissions'$description <- "<p>Comparison of emissions from passenger transport upstream across scenarios</p>" + output$legend = legend return(output) diff --git a/scripts/output/single/notebook_templates/EDGETransportReport.Rmd b/scripts/output/single/notebook_templates/EDGETransportReport.Rmd index b27d9c4..7b8c823 100644 --- a/scripts/output/single/notebook_templates/EDGETransportReport.Rmd +++ b/scripts/output/single/notebook_templates/EDGETransportReport.Rmd @@ -123,7 +123,7 @@ EF_shares <- readRDS(datapath(fname = "EF_shares.RDS")) annual_sales <- readRDS(datapath(fname = "annual_sales.RDS")) mj_km_data <- readRDS(datapath(fname = "mj_km_data.RDS")) stations <- readRDS(datapath(fname = "stations.RDS")) - +loadFactor <- readRDS(datapath(fname = "loadFactor.RDS")) ## Load population to calculate per capita values POP_country=calcOutput("Population", aggregate = F)[,, "pop_SSP2"] POP <- magpie2dt(POP_country, regioncol = "iso", @@ -138,7 +138,7 @@ miffile <- as.data.table(read.quitte(name_mif)) ```{r, echo=FALSE, warning=FALSE} -plotVint = function(vintcomp, newcomp, sharesVS1){ +plotVint = function(vintcomp, newcomp, sharesVS1, loadFactor){ vintcomp = vintcomp[,.(totdem, iso, subsector_L1, year, technology,vehicle_type, sector, sharetech_vint)] newcomp = newcomp[,.(iso, subsector_L1, year, technology,vehicle_type, sector, sharetech_new)] @@ -150,9 +150,9 @@ plotVint = function(vintcomp, newcomp, sharesVS1){ "year"), measure.vars = c("vintdem", "newdem")) allfleet[,alpha:=ifelse(variable == "vintdem", 0, 1)] - load_factor = 2 + allfleet = merge(allfleet, loadFactor, all.x = TRUE, by = c("iso", "vehicle_type", "year")) annual_mileage = 15000 - allfleet = allfleet[,.(value = sum(value/load_factor/annual_mileage)), by = c("iso", "technology", "variable", "year")] + allfleet = allfleet[,.(value = sum(value/loadFactor/annual_mileage)), by = c("iso", "technology", "variable", "year")] allfleet = merge(allfleet, REMIND2ISO_MAPPING, by = "iso") allfleet = allfleet[,.(value = sum(value)), by = c("region", "technology", "variable", "year")] @@ -184,7 +184,7 @@ plotVint = function(vintcomp, newcomp, sharesVS1){ } -p = plotVint(vintcomp, newcomp, shares$VS1_shares) +p = plotVint(vintcomp, newcomp, shares$VS1_shares, loadFactor) p -- GitLab