From b449a59acbe057c4e28073c70e6ee3d003121fb5 Mon Sep 17 00:00:00 2001 From: Antoine LALECHERE Date: Mon, 27 May 2024 14:40:45 +0200 Subject: [PATCH 1/4] update weighting for the Aggregate score based on WEO2023 --- data-raw/remaining_carbon_budgets.R | 54 ++++++++++++++++++++++------ data/remaining_carbon_budgets.rda | Bin 454 -> 494 bytes 2 files changed, 44 insertions(+), 10 deletions(-) diff --git a/data-raw/remaining_carbon_budgets.R b/data-raw/remaining_carbon_budgets.R index 54e602bb..16544c25 100644 --- a/data-raw/remaining_carbon_budgets.R +++ b/data-raw/remaining_carbon_budgets.R @@ -1,15 +1,49 @@ # styler: off -remaining_carbon_budgets <- tibble::tribble( - ~scenario_source, ~ald_sector, ~remaining_carbon_budget, ~unit, ~weighting_factor, - "GECO2021", "coal", 84934.79, "Mt CO2 (2019)", 0.25, - "GECO2021", "oil", 82987.79, "Mt CO2 (2019)", 0.24, - "GECO2021", "gas", 49094.21, "Mt CO2 (2019)", 0.14, - "GECO2021", "power", 91121.17, "Mt CO2 (2019)", 0.27, - "GECO2021", "steel", 10746.03, "Mt CO2 (2019)", 0.03, - "GECO2021", "automotive", 11338.9, "Mt CO2 (2019)", 0.03, - "GECO2021", "hdv", 7388.01, "Mt CO2 (2019)", 0.02, - "GECO2021", "aviation", 5963.32, "Mt CO2 (2019)", 0.02 +carbon_emissions <- read_xlsx("/Users/antoinelalechere/Library/CloudStorage/OneDrive-RMI/PACTA_Documents/General Projects/Scenarios/IEA WEO/WEO 2023 Extended Data/WEO2023_Extended_Data.xlsx", + sheet = "World CO2 Emissions", + range = "J7:AP45") %>% + select(-c("2022...5", "2030...6", "2035...7", "2040...8", "2045...9", "2050...10", "...11", "2030...12", "2050...13", + "2022...15", "2030...16", "2035...17", "2040...18", "2045...19", "2050...20", "...21", "2030...22", "2050...23", "...24", + "...31", "2030...32", "2050...33", "...14")) %>% + rename( + sector = "...1", + emissions_2022 = "2022...25", + emissions_2030 = "2030...26", + emissions_2035 = "2035...27", + emissions_2040 = "2040...28", + emissions_2045 = "2045...29", + emissions_2050 = "2050...30", + ) %>% + filter(sector %in% c("Coal", "Oil", "Natural gas", "Electricity and heat sectors", "Iron and steel**", "Cement**", "Passenger cars", "Aviation")) %>% + mutate( + scenario_source = "WEO2023", + unit = "Mt CO2 (2022)" ) + +carbon_emissions <- carbon_emissions[-5,] +carbon_emissions <- carbon_emissions[-5,] +carbon_emissions <- carbon_emissions[-5,] +carbon_emissions <- carbon_emissions[-5,] +carbon_emissions <- carbon_emissions[-5,] +carbon_emissions <- carbon_emissions[-5,] + + +remaining_carbon_budgets <- carbon_emissions %>% + mutate( + remaining_carbon_budget = emissions_2022 * 4 + emissions_2030 * 4, # remaining carbon dbusget is the interpolized carbon budget until 2030 for a sector + weighting_factor = remaining_carbon_budget/ sum(remaining_carbon_budget) + ) %>% + mutate(ald_sector = case_when( + sector == "Coal" ~ "coal", + sector == "Oil" ~ "oil", + sector == "Natural gas" ~ "gas", + sector == "Electricity and heat sectors" ~ "power", + sector == "Iron and steel**" ~ "steel", + sector == "Passenger cars" ~ "automotive", + sector == "Aviation" ~ "aviation", + sector == "Cement**" ~ "cement" + )) %>% + select("scenario_source", "unit", "remaining_carbon_budget", "weighting_factor", "ald_sector") # styler: on usethis::use_data(remaining_carbon_budgets, overwrite = TRUE) diff --git a/data/remaining_carbon_budgets.rda b/data/remaining_carbon_budgets.rda index 7749ab556321f668a69691330bd3cb823b58ef98..c07a81ed5cdb75115b571d5460d91e21f31c5710 100644 GIT binary patch literal 494 zcmVbn`2Ybj|NsB<%)`K8SOea|w9&uk|IlU>7zS9e0Z=fa z(vC1KpUbcTcuYYmnklqp8fX9-000^^0BF$A0MHFI^#ee}+K*GkJfLc)=s_ptHm0YF zZ9o7300E#hGynr5Lq>oA00fkT$}uuxXfyx-003w-000004FCb4Xdl3Z1w6tVZ3!_# z8b(6^$B@%zygGLl2kwMKrkJKm%WVQt*eOOe90$bP&c}q4&phs9(NcCJgRnx0fGGfh zfG7-2uqC(+F@tOYEoLMO4q0g0OTB`NGpCo?@YW9Hlkg(}a05Vd=IpisFRnI74gr1w zU}yj+1*%x@#vpcmu;z5C7(ZLTn^9A_RoI|$cegAFaLFKXfq(@Rq;OaPZOdmNDTbOR zF_9&KMfKJuh*@>mgB3z3oF))9#Jvep@tjmy;rF?cyo9VW8bJrgf;$E;TDb zZ;0kOHil=1PH;p)vGzg8SZ*MI#%?-JkYMx+pqb7ns+|j&H2bY6oJ87SXwn&blmNsP zsi2BCVH8k`<{43Yo@yE4Iwz}%u+uZ5NAj$8kLxg!UANn2f%4QS`ia5nOjeQy+#)pd kagkc`)SOAzsh{nX{P+h?^yq!UfJct0%gHumaYBYLBs5DI}>SIQT3FQg_QC)Ns+a=O9~Ewv2jQzgiJfeM0ZfW@Cc!=+FpVT> z0tNwYGIIlgnU~YB1q&eprS_(|2;$84PAww{2*6yL1RS7t+QR`(0yF?l0f2BB$@jqD zQ0z=P+ecgV=@LBY4>}zHI{>ZR1Hea(7`j060JO0c=h}(l0Kfa1Q4~S;e*IpR)rqNzFtCWtH)BM&!x~V+Ad*QfjEVmjaz!{$kk;dvBMxxJE&u=k From 98f2c2885b0c149c1e47b741f3caa572d535d13c Mon Sep 17 00:00:00 2001 From: MonikaFu Date: Wed, 29 May 2024 17:36:36 +0200 Subject: [PATCH 2/4] Anonymize path and point to azure location --- data-raw/remaining_carbon_budgets.R | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/data-raw/remaining_carbon_budgets.R b/data-raw/remaining_carbon_budgets.R index 16544c25..3ce1a855 100644 --- a/data-raw/remaining_carbon_budgets.R +++ b/data-raw/remaining_carbon_budgets.R @@ -1,5 +1,11 @@ # styler: off -carbon_emissions <- read_xlsx("/Users/antoinelalechere/Library/CloudStorage/OneDrive-RMI/PACTA_Documents/General Projects/Scenarios/IEA WEO/WEO 2023 Extended Data/WEO2023_Extended_Data.xlsx", +# The Extended file data for WEO 2023 is stored here: +# https://portal.azure.com/#view/Microsoft_Azure_FileStorage/FileShareMenuBlade/~/browse/storageAccountId/%2Fsubscriptions%2Ffeef729b-4584-44af-a0f9-4827075512f9%2FresourceGroups%2FRMI-SP-PACTA-PROD%2Fproviders%2FMicrosoft.Storage%2FstorageAccounts%2Fpactarawdata/path/scenario-sources/protocol/SMB +# The specific file is 'weo_2023-20240222/WEO2023 extended data/WEO2023_Extended_Data.xlsx' +# Please download the file and replace the dummy path in variable 'file_scenario_emissions_data' +# to the path on your computer before running the code. +file_scenario_emissions_data <- "PATH/TO/WEO2023/SCENARIO/EXTENDED/DATA" +carbon_emissions <- read_xlsx(file_scenario_emissions_data, sheet = "World CO2 Emissions", range = "J7:AP45") %>% select(-c("2022...5", "2030...6", "2035...7", "2040...8", "2045...9", "2050...10", "...11", "2030...12", "2050...13", From e41258cffed49aff70bb55b6d9e478518f0ac71f Mon Sep 17 00:00:00 2001 From: MonikaFu Date: Thu, 30 May 2024 12:02:33 +0200 Subject: [PATCH 3/4] Refactor --- data-raw/remaining_carbon_budgets.R | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/data-raw/remaining_carbon_budgets.R b/data-raw/remaining_carbon_budgets.R index 3ce1a855..9fb33cf7 100644 --- a/data-raw/remaining_carbon_budgets.R +++ b/data-raw/remaining_carbon_budgets.R @@ -5,12 +5,10 @@ # Please download the file and replace the dummy path in variable 'file_scenario_emissions_data' # to the path on your computer before running the code. file_scenario_emissions_data <- "PATH/TO/WEO2023/SCENARIO/EXTENDED/DATA" -carbon_emissions <- read_xlsx(file_scenario_emissions_data, +carbon_emissions <- readxl::read_xlsx(file_scenario_emissions_data, sheet = "World CO2 Emissions", range = "J7:AP45") %>% - select(-c("2022...5", "2030...6", "2035...7", "2040...8", "2045...9", "2050...10", "...11", "2030...12", "2050...13", - "2022...15", "2030...16", "2035...17", "2040...18", "2045...19", "2050...20", "...21", "2030...22", "2050...23", "...24", - "...31", "2030...32", "2050...33", "...14")) %>% + filter(!row_number() %in% c(12, 13, 14, 18, 19, 20)) %>% rename( sector = "...1", emissions_2022 = "2022...25", @@ -20,20 +18,13 @@ carbon_emissions <- read_xlsx(file_scenario_emissions_data, emissions_2045 = "2045...29", emissions_2050 = "2050...30", ) %>% + select(c("sector", "2010", "2015", "2021", "emissions_2022", "emissions_2030", "emissions_2035", "emissions_2040", "emissions_2045", "emissions_2050")) %>% filter(sector %in% c("Coal", "Oil", "Natural gas", "Electricity and heat sectors", "Iron and steel**", "Cement**", "Passenger cars", "Aviation")) %>% mutate( scenario_source = "WEO2023", unit = "Mt CO2 (2022)" ) -carbon_emissions <- carbon_emissions[-5,] -carbon_emissions <- carbon_emissions[-5,] -carbon_emissions <- carbon_emissions[-5,] -carbon_emissions <- carbon_emissions[-5,] -carbon_emissions <- carbon_emissions[-5,] -carbon_emissions <- carbon_emissions[-5,] - - remaining_carbon_budgets <- carbon_emissions %>% mutate( remaining_carbon_budget = emissions_2022 * 4 + emissions_2030 * 4, # remaining carbon dbusget is the interpolized carbon budget until 2030 for a sector From 9740ede2af90c05d5fb4062193b38c71680f6404 Mon Sep 17 00:00:00 2001 From: MonikaFu Date: Thu, 30 May 2024 16:40:05 +0200 Subject: [PATCH 4/4] Update calculations and comment --- data-raw/remaining_carbon_budgets.R | 6 +++++- data/remaining_carbon_budgets.rda | Bin 494 -> 496 bytes 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/data-raw/remaining_carbon_budgets.R b/data-raw/remaining_carbon_budgets.R index 9fb33cf7..654b0ec0 100644 --- a/data-raw/remaining_carbon_budgets.R +++ b/data-raw/remaining_carbon_budgets.R @@ -27,7 +27,11 @@ carbon_emissions <- readxl::read_xlsx(file_scenario_emissions_data, remaining_carbon_budgets <- carbon_emissions %>% mutate( - remaining_carbon_budget = emissions_2022 * 4 + emissions_2030 * 4, # remaining carbon dbusget is the interpolized carbon budget until 2030 for a sector + # Remaining carbon budget for a sector is the sum of scenario emissions from 2022 until 2030. + # We interpolate the emissions linearly between points for which we have scenario values (2022 and 2030). + # The sum of 7 linearly interpolated points between x and y (including x and y) is equal to 4x + 5y: + # x + 7*x + ((1 + 2 + 3 + 4 + 5 + 6 + 7)/7)*(y-x) + y = 8x + 5y - 4x = 4x + 5y + remaining_carbon_budget = emissions_2022 * 4 + emissions_2030 * 5, weighting_factor = remaining_carbon_budget/ sum(remaining_carbon_budget) ) %>% mutate(ald_sector = case_when( diff --git a/data/remaining_carbon_budgets.rda b/data/remaining_carbon_budgets.rda index c07a81ed5cdb75115b571d5460d91e21f31c5710..28013c30c73d718f28e93bb440634f206955ee09 100644 GIT binary patch literal 496 zcmVG0iXt=v>`)& zbs(t`tPvF-7>0_0zf{JbllCwY9#`z9qCr&sktL!Clu9InLZTCd)6UStM0w|()p{Z$ zufQFg3RM9q!2wVbI-^t?3aT+t1QI{CT&6~GIKEgQMeUcv17TYP2f(A57!5Z7S#vew zH~|(&3E+~pG^%dFCD>@LpD|7YhD<>4uau}C ziKt;M47RG4Lr(_SDI=ORAq6NQ2pIuSnDGRb7&}NR0|CcZJE0^CNh@0oa===Cp?ZKR>KHR%uM mLwq}3?t%3x#_Ch3>_{rT9WSrv!t99%{}*yaI8cyddIS2a4a7hI literal 494 zcmVbn`2Ybj|NsB<%)`K8SOea|w9&uk|IlU>7zS9e0Z=fa z(vC1KpUbcTcuYYmnklqp8fX9-000^^0BF$A0MHFI^#ee}+K*GkJfLc)=s_ptHm0YF zZ9o7300E#hGynr5Lq>oA00fkT$}uuxXfyx-003w-000004FCb4Xdl3Z1w6tVZ3!_# z8b(6^$B@%zygGLl2kwMKrkJKm%WVQt*eOOe90$bP&c}q4&phs9(NcCJgRnx0fGGfh zfG7-2uqC(+F@tOYEoLMO4q0g0OTB`NGpCo?@YW9Hlkg(}a05Vd=IpisFRnI74gr1w zU}yj+1*%x@#vpcmu;z5C7(ZLTn^9A_RoI|$cegAFaLFKXfq(@Rq;OaPZOdmNDTbOR zF_9&KMfKJuh*@>mgB3z3oF))9#Jvep@tjmy;rF?cyo9VW8bJrgf;$E;TDb zZ;0kOHil=1PH;p)vGzg8SZ*MI#%?-JkYMx+pqb7ns+|j&H2bY6oJ87SXwn&blmNsP zsi2BCVH8k`<{43Yo@yE4Iwz}%u+uZ5NAj$8kLxg!UANn2f%4QS`ia5nOjeQy+#)pd kagkc`)SOAzsh{nX{P+h?^yq!Uf