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

Error plotting CH4 network due to link_width argument containing more than gas pipeline links #896

Closed
2 tasks done
koen-vg opened this issue Jan 24, 2024 · 0 comments
Closed
2 tasks done
Labels

Comments

@koen-vg
Copy link
Contributor

koen-vg commented Jan 24, 2024

Checklist

  • I am using the current master branch or the latest release. Please indicate.
  • I am running on an up-to-date pypsa-eur environment. Update via conda env update -f envs/environment.yaml.

Describe the Bug

I've been having this fairly fleeting issue; somehow I can make it happen sometime, but not always? I'm quite confused about this. See error message below.

Anyway; the following does seem to fix it:

modified   scripts/plot_network.py
@@ -544,7 +544,7 @@ def plot_ch4_map(network):
     link_widths_orig = n.links.p_nom / linewidth_factor
     link_widths_orig[n.links.p_nom < line_lower_threshold] = 0.0
 
-    max_usage = n.links_t.p0.abs().max(axis=0)
+    max_usage = n.links_t.p0[n.links.index].abs().max(axis=0)
     link_widths_used = max_usage / linewidth_factor
     link_widths_used[max_usage < line_lower_threshold] = 0.0
 

The problem is that non-gas pipeline links are dropped from n.links earlier, but not from n.links_t. Has anyone had this before? Maybe it's worth just putting the above change in?

Error Message

[Wed Jan 24 16:00:18 2024]
rule plot_network:
    input: results/[...]/postnetworks/elec_s_50_lv1.5__Co2L0_2050.nc, resources/[...]/regions_onshore_elec_s_50.geojson
    output: results/[...]/maps/elec_s_50_lv1.5__Co2L0-costs-all_2050.pdf, results/[...]/maps/elec_s_50_lv1.5__Co2L0_2050-today.pdf
    jobid: 61
    benchmark: benchmarks/[...]/plot_network/elec_s_50_lv1.5__Co2L0_2050
    reason: Code has changed since last execution
    wildcards: simpl=, clusters=50, ll=v1.5, opts=, sector_opts=Co2L0, planning_horizons=2050
    threads: 2
    resources: tmpdir=/tmp, mem_mb=10000, mem_mib=9537

Activating conda environment: .snakemake/conda/0d7d55fa83204a765b0aba3c9ff3a1a3_
Activating conda environment: .snakemake/conda/0d7d55fa83204a765b0aba3c9ff3a1a3_
INFO:pypsa.io:Imported network elec_s_50_lv1.5__Co2L0_2050.nc has buses, carriers, generators, global_constraints, lines, links, loads, storage_units, stores
/home/[...]/.snakemake/scripts/tmp05z29u3u.plot_network.py:105: FutureWarning: DataFrame.groupby with axis=1 is deprecated. Do `frame.T.groupby(...)` without axis instead.
  costs = costs.groupby(costs.columns, axis=1).sum()
INFO:__main__:Dropping non-buses ['', 'EU NH3', 'EU gas', 'EU methanol', 'EU oil', 'EU uranium', 'H2 pipeline', 'gas pipeline']
Warning: Ignoring XDG_SESSION_TYPE=wayland on Gnome. Use QT_QPA_PLATFORM=wayland to run on Wayland anyway.
/home/[...]/.snakemake/conda/0d7d55fa83204a765b0aba3c9ff3a1a3_/lib/python3.11/site-packages/cartopy/mpl/style.py:76: UserWarning: facecolor will have no effect as it has been defined as "never".
  warnings.warn('facecolor will have no effect as it has been '
/home/[...]/.snakemake/conda/0d7d55fa83204a765b0aba3c9ff3a1a3_/lib/python3.11/site-packages/cartopy/mpl/style.py:76: UserWarning: facecolor will have no effect as it has been defined as "never".
  warnings.warn('facecolor will have no effect as it has been '
Traceback (most recent call last):
  File "/home/[...]/.snakemake/scripts/tmp05z29u3u.plot_network.py", line 1104, in <module>
    plot_ch4_map(n)
  File "/home/[...]/.snakemake/scripts/tmp05z29u3u.plot_network.py", line 597, in plot_ch4_map
    n.plot(
  File "/home/[...]/.snakemake/conda/0d7d55fa83204a765b0aba3c9ff3a1a3_/lib/python3.11/site-packages/pypsa/plot.py", line 409, in plot
    (c.df.bus0[df.index].map(x), c.df.bus0[df.index].map(y)),
     ~~~~~~~~~^^^^^^^^^^
  File "/home/[...]/.snakemake/conda/0d7d55fa83204a765b0aba3c9ff3a1a3_/lib/python3.11/site-packages/pandas/core/series.py", line 1143, in __getitem__
    return self._get_with(key)
           ^^^^^^^^^^^^^^^^^^^
  File "/home/[...]/.snakemake/conda/0d7d55fa83204a765b0aba3c9ff3a1a3_/lib/python3.11/site-packages/pandas/core/series.py", line 1184, in _get_with
    return self.loc[key]
           ~~~~~~~~^^^^^
  File "/home/[...]/.snakemake/conda/0d7d55fa83204a765b0aba3c9ff3a1a3_/lib/python3.11/site-packages/pandas/core/indexing.py", line 1192, in __getitem__
    return self._getitem_axis(maybe_callable, axis=axis)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/[...]/.snakemake/conda/0d7d55fa83204a765b0aba3c9ff3a1a3_/lib/python3.11/site-packages/pandas/core/indexing.py", line 1421, in _getitem_axis
    return self._getitem_iterable(key, axis=axis)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/[...]/.snakemake/conda/0d7d55fa83204a765b0aba3c9ff3a1a3_/lib/python3.11/site-packages/pandas/core/indexing.py", line 1361, in _getitem_iterable
    keyarr, indexer = self._get_listlike_indexer(key, axis)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/[...]/.snakemake/conda/0d7d55fa83204a765b0aba3c9ff3a1a3_/lib/python3.11/site-packages/pandas/core/indexing.py", line 1559, in _get_listlike_indexer
    keyarr, indexer = ax._get_indexer_strict(key, axis_name)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/[...]/.snakemake/conda/0d7d55fa83204a765b0aba3c9ff3a1a3_/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 6199, in _get_indexer_strict
    self._raise_if_missing(keyarr, indexer, axis_name)
  File "/home/[...]/.snakemake/conda/0d7d55fa83204a765b0aba3c9ff3a1a3_/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 6251, in _raise_if_missing
    raise KeyError(f"{not_found} not in index")
KeyError: "['13589', [...] 'T6', 'T6-reversed'] not in index"
[Wed Jan 24 16:00:29 2024]
Error in rule plot_network:
    jobid: 61
    input: results/[...]/postnetworks/elec_s_50_lv1.5__Co2L0_2050.nc, resources/[...]/regions_onshore_elec_s_50.geojson
    output: results/[...]/maps/elec_s_50_lv1.5__Co2L0-costs-all_2050.pdf, results/[...]/maps/elec_s_50_lv1.5__Co2L0_2050-today.pdf
    conda-env: /home/[...]/.snakemake/conda/0d7d55fa83204a765b0aba3c9ff3a1a3_

RuleException:
CalledProcessError in file /home/[...]/rules/postprocess.smk, line 36:
Command 'source /home/koen/.local/opt/mambaforge/bin/activate '/home/[...]/.snakemake/conda/0d7d55fa83204a765b0aba3c9ff3a1a3_'; set -euo pipefail;  python /home/[...]/.snakemake/scripts/tmp05z29u3u.plot_network.py' returned non-zero exit status 1.
  File "/home/[...]/rules/postprocess.smk", line 36, in __rule_plot_network
  File "/home/koen/.local/opt/mambaforge/envs/pypsa-eur/lib/python3.11/concurrent/futures/thread.py", line 58, in run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants