remove plot_series() leftovers

This commit is contained in:
Fabian Neumann 2024-01-25 17:32:17 +01:00
parent 46a2f55c1b
commit ce4d18c861

View File

@ -671,168 +671,6 @@ def plot_ch4_map(network):
)
<<<<<<< HEAD
def plot_series(network, carrier="AC", name="test"):
n = network.copy()
assign_location(n)
assign_carriers(n)
buses = n.buses.index[n.buses.carrier.str.contains(carrier)]
supply = pd.DataFrame(index=n.snapshots)
for c in n.iterate_components(n.branch_components):
n_port = 4 if c.name == "Link" else 2
for i in range(n_port):
supply = pd.concat(
(
supply,
(
-1
* c.pnl[f"p{str(i)}"]
.loc[:, c.df.index[c.df[f"bus{str(i)}"].isin(buses)]]
.groupby(c.df.carrier, axis=1)
.sum()
),
),
axis=1,
)
for c in n.iterate_components(n.one_port_components):
comps = c.df.index[c.df.bus.isin(buses)]
supply = pd.concat(
(
supply,
((c.pnl["p"].loc[:, comps]).multiply(c.df.loc[comps, "sign"]))
.groupby(c.df.carrier, axis=1)
.sum(),
),
axis=1,
)
supply = supply.groupby(rename_techs_tyndp, axis=1).sum()
both = supply.columns[(supply < 0.0).any() & (supply > 0.0).any()]
positive_supply = supply[both]
negative_supply = supply[both]
positive_supply[positive_supply < 0.0] = 0.0
negative_supply[negative_supply > 0.0] = 0.0
supply[both] = positive_supply
suffix = " charging"
negative_supply.columns = negative_supply.columns + suffix
supply = pd.concat((supply, negative_supply), axis=1)
# 14-21.2 for flaute
# 19-26.1 for flaute
start = "2013-02-19"
stop = "2013-02-26"
threshold = 10e3
to_drop = supply.columns[(abs(supply) < threshold).all()]
if len(to_drop) != 0:
logger.info(f"Dropping {to_drop.tolist()} from supply")
supply.drop(columns=to_drop, inplace=True)
supply.index.name = None
supply = supply / 1e3
supply.rename(
columns={"electricity": "electric demand", "heat": "heat demand"}, inplace=True
)
supply.columns = supply.columns.str.replace("residential ", "")
supply.columns = supply.columns.str.replace("services ", "")
supply.columns = supply.columns.str.replace("urban decentral ", "decentral ")
preferred_order = pd.Index(
[
"electric demand",
"transmission lines",
"hydroelectricity",
"hydro reservoir",
"run of river",
"pumped hydro storage",
"CHP",
"onshore wind",
"offshore wind",
"solar PV",
"solar thermal",
"building retrofitting",
"ground heat pump",
"air heat pump",
"resistive heater",
"OCGT",
"gas boiler",
"gas",
"natural gas",
"methanation",
"hydrogen storage",
"battery storage",
"hot water storage",
]
)
new_columns = preferred_order.intersection(supply.columns).append(
supply.columns.difference(preferred_order)
)
supply = supply.groupby(supply.columns, axis=1).sum()
fig, ax = plt.subplots()
fig.set_size_inches((8, 5))
(
supply.loc[start:stop, new_columns].plot(
ax=ax,
kind="area",
stacked=True,
linewidth=0.0,
color=[
snakemake.params.plotting["tech_colors"][i.replace(suffix, "")]
for i in new_columns
],
)
)
handles, labels = ax.get_legend_handles_labels()
handles.reverse()
labels.reverse()
new_handles = []
new_labels = []
for i, item in enumerate(labels):
if "charging" not in item:
new_handles.append(handles[i])
new_labels.append(labels[i])
ax.legend(new_handles, new_labels, ncol=3, loc="upper left", frameon=False)
ax.set_xlim([start, stop])
ax.set_ylim([-1300, 1900])
ax.grid(True)
ax.set_ylabel("Power [GW]")
fig.tight_layout()
fig.savefig(
"results/{}maps/series-{}-{}-{}-{}.pdf".format(
snakemake.params.RDIR,
snakemake.wildcards["ll"],
carrier,
start,
stop,
),
transparent=True,
)
def plot_map_perfect(
network,
components=["Link", "Store", "StorageUnit", "Generator"],
@ -985,8 +823,6 @@ def plot_map_perfect(
)
=======
>>>>>>> ead390b4 (plot_network: remove function plot_series())
if __name__ == "__main__":
if "snakemake" not in globals():
from _helpers import mock_snakemake