From fec871c1ccce766b8c710c67f35f4d407278a443 Mon Sep 17 00:00:00 2001 From: Michael Lindner Date: Wed, 17 Jan 2024 18:28:37 +0100 Subject: [PATCH 1/2] eliminate a few future warnings --- scripts/make_summary.py | 15 +++++++-------- scripts/plot_summary.py | 6 +++--- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/scripts/make_summary.py b/scripts/make_summary.py index fb13e91e..9da915ef 100644 --- a/scripts/make_summary.py +++ b/scripts/make_summary.py @@ -522,8 +522,8 @@ def calculate_weighted_prices(n, label, weighted_prices): if not names.empty: load += ( n.links_t.p0[names] - .groupby(n.links.loc[names, "bus0"], axis=1) - .sum() + .T.groupby(n.links.loc[names, "bus0"]) + .sum().T ) # Add H2 Store when charging @@ -560,14 +560,13 @@ def calculate_market_values(n, label, market_values): for tech in techs: gens = generators[n.generators.loc[generators, "carrier"] == tech] - + dispatch = ( n.generators_t.p[gens] - .groupby(n.generators.loc[gens, "bus"], axis=1) - .sum() + .T.groupby(n.generators.loc[gens, "bus"]) + .sum().T .reindex(columns=buses, fill_value=0.0) ) - revenue = dispatch * n.buses_t.marginal_price[buses] market_values.at[tech, label] = revenue.sum().sum() / dispatch.sum().sum() @@ -586,8 +585,8 @@ def calculate_market_values(n, label, market_values): dispatch = ( n.links_t["p" + i][links] - .groupby(n.links.loc[links, "bus" + i], axis=1) - .sum() + .T.groupby(n.links.loc[links, "bus" + i]) + .sum().T .reindex(columns=buses, fill_value=0.0) ) diff --git a/scripts/plot_summary.py b/scripts/plot_summary.py index 67ac9b55..e0067d7f 100644 --- a/scripts/plot_summary.py +++ b/scripts/plot_summary.py @@ -154,7 +154,7 @@ def plot_costs(): df = df.drop(to_drop) - logger.info(f"Total system cost of {round(df.sum()[0])} EUR billion per year") + logger.info(f"Total system cost of {round(df.sum().iloc[0])} EUR billion per year") new_index = preferred_order.intersection(df.index).append( df.index.difference(preferred_order) @@ -214,7 +214,7 @@ def plot_energy(): df = df.drop(to_drop) - logger.info(f"Total energy of {round(df.sum()[0])} TWh/a") + logger.info(f"Total energy of {round(df.sum().iloc[0])} TWh/a") if df.empty: fig, ax = plt.subplots(figsize=(12, 8)) @@ -304,7 +304,7 @@ def plot_balances(): df = df.drop(to_drop) - logger.debug(f"Total energy balance for {v} of {round(df.sum()[0],2)} {units}") + logger.debug(f"Total energy balance for {v} of {round(df.sum().iloc[0],2)} {units}") if df.empty: continue From 213c4b025e9b53a8ed56a4745e0410baa86dbb2f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 17 Jan 2024 17:29:45 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- scripts/make_summary.py | 14 ++++++-------- scripts/plot_summary.py | 4 +++- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/make_summary.py b/scripts/make_summary.py index 9da915ef..7223f4d5 100644 --- a/scripts/make_summary.py +++ b/scripts/make_summary.py @@ -521,9 +521,7 @@ def calculate_weighted_prices(n, label, weighted_prices): if not names.empty: load += ( - n.links_t.p0[names] - .T.groupby(n.links.loc[names, "bus0"]) - .sum().T + n.links_t.p0[names].T.groupby(n.links.loc[names, "bus0"]).sum().T ) # Add H2 Store when charging @@ -560,12 +558,12 @@ def calculate_market_values(n, label, market_values): for tech in techs: gens = generators[n.generators.loc[generators, "carrier"] == tech] - + dispatch = ( n.generators_t.p[gens] .T.groupby(n.generators.loc[gens, "bus"]) - .sum().T - .reindex(columns=buses, fill_value=0.0) + .sum() + .T.reindex(columns=buses, fill_value=0.0) ) revenue = dispatch * n.buses_t.marginal_price[buses] @@ -586,8 +584,8 @@ def calculate_market_values(n, label, market_values): dispatch = ( n.links_t["p" + i][links] .T.groupby(n.links.loc[links, "bus" + i]) - .sum().T - .reindex(columns=buses, fill_value=0.0) + .sum() + .T.reindex(columns=buses, fill_value=0.0) ) revenue = dispatch * n.buses_t.marginal_price[buses] diff --git a/scripts/plot_summary.py b/scripts/plot_summary.py index e0067d7f..2a6c9f15 100644 --- a/scripts/plot_summary.py +++ b/scripts/plot_summary.py @@ -304,7 +304,9 @@ def plot_balances(): df = df.drop(to_drop) - logger.debug(f"Total energy balance for {v} of {round(df.sum().iloc[0],2)} {units}") + logger.debug( + f"Total energy balance for {v} of {round(df.sum().iloc[0],2)} {units}" + ) if df.empty: continue