Merge branch 'feature/add-nodal-supply-energy' of github.com:Climact/pypsa-eur-climact into Climact-feature/add-nodal-supply-energy
This commit is contained in:
commit
e322e21771
@ -212,6 +212,8 @@ Upcoming Release
|
|||||||
|
|
||||||
* Fix custom busmap read in `cluster_network`.
|
* Fix custom busmap read in `cluster_network`.
|
||||||
|
|
||||||
|
* Add `nodal_supply_energy` to `make_summary`.
|
||||||
|
|
||||||
* Data on existing renewable capacities is now consistently taken from powerplantmatching (instead of being retrieved separately); the dataset has also been updated to include 2023 values.
|
* Data on existing renewable capacities is now consistently taken from powerplantmatching (instead of being retrieved separately); the dataset has also been updated to include 2023 values.
|
||||||
|
|
||||||
* Added shapes to .nc file for different stages of the network object in `base_network`, `simplify_network`, and `cluster_network`; the `build_bus_regions` rule is now integrated into the `base_network` rule.
|
* Added shapes to .nc file for different stages of the network object in `base_network`, `simplify_network`, and `cluster_network`; the `build_bus_regions` rule is now integrated into the `base_network` rule.
|
||||||
|
@ -199,6 +199,7 @@ rule make_summary:
|
|||||||
energy=RESULTS + "csvs/energy.csv",
|
energy=RESULTS + "csvs/energy.csv",
|
||||||
supply=RESULTS + "csvs/supply.csv",
|
supply=RESULTS + "csvs/supply.csv",
|
||||||
supply_energy=RESULTS + "csvs/supply_energy.csv",
|
supply_energy=RESULTS + "csvs/supply_energy.csv",
|
||||||
|
nodal_supply_energy=RESULTS + "csvs/nodal_supply_energy.csv",
|
||||||
prices=RESULTS + "csvs/prices.csv",
|
prices=RESULTS + "csvs/prices.csv",
|
||||||
weighted_prices=RESULTS + "csvs/weighted_prices.csv",
|
weighted_prices=RESULTS + "csvs/weighted_prices.csv",
|
||||||
market_values=RESULTS + "csvs/market_values.csv",
|
market_values=RESULTS + "csvs/market_values.csv",
|
||||||
|
@ -413,6 +413,76 @@ def calculate_supply_energy(n, label, supply_energy):
|
|||||||
return supply_energy
|
return supply_energy
|
||||||
|
|
||||||
|
|
||||||
|
def calculate_nodal_supply_energy(n, label, nodal_supply_energy):
|
||||||
|
"""
|
||||||
|
Calculate the total energy supply/consumption of each component at the buses
|
||||||
|
aggregated by carrier and node.
|
||||||
|
"""
|
||||||
|
|
||||||
|
bus_carriers = n.buses.carrier.unique()
|
||||||
|
|
||||||
|
for i in bus_carriers:
|
||||||
|
bus_map = n.buses.carrier == i
|
||||||
|
bus_map.at[""] = False
|
||||||
|
|
||||||
|
for c in n.iterate_components(n.one_port_components):
|
||||||
|
items = c.df.index[c.df.bus.map(bus_map).fillna(False)]
|
||||||
|
|
||||||
|
if len(items) == 0:
|
||||||
|
continue
|
||||||
|
|
||||||
|
s = (
|
||||||
|
pd.concat([
|
||||||
|
(
|
||||||
|
c.pnl.p[items]
|
||||||
|
.multiply(n.snapshot_weightings.generators, axis=0)
|
||||||
|
.sum()
|
||||||
|
.multiply(c.df.loc[items, "sign"])
|
||||||
|
),
|
||||||
|
c.df.loc[items][["bus", "carrier"]]
|
||||||
|
], axis=1)
|
||||||
|
.groupby(by=["bus", "carrier"])
|
||||||
|
.sum()[0]
|
||||||
|
)
|
||||||
|
s = pd.concat([s], keys=[c.list_name])
|
||||||
|
s = pd.concat([s], keys=[i])
|
||||||
|
|
||||||
|
nodal_supply_energy = nodal_supply_energy.reindex(s.index.union(nodal_supply_energy.index))
|
||||||
|
nodal_supply_energy.loc[s.index, label] = s
|
||||||
|
|
||||||
|
for c in n.iterate_components(n.branch_components):
|
||||||
|
for end in [col[3:] for col in c.df.columns if col[:3] == "bus"]:
|
||||||
|
items = c.df.index[c.df["bus" + str(end)].map(bus_map).fillna(False)]
|
||||||
|
|
||||||
|
if (len(items) == 0) or c.pnl["p" + end].empty:
|
||||||
|
continue
|
||||||
|
|
||||||
|
s = (
|
||||||
|
pd.concat([
|
||||||
|
(
|
||||||
|
(-1) * c.pnl["p" + end][items]
|
||||||
|
.multiply(n.snapshot_weightings.generators, axis=0)
|
||||||
|
.sum()
|
||||||
|
),
|
||||||
|
c.df.loc[items][["bus0", "carrier"]]
|
||||||
|
], axis=1)
|
||||||
|
.groupby(by=["bus0", "carrier"])
|
||||||
|
.sum()[0]
|
||||||
|
)
|
||||||
|
|
||||||
|
s.index = s.index.map(lambda x: (x[0], x[1] + end))
|
||||||
|
s = pd.concat([s], keys=[c.list_name])
|
||||||
|
s = pd.concat([s], keys=[i])
|
||||||
|
|
||||||
|
nodal_supply_energy = nodal_supply_energy.reindex(
|
||||||
|
s.index.union(nodal_supply_energy.index)
|
||||||
|
)
|
||||||
|
|
||||||
|
nodal_supply_energy.loc[s.index, label] = s
|
||||||
|
|
||||||
|
return nodal_supply_energy
|
||||||
|
|
||||||
|
|
||||||
def calculate_metrics(n, label, metrics):
|
def calculate_metrics(n, label, metrics):
|
||||||
metrics_list = [
|
metrics_list = [
|
||||||
"line_volume",
|
"line_volume",
|
||||||
@ -637,6 +707,7 @@ def make_summaries(networks_dict):
|
|||||||
"energy",
|
"energy",
|
||||||
"supply",
|
"supply",
|
||||||
"supply_energy",
|
"supply_energy",
|
||||||
|
"nodal_supply_energy",
|
||||||
"prices",
|
"prices",
|
||||||
"weighted_prices",
|
"weighted_prices",
|
||||||
"price_statistics",
|
"price_statistics",
|
||||||
|
Loading…
Reference in New Issue
Block a user