Skip to content
Snippets Groups Projects
Commit 8d1205ff authored by Ingram Jaccard's avatar Ingram Jaccard
Browse files

edit fig.5

parent 5fa5f1b5
No related branches found
No related tags found
No related merge requests found
File added
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
analysis/figures/unnamed-chunk-7-1.png

341 KiB

......@@ -453,23 +453,71 @@ pdat = pdat_int_co2eq %>%
bind_rows(pdat_int_energy) %>%
bind_rows(pdat_basket)
pdat$facet = factor(pdat$indicator, levels = c("Expenditure share (%)", "Energy intensity (MJ/€)", "Carbon intensity (kgCO2eq/€)"))
p1 = pdat_basket %>%
mutate(Decile = if_else(eu_q_rank<10, paste0("D0", eu_q_rank), paste0("D", eu_q_rank))) %>%
ggplot(aes(x=value, y=five_sectors, color=Decile)) +
#geom_point(shape=18, alpha=0.75) +
geom_text(label="I", alpha=0.75, fontface="bold") +
scale_color_viridis(option = "A", end = 0.8,
direction = -1,
discrete = T,
name="European\ndecile") +
theme_minimal() +
labs(x=unique(pdat_basket$indicator),y="")
a = ggplot(pdat, aes(x=value, y=five_sectors, color=eu_q_rank)) +
p2 = pdat_int_energy %>%
mutate(Decile = if_else(eu_q_rank<10, paste0("D0", eu_q_rank), paste0("D", eu_q_rank))) %>%
ggplot(aes(x=value, y=five_sectors, color=Decile)) +
#geom_point(shape=18, alpha=0.75) +
geom_text(label="I", alpha=0.75, fontface="bold") +
scale_colour_viridis_b(option = "A", end = 0.8,
direction = -1,
breaks = c(2,3,4,5,6,7,8,9),
#guide_legend(),
guide = guide_colorsteps(show.limits=TRUE),
name="European\ndecile") +
facet_wrap(~facet, scales="free_x",
strip.position="bottom") +
scale_color_viridis(option = "A", end = 0.8,
direction = -1,
discrete = T,
name="European\ndecile") +
theme_minimal() +
labs(x="",y="") +
theme(text=element_text(size=13, family="Liberation Sans Narrow"),
panel.spacing = unit(2.5, "lines"),
strip.placement="outside")
labs(x=unique(pdat_int_energy$indicator),y="")
p3 = pdat_int_co2eq %>%
mutate(Decile = if_else(eu_q_rank<10, paste0("D0", eu_q_rank), paste0("D", eu_q_rank))) %>%
ggplot(aes(x=value, y=five_sectors, color=Decile)) +
#geom_point(shape=18, alpha=0.75) +
geom_text(label="I", alpha=0.75, fontface="bold") +
scale_color_viridis(option = "A", end = 0.8,
direction = -1,
discrete = T,
name="European\ndecile") +
theme_minimal() +
labs(x=unique(pdat_int_co2eq$indicator),y="")
#plot_annotation(tag_levels = 'a')
a = (p1 + p2 + p3) +
plot_layout(guides = "collect") +
plot_annotation(tag_levels = 'a') &
theme(legend.position = 'bottom',
text=element_text(family="Liberation Sans Narrow"),
axis.title.y = element_text(size=13, hjust = 0.5),
axis.text.x = element_text(size = 12),
axis.text.y = element_text(size = 12),
legend.text = element_text(size=12),
legend.title = element_text(size=13))
#pdat$facet = factor(pdat$indicator, levels = c("Expenditure share (%)", "Energy intensity (MJ/€)", "Carbon intensity (kgCO2eq/€)"))
#a = ggplot(pdat, aes(x=value, y=five_sectors, color=eu_q_rank)) +
# geom_text(label="I", alpha=0.75, fontface="bold") +
# scale_colour_viridis_b(option = "A", end = 0.8,
# direction = -1,
# breaks = c(2,3,4,5,6,7,8,9),
# #guide_legend(),
# guide = guide_colorsteps(show.limits=TRUE),
# name="European\ndecile") +
# facet_wrap(~facet, scales="free_x",
# strip.position="bottom") +
# theme_minimal() +
# labs(x="",y="") +
# theme(text=element_text(size=13, family="Liberation Sans Narrow"),
# panel.spacing = unit(2.5, "lines"),
# strip.placement="outside")
ggsave(here("analysis", "figures", "figure2.pdf"), device=cairo_pdf)
```
......@@ -847,12 +895,6 @@ df_energy_deciles = pdat_final_demand %>%
ineq_curr = df_energy_deciles$pae_energy_use_gj[10]/df_energy_deciles$pae_energy_use_gj[1]
```
```{r }
library(readxl)
df_scenario_info = read_excel(here("analysis/data/raw/scenarios.xlsx"), sheet="overview") %>%
select(scenario, fe_gj_aeu = final_energy_gj_per_aeu_2050,
ccs_required = primary_energy_fossil_w_ccs2050_ej,
......@@ -861,17 +903,15 @@ df_scenario_info = read_excel(here("analysis/data/raw/scenarios.xlsx"), sheet="o
mutate(fe_gj_aeu = round(fe_gj_aeu),
ccs_required = round(ccs_required))
mea = c(min(df_scenario_info$fe_gj_aeu),max(df_scenario_info$fe_gj_aeu))
mer = c(min(df_scenario_info$fe_gj_aeu),53)
mea_seq = c(df_scenario_info$fe_gj_aeu, seq(from=50, to=300, by=50))
#mea = c(16,300)
mer = c(16,60)
c_mean_mea = round((27+mea[2])/2)
c_mean_mer = round((mer[1]+mer[2])/2)
```
```{r , eval = FALSE}
# run once to save file. If changing scenarios included or input data, need to re-run and save 'scenarios_fine.rds'
```{r eval=FALSE, calc-scenarios}
# vectorized function that returns scaled quantiles given
#quantile index column and column with quantile averages
......@@ -879,6 +919,7 @@ c_mean_mer = round((mer[1]+mer[2])/2)
#qavg_to_scale: column to scale
#first_target: target value of first quantile
#mean_target: target mean of scaled quantiles
scaled_quantiles <- function(.data,
qidx,
qavg_to_scale,
......@@ -911,8 +952,8 @@ scaled_quantiles <- function(.data,
## run once to save file
df_all = NULL
for (min_energy in seq(from=mer[1], to=mer[2], by=0.25)) {
for (mean_energy in seq(from=mea[1], to=mea[2], by=0.25)) {
for (min_energy in seq(from=mer[1], to=mer[2], by=0.1)) {
for (mean_energy in mea_seq) {
if (min_energy <= mean_energy) {
df_all = df_all %>%
bind_rows(df_energy_deciles %>%
......@@ -921,14 +962,16 @@ for (min_energy in seq(from=mer[1], to=mer[2], by=0.25)) {
}
}
saveRDS(df_all, here("analysis/data/derived/scenarios_fine.rds"))
saveRDS(df_all, here("analysis/data/derived/scenarios_extrafine.rds"))
```
```{r , fig.width=7, fig.height=5.5}
```{r}
round_by = 10
df_all = readRDS(here("analysis/data/derived/scenarios_fine.rds")) %>%
df_all = readRDS(here("analysis/data/derived/scenarios_extrafine.rds")) %>%
filter(eu_q_rank %in% c(1,10)) %>%
group_by(v_mean, v_first) %>%
summarise(ratio = last(scaled)/first(scaled)) %>%
......@@ -939,30 +982,50 @@ df_all = readRDS(here("analysis/data/derived/scenarios_fine.rds")) %>%
summarise(v_mean = mean(v_mean)) %>%
mutate(bin_ratio = bin_ratio*0.01)
```
```{r, fig.width=8, fig.height=4}
df_grid = df_all %>%
filter(!(v_mean %in% df_scenario_info$fe_gj_aeu))
df_scenario = df_all %>%
filter(v_mean %in% df_scenario_info$fe_gj_aeu) %>%
left_join(df_scenario_info, by=c("v_mean"="fe_gj_aeu"))
library(wesanderson)
a = df_all %>%
ggplot(aes(x=v_first, y=bin_ratio, fill=v_mean)) +
geom_tile() +
geom_hline(yintercept = ineq_curr, alpha=0.8, color="grey", linetype=2) +
geom_line(data=df_scenario, aes(color=scenario, group=scenario)) +
annotate(geom="text", x=max(df_all$v_first)-5.7,y=ineq_curr+0.6,label = "Current (2015) 10:10 ratio") +
#scale_fill_viridis("Mean energy\navailable") +
scale_fill_gradient("Average energy\navailable (GJ/ae)",
low=wes_palette("Chevalier1")[3],
high = wes_palette("Rushmore1")[4]) +
scale_color_manual(values=wes_palette("Darjeeling1")) +
filter((v_mean %in% df_scenario_info$fe_gj_aeu))
df_dle = tibble(bin_ratio = 1, v_first = 16, v_mean = 16)
scenario_label = df_scenario_info %>%
mutate(labl = paste0(scenario, " (", fe_gj_aeu, ")")) %>%
pull(labl)
library(ggsci)
a = df_grid %>%
ggplot(aes(x=v_first, y=bin_ratio, group=v_mean)) +
geom_smooth(aes(linetype="Maximum energy\nsupply (GJ/ae)"), se=FALSE, color="grey", size=0.5) +
scale_linetype_manual(name="", values = c(2)) +
geom_smooth(data=df_scenario, aes(color=factor(v_mean)), se=FALSE) +
geom_point(data=df_dle, aes(color=factor(v_mean))) +
geom_hline(yintercept = ineq_curr, color="grey") +
annotate(geom="text",x=56,y=12,label="300", angle=-35, size=3, color="grey32") +
annotate(geom="text",x=46,y=9.5,label="200", angle=-35, size=3, color="grey32") +
annotate(geom="text",x=33.5,y=6,label="100", angle=-35, size=3, color="grey32") +
annotate(geom="text",x=60,y=ineq_curr-0.28,
label="energy use inequality 2015", size=3.75, hjust=1, color="grey40") +
scale_color_npg(
name = "Scenario",
labels = scenario_label) +
lims(x=c(15.5,60), y=c(1,13)) +
labs(x= "Minimum energy use (GJ/ae)", y="Max. possible energy use inequality (10:10 ratio)") +
theme_minimal() +
labs(x="Minimum energy requirement (GJ/ae)", y="Maximum energy inequality (10:10 ratio)", color = "Scenario")+
theme(text=element_text(family="Liberation Sans Narrow"),
axis.text.x = element_text(size = 13),
axis.text.y = element_text(size = 13)) +
scale_y_continuous(breaks = c(2.5,5,7.5,10,12.5)) # +
#theme_ipsum()
axis.title.y = element_text(size=13, hjust = 0.5),
axis.text.x = element_text(size = 12),
axis.text.y = element_text(size = 12),
legend.text = element_text(size=12),
legend.title = element_text(size=13))
ggsave(here("analysis", "figures", "figure5.pdf"))
```
......
No preview for this file type
......@@ -76,6 +76,7 @@ pacman::p_load(tidyverse,
ggridges,
patchwork,
kableExtra,
readxl,
flextable)
pal <- wes_palette("Cavalcanti1", 5, type = "discrete")
......@@ -2080,12 +2081,6 @@ df_energy_deciles = pdat_final_demand %>%
ineq_curr = df_energy_deciles$pc_energy_use_gj[10]/df_energy_deciles$pc_energy_use_gj[1]
```
```{r }
library(readxl)
df_scenario_info = read_excel(here("analysis/data/raw/scenarios_additions.xlsx"), sheet="overview") %>%
select(scenario, fe_gj_pc = final_energy_gj_per_capita_2050,
ccs_required = primary_energy_fossil_w_ccs2050_ej,
......@@ -2095,17 +2090,13 @@ df_scenario_info = read_excel(here("analysis/data/raw/scenarios_additions.xlsx")
fe_gj_pc = round(fe_gj_pc),
ccs_required = round(ccs_required))
mea = c(min(df_scenario_info$fe_gj_pc),max(df_scenario_info$fe_gj_pc))
mer = c(min(df_scenario_info$fe_gj_pc),53) #before was 33: multiplied 53 by 0.63 and rounded up
c_mean_mea = round((17+mea[2])/2) #multiplied 27 by 0.63 and rounded up
c_mean_mer = round((mer[1]+mer[2])/2)
mea_seq = c(df_scenario_info$fe_gj_pc, seq(from=50, to=300, by=50))
#mea = c(16,300)
mer = c(16,60)
```
```{r , eval = FALSE}
# run once to save file. If changing scenarios included or input data, need to re-run and save 'scenarios_fine.rds'
```{r eval=FALSE, calc-scenarios}
# vectorized function that returns scaled quantiles given
#quantile index column and column with quantile averages
......@@ -2113,6 +2104,7 @@ c_mean_mer = round((mer[1]+mer[2])/2)
#qavg_to_scale: column to scale
#first_target: target value of first quantile
#mean_target: target mean of scaled quantiles
scaled_quantiles <- function(.data,
qidx,
qavg_to_scale,
......@@ -2145,8 +2137,8 @@ scaled_quantiles <- function(.data,
## run once to save file
df_all = NULL
for (min_energy in seq(from=mer[1], to=mer[2], by=0.25)) {
for (mean_energy in seq(from=mea[1], to=mea[2], by=0.25)) {
for (min_energy in seq(from=mer[1], to=mer[2], by=0.1)) {
for (mean_energy in mea_seq) {
if (min_energy <= mean_energy) {
df_all = df_all %>%
bind_rows(df_energy_deciles %>%
......@@ -2155,14 +2147,15 @@ for (min_energy in seq(from=mer[1], to=mer[2], by=0.25)) {
}
}
saveRDS(df_all, here("analysis/data/derived/si/scenarios_fine.rds"))
saveRDS(df_all, here("analysis/data/derived/si/scenarios_extrafine.rds"))
```
```{r , fig.width=7, fig.height=5.5, fig.cap="***Figure S7: Mean energy available for Europe in decarbonisation scenarios, positioned in option space between a range of minimum energy requirements and range of associated maximum inequality. All expenditure deciles have 'best technology' already. Unit of analysis is household GJ per capita. Final energy (in household GJ per capita in 2050) from two more SSP scenarios (which do not necessarily hit the 1.5°C target) are added from the IIASA scenario database [@riahi_shared_2017] for comparison: SSP3-3.4 (MESSAGE-GLOBIOM, OECD), SSP4-1.9 (WITCH-GLOBIOM, OECD).***"}
```{r}
round_by = 10
df_all = readRDS(here("analysis/data/derived/si/scenarios_fine.rds")) %>%
df_all = readRDS(here("analysis/data/derived/si/scenarios_extrafine.rds")) %>%
filter(eu_q_rank %in% c(1,10)) %>%
group_by(v_mean, v_first) %>%
summarise(ratio = last(scaled)/first(scaled)) %>%
......@@ -2173,51 +2166,49 @@ df_all = readRDS(here("analysis/data/derived/si/scenarios_fine.rds")) %>%
summarise(v_mean = mean(v_mean)) %>%
mutate(bin_ratio = bin_ratio*0.01)
```
```{r, fig.width=8, fig.height=4}
df_grid = df_all %>%
filter(!(v_mean %in% df_scenario_info$fe_gj_pc))
df_scenario = df_all %>%
filter(v_mean %in% df_scenario_info$fe_gj_pc) %>%
left_join(df_scenario_info, by=c("v_mean"="fe_gj_pc")) %>%
filter(!(scenario == "DLE")) %>%
mutate(scenario = dplyr::recode(scenario,
"LED" = "LED (33)",
"IEA ETP B2DS" = "IEA ETP B2DS (52)",
"GEA efficiency" = "GEA efficiency (40)",
"SSP1-1.9" = "SSP1-1.9 (54)",
"SSP2-1.9" = "SSP2-1.9 (58)",
"SSP4-1.9" = "SSP4-1.9 (64)",
"SSP3-3.4" = "SSP3-3.4 (90)",
"SSP5-6.0" = "SSP5-6.0 (94)"))
library(wesanderson)
a = df_all %>%
ggplot(aes(x=v_first, y=bin_ratio, fill=v_mean)) +
#geom_tile() +
geom_hline(yintercept = ineq_curr, alpha=0.8, color="grey", linetype=2) +
geom_line(data=df_scenario, aes(color=scenario, group=scenario)) +
annotate(geom="text", x=max(df_all$v_first)-7.5,y=ineq_curr+0.6,label = "Current (2015) 10:10 ratio") +
#scale_fill_viridis("Mean energy\navailable") +
#scale_fill_gradient("Mean energy\navailable (GJ/cap)",
# low=wes_palette("Chevalier1")[3],
# high = wes_palette("Rushmore1")[4]) +
#scale_color_manual(values=wes_palette("Darjeeling1")) +
filter((v_mean %in% df_scenario_info$fe_gj_pc))
df_dle = tibble(bin_ratio = 1, v_first = 16, v_mean = 16)
scenario_label = df_scenario_info %>%
mutate(labl = paste0(scenario, " (", fe_gj_pc, ")")) %>%
pull(labl)
library(ggsci)
a = df_grid %>%
ggplot(aes(x=v_first, y=bin_ratio, group=v_mean)) +
geom_smooth(aes(linetype="Maximum energy\nsupply (GJ/cap)"), se=FALSE, color="grey", size=0.5) +
scale_linetype_manual(name="", values = c(2)) +
geom_smooth(data=df_scenario, aes(color=factor(v_mean)), se=FALSE) +
geom_point(data=df_dle, aes(color=factor(v_mean))) +
geom_hline(yintercept = ineq_curr, color="grey") +
annotate(geom="text",x=56,y=12,label="300", angle=-35, size=3, color="grey32") +
annotate(geom="text",x=46,y=9.5,label="200", angle=-35, size=3, color="grey32") +
annotate(geom="text",x=33.5,y=6,label="100", angle=-35, size=3, color="grey32") +
annotate(geom="text",x=60,y=ineq_curr-0.28,
label="energy use inequality 2015", size=3.75, hjust=1, color="grey40") +
scale_color_npg(
name = "Scenario",
labels = scenario_label) +
lims(x=c(15.5,60), y=c(1,13)) +
labs(x= "Minimum energy use (GJ/cap)", y="Max. possible energy use inequality (10:10 ratio)") +
theme_minimal() +
labs(x="Minimum energy requirement (GJ/cap)", y="Maximum energy inequality (10:10 ratio)", color = "Scenario")+
theme(text=element_text(family="Liberation Sans Narrow"),
axis.text.x = element_text(size = 13),
axis.text.y = element_text(size = 13)) +
#scale_color_discrete(name = "Scenario (mean GJ/cap)") +
xlim(10,53) +
#ylim(0,15) +
scale_y_continuous(breaks = c(2.5,5,7.5,10,12.5,15), limits = c(1,15)) +
scale_color_discrete(name = "Scenario\n(mean GJ/cap)", breaks=c("LED (33)",
"GEA efficiency (40)",
"IEA ETP B2DS (52)",
"SSP1-1.9 (54)",
"SSP2-1.9 (58)",
"SSP4-1.9 (64)",
"SSP3-3.4 (90)",
"SSP5-6.0 (94)")) #+
#theme_ipsum()
axis.title.y = element_text(size=13, hjust = 0.5),
axis.text.x = element_text(size = 12),
axis.text.y = element_text(size = 12),
legend.text = element_text(size=12),
legend.title = element_text(size=13))
a
ggsave(here("analysis", "figures", "figureS7.pdf"))
```
......
No preview for this file type
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