-
Notifications
You must be signed in to change notification settings - Fork 19
feat(plot): add voltage-over-distance comparison plots for LV and MV #590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
| return s | ||
|
|
||
|
|
||
| def _shortest_distances_km(G, source_bus: str, weight: Optional[str] = "length") -> pd.Series: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We allready have the function edisgo.tools.tools.get_path_length_to_station
| title = None | ||
| plots.histogram(data=data, title=title, timeindex=timestep, **kwargs) | ||
|
|
||
| def plot_voltage_over_dist(self, mv_id, lv_id, other, save_as=False, split_branches=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other parameter should be obsolete. The comparison between two grids should also be optional (sorry, I didn’t describe this correctly before). You shouldn’t need this parameter, since the reinforcement results are already stored in the edisgo object.
Have a look at the plot_plotly function here. In that function, the reinforcement results are taken directly from the object itself, which allows you to compare both versions.
|
|
||
| # Distances (Dijkstra) | ||
| # Edge weight attribute commonly is 'length' in eDisGo graphs; adjust if your graph uses 'length_km' | ||
| dist_a = _shortest_distances_km(lv_grid_a.graph, source_bus=source_a, weight="length") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| v_b_feed = _series_at_t(v_b, t_feed_b) | ||
|
|
||
| # Buses to plot: intersection | ||
| buses = pd.Index([str(b) for b in lv_grid_a.buses_df.index]).intersection( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use all buses. As explained above, you don’t need to take the intersection, since both grids are identical.
| # needs analysis results | ||
| self.edisgo.analyze() | ||
| v_res = self.edisgo.results.v_res() if callable(self.edisgo.results.v_res) else self.edisgo.results.v_res | ||
| if getattr(v_res, "empty", True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't build a skip function in a test since you want to see the test failing.
| def test_plot_voltage_over_dist_mv(self): | ||
| self.edisgo.analyze() | ||
| v_res = self.edisgo.results.v_res() if callable(self.edisgo.results.v_res) else self.edisgo.results.v_res | ||
| if getattr(v_res, "empty", True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
| if getattr(v_res, "empty", True): | ||
| import pytest | ||
| pytest.skip("No voltage results (v_res empty) in this test fixture; skipping voltage-over-distance plot test.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same as above
| import pytest | ||
| pytest.skip("No voltage results (v_res empty) in this test fixture; skipping voltage-over-distance plot test.") | ||
| fig = self.edisgo.plot_voltage_over_dist_mv(mv_id=None, other=other) | ||
| assert fig is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test only checks whether a figure is created, not whether the results are the expected ones. To test that, you would probably need the new functions to return the DataFrames, so you can verify that the DataFrames contain the expected values.
Description
This PR adds Plotly-based “voltage over distance” comparison plots to eDisGo.
It introduces two new methods on
EDisGo:plot_voltage_over_dist(mv_id, lv_id, other, save_as=False, split_branches=False)LV voltage (p.u.) vs. shortest-path distance to the MV/LV transformer; compares two
EDisGoobjects and visualizes load/feed-in worst cases. Includes LV tolerance band (0.90–1.10 p.u.).plot_voltage_over_dist_mv(mv_id, other, save_as=False)MV voltage (p.u.) vs. shortest-path distance to the HV/MV transformer; compares two
EDisGoobjects and visualizes load/feed-in worst cases. Includes MV tolerance band (0.96–1.06 p.u.).Distances are computed using Dijkstra shortest paths on the grid graph. Export to HTML/PNG is supported via
save_as. Core logic is implemented inedisgo/tools/voltage_over_distance.pywith thin wrappers inedisgo/edisgo.py. Tests are added (skipped whenresults.v_resis empty in the default fixture).Fixes #565
Type of change
Checklist:
pre-commithooks