Skip to content
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

Feature/#532 update to plotpy #568

Merged
merged 63 commits into from
Sep 27, 2023
Merged

Feature/#532 update to plotpy #568

merged 63 commits into from
Sep 27, 2023

Conversation

Alonsoju95
Copy link
Contributor

changes in plot.py in calc_network_expansion to plot only DC links and in v_nom

@CarlosEpia
Copy link
Contributor

When I try etrago.plot_grid(line_colors= "v_nom" , bus_sizes= 0.001), the result looks like the figure below. I can see that there are some buses which are nor connected. Are they not electrical? in that case, they should not be plotted.
image

@CarlosEpia
Copy link
Contributor

The option line_colors= "line_loading" is not working for me. Does it work in your machine?
image

@CarlosEpia
Copy link
Contributor

The default value fo bus_sizes produces plots like this. I would suggest finding a better one. Additionally, the message "WARNING:etrago.tools.plot:bus_color grey undefined" appears.
image

@CarlosEpia
Copy link
Contributor

The network expansion looks like the figure below. Since you are showing just electrical network expansion, the other sectors are not supposed to be displayed. This makes the extension of the map to go until Rusia, but would be better to stay around Germany.
image

Copy link
Contributor

@CarlosEpia CarlosEpia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Alonso,
I tested the main features of the plot_grid function and left some comments. Please check and apply them. Furthermore, please check each one of the options we have for the parameters line_colors and bus_colors before the next review.

@Alonsoju95
Copy link
Contributor Author

Hi @CarlosEpia

I made some changes and now its only plotting AC buses in expansion_abs plot
I will continue working on the other comments

expansion_abs

@Alonsoju95
Copy link
Contributor Author

Hi @CarlosEpia

This is how etrago.plot_grid(line_colors= "v_nom" , bus_sizes= 0.001) looks like now. I have just pushed the changes
image

@Alonsoju95
Copy link
Contributor Author

Hi @CarlosEpia
I have made the required changes.
Can you take a look again?
Thanks
Alonso

@CarlosEpia
Copy link
Contributor

Hi @CarlosEpia I have made the required changes. Can you take a look again? Thanks Alonso

Hi Alonso. Please send me by email plots where we can see the current state of each plot available in the function plot_grid(). Then I will proceed to check the code.

@CarlosEpia CarlosEpia self-requested a review March 31, 2023 11:17
@CarlosEpia
Copy link
Contributor

It is working in a new environment. It would still be good to know which package version created the problem to adjust the installation of eTraGo.

The plots you mentioned above are working, I didn't tested all of them, bus some. But when I use other settings, e.g. this one:

etrago.plot_grid(
    "expansion_abs",
    ext_width=4000,
    filename="test.png",
)

it fails:

/home/clara/etrago-dev/venv-plots/lib/python3.8/site-packages/pypsa/plot.py:259: FutureWarning: iteritems is deprecated and will be removed in a future version. Use .items instead.
  for i, ratio in ratios.iteritems():
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/clara/etrago-dev/eTraGo/etrago/tools/plot.py", line 2627, in plot_grid
    ll = network.plot(
  File "/home/clara/etrago-dev/venv-plots/lib/python3.8/site-packages/pypsa/plot.py", line 347, in plot
    b_widths = as_branch_series(branch_widths[c.name], "width", c.name, n)
  File "/home/clara/etrago-dev/venv-plots/lib/python3.8/site-packages/pypsa/plot.py", line 420, in as_branch_series
    assert not ser.isnull().any(), (
AssertionError: Link_widths does not specify all entries. Missing values for Link: ['0', '524', '525', '526', '527', '528', '529', '530', '531', '532', '533', '534', '535', '536', '537', '538', '539', '540', '541', '542', '543', '544', '545', '546', '547', '548', '549', '550',  ....

Have you ever tried out this "ext_width" option?

Also, the legend entries are not completely visible: nodal_production_balance

The described problems were solved in the commits 569303d, 55bfbdd and 82eae3a

@ClaraBuettner ClaraBuettner removed the request for review from CarlosEpia April 5, 2023 11:42
@CarlosEpia
Copy link
Contributor

I just went through the different plots and they look OK. I think it is worth giving it a try @ClaraBuettner.

@@ -1607,60 +1673,78 @@ def calc_network_expansion(network, method="abs", ext_min=0.1):

Returns
-------
all_network : :class:`pypsa.Network
network_c : :class:`pypsa.Network
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter is named network, so you should also call it like this in the docstring

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree

etrago/tools/plot.py Outdated Show resolved Hide resolved
etrago/tools/plot.py Outdated Show resolved Hide resolved
@ClaraBuettner
Copy link
Contributor

ClaraBuettner commented Sep 25, 2023

When I try out etrago.plot_grid(line_colors= "expansion_abs") or etrago.plot_grid(line_colors= "expansion_rel") I run into this error:

Traceback (most recent call last):

  Cell In[7], line 1
    etrago.plot_grid(line_colors= "expansion_abs")

  File ~/etrago-powerd/eTraGo/etrago/tools/plot.py:2481 in plot_grid
    all_network, line_colors, link_colors = calc_network_expansion(

  File ~/etrago-powerd/eTraGo/etrago/tools/plot.py:1738 in calc_network_expansion
    extension_links[extension_links.carrier != "DC"] = 0

  File ~/etrago-powerd/vemv/lib/python3.8/site-packages/pandas/core/frame.py:3968 in __setitem__
    self._setitem_array(key, value)

  File ~/etrago-powerd/vemv/lib/python3.8/site-packages/pandas/core/frame.py:4003 in _setitem_array
    self.iloc[indexer] = value

  File ~/etrago-powerd/vemv/lib/python3.8/site-packages/pandas/core/indexing.py:818 in __setitem__
    iloc._setitem_with_indexer(indexer, value, self.name)

  File ~/etrago-powerd/vemv/lib/python3.8/site-packages/pandas/core/indexing.py:1795 in _setitem_with_indexer
    self._setitem_with_indexer_split_path(indexer, value, name)

  File ~/etrago-powerd/vemv/lib/python3.8/site-packages/pandas/core/indexing.py:1888 in _setitem_with_indexer_split_path
    self._setitem_single_column(loc, value, pi)

  File ~/etrago-powerd/vemv/lib/python3.8/site-packages/pandas/core/indexing.py:1992 in _setitem_single_column
    self.obj._mgr.column_setitem(loc, plane_indexer, value)

  File ~/etrago-powerd/vemv/lib/python3.8/site-packages/pandas/core/internals/managers.py:1391 in column_setitem
    new_mgr = col_mgr.setitem((idx,), value)

  File ~/etrago-powerd/vemv/lib/python3.8/site-packages/pandas/core/internals/managers.py:393 in setitem
    return self.apply("setitem", indexer=indexer, value=value)

  File ~/etrago-powerd/vemv/lib/python3.8/site-packages/pandas/core/internals/managers.py:352 in apply
    applied = getattr(b, f)(**kwargs)

  File ~/etrago-powerd/vemv/lib/python3.8/site-packages/pandas/core/internals/blocks.py:1417 in setitem
    values[indexer] = value

  File ~/etrago-powerd/vemv/lib/python3.8/site-packages/geopandas/array.py:421 in __setitem__
    raise TypeError(

TypeError: Value should be either a BaseGeometry or None, got 0

@ClaraBuettner
Copy link
Contributor

etrago.plot_grid("v_nom", bus_colors= "PowerToH2", scaling_store_expansion= None) does not return any error message, but the limit for PowerToH2 expansion is nan:
image

@CarlosEpia
Copy link
Contributor

The mentioned problems were already addressed.

@CarlosEpia CarlosEpia merged commit 1ceb4a6 into dev Sep 27, 2023
6 checks passed
@ClaraBuettner ClaraBuettner deleted the feature/#532-update-to-plotpy branch October 30, 2023 10:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants