Skip to content

Commit

Permalink
plots: Add more plot types
Browse files Browse the repository at this point in the history
  • Loading branch information
stroitzsch committed Sep 13, 2023
1 parent 2de275f commit da643c8
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions examples/development/entrypoint_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def main():
mesmo.plots.der_aggregated_active_power_time_series(run_results, results_path)
mesmo.plots.der_aggregated_reactive_power_time_series(run_results, results_path)
mesmo.plots.der_aggregated_apparent_power_time_series(run_results, results_path)
mesmo.plots.node_voltage_per_unit_time_series(run_results, results_path)
mesmo.plots.node_aggregated_voltage_per_unit_time_series(run_results, results_path)

# Print results path.
mesmo.utils.launch(results_path)
Expand Down
2 changes: 2 additions & 0 deletions mesmo/plots/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
der_aggregated_active_power_time_series,
der_aggregated_reactive_power_time_series,
der_aggregated_apparent_power_time_series,
node_voltage_per_unit_time_series,
node_aggregated_voltage_per_unit_time_series,
)
3 changes: 3 additions & 0 deletions mesmo/plots/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ class ValueUnitLabels(str, enum.Enum):
WATT = "MW"
VOLT_AMPERE_REACTIVE = "MVAr"
VOLT_AMPERE = "MVA"
VOLT_PER_UNIT = "V (per-unit)"


class ValueLabels(str, enum.Enum):
TIME = "Date/Time"
DERS = "DERs"
NODES = "Nodes"
ACTIVE_POWER = "Active power"
REACTIVE_POWER = "Reactive power"
APPARENT_POWER = "Apparent power"
VOLTAGE = "Voltage"
41 changes: 41 additions & 0 deletions mesmo/plots/time_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def der_aggregated_active_power_time_series(results: data_models.RunResults, res
title=title,
xaxis_title=x_label,
yaxis_title=y_label,
showlegend=False,
)
plot_utils.write_figure_plotly(figure, results_path / filename)

Expand All @@ -104,6 +105,7 @@ def der_aggregated_reactive_power_time_series(results: data_models.RunResults, r
title=title,
xaxis_title=x_label,
yaxis_title=y_label,
showlegend=False,
)
plot_utils.write_figure_plotly(figure, results_path / filename)

Expand All @@ -126,5 +128,44 @@ def der_aggregated_apparent_power_time_series(results: data_models.RunResults, r
title=title,
xaxis_title=x_label,
yaxis_title=y_label,
showlegend=False,
)
plot_utils.write_figure_plotly(figure, results_path / filename)

def node_voltage_per_unit_time_series(results: data_models.RunResults, results_path: pathlib.Path):
title = f"{constants.ValueLabels.VOLTAGE} per Nodes"
filename = node_voltage_per_unit_time_series.__name__
x_label = constants.ValueLabels.TIME
y_label = f"{constants.ValueLabels.VOLTAGE} [{constants.ValueUnitLabels.VOLT_PER_UNIT}]"
legend_title = constants.ValueLabels.NODES

figure = go.Figure()
for node_type, node_name, phase in results.electric_grid_model_index.nodes:
values = results.electric_grid_operation_results.node_voltage_magnitude_vector_per_unit.loc[:, (slice(None), node_name, slice(None))].mean(axis="columns")
figure.add_trace(go.Scatter(x=values.index, y=values.values, name=f"{node_name} ({node_type})"))
figure.update_layout(
title=title,
xaxis_title=x_label,
yaxis_title=y_label,
legend=go.layout.Legend(title=legend_title, x=0.99, xanchor="auto", y=0.99, yanchor="auto"),
)
plot_utils.write_figure_plotly(figure, results_path / filename)


def node_aggregated_voltage_per_unit_time_series(results: data_models.RunResults, results_path: pathlib.Path):
title = f"{constants.ValueLabels.VOLTAGE} aggregated for all Nodes"
filename = node_voltage_per_unit_time_series.__name__
x_label = constants.ValueLabels.TIME
y_label = f"{constants.ValueLabels.VOLTAGE} [{constants.ValueUnitLabels.VOLT_PER_UNIT}]"

figure = go.Figure()
for timestep in results.electric_grid_model_index.timesteps:
values = results.electric_grid_operation_results.node_voltage_magnitude_vector_per_unit.loc[timestep, :]
figure.add_trace(go.Box(name=timestep.isoformat(), y=values.T.values))
figure.update_layout(
title=title,
xaxis_title=x_label,
yaxis_title=y_label,
showlegend=False,
)
plot_utils.write_figure_plotly(figure, results_path / filename)

0 comments on commit da643c8

Please sign in to comment.