rl-institut / oemof-B3

An open-source energy system model for Brandenburg/Berlin.
https://oemof-b3.readthedocs.io/
GNU Affero General Public License v3.0
9 stars 5 forks source link

plot_all_examples not working #262

Closed MaGering closed 1 year ago

MaGering commented 1 year ago

Updated error report:

Plotting with plot_scalar_results.py does not work for examples and single scenarios. There are the following errors:

  1. capacities have been removed from results. This leads to an error running

    plot_capacities()

    We will drop this function as the capacities are input parameters, not results.

  2. These plotting functions do not work with single scenarios, we have to find out why:

    subplot_invest_out_multi_carrier(CARRIERS_WO_CH4)
    subplot_storage_invest_multi_carrier(CARRIERS_WO_CH4)
    subplot_flow_out_multi_carrier(CARRIERS_WO_CH4)
    subplot_demands(CARRIERS)
    subplot_energy_usage_multi_carrier(CARRIERS)

Original error report:

I can't run

snakemake -j1 plot_all_examples

due to FileNotFoundError:

[Errno 2] No such file or directory: 'scenarios/example_base.yml'

Is there something one has to do in order to get the examples running (copying a file from A to B)? If yes, it is not mentioned in the docs so far and the label needs to change from bug to documentation.

jnnr commented 1 year ago

This probably has the same cause as #261

jnnr commented 1 year ago

Moved from @MaGering's comment in #264:

Executing

snakemake -j1 plot_all_examples

however I get the following error (Update: moved to #262

[Wed Sep 28 15:18:38 2022]
rule plot_scalar_results:
    input: results/example_base/postprocessed
    output: results/example_base/plotted/scalars
    jobid: 1
    reason: Missing output files: results/example_base/plotted/scalars
    wildcards: scenario=example_base
    resources: tmpdir=/tmp

Traceback (most recent call last):
  File "scripts/plot_scalar_results.py", line 869, in <module>
    plot_capacities()
  File "scripts/plot_scalar_results.py", line 454, in plot_capacities
    plot.prepare_data(agg_regions=config.settings.plot_scalar_results.agg_regions)
  File "scripts/plot_scalar_results.py", line 189, in prepare_data
    self.prepared_scalar_data = prepare_scalar_data(
  File "scripts/plot_scalar_results.py", line 121, in prepare_scalar_data
    df_pivot = drop_constant_multiindex_levels(df_pivot)
  File "scripts/plot_scalar_results.py", line 117, in drop_constant_multiindex_levels
    _df.index = _df.index.droplevel(drop_levels)
  File "/home/local/RL-INSTITUT/marie-claire.gering/anaconda3/envs/oemof-B3/lib/python3.8/site-packages/pandas/core/indexes/base.py", line 1505, in droplevel
    raise ValueError(
ValueError: Cannot remove 3 levels from an index with 3 levels: at least one level must be left.
[Wed Sep 28 15:18:39 2022]
Error in rule plot_scalar_results:
    jobid: 1
    output: results/example_base/plotted/scalars
    shell:
        python scripts/plot_scalar_results.py results/example_base/postprocessed results/example_base/plotted/scalars results/example_base/example_base.log
        (one of the commands exited with non-zero exit code; note that snakemake uses bash strict mode!)

Removing output files of failed job plot_scalar_results since they might be corrupted:
results/example_base/plotted/scalars
Shutting down, this might take some time.
Exiting because a job execution failed. Look above for error message
Complete log: .snakemake/log/2022-09-28T151838.529322.snakemake.log
jnnr commented 1 year ago

This is a bug in the script "plot_scalars". The scalar plots stopped working for single scenarios after supporting plots for several scenarios.