Skip to content

Commit ab14fd2

Browse files
committed
Update mca.py
1 parent 1b5072b commit ab14fd2

1 file changed

Lines changed: 24 additions & 31 deletions

File tree

src/muse/outputs/mca.py

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,14 @@ def sector_fuel_costs(
266266
agent_market = market.copy()
267267
if len(technologies) > 0:
268268
for a in agents:
269-
output_year = a.year - a.forecast
270269
agent_market["consumption"] = (market.consumption * a.quantity).sel(
271-
year=output_year
270+
year=year
272271
)
273272
commodity = is_fuel(technologies.comm_usage)
274273

275274
capacity = a.filter_input(
276275
a.assets.capacity,
277-
year=output_year,
276+
year=year,
278277
).fillna(0.0)
279278

280279
production = supply(
@@ -283,7 +282,7 @@ def sector_fuel_costs(
283282
technologies,
284283
)
285284

286-
prices = a.filter_input(market.prices, year=output_year)
285+
prices = a.filter_input(market.prices, year=year)
287286
fcons = consumption(
288287
technologies=technologies, production=production, prices=prices
289288
)
@@ -292,7 +291,7 @@ def sector_fuel_costs(
292291
data_agent["agent"] = a.name
293292
data_agent["category"] = a.category
294293
data_agent["sector"] = getattr(sector, "name", "unnamed")
295-
data_agent["year"] = output_year
294+
data_agent["year"] = year
296295
data_agent = multiindex_to_coords(data_agent, "timeslice").to_dataframe(
297296
"fuel_consumption_costs"
298297
)
@@ -324,18 +323,17 @@ def sector_capital_costs(
324323

325324
if len(technologies) > 0:
326325
for a in agents:
327-
output_year = a.year - a.forecast
328-
capacity = a.filter_input(a.assets.capacity, year=output_year).fillna(0.0)
326+
capacity = a.filter_input(a.assets.capacity, year=year).fillna(0.0)
329327
data = a.filter_input(
330328
technologies[["cap_par", "cap_exp"]],
331-
year=output_year,
329+
year=year,
332330
technology=capacity.technology,
333331
)
334332
data_agent = distribute_timeslice(data.cap_par * (capacity**data.cap_exp))
335333
data_agent["agent"] = a.name
336334
data_agent["category"] = a.category
337335
data_agent["sector"] = getattr(sector, "name", "unnamed")
338-
data_agent["year"] = output_year
336+
data_agent["year"] = year
339337
data_agent = multiindex_to_coords(data_agent, "timeslice").to_dataframe(
340338
"capital_costs"
341339
)
@@ -371,23 +369,22 @@ def sector_emission_costs(
371369
agent_market = market.copy()
372370
if len(technologies) > 0:
373371
for a in agents:
374-
output_year = a.year - a.forecast
375372
agent_market["consumption"] = (market.consumption * a.quantity).sel(
376-
year=output_year
373+
year=year
377374
)
378375

379-
capacity = a.filter_input(a.assets.capacity, year=output_year).fillna(0.0)
376+
capacity = a.filter_input(a.assets.capacity, year=year).fillna(0.0)
380377
allemissions = a.filter_input(
381378
technologies.fixed_outputs,
382379
commodity=is_pollutant(technologies.comm_usage),
383380
technology=capacity.technology,
384-
year=output_year,
381+
year=year,
385382
)
386383
envs = is_pollutant(technologies.comm_usage)
387384
enduses = is_enduse(technologies.comm_usage)
388385
i = (np.where(envs))[0][0]
389386
red_envs = envs[i].commodity.values
390-
prices = a.filter_input(market.prices, year=output_year, commodity=red_envs)
387+
prices = a.filter_input(market.prices, year=year, commodity=red_envs)
391388
production = supply(
392389
agent_market,
393390
capacity,
@@ -399,7 +396,7 @@ def sector_emission_costs(
399396
data_agent["agent"] = a.name
400397
data_agent["category"] = a.category
401398
data_agent["sector"] = getattr(sector, "name", "unnamed")
402-
data_agent["year"] = output_year
399+
data_agent["year"] = year
403400
data_agent = multiindex_to_coords(data_agent, "timeslice").to_dataframe(
404401
"emission_costs"
405402
)
@@ -438,8 +435,7 @@ def sector_lcoe(
438435
agents = retro if len(retro) > 0 else new
439436
if len(technologies) > 0:
440437
for agent in agents:
441-
output_year = agent.year - agent.forecast
442-
agent_market = market.sel(year=output_year).copy()
438+
agent_market = market.sel(year=agent.year).copy()
443439
agent_market["consumption"] = agent_market.consumption * agent.quantity
444440
included = [
445441
i
@@ -450,16 +446,15 @@ def sector_lcoe(
450446
i for i in agent_market["commodity"].values if i not in included
451447
]
452448
agent_market.loc[dict(commodity=excluded)] = 0
453-
years = [output_year, agent.year]
454-
agent_market["prices"] = agent.filter_input(market["prices"], year=years)
449+
agent_market["prices"] = agent.filter_input(
450+
market["prices"], year=agent.year
451+
)
455452

456453
techs = agent.filter_input(
457454
technologies,
458455
year=agent.year,
459456
)
460-
prices = agent_market["prices"].sel(
461-
commodity=techs.commodity, year=agent.year
462-
)
457+
prices = agent_market["prices"].sel(commodity=techs.commodity)
463458
demand = agent_market.consumption.sel(commodity=included)
464459
capacity = agent.filter_input(capacity_to_service_demand(demand, techs))
465460
production = (
@@ -484,7 +479,7 @@ def sector_lcoe(
484479
data_agent["agent"] = agent.name
485480
data_agent["category"] = agent.category
486481
data_agent["sector"] = getattr(sector, "name", "unnamed")
487-
data_agent["year"] = output_year
482+
data_agent["year"] = agent.year
488483
data_agent = data_agent.fillna(0)
489484
data_agent = multiindex_to_coords(data_agent, "timeslice").to_dataframe(
490485
"LCOE"
@@ -523,8 +518,7 @@ def sector_eac(
523518
agents = retro if len(retro) > 0 else new
524519
if len(technologies) > 0:
525520
for agent in agents:
526-
output_year = agent.year - agent.forecast
527-
agent_market = market.sel(year=output_year).copy()
521+
agent_market = market.sel(year=agent.year).copy()
528522
agent_market["consumption"] = agent_market.consumption * agent.quantity
529523
included = [
530524
i
@@ -535,16 +529,15 @@ def sector_eac(
535529
i for i in agent_market["commodity"].values if i not in included
536530
]
537531
agent_market.loc[dict(commodity=excluded)] = 0
538-
years = [output_year, agent.year]
539-
agent_market["prices"] = agent.filter_input(market["prices"], year=years)
532+
agent_market["prices"] = agent.filter_input(
533+
market["prices"], year=agent.year
534+
)
540535

541536
techs = agent.filter_input(
542537
technologies,
543538
year=agent.year,
544539
)
545-
prices = agent_market["prices"].sel(
546-
commodity=techs.commodity, year=agent.year
547-
)
540+
prices = agent_market["prices"].sel(commodity=techs.commodity)
548541
demand = agent_market.consumption.sel(commodity=included)
549542
capacity = agent.filter_input(capacity_to_service_demand(demand, techs))
550543
production = (
@@ -568,7 +561,7 @@ def sector_eac(
568561
data_agent["agent"] = agent.name
569562
data_agent["category"] = agent.category
570563
data_agent["sector"] = getattr(sector, "name", "unnamed")
571-
data_agent["year"] = output_year
564+
data_agent["year"] = agent.year
572565
data_agent = multiindex_to_coords(data_agent, "timeslice").to_dataframe(
573566
"capital_costs"
574567
)

0 commit comments

Comments
 (0)