88 @register_output_quantity
99 def quantity(
1010 sectors: List[AbstractSector],
11- market: xr.Dataset, **kwargs
11+ market: xr.Dataset,
12+ year: int,
13+ **kwargs
1214 ) -> Union[pd.DataFrame, xr.DataArray]:
1315 pass
1416
@@ -76,9 +78,13 @@ def round_values(function: Callable) -> OUTPUT_QUANTITY_SIGNATURE:
7678
7779 @wraps (function )
7880 def rounded (
79- market : xr .Dataset , sectors : list [AbstractSector ], rounding : int = 4 , ** kwargs
81+ market : xr .Dataset ,
82+ sectors : list [AbstractSector ],
83+ year : int ,
84+ rounding : int = 4 ,
85+ ** kwargs ,
8086 ) -> xr .DataArray :
81- result = function (market , sectors , ** kwargs )
87+ result = function (market = market , sectors = sectors , year = year , ** kwargs )
8288
8389 if hasattr (result , "to_dataframe" ):
8490 result = result .to_dataframe ()
@@ -150,15 +156,17 @@ def reformat_finite_resources(params):
150156@register_output_quantity
151157@round_values
152158def consumption (
153- market : xr .Dataset , sectors : list [AbstractSector ], ** kwargs
159+ market : xr .Dataset , sectors : list [AbstractSector ], year : int , ** kwargs
154160) -> pd .DataFrame :
155161 """Current consumption."""
156162 return market_quantity (market .consumption , ** kwargs ).to_dataframe ().reset_index ()
157163
158164
159165@register_output_quantity
160166@round_values
161- def supply (market : xr .Dataset , sectors : list [AbstractSector ], ** kwargs ) -> pd .DataFrame :
167+ def supply (
168+ market : xr .Dataset , sectors : list [AbstractSector ], year : int , ** kwargs
169+ ) -> pd .DataFrame :
162170 """Current supply."""
163171 return market_quantity (market .supply , ** kwargs ).to_dataframe ().reset_index ()
164172
@@ -168,6 +176,7 @@ def supply(market: xr.Dataset, sectors: list[AbstractSector], **kwargs) -> pd.Da
168176def prices (
169177 market : xr .Dataset ,
170178 sectors : list [AbstractSector ],
179+ year : int ,
171180 ** kwargs ,
172181) -> pd .DataFrame :
173182 """Current MCA market prices."""
@@ -177,7 +186,7 @@ def prices(
177186@register_output_quantity
178187@round_values
179188def capacity (
180- market : xr .Dataset , sectors : list [AbstractSector ], ** kwargs
189+ market : xr .Dataset , sectors : list [AbstractSector ], year : int , ** kwargs
181190) -> pd .DataFrame :
182191 """Current capacity across all sectors."""
183192 return _aggregate_sectors (sectors , op = sector_capacity )
@@ -236,14 +245,14 @@ def _aggregate_sectors(
236245
237246@register_output_quantity (name = ["fuel_costs" ])
238247def metric_fuel_costs (
239- market : xr .Dataset , sectors : list [AbstractSector ], ** kwargs
248+ market : xr .Dataset , sectors : list [AbstractSector ], year : int , ** kwargs
240249) -> pd .DataFrame :
241250 """Current fuel costs across all sectors."""
242- return _aggregate_sectors (sectors , market , op = sector_fuel_costs )
251+ return _aggregate_sectors (sectors , market , year , op = sector_fuel_costs )
243252
244253
245254def sector_fuel_costs (
246- sector : AbstractSector , market : xr .Dataset , ** kwargs
255+ sector : AbstractSector , market : xr .Dataset , year : int , ** kwargs
247256) -> pd .DataFrame :
248257 """Sector fuel costs with agent annotations."""
249258 from muse .commodities import is_fuel
@@ -258,13 +267,13 @@ def sector_fuel_costs(
258267 if len (technologies ) > 0 :
259268 for a in agents :
260269 agent_market ["consumption" ] = (market .consumption * a .quantity ).sel (
261- year = a . year
270+ year = year
262271 )
263272 commodity = is_fuel (technologies .comm_usage )
264273
265274 capacity = a .filter_input (
266275 a .assets .capacity ,
267- year = a . year ,
276+ year = year ,
268277 ).fillna (0.0 )
269278
270279 production = supply (
@@ -273,7 +282,7 @@ def sector_fuel_costs(
273282 technologies ,
274283 )
275284
276- prices = a .filter_input (market .prices , year = a . year )
285+ prices = a .filter_input (market .prices , year = year )
277286 fcons = consumption (
278287 technologies = technologies , production = production , prices = prices
279288 )
@@ -282,7 +291,7 @@ def sector_fuel_costs(
282291 data_agent ["agent" ] = a .name
283292 data_agent ["category" ] = a .category
284293 data_agent ["sector" ] = getattr (sector , "name" , "unnamed" )
285- data_agent ["year" ] = a . year
294+ data_agent ["year" ] = year
286295 data_agent = multiindex_to_coords (data_agent , "timeslice" ).to_dataframe (
287296 "fuel_consumption_costs"
288297 )
@@ -298,14 +307,14 @@ def sector_fuel_costs(
298307
299308@register_output_quantity (name = ["capital_costs" ])
300309def metric_capital_costs (
301- market : xr .Dataset , sectors : list [AbstractSector ], ** kwargs
310+ market : xr .Dataset , sectors : list [AbstractSector ], year : int , ** kwargs
302311) -> pd .DataFrame :
303312 """Current capital costs across all sectors."""
304- return _aggregate_sectors (sectors , market , op = sector_capital_costs )
313+ return _aggregate_sectors (sectors , market , year , op = sector_capital_costs )
305314
306315
307316def sector_capital_costs (
308- sector : AbstractSector , market : xr .Dataset , ** kwargs
317+ sector : AbstractSector , market : xr .Dataset , year : int , ** kwargs
309318) -> pd .DataFrame :
310319 """Sector capital costs with agent annotations."""
311320 data_sector : list [xr .DataArray ] = []
@@ -314,17 +323,17 @@ def sector_capital_costs(
314323
315324 if len (technologies ) > 0 :
316325 for a in agents :
317- capacity = a .filter_input (a .assets .capacity , year = a . year ).fillna (0.0 )
326+ capacity = a .filter_input (a .assets .capacity , year = year ).fillna (0.0 )
318327 data = a .filter_input (
319328 technologies [["cap_par" , "cap_exp" ]],
320- year = a . year ,
329+ year = year ,
321330 technology = capacity .technology ,
322331 )
323332 data_agent = distribute_timeslice (data .cap_par * (capacity ** data .cap_exp ))
324333 data_agent ["agent" ] = a .name
325334 data_agent ["category" ] = a .category
326335 data_agent ["sector" ] = getattr (sector , "name" , "unnamed" )
327- data_agent ["year" ] = a . year
336+ data_agent ["year" ] = year
328337 data_agent = multiindex_to_coords (data_agent , "timeslice" ).to_dataframe (
329338 "capital_costs"
330339 )
@@ -340,14 +349,14 @@ def sector_capital_costs(
340349
341350@register_output_quantity (name = ["emission_costs" ])
342351def metric_emission_costs (
343- market : xr .Dataset , sectors : list [AbstractSector ], ** kwargs
352+ market : xr .Dataset , sectors : list [AbstractSector ], year : int , ** kwargs
344353) -> pd .DataFrame :
345354 """Current emission costs across all sectors."""
346- return _aggregate_sectors (sectors , market , op = sector_emission_costs )
355+ return _aggregate_sectors (sectors , market , year , op = sector_emission_costs )
347356
348357
349358def sector_emission_costs (
350- sector : AbstractSector , market : xr .Dataset , ** kwargs
359+ sector : AbstractSector , market : xr .Dataset , year : int , ** kwargs
351360) -> pd .DataFrame :
352361 """Sector emission costs with agent annotations."""
353362 from muse .commodities import is_enduse , is_pollutant
@@ -361,21 +370,21 @@ def sector_emission_costs(
361370 if len (technologies ) > 0 :
362371 for a in agents :
363372 agent_market ["consumption" ] = (market .consumption * a .quantity ).sel (
364- year = a . year
373+ year = year
365374 )
366375
367- capacity = a .filter_input (a .assets .capacity , year = a . year ).fillna (0.0 )
376+ capacity = a .filter_input (a .assets .capacity , year = year ).fillna (0.0 )
368377 allemissions = a .filter_input (
369378 technologies .fixed_outputs ,
370379 commodity = is_pollutant (technologies .comm_usage ),
371380 technology = capacity .technology ,
372- year = a . year ,
381+ year = year ,
373382 )
374383 envs = is_pollutant (technologies .comm_usage )
375384 enduses = is_enduse (technologies .comm_usage )
376385 i = (np .where (envs ))[0 ][0 ]
377386 red_envs = envs [i ].commodity .values
378- prices = a .filter_input (market .prices , year = a . year , commodity = red_envs )
387+ prices = a .filter_input (market .prices , year = year , commodity = red_envs )
379388 production = supply (
380389 agent_market ,
381390 capacity ,
@@ -387,7 +396,7 @@ def sector_emission_costs(
387396 data_agent ["agent" ] = a .name
388397 data_agent ["category" ] = a .category
389398 data_agent ["sector" ] = getattr (sector , "name" , "unnamed" )
390- data_agent ["year" ] = a . year
399+ data_agent ["year" ] = year
391400 data_agent = multiindex_to_coords (data_agent , "timeslice" ).to_dataframe (
392401 "emission_costs"
393402 )
@@ -404,13 +413,15 @@ def sector_emission_costs(
404413
405414@register_output_quantity (name = ["LCOE" ])
406415def metric_lcoe (
407- market : xr .Dataset , sectors : list [AbstractSector ], ** kwargs
416+ market : xr .Dataset , sectors : list [AbstractSector ], year : int , ** kwargs
408417) -> pd .DataFrame :
409418 """Current lifetime levelised cost across all sectors."""
410- return _aggregate_sectors (sectors , market , op = sector_lcoe )
419+ return _aggregate_sectors (sectors , market , year , op = sector_lcoe )
411420
412421
413- def sector_lcoe (sector : AbstractSector , market : xr .Dataset , ** kwargs ) -> pd .DataFrame :
422+ def sector_lcoe (
423+ sector : AbstractSector , market : xr .Dataset , year : int , ** kwargs
424+ ) -> pd .DataFrame :
414425 """Levelized cost of energy () of technologies over their lifetime."""
415426 from muse .costs import levelized_cost_of_energy as LCOE
416427 from muse .quantities import capacity_to_service_demand , consumption
@@ -485,13 +496,15 @@ def sector_lcoe(sector: AbstractSector, market: xr.Dataset, **kwargs) -> pd.Data
485496
486497@register_output_quantity (name = ["EAC" ])
487498def metric_eac (
488- market : xr .Dataset , sectors : list [AbstractSector ], ** kwargs
499+ market : xr .Dataset , sectors : list [AbstractSector ], year : int , ** kwargs
489500) -> pd .DataFrame :
490501 """Current emission costs across all sectors."""
491- return _aggregate_sectors (sectors , market , op = sector_eac )
502+ return _aggregate_sectors (sectors , market , year , op = sector_eac )
492503
493504
494- def sector_eac (sector : AbstractSector , market : xr .Dataset , ** kwargs ) -> pd .DataFrame :
505+ def sector_eac (
506+ sector : AbstractSector , market : xr .Dataset , year : int , ** kwargs
507+ ) -> pd .DataFrame :
495508 """Net Present Value of technologies over their lifetime."""
496509 from muse .costs import equivalent_annual_cost as EAC
497510 from muse .quantities import capacity_to_service_demand , consumption
0 commit comments