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

Dashboard: emissions changed, plots rearranged, layout improvements.

parent b21c9c1b
No related branches found
No related tags found
1 merge request!194Updates to EDGE-Transport
...@@ -45,7 +45,7 @@ CO2km_int_newsales_all = NULL ...@@ -45,7 +45,7 @@ CO2km_int_newsales_all = NULL
emidem_all = NULL emidem_all = NULL
EJfuelsPass_all = NULL EJfuelsPass_all = NULL
EJfuelsFrgt_all = NULL EJfuelsFrgt_all = NULL
emipFosEl_all = NULL emipSource_all = NULL
scenNames <- getScenNames(outputdirs) scenNames <- getScenNames(outputdirs)
EDGEdata_path <- path(outputdirs, paste("EDGE-T/")) EDGEdata_path <- path(outputdirs, paste("EDGE-T/"))
...@@ -331,88 +331,74 @@ emidemFun = function(emidem){ ...@@ -331,88 +331,74 @@ emidemFun = function(emidem){
} }
emipfosElFun = function(miffile, gdx){ emipSourceFun = function(miffile){
minyr <- 2015 minyr <- 2015
maxyr <- 2100 maxyr <- 2100
TWa_2_EJ <- 31.536 ## fe hydrogen used for liquids consumption in passenger transport
GtC_2_MtCO2 <- 44 / 12 * 1000 h2liqp = miffile[
variable == "FE|Transport|Pass|Liquids|Hydrogen" &
prodSe <- readgdx(gdx, "vm_prodSe")[
tall >= minyr & tall <= maxyr][, value := value*TWa_2_EJ]
setnames(prodSe, c("year", "region", "pe", "se", "te", "value"))
prodSyn <- prodSe[te == "MeOH"]
prodSyn[, se := "synliq"]
prodSyn[, c("pe", "te") := NULL]
setnames(prodSyn, "value", "syn_val")
prodSyn <- rbind(prodSyn, CJ(year=c(2015, 2020),
region=prodSyn$region,
se="synliq", syn_val=0,
unique=T))
## Electricity consumption for H2 production
prodEl <- prodSe[se == "seel"]
prodEl[, allEl := sum(value), by=.(year, region)][
, c("pe", "se", "te", "value", "tenames") := 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]
## CO2 emission for electricity
vemi <- readgdx(gdx, "vm_emiTeDetail")[ttot >= minyr & ttot <= maxyr]
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
## add electric cars upstream emissions
bevemi = miffile[
variable == "Emi|CO2|Transport|Pass|Short-Medium Distance|Electricity" &
year >= minyr & year <= maxyr][ year >= minyr & year <= maxyr][
, .(year, region, se="bevs", co2=value)] , .(year, region, fes="feh2l", fe=value)]
## fossil emissions ## fe hydrogen used in passenger transport
fosemi = miffile[ h2p = miffile[
variable == "Emi|CO2|Transport|Pass|Short-Medium Distance|Liquids" & variable == "FE|Transport|Pass|Hydrogen" &
year >= minyr & year <= maxyr][ year >= minyr & year <= maxyr][
, .(year, region, se="fos", co2=value)] , .(year, region, fes="feh2", fe=value)]
## combine all
emi_all <- rbindlist(list(
emisyn,
bevemi,
fosemi))
## sum bev and hydrogen upstream emissions ## elec used in passenger transport
emi_wide <- dcast(emi_all, year+region ~ se)[, all_el := bevs + seh2] elp = miffile[
variable == "FE|Transport|Pass|Electricity" &
year >= minyr & year <= maxyr][
, .(year, region, fes="el", fe=value)]
emi_result <- melt(emi_wide, ## final energy electricity
value.name="co2", el = miffile[
id.vars = c("year", "region"), variable == "FE|+|Electricity" &
variable.name = "tech")[tech %in% c("all_el", "fos")] year >= minyr & year <= maxyr][
, .(year, region, fes="el", fe=value)]
## emission supply side from electricity
emiel = miffile[
variable == "Emi|CO2|Energy|Supply|Electricity|Gross" &
year >= minyr & year <= maxyr][
, .(year, region, emis="el", emi=value)]
return(emi_result) ## emissions from transport passenger
emip = miffile[
variable == "Emi|CO2|Transport|Pass|Short-Medium Distance|Liquids" &
year >= minyr & year <= maxyr][
, .(year, region, source="liq", emi=value)]
## calculate fossil electricity carbon intensity
elint = merge(el, emiel, by = c("year", "region"))
elint[, int := emi/fe]
elint = elint[,.(year, region, int)]
## calculate emissions from electricity of electrified transport
emielp = merge(elint, elp, by = c("year", "region"))
emielp[, emi := int*fe]
emielp = emielp[,.(year, region, emi, source = "elp")]
## estimate the secondary energy from electricity based synfuels in passenger transport
sesynp = h2liqp[][, se := fe/0.55][, fe := NULL]
## estimate the secondary energy from hydrogen in passenger transport
seh2np = h2p[][, se := fe/0.7][, fe := NULL]
## emissions CO2 derived from synfuels in passenger transport
emisynp = merge(sesynp, elint, by = c("year", "region"))
emisynp[, emi := se*int]
emisynp = emisynp[,.(year, region, emi, source = "synf")]
## emissions CO2 derived from hydrogen
emih2p = merge(seh2np, elint, by = c("year", "region"))
emih2p[, emi := se*int]
emih2p = emih2p[,.(year, region, emi, source = "h2")]
## summarize emissions
emi_all = rbindlist(list(emih2p, emisynp, emielp, emip), use.names=TRUE)
return(emi_all)
} }
for (outputdir in outputdirs) { for (outputdir in outputdirs) {
...@@ -471,7 +457,7 @@ for (outputdir in outputdirs) { ...@@ -471,7 +457,7 @@ for (outputdir in outputdirs) {
## calculate demand emissions ## calculate demand emissions
emidem = emidemFun(emidem) emidem = emidemFun(emidem)
## calculate emissions from passenger SM fossil fuels (liquids) ## calculate emissions from passenger SM fossil fuels (liquids)
emipFosEl = emipfosElFun(miffile, gdx) emipSource = emipSourceFun(miffile)
## add scenario dimension to the results ## add scenario dimension to the results
fleet[, scenario := as.character(unique(miffile$scenario))] fleet[, scenario := as.character(unique(miffile$scenario))]
salescomp[, scenario := unique(miffile$scenario)] salescomp[, scenario := unique(miffile$scenario)]
...@@ -483,7 +469,7 @@ for (outputdir in outputdirs) { ...@@ -483,7 +469,7 @@ for (outputdir in outputdirs) {
emidem[, scenario := as.character(unique(miffile$scenario))] emidem[, scenario := as.character(unique(miffile$scenario))]
EJfuelsPass[, scenario := as.character(unique(miffile$scenario))] EJfuelsPass[, scenario := as.character(unique(miffile$scenario))]
EJfuelsFrgt[, scenario := as.character(unique(miffile$scenario))] EJfuelsFrgt[, scenario := as.character(unique(miffile$scenario))]
emipFosEl[, scenario := as.character(unique(miffile$scenario))] emipSource[, scenario := as.character(unique(miffile$scenario))]
## rbind scenarios ## rbind scenarios
salescomp_all = rbind(salescomp_all, salescomp) salescomp_all = rbind(salescomp_all, salescomp)
fleet_all = rbind(fleet_all, fleet) fleet_all = rbind(fleet_all, fleet)
...@@ -495,7 +481,7 @@ for (outputdir in outputdirs) { ...@@ -495,7 +481,7 @@ for (outputdir in outputdirs) {
emidem_all = rbind(emidem_all, emidem) emidem_all = rbind(emidem_all, emidem)
EJfuelsPass_all = rbind(EJfuelsPass_all, EJfuelsPass) EJfuelsPass_all = rbind(EJfuelsPass_all, EJfuelsPass)
EJfuelsFrgt_all = rbind(EJfuelsFrgt_all, EJfuelsFrgt) EJfuelsFrgt_all = rbind(EJfuelsFrgt_all, EJfuelsFrgt)
emipFosEl_all = rbind(emipFosEl_all, emipFosEl) emipSource_all = rbind(emipSource_all, emipSource)
} }
outdir = paste0("output/comparerunEDGE", gsub(" | ^([[:alpha:]]*).*","", Sys.time())) outdir = paste0("output/comparerunEDGE", gsub(" | ^([[:alpha:]]*).*","", Sys.time()))
...@@ -513,7 +499,7 @@ saveRDS(CO2km_int_newsales_all, paste0(outdir, "/CO2km_int_newsales_all.RDS")) ...@@ -513,7 +499,7 @@ saveRDS(CO2km_int_newsales_all, paste0(outdir, "/CO2km_int_newsales_all.RDS"))
saveRDS(emidem_all, paste0(outdir, "/emidem_all.RDS")) saveRDS(emidem_all, paste0(outdir, "/emidem_all.RDS"))
saveRDS(EJfuelsPass_all, paste0(outdir, "/EJfuelsPass_all.RDS")) saveRDS(EJfuelsPass_all, paste0(outdir, "/EJfuelsPass_all.RDS"))
saveRDS(EJfuelsFrgt_all, paste0(outdir, "/EJfuelsFrgt_all.RDS")) saveRDS(EJfuelsFrgt_all, paste0(outdir, "/EJfuelsFrgt_all.RDS"))
saveRDS(emipFosEl_all, paste0(outdir, "/emipFosEl_all.RDS")) saveRDS(emipSource_all, paste0(outdir, "/emipSource_all.RDS"))
file.copy(file.path("./scripts/output/comparison/notebook_templates", md_template), outdir) file.copy(file.path("./scripts/output/comparison/notebook_templates", md_template), outdir)
rmarkdown::render(path(outdir, md_template), output_format="pdf_document") rmarkdown::render(path(outdir, md_template), output_format="pdf_document")
......
...@@ -38,8 +38,34 @@ legend=plotlist$legend ...@@ -38,8 +38,34 @@ legend=plotlist$legend
#data frame with help tooltips #data frame with help tooltips
helpTooltip_df <- data.frame( helpTooltip_df <- data.frame(
title=c("Distance traveled per capita", "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 transport fossil fuels emissions", "Comparison of passenger electricity production emissions"), title=c("Distance traveled per capita",
placement=c("right", "left", "right", "left", "right", "right", "right", "right", "right", "left", "left", "right", "left", "left")) "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",
"Passenger transport emissions supply and demand",
"Emission intensity of new sales",
"Comparison of sales composition",
"Comparison of passenger transport emissions supply and demand",
"Comparison of passenger tailpipe emissions from fossil fuels"),
placement=c("right",
"left",
"right",
"left",
"right",
"right",
"right",
"left",
"right",
"left",
"left",
"right",
"right",
"left"))
helpTooltip = function(tooltipdf){ helpTooltip = function(tooltipdf){
...@@ -112,7 +138,7 @@ Row {data-height=300} ...@@ -112,7 +138,7 @@ Row {data-height=300}
### Transport scenario {data-width=100} ### Transport scenario {data-width=100}
```{r} ```{r}
valueBox("Conventional Case NoTax") valueBox("Baseline")
``` ```
...@@ -439,33 +465,37 @@ Row {data-height = 450} ...@@ -439,33 +465,37 @@ Row {data-height = 450}
plotlist$comparison$plot$vintscen plotlist$comparison$plot$vintscen
``` ```
### Comparison of passenger final energy demand ### Comparison of sales composition
```{r} ```{r}
plotlist$comparison$plot$EJpassfuels_scen plotlist$comparison$plot$salescom_scen
``` ```
### Comparison of passenger transport fossil fuels emissions ### Emission intensity, new sales comparison
```{r} ```{r}
plotlist$comparison$plot$emipfos_scen plotlist$comparison$plot$CO2km_intensity_newsales_scen
``` ```
Row {data-height = 450} Row {data-height = 450}
----------------------------------------------------------------------- -----------------------------------------------------------------------
### Comparison of sales composition ### Comparison of passenger final energy demand
```{r} ```{r}
plotlist$comparison$plot$salescom_scen plotlist$comparison$plot$EJpassfuels_scen
``` ```
### Emission intensity, new sales comparison
### Comparison of passenger transport emissions supply and demand
```{r} ```{r}
plotlist$comparison$plot$CO2km_intensity_newsales_scen plotlist$comparison$plot$emiptot_scen
``` ```
### Comparison of passenger electricity production emissions
### Comparison of passenger tailpipe emissions from fossil fuels
```{r} ```{r}
plotlist$comparison$plot$emipel_scen plotlist$comparison$plot$emipfos_scen
``` ```
Passenger transport overview {data-icon="glyphicon glyphicon-scale"} Passenger transport overview {data-icon="glyphicon glyphicon-scale"}
...@@ -484,7 +514,7 @@ Row {data-height=300} ...@@ -484,7 +514,7 @@ Row {data-height=300}
### Transport scenario {data-width=100} ### Transport scenario {data-width=100}
```{r} ```{r}
valueBox("Conventional Case NoTax") valueBox("Baseline")
``` ```
...@@ -523,7 +553,7 @@ Row {data-heigth=500} ...@@ -523,7 +553,7 @@ Row {data-heigth=500}
plotlist$`ConvCase NoTax`$plot$EJpassfuels plotlist$`ConvCase NoTax`$plot$EJpassfuels
``` ```
### Emissions passenger transport ### Passenger transport emissions supply and demand
```{r} ```{r}
plotlist$`ConvCase NoTax`$plot$emip plotlist$`ConvCase NoTax`$plot$emip
...@@ -586,7 +616,7 @@ Row {data-heigth=500} ...@@ -586,7 +616,7 @@ Row {data-heigth=500}
plotlist$ConvCase$plot$EJpassfuels plotlist$ConvCase$plot$EJpassfuels
``` ```
### Emissions passenger transport ### Passenger transport emissions supply and demand
```{r} ```{r}
plotlist$ConvCase$plot$emip plotlist$ConvCase$plot$emip
...@@ -651,7 +681,7 @@ Row {data-heigth=500} ...@@ -651,7 +681,7 @@ Row {data-heigth=500}
plotlist$HydrHype$plot$EJpassfuels plotlist$HydrHype$plot$EJpassfuels
``` ```
### Emissions passenger transport ### Passenger transport emissions supply and demand
```{r} ```{r}
plotlist$HydrHype$plot$emip plotlist$HydrHype$plot$emip
...@@ -714,7 +744,7 @@ Row {data-heigth=500} ...@@ -714,7 +744,7 @@ Row {data-heigth=500}
plotlist$ElecEra$plot$EJpassfuels plotlist$ElecEra$plot$EJpassfuels
``` ```
### Emissions passenger transport ### Passenger transport emissions supply and demand
```{r} ```{r}
plotlist$ElecEra$plot$emip plotlist$ElecEra$plot$emip
...@@ -776,7 +806,7 @@ Row {data-heigth=500} ...@@ -776,7 +806,7 @@ Row {data-heigth=500}
plotlist$SynSurge$plot$EJpassfuels plotlist$SynSurge$plot$EJpassfuels
``` ```
### Emissions passenger transport ### Passenger transport emissions supply and demand
```{r} ```{r}
plotlist$SynSurge$plot$emip plotlist$SynSurge$plot$emip
...@@ -790,49 +820,53 @@ Column {data-width= 450} ...@@ -790,49 +820,53 @@ Column {data-width= 450}
----------------------------------------------------------------------- -----------------------------------------------------------------------
### Baseline (No Carbon Pricing) {data-height=200} ### Baseline (No Carbon Pricing) {data-height=200}
</ul> </ul style="padding-left:20px">
<li> Structurally conservative: continuation of historic consumer preferences for conventional combustion engine cars. </li> <li class="shift"> Structurally conservative: continuation of historic consumer preferences for conventional combustion engine cars. </li>
<li> No policies to promote alternative vehicles </li> <li class="shift"> No policies to promote alternative vehicles </li>
<li> Slow build-up of electric recharging stations </li> <li class="shift"> Slow build-up of electric recharging stations </li>
</ul> </ul>
### Conventional Case {data-height=200} ### Conventional Case {data-height=200}
</ul> </ul style="padding-left:20px">
<li> Structurally conservative: continuation of historic consumer preferences for conventional combustion engine cars </li> <li class="shift"> Carbon pricing </li>
<li> No policies to promote alternative vehicles </li> <li class="shift"> Structurally conservative: continuation of historic consumer preferences for conventional combustion engine cars </li>
<li> Slow build-up of electric recharging stations </li> <li class="shift"> No policies to promote alternative vehicles </li>
<li class="shift"> Slow build-up of electric recharging stations </li>
</ul> </ul>
### Hydrogen Hype {data-height=200} ### Hydrogen Hype {data-height=200}
</ul> </ul style="padding-left:20px">
<li> Fast build-up of hydrogen refuelling stations </li> <li class="shift"> Carbon pricing </li>
<li> 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 </li> <li class="shift"> Fast build-up of hydrogen refuelling stations </li>
<li> Increasing dis-preference for internal combustion engines due to tightening regulation </li> <li class="shift"> 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 </li>
<li> Policy push for FCEVs: Support policies induce a shift from dis-preference to preference of hydrogen vehicles, e.g. incentives to carmakers and car retailers to provide hidrogen vehicles </li> <li class="shift"> Increasing dis-preference for internal combustion engines due to tightening regulation </li>
<li> Hydrogen from renewable resources (green hydrogen) is at least 95&#37; of the total hydrogen </li> <li class="shift"> Policy push for FCEVs: Support policies induce a shift from dis-preference to preference of hydrogen vehicles, e.g. incentives to carmakers and car retailers to provide hidrogen vehicles </li>
<li> Slow build-up of electric recharging stations </li> <li class="shift"> Hydrogen from electricity is at least 95&#37; of the total hydrogen, with electricity from renewable resources reaching around 90&#37; of the electricity production in 2050 </li>
<li class="shift"> Slow build-up of electric recharging stations </li>
</ul> </ul>
### Electric Era {data-height=200} ### Electric Era {data-height=200}
</ul> </ul style="padding-left:20px">
<li> 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 </li> <li class="shift"> Carbon pricing </li>
<li> Increasing dis-preference for internal combustion engines due to tightening regulation </li> <li class="shift"> 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 </li>
<li class="shift"> Increasing dis-preference for internal combustion engines due to tightening regulation </li>
</ul> </ul>
### Synfuel Surge {data-height=200} ### Synfuel Surge {data-height=200}
</ul> </ul style="padding-left:20px">
<li> Structurally conservative: continuation of historic consumer preferences for conventional combustion engine cars </li> <li class="shift"> Carbon pricing </li>
<li> Synfuels are forced in the liquids mix blending mandates reaching 10&#37; of liquids fuels in transportation by 2035 </li> <li class="shift"> Structurally conservative: continuation of historic consumer preferences for conventional combustion engine cars </li>
<li> Hydrogen from renewable resources (green hydrogen) is at least 95&#37; of the total hydrogen </li> <li class="shift"> Synfuels are forced in the liquids mix blending mandates reaching 20&#37; of liquids fuels in transportation by 2035 </li>
<li> CO<sub>2</sub> emissions from other sources (e.g., industrial installations) are captured and reused to produce syntethic fuels (Carbon Capture and Utilization) </li> <li class="shift"> Hydrogen from electricity is at least 95&#37; of the total hydrogen, with electricity from renewable resources reaching around 90&#37; of the electricity production in 2050</li>
<li class="shift"> CO<sub>2</sub> emissions from other sources (e.g., industrial installations) are captured and reused to produce syntethic fuels (Carbon Capture and Utilization) </li>
</ul> </ul>
...@@ -1001,7 +1035,7 @@ navBarMemory = function(topMenuLabel, sideBarClass){ ...@@ -1001,7 +1035,7 @@ navBarMemory = function(topMenuLabel, sideBarClass){
user-select: none; user-select: none;
} }
<!-- element "legend" of panels --> /*legend element with tooltip*/
.rightal { .rightal {
float: right; float: right;
font-weight: bold; font-weight: bold;
...@@ -1009,11 +1043,13 @@ navBarMemory = function(topMenuLabel, sideBarClass){ ...@@ -1009,11 +1043,13 @@ navBarMemory = function(topMenuLabel, sideBarClass){
color: #7c7c7c; color: #7c7c7c;
padding: 5px 10px; padding: 5px 10px;
} }
ul{
list-tyle:none;
}
<!-- indentation for bullet points list --> .shift{
li{
margin-left:20px; margin-left:20px;
} }
</style> </style>
...@@ -67,12 +67,10 @@ cols <- c("NG" = "#d11141", ...@@ -67,12 +67,10 @@ cols <- c("NG" = "#d11141",
"Hydrogen_push" = "#00aedb", "Hydrogen_push" = "#00aedb",
"Conservative_liquids" = "#113245", "Conservative_liquids" = "#113245",
"ConvCase" = "#113245", "ConvCase" = "#113245",
"ConvCaseNoTax" = "#d11141", "Baseline" = "#d11141",
"ConvCaseWise" = "#d11141", "ConvCaseWise" = "#d11141",
"SynSurge" = "orchid", "SynSurge" = "orchid",
"Fossil fuels" = "#113245", "Fossil fuels" = "#113245")
"Fossil fuels + Electricity production" = "#f37735",
"Electricity production" = "#6495ed")
legend_ord_modes <- c("Freight Rail", "Truck", "Shipping", "International Shipping", "Domestic Shipping", "Trucks", legend_ord_modes <- c("Freight Rail", "Truck", "Shipping", "International Shipping", "Domestic Shipping", "Trucks",
"Motorbikes", "Small Cars", "Large Cars", "Van", "Motorbikes", "Small Cars", "Large Cars", "Van",
...@@ -96,7 +94,7 @@ ESmodecap_all = readRDS("ESmodecap_all.RDS") ...@@ -96,7 +94,7 @@ ESmodecap_all = readRDS("ESmodecap_all.RDS")
ESmodeabs_all = readRDS("ESmodeabs_all.RDS") ESmodeabs_all = readRDS("ESmodeabs_all.RDS")
CO2km_int_newsales_all = readRDS("CO2km_int_newsales_all.RDS") CO2km_int_newsales_all = readRDS("CO2km_int_newsales_all.RDS")
EJpass_all = readRDS("EJfuelsPass_all.RDS") EJpass_all = readRDS("EJfuelsPass_all.RDS")
emipFosEl_all = readRDS("emipFosEl_all.RDS") emipSource_all = readRDS("emipSource_all.RDS")
## scenarios ## scenarios
scens = unique(EJmode_all$scenario) scens = unique(EJmode_all$scenario)
...@@ -142,13 +140,13 @@ vintcomparisondash = function(dt, scen){ ...@@ -142,13 +140,13 @@ vintcomparisondash = function(dt, scen){
vintscen_dash = function(dt){ vintscen_dash = function(dt){
dt[, scenario := ifelse(scenario == "Base_ConvCase", "ConvCaseNoTax", scenario)] dt[, scenario := ifelse(scenario == "Base_ConvCase", "Baseline", scenario)]
dt = dt[year %in% c(2020, 2030, 2050)] dt = dt[year %in% c(2020, 2030, 2050)]
dt[, year := as.character(year)] dt[, year := as.character(year)]
dt = dt[region == region_plot] dt = dt[region == region_plot]
dt = dt[,.(value = sum(value)), by = c("region", "technology", "year", "scenario")] dt = dt[,.(value = sum(value)), by = c("region", "technology", "year", "scenario")]
dt[, scenario := gsub(".*_", "", scenario)] dt[, scenario := gsub(".*_", "", scenario)]
dt[, scenario := factor(scenario, levels = c("ConvCaseNoTax", "ConvCase", "HydrHype", "ElecEra", "SynSurge"))] dt[, scenario := factor(scenario, levels = c("Baseline", "ConvCase", "HydrHype", "ElecEra", "SynSurge"))]
dt[, details := paste0("Vehicles: ", round(value, 0), " [million]", "<br>", "Technology: ", technology, "<br>", "Region: ", region," <br>", "Year: ", year) ] dt[, details := paste0("Vehicles: ", round(value, 0), " [million]", "<br>", "Technology: ", technology, "<br>", "Region: ", region," <br>", "Year: ", year) ]
g1 = ggplot()+ g1 = ggplot()+
geom_bar(data = dt[year %in% c(2030, 2050)], geom_bar(data = dt[year %in% c(2030, 2050)],
...@@ -247,7 +245,7 @@ salescomdash = function(dt, scen){ ...@@ -247,7 +245,7 @@ salescomdash = function(dt, scen){
ESmodecapdash = function(dt, scen){ ESmodecapdash = function(dt, scen){
dt = dt[region == region_plot & scenario == scen & year <= 2050] dt = dt[region == region_plot & scenario == scen & year <= 2050]
dt[, details := paste0("Demand: ", round(cap_dem, digits = 0), ifelse(mode == "pass", " [pkm/cap]", " [tkm/cap]"), "<br>", "Vehicle: ", vehicle_type_plot, "<br>", "Region: ", region," <br>", "Year: ", year) ] dt[, details := paste0("Demand: ", round(cap_dem, digits = 0), ifelse(mode == "pass", " [km]", " [tkm/cap]"), "<br>", "Vehicle: ", vehicle_type_plot, "<br>", "Region: ", region," <br>", "Year: ", year) ]
plot_pass = ggplot()+ plot_pass = ggplot()+
geom_area(data = dt[mode == "pass"], aes(x = year, y = cap_dem, group = vehicle_type_plot, fill = vehicle_type_plot, text = details), position= position_stack())+ geom_area(data = dt[mode == "pass"], aes(x = year, y = cap_dem, group = vehicle_type_plot, fill = vehicle_type_plot, text = details), position= position_stack())+
...@@ -371,12 +369,12 @@ EJpass_dash = function(dt, scen){ ...@@ -371,12 +369,12 @@ EJpass_dash = function(dt, scen){
} }
EJpass_scen_dash = function(dt){ EJpass_scen_dash = function(dt){
dt[, scenario := ifelse(scenario == "Base_ConvCase", "ConvCaseNoTax", scenario)] dt[, scenario := ifelse(scenario == "Base_ConvCase", "Baseline", scenario)]
dt[, subtech := factor(subtech, levels = legend_ord)] dt[, subtech := factor(subtech, levels = legend_ord)]
dt = dt[region == region_plot & year %in% c(2020, 2030, 2050) & sector == "trn_pass"] dt = dt[region == region_plot & year %in% c(2020, 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[, details := paste0("Demand: ", round(demand_EJ, digits = 0), " [EJ]","<br>", "Technology: ", subtech, "<br>", "Region: ", region," <br>", "Year: ", year) ]
dt[, scenario := gsub(".*_", "", scenario)] dt[, scenario := gsub(".*_", "", scenario)]
dt[, scenario := factor(scenario, levels = c("ConvCaseNoTax", "ConvCase", "HydrHype", "ElecEra", "SynSurge"))] dt[, scenario := factor(scenario, levels = c("Baseline", "ConvCase", "HydrHype", "ElecEra", "SynSurge"))]
g1 = ggplot()+ g1 = ggplot()+
geom_bar(data = dt[year %in% c(2030, 2050)], aes(x = scenario, y = demand_EJ, group = subtech, geom_bar(data = dt[year %in% c(2030, 2050)], aes(x = scenario, y = demand_EJ, group = subtech,
...@@ -470,7 +468,7 @@ CO2km_intensity_newsalesdash = function(dt, scen){ ...@@ -470,7 +468,7 @@ CO2km_intensity_newsalesdash = function(dt, scen){
CO2km_intensity_newsales_scen_dash = function(dt){ CO2km_intensity_newsales_scen_dash = function(dt){
dt[, scenario := ifelse(scenario == "Base_ConvCase", "ConvCaseNoTax", scenario)] dt[, scenario := ifelse(scenario == "Base_ConvCase", "Baseline", scenario)]
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)) 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))
historical_values[, details := "Historical values"] historical_values[, details := "Historical values"]
targets = data.table(name = c("2021 target", "2025 target", "2030 target"), value = c(95, 95*(1-0.15), 95*(1-0.37))) targets = data.table(name = c("2021 target", "2025 target", "2030 target"), value = c(95, 95*(1-0.15), 95*(1-0.37)))
...@@ -553,20 +551,20 @@ EJLDVdash <- function(dt, scen){ ...@@ -553,20 +551,20 @@ EJLDVdash <- function(dt, scen){
emip_dash = function(dt, scen){ emip_dash = function(dt, scen){
dt[, year:= as.numeric(year)] dt[, year:= as.numeric(year)]
dt = dt[region == region_plot & scenario == scen & year <= 2050 & year >= 2020] dt = dt[region == region_plot & scenario == scen & year <= 2050 & year >= 2020]
dt = dcast(dt, region + year + scenario ~ tech, value.var = "co2") dt = dcast(dt, region + year + scenario ~ source, value.var = "emi")
dt[, tot := fos + all_el]
dt = melt(dt, id.vars = c("region", "year", "scenario")) dt = melt(dt, id.vars = c("region", "year", "scenario"))
dt[variable == "tot", type := "Fossil fuels + Electricity production"] dt[variable == "synf", type := "Synfuel"]
dt[variable == "all_el", type := "Electricity production"] dt[variable == "h2", type := "Hydrogen"]
dt[variable == "fos", type := "Fossil fuels"] dt[variable == "elp", type := "Electricity"]
dt[variable == "liq", type := "Fossil fuels"]
dt[variable == "synf" & value <0, value := 0]
dt[, details := paste0("Emissions: ", round(value, digits = 0), " [MtCO<sub>2</sub>]", "<br>", "Type: ", type, "<br>", "Region: ", region," <br>", "Year: ", year) ] dt[, details := paste0("Emissions: ", round(value, digits = 0), " [MtCO<sub>2</sub>]", "<br>", "Type: ", type, "<br>", "Region: ", region," <br>", "Year: ", year) ]
plot = ggplot()+ plot = ggplot()+
geom_area(data = dt[year >= 2020 & type == "Fossil fuels + Electricity production"], aes(x = year, y = value, text = details, fill =type, group = type), alpha = 0.4, position = position_stack())+ geom_bar(data = dt[year >= 2020], aes(x = year, y = value, text = details, fill = type, group = type), position = position_stack(), stat = "identity")+
geom_line(data = dt[year >= 2020 & type != "Fossil fuels + Electricity production"], aes(x = year, y = value, text = details, group = type, color = type))+
labs(x = "", y = "")+ labs(x = "", y = "")+
theme_minimal()+ theme_minimal()+
expand_limits(y = c(0,1))+ expand_limits(y = c(0,1))+
...@@ -597,24 +595,26 @@ emip_dash = function(dt, scen){ ...@@ -597,24 +595,26 @@ emip_dash = function(dt, scen){
} }
emipscen_dash = function(dt){ emipscen_dash = function(dt){
dt = dt[region == region_plot & year <= 2050 & year >= 2020] dt = dt[region == region_plot & year <= 2050 & year >= 2015]
dt[, year := as.numeric(year)] dt[, year := as.numeric(year)]
dt[, scenario := ifelse(scenario == "Base_ConvCase", "ConvCaseNoTax", scenario)] dt[, scenario := ifelse(scenario == "Base_ConvCase", "Baseline", scenario)]
dt[, scenario := gsub(".*_", "", scenario)] dt[, scenario := gsub(".*_", "", scenario)]
dt = dt[scenario != "Baseline"]
dt = dcast(dt, region + year + scenario ~ source, value.var = "emi")
dt = dcast(dt, region + year + scenario ~ tech, value.var = "co2") dt[, tot := h2 + synf + elp + liq]
dt[, tot := fos + all_el]
dt = melt(dt, id.vars = c("region", "year", "scenario")) dt = melt(dt, id.vars = c("region", "year", "scenario"))
dt[variable == "tot", type := "Fossil fuels + Electricity production"] dt[variable == "tot", type := "Passenger transport emissions, supply and demand"]
dt[variable == "all_el", type := "Electricity production"] dt[variable == "synf", type := "Synfuels"]
dt[variable == "fos", type := "Fossil fuels"] dt[variable == "h2", type := "Hydrogen"]
dt[variable == "elp", type := "Electricity"]
dt[variable == "liq", type := "Fossil fuels"]
dt[, details := scenario ] dt[, details := scenario ]
pfos = ggplot()+ ptot = ggplot()+
geom_line(data = dt[type == "Fossil fuels"], aes(x = year, y = value, text = details, group = scenario, color = scenario))+ geom_line(data = dt[variable == "tot"], aes(x = year, y = value, text = details, group = scenario, color = scenario))+
labs(x = "", y = "")+ labs(x = "", y = "")+
theme_minimal()+ theme_minimal()+
expand_limits(y = c(0,1))+ expand_limits(y = c(0,1))+
...@@ -630,19 +630,19 @@ emipscen_dash = function(dt){ ...@@ -630,19 +630,19 @@ emipscen_dash = function(dt){
strip.background = element_rect(color = "grey"))+ strip.background = element_rect(color = "grey"))+
scale_color_manual(values = cols) scale_color_manual(values = cols)
pfos = ggplotly(pfos, tooltip = c("text")) %>% ptot = ggplotly(ptot, tooltip = c("text")) %>%
config(modeBarButtonsToRemove=plotlyButtonsToHide, displaylogo=FALSE) %>% config(modeBarButtonsToRemove=plotlyButtonsToHide, displaylogo=FALSE) %>%
layout(yaxis=list(title='[MtCO<sub>2</sub>]', titlefont = list(size = 10))) layout(yaxis=list(title='[MtCO<sub>2</sub>]', titlefont = list(size = 10)))
vars = as.character(unique(dt$scenario)) vars = as.character(unique(dt$scenario))
pel = ggplot()+ pfos = ggplot()+
geom_line(data = dt[type == "Electricity production"], aes(x = year, y = value, text = scenario, group = scenario, color = scenario))+ geom_line(data = dt[variable == "liq"], aes(x = year, y = value, text = scenario, group = scenario, color = scenario))+
labs(x = "", y = "")+ labs(x = "", y = "")+
theme_minimal()+ theme_minimal()+
expand_limits(y = c(0,1))+ expand_limits(y = c(0,1))+
ylim(-80, 140)+ ylim(0, 1800)+
scale_x_continuous(breaks = c(2020, 2030, 2050))+ scale_x_continuous(breaks = c(2020, 2030, 2050))+
theme(axis.text.x = element_text(angle = 90, size = 8, vjust=0.5, hjust=1), theme(axis.text.x = element_text(angle = 90, size = 8, vjust=0.5, hjust=1),
axis.text.y = element_text(size = 8), axis.text.y = element_text(size = 8),
...@@ -654,11 +654,11 @@ emipscen_dash = function(dt){ ...@@ -654,11 +654,11 @@ emipscen_dash = function(dt){
strip.background = element_rect(color = "grey"))+ strip.background = element_rect(color = "grey"))+
scale_color_manual(values = cols) scale_color_manual(values = cols)
pel = ggplotly(pel, tooltip = c("text")) %>% pfos = ggplotly(pfos, tooltip = c("text")) %>%
config(modeBarButtonsToRemove=plotlyButtonsToHide, displaylogo=FALSE) %>% config(modeBarButtonsToRemove=plotlyButtonsToHide, displaylogo=FALSE) %>%
layout(yaxis=list(title='[MtCO<sub>2</sub>]', titlefont = list(size = 10))) layout(yaxis=list(title='[MtCO<sub>2</sub>]', titlefont = list(size = 10)))
plot = list(pfos = pfos, pel = pel, vars = vars) plot = list(pfos = pfos, ptot = ptot, vars = vars)
return(plot) return(plot)
...@@ -667,11 +667,11 @@ emipscen_dash = function(dt){ ...@@ -667,11 +667,11 @@ emipscen_dash = function(dt){
salescom_scen_dash = function(dt){ salescom_scen_dash = function(dt){
dt[, scenario := as.character(scenario)] dt[, scenario := as.character(scenario)]
dt[, scenario := ifelse(scenario == "Base_ConvCase", "ConvCaseNoTax", scenario)] dt[, scenario := ifelse(scenario == "Base_ConvCase", "Baseline", scenario)]
dt = dt[region == region_plot & year %in% c(2020, 2030, 2050)] dt = dt[region == region_plot & year %in% c(2020, 2030, 2050)]
dt[, year := as.numeric(as.character(year))] dt[, year := as.numeric(as.character(year))]
dt[, scenario := gsub(".*_", "", scenario)] dt[, scenario := gsub(".*_", "", scenario)]
dt[, scenario := factor(scenario, levels = c("ConvCaseNoTax", "ConvCase", "HydrHype", "ElecEra", "SynSurge"))] dt[, scenario := factor(scenario, levels = c("Baseline", "ConvCase", "HydrHype", "ElecEra", "SynSurge"))]
## normalize shares so to have sum to 1 ## normalize shares so to have sum to 1
dt[, shareFS1 := round(shareFS1*100, digits = 0)] dt[, shareFS1 := round(shareFS1*100, digits = 0)]
dt[, shareFS1 := shareFS1/sum(shareFS1), by = c("region", "year", "scenario")] dt[, shareFS1 := shareFS1/sum(shareFS1), by = c("region", "year", "scenario")]
...@@ -767,7 +767,7 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue ...@@ -767,7 +767,7 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue
## final energy LDVs by fuel ## final energy LDVs by fuel
EJLDV = EJLDVdash(EJroad_all, scen) EJLDV = EJLDVdash(EJroad_all, scen)
## emissions passenger transport demand and upstream emissions ## emissions passenger transport demand and upstream emissions
emip = emip_dash(emipFosEl_all, scen) emip = emip_dash(emipSource_all, scen)
## collect plots ## collect plots
output[[scenname]]$plot$vintcomp = vintcomp$plot output[[scenname]]$plot$vintcomp = vintcomp$plot
...@@ -792,7 +792,7 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue ...@@ -792,7 +792,7 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue
## sales ## sales
salescom_scen = salescom_scen_dash(salescomp_all) salescom_scen = salescom_scen_dash(salescomp_all)
## emissions ## emissions
emip_scen = emipscen_dash(emipFosEl_all) emip_scen = emipscen_dash(emipSource_all)
output[["comparison"]]$plot$vintscen = vintscen$plot output[["comparison"]]$plot$vintscen = vintscen$plot
...@@ -800,7 +800,7 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue ...@@ -800,7 +800,7 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue
output[["comparison"]]$plot$EJpassfuels_scen = EJpassfuels_scen$plot output[["comparison"]]$plot$EJpassfuels_scen = EJpassfuels_scen$plot
output[["comparison"]]$plot$salescom_scen = salescom_scen$plot output[["comparison"]]$plot$salescom_scen = salescom_scen$plot
output[["comparison"]]$plot$emipfos_scen = emip_scen$pfos output[["comparison"]]$plot$emipfos_scen = emip_scen$pfos
output[["comparison"]]$plot$emipel_scen = emip_scen$pel output[["comparison"]]$plot$emiptot_scen = emip_scen$ptot
...@@ -816,9 +816,9 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue ...@@ -816,9 +816,9 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue
names(legend$'Total Passenger Transport Energy Services Demand'$contents) <- ESmodeabs$vars names(legend$'Total Passenger Transport Energy Services Demand'$contents) <- ESmodeabs$vars
legend$'Total Passenger Transport Energy Services Demand'$description <- "<p>Energy services demand, passenger transport</p>" legend$'Total Passenger Transport Energy Services Demand'$description <- "<p>Energy services demand, passenger transport</p>"
legend$'Emissions passenger transport'$contents <- lapply(emip$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) }) legend$'Passenger transport emissions supply and demand'$contents <- lapply(emip$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) })
names(legend$'Emissions passenger transport'$contents) <- emip$vars names(legend$'Passenger transport emissions supply and demand'$contents) <- emip$vars
legend$'Emissions passenger transport'$description <- "<p>Emissions from fossil fuels and electricity production and use, passenger transport (international aviation excluded)<p>" legend$'Passenger transport emissions supply and demand'$description <- "<p>Passenger transport emissions supply and demand<p>"
legend$'Emission intensity of new sales'$description <- "CO<sub>2</sub> intensity of light duty vehicles sales, historical and projected values" legend$'Emission intensity of new sales'$description <- "CO<sub>2</sub> intensity of light duty vehicles sales, historical and projected values"
...@@ -857,13 +857,13 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue ...@@ -857,13 +857,13 @@ create_plotlist = function(scens, salescomp_all, fleet_all, ESmodecap_all, EJfue
names(legend$'Comparison of sales composition'$contents) <- salescom_scen$vars 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</p>" legend$'Comparison of sales composition'$description <- "<p>Composition of sales of light duty vehicles in selected years</p>"
legend$'Comparison of passenger transport fossil fuels emissions'$contents <- lapply(emip_scen$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) }) legend$'Comparison of passenger transport emissions supply and demand'$contents <- lapply(emip_scen$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) })
names(legend$'Comparison of passenger transport fossil fuels emissions'$contents) <- emip_scen$vars names(legend$'Comparison of passenger transport emissions supply and demand'$contents) <- emip_scen$vars
legend$'Comparison of passenger transport fossil fuels emissions'$description <- "<p>Emissions from fossil fuels production and use in passenger transport</p>" legend$'Comparison of passenger transport emissions supply and demand'$description <- "<p>Emissions from supply and demand, passenger transport (includes electricity-related, hydrogen-related, synfuels-related emissions)</p>"
legend$'Comparison of passenger electricity production emissions'$contents <- lapply(emip_scen$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) }) legend$'Comparison of passenger tailpipe emissions from fossil fuels'$contents <- lapply(emip_scen$vars, function(var) { return(list("fill"=toString(cols[var]),"linetype"=NULL)) })
names(legend$'Comparison of passenger electricity production emissions'$contents) <- emip_scen$vars names(legend$'Comparison of passenger tailpipe emissions from fossil fuels'$contents) <- emip_scen$vars
legend$'Comparison of passenger electricity production emissions'$description <- "<p>Emissions from electricity production and consumption in passenger transport</p>" legend$'Comparison of passenger tailpipe emissions from fossil fuels'$description <- "<p>Tailpipe emissions of passenger transport, derived from fossil fuels consumption</p>"
output$legend = legend output$legend = legend
return(output) return(output)
......
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