@@ -307,14 +307,14 @@ def update_macro_calib_file(
307307 if extrapolate :
308308 df ["node" ] = pd .Categorical (df ["node" ], nodes )
309309 df = df [df ["year" ].isin (years_cost )].groupby (["node" ]).apply (cost_fit )
310- ws = wb . get_sheet_by_name ( "cost_ref" )
310+ ws = wb [ "cost_ref" ]
311311 for i in range (2 , 14 ):
312312 ws [f"A{ i } " ].value = nodes [i - 2 ]
313313 ws [f"B{ i } " ].value = df .values [i - 2 ]
314314 else :
315315 vals = df [df ["year" ] == fmy + 5 ]["lvl" ].values
316316 nodes = df ["node" ].values
317- ws = wb . get_sheet_by_name ( "cost_ref" )
317+ ws = wb [ "cost_ref" ]
318318 for i in range (2 , 14 ):
319319 ws [f"A{ i } " ].value = nodes
320320 ws [f"B{ i } " ].value = (vals [i - 2 ] / 1000 ).round (3 )
@@ -336,12 +336,20 @@ def update_macro_calib_file(
336336
337337 # demand_ref
338338 df = scenario .par ("demand" , filters = {"commodity" : comms , "year" : fmy })
339- ws = wb . get_sheet_by_name ( "demand_ref" )
339+ ws = wb [ "demand_ref" ]
340340 for i in range (2 , 62 ):
341341 ws [f"A{ i } " ].value = df .node .values [i - 2 ]
342342 ws [f"B{ i } " ].value = df .commodity .values [i - 2 ]
343343 ws [f"C{ i } " ].value = df .value .values [i - 2 ]
344344
345+ ws = wb ["gdp_calibrate" ]
346+ gdp = scenario .par ("bound_activity_up" , filters = {"technology" : "GDP" })
347+ gdp = gdp [gdp ["year_act" ] >= 2015 ].sort_values (["node_loc" , "year_act" ])
348+ for i in range (2 , len (gdp .index ) + 2 ):
349+ ws [f"A{ i } " ].value = gdp .year_act .values [i - 2 ]
350+ ws [f"B{ i } " ].value = gdp .node_loc .values [i - 2 ]
351+ ws [f"C{ i } " ].value = gdp .value .values [i - 2 ]
352+
345353 wb .save (path )
346354
347355
0 commit comments