|
def plot_storage_expansion( |
|
ego, filename=None, dpi=300, column="overnight_costs", scaling=1 |
|
): |
|
"""Plot line expantion |
|
|
|
Parameters |
|
---------- |
|
ego : :class:`ego.tools.io.eGo` |
|
eGo ``eGo`` inclueds eTraGo and eDisGo results |
|
filename: str |
|
Filename and/or path of location to store graphic |
|
dpi: int |
|
dpi value of graphic |
|
column: str |
|
column name of eTraGo's line costs. Default: ``overnight_costs`` in EURO. |
|
Also available ``s_nom_expansion`` in MVA or |
|
annualized ``investment_costs`` in EURO |
|
scaling: numeric |
|
Factor to scale storage size of bus_sizes |
|
|
|
Returns |
|
------- |
|
plot :obj:`matplotlib.pyplot.show` |
|
https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.show |
|
""" |
|
|
|
network = ego.etrago.network |
|
json_file = ego.json_file |
|
|
|
# get storage values |
|
if "storage" in ego.json_file["eTraGo"]["extendable"]: |
|
storage_inv = network.storage_units[network.storage_units.capital_cost > 0.0] |
|
storage_inv["investment_costs"] = ( |
|
storage_inv.capital_cost * storage_inv.p_nom_opt |
|
) |
|
storage_inv["overnight_costs"] = etrago_convert_overnight_cost( |
|
storage_inv["investment_costs"], json_file |
|
) |
|
|
|
msd_max = storage_inv[column].max() |
|
msd_median = storage_inv[column].median() |
|
msd_min = storage_inv[column].min() |
|
|
|
if (msd_max - msd_min) > 1.0e5: |
|
|
|
if msd_max != 0: |
|
LabelVal = int(log10(msd_max)) |
|
else: |
|
LabelVal = 0 |
|
if LabelVal < 0: |
|
LabelUnit = "€" |
|
msd_max, msd_median, msd_min = ( |
|
msd_max * 1000, |
|
msd_median * 1000, |
|
msd_min * 1000, |
|
) |
|
storage_inv[column] = storage_inv[column] * 1000 |
|
elif LabelVal < 3: |
|
LabelUnit = "k €" |
|
else: |
|
LabelUnit = "M €" |
|
msd_max, msd_median, msd_min = ( |
|
msd_max / 1000, |
|
msd_median / 1000, |
|
msd_min / 1000, |
|
) |
|
storage_inv[column] = storage_inv[column] / 1000 |
|
else: |
|
LabelUnit = "€" |
|
|
|
# start plotting |
|
figsize = 6, 6 |
|
fig, ax = plt.subplots(1, 1, figsize=(figsize)) |
|
|
|
bus_sizes = storage_inv[column] * scaling |
|
|
|
if column == "investment_costs": |
|
title = "Annualized Storage costs per timestep" |
|
ltitel = "Storage costs" |
|
if column == "overnight_costs": |
|
title = "Total Expansion Costs Overnight" |
|
ltitel = "Storage costs" |
|
if column == "p_nom_opt": |
|
title = "Storage Expansion in MVA" |
|
ltitel = "Storage size" |
|
LabelUnit = "kW" |
|
if column not in ["investment_costs", "overnight_costs", "p_nom_opt"]: |
|
title = "unknown" |
|
ltitel = "unknown" |
|
LabelUnit = "unknown" |
|
|
|
if sum(storage_inv[column]) == 0: |
|
sc = network.plot(bus_sizes=0, ax=ax, title="No storage expantion") |
|
else: |
|
sc = network.plot( |
|
bus_sizes=bus_sizes, |
|
bus_colors="g", |
|
# bus_cmap= |
|
# line_colors='gray', |
|
title=title, |
|
line_widths=0.3, |
|
) |
|
|
|
ax.set_alpha(0.4) |
|
|
|
# add legend |
|
for area in [msd_max, msd_median, msd_min]: |
|
plt.scatter( |
|
[], |
|
[], |
|
c="white", |
|
s=area * scaling, |
|
label="= " + str(round(area, 0)) + LabelUnit + " ", |
|
) |
|
|
|
plt.legend( |
|
scatterpoints=1, |
|
labelspacing=1, |
|
title=ltitel, |
|
loc="upper left", |
|
shadow=True, |
|
fontsize="x-large", |
|
) |
|
|
|
ax.autoscale(tight=True) |
|
|
|
if filename is None: |
|
plt.show() |
|
else: |
|
fig = ax.get_figure() |
|
fig.set_size_inches(10, 8, forward=True) |
|
fig.savefig(filename, dpi=dpi) |
|
plt.close() |
|
|
|
|
|
def plot_line_expansion(ego, filename=None, dpi=300, column="overnight_costs"): |
|
"""Plot line expantion |
|
|
|
Parameters |
|
---------- |
|
ego : :class:`ego.tools.io.eGo` |
|
eGo ``eGo`` inclueds eTraGo and eDisGo results |
|
filename: str |
|
Filename and or path of location to store graphic |
|
dpi: int |
|
dpi value of graphic |
|
column: str |
|
column name of eTraGo's line costs. Default: ``overnight_costs`` in EUR. |
|
Also available ``s_nom_expansion`` in MVA or |
|
annualized ``investment_costs`` in EUR |
|
|
|
Returns |
|
------- |
|
plot :obj:`matplotlib.pyplot.show` |
|
https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.show |
|
""" |
|
|
|
network = ego.etrago.network |
|
json_file = ego.json_file |
|
|
|
# get values |
|
if "network" in ego.json_file["eTraGo"]["extendable"]: |
|
network.lines["s_nom_expansion"] = network.lines.s_nom_opt.subtract( |
|
network.lines.s_nom, axis="index" |
|
) |
|
network.lines["investment_costs"] = network.lines.s_nom_expansion.multiply( |
|
network.lines.capital_cost, axis="index" |
|
) |
|
network.lines["overnight_costs"] = etrago_convert_overnight_cost( |
|
network.lines["investment_costs"], json_file |
|
) |
|
|
|
else: |
|
network.lines["s_nom_expansion"] = None |
|
network.lines["investment_costs"] = None |
|
network.lines["overnight_costs"] = None |
|
|
|
# start plotting |
|
figsize = 10, 8 |
|
fig, ax = plt.subplots(1, 1, figsize=(figsize)) |
|
|
|
cmap = plt.cm.jet |
|
|
|
if column == "s_nom_expansion": |
|
line_value = network.lines[column] |
|
title = "Line expansion in MVA" |
|
if column == "overnight_costs": |
|
line_value = network.lines[column] |
|
title = "Total Expansion Costs in € per line" |
|
if column == "investment_costs": |
|
line_value = network.lines[column] |
|
title = "Annualized Expansion Costs in € per line and time step" |
|
|
|
line_widths = line_value / line_value.max() |
|
|
|
lc = network.plot( |
|
ax=ax, |
|
line_colors=line_value, |
|
line_cmap=cmap, |
|
title=title, |
|
line_widths=line_widths, |
|
) |
|
|
|
boundaries = [min(line_value), max(line_value)] |
|
|
|
v = np.linspace(boundaries[0], boundaries[1], 101) |
|
print(v.dtype.name) |
|
# colorbar |
|
cb = plt.colorbar(lc[1], boundaries=v, ticks=v[0:101:10], ax=ax) |
|
cb.set_clim(vmin=boundaries[0], vmax=boundaries[1]) |
|
|
|
if column == "s_nom_expansion": |
|
cb.set_label("Expansion in MVA per line") |
|
if column == "overnight_costs": |
|
cb.set_label("Total Expansion Costs in € per line") |
|
if column == "investment_costs": |
|
cb.set_label("Annualized Expansion Costs in € per line") |
|
|
|
ax.autoscale(tight=True) |
|
|
|
if filename is None: |
|
plt.show() |
|
else: |
|
fig = ax.get_figure() |
|
fig.set_size_inches(10, 8, forward=True) |
|
fig.savefig(filename, dpi=dpi) |
|
plt.close() |
|
|
|
|
|
def plot_grid_storage_investment(costs_df, filename, display, var=None): |
|
"""Plot total grid and storage investment. |
|
|
|
Parameters |
|
---------- |
|
costs_df: :pandas:`pandas.DataFrame<dataframe>` |
|
Dataframe containing total_investment_costs of ego |
|
filename: str |
|
Filename and or path of location to store graphic |
|
display: bool |
|
Display plot |
|
var: str |
|
Cost variable of ``overnight_cost`` by default displays annualized |
|
costs of timesteps |
|
|
|
Returns |
|
------- |
|
plot :obj:`matplotlib.pyplot.show` |
|
https://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.show |
|
|
|
|
|
""" |
|
colors = ego_colore() |
|
bar_width = 0.35 |
|
opacity = 0.4 |
|
|
|
if var == "overnight_cost": |
|
tic = costs_df[ |
|
["component", "overnight_costs", "voltage_level", "differentiation"] |
|
] |
|
tic.set_index(["voltage_level", "component", "differentiation"], inplace=True) |
|
ax = tic.unstack().plot( |
|
kind="bar", |
|
stacked=False, |
|
rot=0, |
|
color=([colors.get(key) for key in ["egoblue1", "egoblue2", "egoblue4"]]), |
|
legend=False, |
|
) |
|
ax.set_ylabel("Overnight costs of simulation") |
|
ax.set_title( |
|
"Total costs of simulation, " "voltage level and component", y=1.08 |
|
) |
|
|
|
else: |
|
tic = costs_df[ |
|
["component", "capital_cost", "voltage_level", "differentiation"] |
|
] |
|
tic.set_index(["voltage_level", "component", "differentiation"], inplace=True) |
|
ax = tic.unstack().plot( |
|
kind="bar", |
|
rot=0, |
|
stacked=False, |
|
color=([colors.get(key) for key in ["egoblue1", "egoblue2", "egoblue3"]]), |
|
legend=False, |
|
) |
|
ax.set_ylabel("Annualized costs per simulation periods") |
|
ax.set_title( |
|
"Annualized costs per simulation periods, " "voltage level and component", |
|
y=1.08, |
|
) |
|
|
|
ax.set_xlabel("Voltage level and component") |
|
ax.set_yscale("symlog") |
|
ax.legend(("cross-border", "domestic", "foreign")) |
|
ax.autoscale() |
|
|
|
if display is True: |
|
plt.show() |
|
else: |
|
fig = ax.get_figure() |
|
fig.set_size_inches(10, 8, forward=True) |
|
fig.savefig(filename, dpi=100) |
|
plt.close() |
eGo currently includes functions which analyze only the transmission grid side. It would be better to migrate them to eTraGo, or replace them with existing eTraGo-functions.
eGo/ego/tools/economics.py
Lines 117 to 162 in d121771
-> should be moved to eTraGo and needs to be adjusted
eGo/ego/tools/plots.py
Lines 78 to 111 in d121771
-> can be replaced by etrago.carrier_colors
eGo/ego/tools/plots.py
Lines 132 to 433 in d121771
-> in case these are only plotting results from eTraGo, they can be replaced by existing eTraGo plots
eGo/ego/tools/plots.py
Lines 436 to 527 in d121771
-> sth like this is currently not part of eTraGo. If we need it, it needs to be adjusted and moved to eTraGo
eGo/ego/tools/plots.py
Lines 530 to 576 in d121771
-> not working anymore, no data from renpass gis, do we need it?