Skip to content

Commit

Permalink
update scenario names for total costs plot
Browse files Browse the repository at this point in the history
  • Loading branch information
yerbol-akhmetov committed Sep 18, 2024
1 parent a177f52 commit 1448fb7
Showing 1 changed file with 23 additions and 23 deletions.
46 changes: 23 additions & 23 deletions plots/plot_total_costs.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ def plot_costs(cost_df, clusters, planning_horizon, plot_width=7, plot_name="tot
ax.set_yticks(np.arange(0, y_tick_max, 100))

x_ticks = list(df.columns)
if planning_horizon in ["2040", "2050"] and "Limited \nRenovation &\nCost-Optimal Heating" in x_ticks:
if planning_horizon in ["2040", "2050"] and "Limited \nRenovation" in x_ticks:
# replace name for Limited Renovation scenario for 2030 to be LROH
x_ticks[x_ticks.index("Limited \nRenovation &\nCost-Optimal Heating")] = "Limited \nRenovation &\nElectric Heating"
x_ticks[x_ticks.index("Limited \nRenovation")] = "Limited \nRenovation &\nElectrification"

ax.set_xticklabels(x_ticks)

Expand All @@ -110,7 +110,7 @@ def plot_costs(cost_df, clusters, planning_horizon, plot_width=7, plot_name="tot
)

if planning_horizon == BAU_HORIZON:
ax.set_title("BAU", fontsize=12)
ax.set_title("2023", fontsize=12)
else:
ax.set_title(planning_horizon, fontsize=12)

Expand Down Expand Up @@ -218,9 +218,9 @@ def plot_capacities(caps_df, clusters, planning_horizon, plot_width=7):
ax.set_yticks(np.arange(0, 23, 2))

x_ticks = list(df.columns)
if planning_horizon in ["2040", "2050"] and "Limited \nRenovation &\nCost-Optimal Heating" in x_ticks:
if planning_horizon in ["2040", "2050"] and "Limited \nRenovation" in x_ticks:
# replace name for Limited Renovation scenario for 2030 to be LROH
x_ticks[x_ticks.index("Limited \nRenovation &\nCost-Optimal Heating")] = "Limited \nRenovation &\nElectric Heating"
x_ticks[x_ticks.index("Limited \nRenovation")] = "Limited \nRenovation &\nElectrification"

ax.set_xticklabels(x_ticks)

Expand All @@ -232,7 +232,7 @@ def plot_capacities(caps_df, clusters, planning_horizon, plot_width=7):
)

if planning_horizon == BAU_HORIZON:
ax.set_title("BAU", fontsize=12)
ax.set_title("2023", fontsize=12)
else:
ax.set_title(planning_horizon, fontsize=12)

Expand Down Expand Up @@ -343,10 +343,10 @@ def fill_table_df(df, planning_horizon, scenarios, values):
opts = config["plotting"]["sector_opts"]

# define scenario namings
scenarios = {"flexible": "Optimal \nRenovation &\nCost-Optimal Heating",
"retro_tes": "Optimal \nRenovation &\nElectric Heating",
"flexible-moderate": "Limited \nRenovation &\nCost-Optimal Heating",
"rigid": "No \nRenovation &\nElectric Heating"}
scenarios = {"flexible": "Widespread \nRenovation",
"retro_tes": "Widespread \nRenovation &\nElectrification",
"flexible-moderate": "Limited \nRenovation",
"rigid": "Business\nas Usual &\nElectrification"}

# initialize capital cost and p_nom_opt storing dictionary for different horizons
cap_costs_dict = {}
Expand Down Expand Up @@ -448,45 +448,45 @@ def fill_table_df(df, planning_horizon, scenarios, values):
# Skip further computation for this scenario if network is not loaded
print(f"Network is not found for scenario '{scenario}', BAU year '{BAU_horizon}'. Skipping...")
else:
cap_costs = compute_costs(n, "BAU", "Capital")
op_costs = compute_costs(n, "BAU", "Operational")
cap_costs = compute_costs(n, "Baseline 2023", "Capital")
op_costs = compute_costs(n, "Baseline 2023", "Operational")
cost_BAU = sum_costs(cap_costs, op_costs)
# operational and investment costs for BAU
invest_cost_BAU = sum_costs(cap_costs, 0)
oper_cost_BAU = sum_costs(0, op_costs)
capacities_BAU = compute_capacities(n, "BAU")
capacities_BAU = compute_capacities(n, "Baseline 2023")
if not table_cost_df.empty and not cost_BAU.empty:
processed_cost_BAU = plot_costs(cost_BAU, clusters, BAU_horizon, plot_width=1.6)
table_cost_df = fill_table_df(table_cost_df, BAU_horizon, {"BAU":"BAU"}, processed_cost_BAU)
table_cost_df = fill_table_df(table_cost_df, BAU_horizon, {"BAU":"Baseline 2023"}, processed_cost_BAU)
# plot operational and investment costs
processed_oper_cost_BAU = plot_costs(oper_cost_BAU, clusters, BAU_horizon, plot_width=1.6, plot_name="operational_costs")
processed_invest_cost_BAU = plot_costs(invest_cost_BAU, clusters, BAU_horizon, plot_width=1.6, plot_name="investment_costs")

if not table_cap_df.empty and not capacities_BAU.empty:
processed_capacities_BAU = plot_capacities(capacities_BAU, clusters, BAU_horizon, plot_width=1.6)
table_cap_df = fill_table_df(table_cap_df, BAU_horizon, {"BAU":"BAU"}, processed_capacities_BAU)
table_cap_df = fill_table_df(table_cap_df, BAU_horizon, {"BAU":"Baseline 2023"}, processed_capacities_BAU)


# save all costs to csv
if not table_cost_df.empty:
table_cost_df.index.name = "System cost [EUR billion per year]"
table_cost_df.columns = replace_multiindex_values(table_cost_df.columns,
("2040", "Limited \nRenovation &\nCost-Optimal Heating"),
("2040","Limited \nRenovation &\nElectric Heating"))
("2040", "Limited \nRenovation"),
("2040","Limited \nRenovation &\nElectrification"))
table_cost_df.columns = replace_multiindex_values(table_cost_df.columns,
("2050", "Limited \nRenovation &\nCost-Optimal Heating"),
("2050","Limited \nRenovation &\nElectric Heating"))
("2050", "Limited \nRenovation"),
("2050","Limited \nRenovation &\nElectrification"))

table_cost_df.to_csv(snakemake.output.costs)

# save all capacities to csv
if not table_cap_df.empty:
table_cap_df.index.name = "Installed capacity [GW]"
table_cap_df.columns = replace_multiindex_values(table_cap_df.columns,
("2040", "Limited \nRenovation &\nCost-Optimal Heating"),
("2040","Limited \nRenovation &\nElectric Heating"))
("2040", "Limited \nRenovation"),
("2040","Limited \nRenovation &\nElectrification"))
table_cap_df.columns = replace_multiindex_values(table_cap_df.columns,
("2050", "Limited \nRenovation &\nCost-Optimal Heating"),
("2050","Limited \nRenovation &\nElectric Heating"))
("2050", "Limited \nRenovation"),
("2050","Limited \nRenovation &\nElectrification"))

table_cap_df.to_csv(snakemake.output.capacities)

0 comments on commit 1448fb7

Please sign in to comment.