Skip to content

Commit

Permalink
minor updates and replace energy balance by new statistics implementa…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
p-glaum committed Jul 8, 2024
1 parent 9f17ca0 commit dda6baf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
13 changes: 9 additions & 4 deletions scripts/plot_statistics_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,18 @@ def plot_static_comparison(df, ax, stacked=False):
df = df.div(float(factor)) if factor != "-" else df
df = df.rename(index=rename_techs).groupby(["component", "carrier"]).sum()
# sort values in descending order
df = df.reindex(df.sum(1).sort_values().index)
df = df.reindex(df.abs().sum(1).sort_values().index)
carriers = df.index.get_level_values("carrier")
carrier_colors = get_carrier_colors(carriers, tech_colors)
df = df.pipe(rename_index).T
# max_carrier_value = df.max(axis=1)
# df.div(max_carrier_value, axis=0).where(lambda x: abs(x)<0.05).all()
df.plot.bar(color=carrier_colors, ax=ax, stacked=stacked, legend=False, ylabel=unit)
df.plot.bar(
color=carrier_colors,
ax=ax,
stacked=stacked,
legend=False,
ylabel=unit,
linewidth=0.1,
)
ax.legend(
bbox_to_anchor=(1, 1),
loc="upper left",
Expand Down
10 changes: 0 additions & 10 deletions scripts/write_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,6 @@ def call_with_handle(func, **kwargs):
for output in snakemake.output.keys():
if "touch" in output:
continue
# if output == "energy_balance":
# supply = call_with_handle(n.statistics.supply, **kwargs)
# withdrawal = call_with_handle(n.statistics.withdrawal, **kwargs)
# ds = (
# pd.concat([supply, withdrawal.mul(-1)])
# .groupby(level=["component", "country", "carrier"])
# .sum()
# )
# ds.attrs = supply.attrs
# ds.attrs["name"] = "Energy Balance"
elif output == "total_cost":
opex = call_with_handle(n.statistics.opex, **kwargs)
capex = call_with_handle(n.statistics.capex, **kwargs)
Expand Down

0 comments on commit dda6baf

Please sign in to comment.