Skip to content

Commit

Permalink
Merge pull request #393 from GermanZero-de/methodology_year_ref
Browse files Browse the repository at this point in the history
Methodology: use year_ref instead of 2018
  • Loading branch information
bgrundmann authored May 14, 2024
2 parents e231ceb + 8ea078a commit 305a6b8
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 70 deletions.
61 changes: 31 additions & 30 deletions src/climatevision/generator/methodology183x.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,18 +215,19 @@ def calc_budget(
m183X.GHG_budget_2016_to_year_target - m183X.nonCO2_budget_2016_to_year_target
)

############################################
### 2018 as base for emissions 2016-2021 ###
############################################
### beginning with LULUCF ###
############################################
################################################
### year_ref as base for emissions 2016-2021 ###
################################################
### beginning with LULUCF ###
################################################
start_year = 2015
current_year = 2022
year_ref = entries.m_year_ref

years_list = list(range(start_year, current_year))

years_list_wo_2018 = years_list.copy()
years_list_wo_2018.remove(2018)
years_list_wo_year_ref = years_list.copy()
years_list_wo_year_ref.remove(year_ref)

years_list_wo_2015 = years_list.copy()
years_list_wo_2015.remove(2015)
Expand All @@ -237,25 +238,25 @@ def calc_budget(

years_dict: dict[int, dict[str, float]] = {year: {} for year in years_list}

# get the CO2e of LULUCF for 2018 as calculated
years_dict[2018]["CO2e_lulucf"] = l18.l.CO2e_total
# get the CO2e of LULUCF for year_ref as calculated
years_dict[year_ref]["CO2e_lulucf"] = l18.l.CO2e_total

# calculate the CO2e of LULUCF for 2015-2017 and 2019-2021 by multiplying 2018's value with percentage
# calculate the CO2e of LULUCF for 2015-2021 by multiplying year_ref's value with percentage
# 2015 just as a backup, probably not needed

for year in years_list_wo_2018:
years_dict[year]["CO2e_lulucf"] = years_dict[2018]["CO2e_lulucf"] * fact(
for year in years_list_wo_year_ref:
years_dict[year]["CO2e_lulucf"] = years_dict[year_ref]["CO2e_lulucf"] * fact(
f"Fact_M_CO2e_lulucf_{year}_vs_year_ref"
)

############################################
### 2018 as base for emissions 2016-2021 ###
############################################
### second emissions without (wo) LULUCF ###
############################################
################################################
### year_ref as base for emissions 2016-2021 ###
################################################
### second emissions without (wo) LULUCF ###
################################################

# get the CO2e of all sectors for 2018 excluding LULUCF since this is negative
years_dict[2018]["CO2e_wo_lulucf"] = (
# get the CO2e of all sectors for year_ref excluding LULUCF since this is negative
years_dict[year_ref]["CO2e_wo_lulucf"] = (
h18.h.CO2e_total
+ e18.e.CO2e_total
+ f18.f.CO2e_total
Expand All @@ -267,20 +268,20 @@ def calc_budget(
+ w18.w.CO2e_total
)

# calculate the CO2e of all sectors without LULUCF for 2015-2017 and 2019-2021 by multiplying 2018's value with percentage
# calculate the CO2e of all sectors without LULUCF for 2015-2021 by multiplying year_ref's value with percentage
# 2015 just as a backup, probably not needed
for year in years_list_wo_2018:
years_dict[year]["CO2e_wo_lulucf"] = years_dict[2018]["CO2e_wo_lulucf"] * fact(
f"Fact_M_CO2e_wo_lulucf_{year}_vs_year_ref"
)
for year in years_list_wo_year_ref:
years_dict[year]["CO2e_wo_lulucf"] = years_dict[year_ref][
"CO2e_wo_lulucf"
] * fact(f"Fact_M_CO2e_wo_lulucf_{year}_vs_year_ref")

#############################################
### 2018 as base for emissions 2016-2021 ###
#############################################
### sum up CO2e_wo_lulucf and CO2e_lulucf ###
#############################################
#################################################
### year_ref as base for emissions 2016-2021 ###
#################################################
### sum up CO2e_wo_lulucf and CO2e_lulucf ###
#################################################

# 2015 just as a backup, probably not
# 2015 just as a backup, probably not needed
for year in years_list:
years_dict[year]["CO2e_w_lulucf"] = (
years_dict[year]["CO2e_wo_lulucf"] + years_dict[year]["CO2e_lulucf"]
Expand Down
12 changes: 6 additions & 6 deletions tests/end_to_end_expected/2021/production_03159016_2021.json
Original file line number Diff line number Diff line change
Expand Up @@ -8658,27 +8658,27 @@
"CO2_budget_2016_to_year_target": 9143826.171654996,
"nonCO2_budget_2016_to_year_target": 895482.7628942638,
"GHG_budget_2016_to_year_target": 10039308.934549259,
"GHG_budget_2022_to_year_target": 4920930.787394831,
"GHG_budget_after_year_target": 4920930.787394831,
"GHG_budget_2022_to_year_target": 4862241.791617478,
"GHG_budget_after_year_target": 4862241.791617478,
"CO2e_w_lulucf_change_pa": 826840.0490109223,
"CO2e_lulucf_2015": -5958.902110823803,
"CO2e_lulucf_2016": -6190.890844896049,
"CO2e_lulucf_2017": -6336.192299348214,
"CO2e_lulucf_2018": -5095.114271193101,
"CO2e_lulucf_2018": -5641.151584102509,
"CO2e_lulucf_2019": -5079.072497028531,
"CO2e_lulucf_2020": -5095.114271193101,
"CO2e_lulucf_2021": -5095.114271193101,
"CO2e_wo_lulucf_2015": 941536.113416536,
"CO2e_wo_lulucf_2016": 945394.8765143125,
"CO2e_wo_lulucf_2017": 928847.800650884,
"CO2e_wo_lulucf_2018": 831935.1632821154,
"CO2e_wo_lulucf_2018": 891170.1963723776,
"CO2e_wo_lulucf_2019": 843179.3032424201,
"CO2e_wo_lulucf_2020": 769977.3386374316,
"CO2e_wo_lulucf_2021": 831935.1632821154,
"CO2e_w_lulucf_2015": 935577.2113057122,
"CO2e_w_lulucf_2016": 939203.9856694164,
"CO2e_w_lulucf_2017": 922511.6083515359,
"CO2e_w_lulucf_2018": 826840.0490109223,
"CO2e_w_lulucf_2018": 885529.044788275,
"CO2e_w_lulucf_2019": 838100.2307453916,
"CO2e_w_lulucf_2020": 764882.2243662386,
"CO2e_w_lulucf_2021": 826840.0490109223,
Expand Down Expand Up @@ -8715,7 +8715,7 @@
"CO2e_lulucf_203X": -15449.48537350322,
"CO2e_wo_lulucf_203X": 15449.48537350322,
"CO2e_w_lulucf_203X": 0.0,
"change_CO2e_t": -826840.0490109223,
"change_CO2e_t": -885529.044788275,
"change_CO2e_pct": -1.0,
"cost_climate_saved": 4595669779.548696,
"z": {
Expand Down
14 changes: 7 additions & 7 deletions tests/end_to_end_expected/2021/production_03159016_2025.json
Original file line number Diff line number Diff line change
Expand Up @@ -8658,27 +8658,27 @@
"CO2_budget_2016_to_year_target": 9143826.172232216,
"nonCO2_budget_2016_to_year_target": 1372104.9310517074,
"GHG_budget_2016_to_year_target": 10515931.103283923,
"GHG_budget_2022_to_year_target": 5397552.956129497,
"GHG_budget_after_year_target": 3743872.858107652,
"GHG_budget_2022_to_year_target": 5338863.960352144,
"GHG_budget_after_year_target": 3685183.862330299,
"CO2e_w_lulucf_change_pa": 165368.00980218448,
"CO2e_lulucf_2015": -5958.902110823803,
"CO2e_lulucf_2016": -6190.890844896049,
"CO2e_lulucf_2017": -6336.192299348214,
"CO2e_lulucf_2018": -5095.114271193101,
"CO2e_lulucf_2018": -5641.151584102509,
"CO2e_lulucf_2019": -5079.072497028531,
"CO2e_lulucf_2020": -5095.114271193101,
"CO2e_lulucf_2021": -5095.114271193101,
"CO2e_wo_lulucf_2015": 941536.113416536,
"CO2e_wo_lulucf_2016": 945394.8765143125,
"CO2e_wo_lulucf_2017": 928847.800650884,
"CO2e_wo_lulucf_2018": 831935.1632821154,
"CO2e_wo_lulucf_2018": 891170.1963723776,
"CO2e_wo_lulucf_2019": 843179.3032424201,
"CO2e_wo_lulucf_2020": 769977.3386374316,
"CO2e_wo_lulucf_2021": 831935.1632821154,
"CO2e_w_lulucf_2015": 935577.2113057122,
"CO2e_w_lulucf_2016": 939203.9856694164,
"CO2e_w_lulucf_2017": 922511.6083515359,
"CO2e_w_lulucf_2018": 826840.0490109223,
"CO2e_w_lulucf_2018": 885529.044788275,
"CO2e_w_lulucf_2019": 838100.2307453916,
"CO2e_w_lulucf_2020": 764882.2243662386,
"CO2e_w_lulucf_2021": 826840.0490109223,
Expand Down Expand Up @@ -8715,7 +8715,7 @@
"CO2e_lulucf_203X": -15449.48537350322,
"CO2e_wo_lulucf_203X": 15449.48537350322,
"CO2e_w_lulucf_203X": 0.0,
"change_CO2e_t": -826840.0490109223,
"change_CO2e_t": -885529.044788275,
"change_CO2e_pct": -1.0,
"cost_climate_saved": 4273166637.124225,
"z": {
Expand Down Expand Up @@ -9184,7 +9184,7 @@
"CO2e_per_capita_com": 6.901779192251503,
"CO2e_per_capita_com_pct_of_nat": 0.6840706071610158,
"GHG_budget_2022_to_year_target_nat": 2391448453.0,
"CO2e_2022_to_year_target": 1653680.0980218449
"CO2e_2022_to_year_target": 1653680.0980218453
},
"bisko": {
"priv_residences": {
Expand Down
12 changes: 6 additions & 6 deletions tests/end_to_end_expected/2021/production_03159016_2035.json
Original file line number Diff line number Diff line change
Expand Up @@ -8658,27 +8658,27 @@
"CO2_budget_2016_to_year_target": 9143826.172232214,
"nonCO2_budget_2016_to_year_target": 2289672.898167259,
"GHG_budget_2016_to_year_target": 11433499.070399474,
"GHG_budget_2022_to_year_target": 6315120.923245047,
"GHG_budget_after_year_target": 527240.5801685886,
"GHG_budget_2022_to_year_target": 6256431.927467695,
"GHG_budget_after_year_target": 468551.58439123695,
"CO2e_w_lulucf_change_pa": 55122.66993406149,
"CO2e_lulucf_2015": -5958.902110823803,
"CO2e_lulucf_2016": -6190.890844896049,
"CO2e_lulucf_2017": -6336.192299348214,
"CO2e_lulucf_2018": -5095.114271193101,
"CO2e_lulucf_2018": -5641.151584102509,
"CO2e_lulucf_2019": -5079.072497028531,
"CO2e_lulucf_2020": -5095.114271193101,
"CO2e_lulucf_2021": -5095.114271193101,
"CO2e_wo_lulucf_2015": 941536.113416536,
"CO2e_wo_lulucf_2016": 945394.8765143125,
"CO2e_wo_lulucf_2017": 928847.800650884,
"CO2e_wo_lulucf_2018": 831935.1632821154,
"CO2e_wo_lulucf_2018": 891170.1963723776,
"CO2e_wo_lulucf_2019": 843179.3032424201,
"CO2e_wo_lulucf_2020": 769977.3386374316,
"CO2e_wo_lulucf_2021": 831935.1632821154,
"CO2e_w_lulucf_2015": 935577.2113057122,
"CO2e_w_lulucf_2016": 939203.9856694164,
"CO2e_w_lulucf_2017": 922511.6083515359,
"CO2e_w_lulucf_2018": 826840.0490109223,
"CO2e_w_lulucf_2018": 885529.044788275,
"CO2e_w_lulucf_2019": 838100.2307453916,
"CO2e_w_lulucf_2020": 764882.2243662386,
"CO2e_w_lulucf_2021": 826840.0490109223,
Expand Down Expand Up @@ -8715,7 +8715,7 @@
"CO2e_lulucf_203X": -15449.48537350322,
"CO2e_wo_lulucf_203X": 15449.48537350322,
"CO2e_w_lulucf_203X": 0.0,
"change_CO2e_t": -826840.0490109223,
"change_CO2e_t": -885529.044788275,
"change_CO2e_pct": -1.0,
"cost_climate_saved": 3466908781.06305,
"z": {
Expand Down
14 changes: 7 additions & 7 deletions tests/end_to_end_expected/2021/production_03159016_2050.json
Original file line number Diff line number Diff line change
Expand Up @@ -8658,27 +8658,27 @@
"CO2_budget_2016_to_year_target": 9143826.172232216,
"nonCO2_budget_2016_to_year_target": 3407697.817603583,
"GHG_budget_2016_to_year_target": 12551523.989835799,
"GHG_budget_2022_to_year_target": 7433145.842681372,
"GHG_budget_after_year_target": -4556034.8679769905,
"GHG_budget_2022_to_year_target": 7374456.84690402,
"GHG_budget_after_year_target": -4614723.863754343,
"CO2e_w_lulucf_change_pa": 27561.334967030743,
"CO2e_lulucf_2015": -5958.902110823803,
"CO2e_lulucf_2016": -6190.890844896049,
"CO2e_lulucf_2017": -6336.192299348214,
"CO2e_lulucf_2018": -5095.114271193101,
"CO2e_lulucf_2018": -5641.151584102509,
"CO2e_lulucf_2019": -5079.072497028531,
"CO2e_lulucf_2020": -5095.114271193101,
"CO2e_lulucf_2021": -5095.114271193101,
"CO2e_wo_lulucf_2015": 941536.113416536,
"CO2e_wo_lulucf_2016": 945394.8765143125,
"CO2e_wo_lulucf_2017": 928847.800650884,
"CO2e_wo_lulucf_2018": 831935.1632821154,
"CO2e_wo_lulucf_2018": 891170.1963723776,
"CO2e_wo_lulucf_2019": 843179.3032424201,
"CO2e_wo_lulucf_2020": 769977.3386374316,
"CO2e_wo_lulucf_2021": 831935.1632821154,
"CO2e_w_lulucf_2015": 935577.2113057122,
"CO2e_w_lulucf_2016": 939203.9856694164,
"CO2e_w_lulucf_2017": 922511.6083515359,
"CO2e_w_lulucf_2018": 826840.0490109223,
"CO2e_w_lulucf_2018": 885529.044788275,
"CO2e_w_lulucf_2019": 838100.2307453916,
"CO2e_w_lulucf_2020": 764882.2243662386,
"CO2e_w_lulucf_2021": 826840.0490109223,
Expand Down Expand Up @@ -8715,7 +8715,7 @@
"CO2e_lulucf_203X": -15449.48537350322,
"CO2e_wo_lulucf_203X": 15449.48537350322,
"CO2e_w_lulucf_203X": 0.0,
"change_CO2e_t": -826840.0490109223,
"change_CO2e_t": -885529.044788275,
"change_CO2e_pct": -1.0,
"cost_climate_saved": 2257521996.971288,
"z": {
Expand Down Expand Up @@ -9184,7 +9184,7 @@
"CO2e_per_capita_com": 6.901779192251503,
"CO2e_per_capita_com_pct_of_nat": 0.6840706071610158,
"GHG_budget_2022_to_year_target_nat": 3802065388.0,
"CO2e_2022_to_year_target": 11989180.710658362
"CO2e_2022_to_year_target": 11989180.710658364
},
"bisko": {
"priv_residences": {
Expand Down
14 changes: 7 additions & 7 deletions tests/end_to_end_expected/2021/production_07338007_2035.json
Original file line number Diff line number Diff line change
Expand Up @@ -8658,27 +8658,27 @@
"CO2_budget_2016_to_year_target": 460240.4973127125,
"nonCO2_budget_2016_to_year_target": 115247.18137535223,
"GHG_budget_2016_to_year_target": 575487.6786880647,
"GHG_budget_2022_to_year_target": 406432.03912335227,
"GHG_budget_after_year_target": 214794.17707974446,
"GHG_budget_2022_to_year_target": 404545.4459343724,
"GHG_budget_after_year_target": 212907.58389076457,
"CO2e_w_lulucf_change_pa": 1825.1224956534086,
"CO2e_lulucf_2015": -2038.0966872871425,
"CO2e_lulucf_2016": -2117.4427583598244,
"CO2e_lulucf_2017": -2167.139566172635,
"CO2e_lulucf_2018": -1742.6591886122615,
"CO2e_lulucf_2018": -1929.4178931317397,
"CO2e_lulucf_2019": -1737.1724922082994,
"CO2e_lulucf_2020": -1742.6591886122615,
"CO2e_lulucf_2021": -1742.6591886122615,
"CO2e_wo_lulucf_2015": 32955.76252275475,
"CO2e_wo_lulucf_2016": 33090.827421986745,
"CO2e_wo_lulucf_2017": 32511.644643089017,
"CO2e_wo_lulucf_2018": 29119.49662341339,
"CO2e_wo_lulucf_2018": 31192.84851691275,
"CO2e_wo_lulucf_2019": 29513.06538941619,
"CO2e_wo_lulucf_2020": 26950.841245971318,
"CO2e_wo_lulucf_2021": 29119.49662341339,
"CO2e_w_lulucf_2015": 30917.665835467604,
"CO2e_w_lulucf_2016": 30973.384663626923,
"CO2e_w_lulucf_2017": 30344.505076916383,
"CO2e_w_lulucf_2018": 27376.837434801128,
"CO2e_w_lulucf_2018": 29263.43062378101,
"CO2e_w_lulucf_2019": 27775.892897207894,
"CO2e_w_lulucf_2020": 25208.182057359056,
"CO2e_w_lulucf_2021": 27376.837434801128,
Expand Down Expand Up @@ -8715,8 +8715,8 @@
"CO2e_lulucf_203X": -2802.668069178987,
"CO2e_wo_lulucf_203X": 797.4532360839451,
"CO2e_w_lulucf_203X": -2005.214833095042,
"change_CO2e_t": -29382.052267896168,
"change_CO2e_pct": -1.0732449406499391,
"change_CO2e_t": -31268.64545687605,
"change_CO2e_pct": -1.0685228898441421,
"cost_climate_saved": 123203475.25631808,
"z": {
"energy_18": 93695.07254513228,
Expand Down
14 changes: 7 additions & 7 deletions tests/end_to_end_expected/2021/production_DG000000_2035.json
Original file line number Diff line number Diff line change
Expand Up @@ -8658,27 +8658,27 @@
"CO2_budget_2016_to_year_target": 6336451721.0,
"nonCO2_budget_2016_to_year_target": 1586688275.0,
"GHG_budget_2016_to_year_target": 7923139996.0,
"GHG_budget_2022_to_year_target": 2323190310.7866263,
"GHG_budget_after_year_target": -4009753113.706034,
"GHG_budget_2022_to_year_target": 2259034752.35024,
"GHG_budget_after_year_target": -4073908672.1424203,
"CO2e_w_lulucf_change_pa": 60313746.89993005,
"CO2e_lulucf_2015": -8482982.440657413,
"CO2e_lulucf_2016": -8813237.296495805,
"CO2e_lulucf_2017": -9020085.750086073,
"CO2e_lulucf_2018": -7253310.105088932,
"CO2e_lulucf_2018": -8030638.688644722,
"CO2e_lulucf_2019": -7230473.3331426615,
"CO2e_lulucf_2020": -7253310.105088932,
"CO2e_lulucf_2021": -7253310.105088932,
"CO2e_wo_lulucf_2015": 1032103045.9206712,
"CO2e_wo_lulucf_2016": 1036332985.7922813,
"CO2e_wo_lulucf_2017": 1018194236.6180694,
"CO2e_wo_lulucf_2018": 911959513.6040398,
"CO2e_wo_lulucf_2018": 976892400.623982,
"CO2e_wo_lulucf_2019": 924285234.239096,
"CO2e_wo_lulucf_2020": 844041928.0508378,
"CO2e_wo_lulucf_2021": 911959513.6040398,
"CO2e_w_lulucf_2015": 1023620063.4800138,
"CO2e_w_lulucf_2016": 1027519748.4957855,
"CO2e_w_lulucf_2017": 1009174150.8679833,
"CO2e_w_lulucf_2018": 904706203.4989508,
"CO2e_w_lulucf_2018": 968861761.9353372,
"CO2e_w_lulucf_2019": 917054760.9059534,
"CO2e_w_lulucf_2020": 836788617.9457488,
"CO2e_w_lulucf_2021": 904706203.4989508,
Expand Down Expand Up @@ -8715,8 +8715,8 @@
"CO2e_lulucf_203X": -51049537.497717485,
"CO2e_wo_lulucf_203X": 45426622.01735288,
"CO2e_w_lulucf_203X": -5622915.480364606,
"change_CO2e_t": -910329118.9793154,
"change_CO2e_pct": -1.0062151839554299,
"change_CO2e_t": -974484677.4157017,
"change_CO2e_pct": -1.0058036303023588,
"cost_climate_saved": 3816819461920.7803,
"z": {
"energy_18": 2572665401.1253977,
Expand Down

0 comments on commit 305a6b8

Please sign in to comment.