@@ -77,55 +77,62 @@ def get_primary_steel_share(df, planning_horizons):
7777
7878 return primary_steel_share .set_index (pd .Index (["Primary_Steel_Share" ]))
7979
80- def get_ksg_targets (df ):
80+ def get_co2_budget (df , source ):
8181 # relative to the DE emissions in 1990 *including bunkers*; also
8282 # account for non-CO2 GHG and allow extra room for international
8383 # bunkers which are excluded from the national targets
8484
8585 # Baseline emission in DE in 1990 in Mt as understood by the KSG and by PyPSA
86- baseline_ksg = 1251
86+ baseline_co2 = 1251
8787 baseline_pypsa = 1052
88+ if source == "KSG" :
89+ ## GHG targets according to KSG
90+ initial_years_co2 = pd .Series (
91+ index = [2020 , 2025 , 2030 ],
92+ data = [813 , 643 , 438 ],
93+ )
8894
89- ## GHG targets according to KSG
90- initial_years_ksg = pd .Series (
91- index = [2020 , 2025 , 2030 ],
92- data = [813 , 643 , 438 ],
93- )
94-
95- later_years_ksg = pd .Series (
96- index = [2035 , 2040 , 2045 , 2050 ],
97- data = [0.77 , 0.88 , 1.0 , 1.0 ],
98- )
99-
100- targets_ksg = pd .concat (
101- [initial_years_ksg , (1 - later_years_ksg ) * baseline_ksg ],
102- )
95+ later_years_co2 = pd .Series (
96+ index = [2035 , 2040 , 2045 , 2050 ],
97+ data = [0.77 , 0.88 , 1.0 , 1.0 ],
98+ )
10399
100+ targets_co2 = pd .concat (
101+ [initial_years_co2 , (1 - later_years_co2 ) * baseline_co2 ],
102+ )
103+ elif source == "UBA" :
104+ ## For Zielverfehlungsszenarien use UBA Projektionsbericht
105+ targets_co2 = pd .Series (
106+ index = [2020 , 2025 , 2030 , 2035 , 2040 , 2045 , 2050 ],
107+ data = [813 , 655 , 455 , 309 , 210 , 169 , 157 ],
108+ )
109+ else :
110+ raise ValueError ("Invalid source for CO2 budget." )
104111 ## Compute nonco2 from Ariadne-Leitmodell (REMIND)
105112
106- co2_ksg = (
113+ co2 = (
107114 df .loc ["Emissions|CO2 incl Bunkers" ,"Mt CO2/yr" ]
108115 - df .loc ["Emissions|CO2|Land-Use Change" ,"Mt CO2-equiv/yr" ]
109116 - df .loc ["Emissions|CO2|Energy|Demand|Bunkers" ,"Mt CO2/yr" ]
110117 )
111118
112- ghg_ksg = (
119+ ghg = (
113120 df .loc ["Emissions|Kyoto Gases" ,"Mt CO2-equiv/yr" ]
114121 - df .loc ["Emissions|Kyoto Gases|Land-Use Change" ,"Mt CO2-equiv/yr" ]
115122 # No Kyoto Gas emissions for Bunkers recorded in Ariadne DB
116123 )
117124
118- nonco2 = ghg_ksg - co2_ksg
125+ nonco2 = ghg - co2
119126
120127 ## PyPSA disregards nonco2 GHG emissions, but includes bunkers
121128
122129 targets_pypsa = (
123- targets_ksg - nonco2
130+ targets_co2 - nonco2
124131 + df .loc ["Emissions|CO2|Energy|Demand|Bunkers" ,"Mt CO2/yr" ]
125132 )
126133
127134 target_fractions_pypsa = (
128- targets_pypsa .loc [targets_ksg .index ] / baseline_pypsa
135+ targets_pypsa .loc [targets_co2 .index ] / baseline_pypsa
129136 )
130137
131138 return target_fractions_pypsa .round (3 )
@@ -140,14 +147,13 @@ def write_to_scenario_yaml(
140147 for scenario in scenarios :
141148 reference_scenario = config [scenario ]["iiasa_database" ]["reference_scenario" ]
142149 if scenario == "CurrentPolicies" :
143- ksg_target_fractions = get_ksg_targets (
144- df .loc ["REMIND-EU v1.1" , "8Gt_Bal_v3" ]
145- )
146- ksg_target_fractions [[2035 , 2040 , 2045 ]] = ksg_target_fractions [2030 ]
147- else :
148- ksg_target_fractions = get_ksg_targets (
149- df .loc ["REMIND-EU v1.1" , reference_scenario ]
150- )
150+ reference_scenario = "8Gt_Bal_v3" # hotfix until DB is updated
151+ co2_budget_source = config [scenario ]["co2_budget_DE_source" ]
152+
153+ co2_budget_fractions = get_co2_budget (
154+ df .loc ["REMIND-EU v1.1" , "8Gt_Bal_v3" ],
155+ co2_budget_source
156+ )
151157
152158 planning_horizons = [2020 , 2025 , 2030 , 2035 , 2040 , 2045 ] # for 2050 we still need data
153159
@@ -192,10 +198,9 @@ def write_to_scenario_yaml(
192198 for year in st_primary_fraction .columns :
193199 config [scenario ]["industry" ]["St_primary_fraction" ][year ] = round (st_primary_fraction .loc ["Primary_Steel_Share" , year ].item (), 4 )
194200 config [scenario ]["co2_budget_national" ] = {}
195- for year , target in ksg_target_fractions .items ():
201+ for year , target in co2_budget_fractions .items ():
196202 config [scenario ]["co2_budget_national" ][year ] = {}
197- target_value = float (ksg_target_fractions [2030 ]) if year > 2030 and scenario == "CurrentPolicies" else target
198- config [scenario ]["co2_budget_national" ][year ]["DE" ] = target_value
203+ config [scenario ]["co2_budget_national" ][year ]["DE" ] = target
199204
200205 # write back to yaml file
201206 yaml .dump (config , Path (output ))
@@ -225,7 +230,7 @@ def write_to_scenario_yaml(
225230 :,
226231 "Deutschland" ]
227232
228- scenarios = snakemake .params .scenario_name
233+ scenarios = snakemake .params .scenarios
229234
230235 input = snakemake .input .scenario_yaml
231236 output = snakemake .output .scenario_yaml
0 commit comments