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

Plot scalar results #93

Merged
merged 41 commits into from
Feb 28, 2022
Merged

Plot scalar results #93

merged 41 commits into from
Feb 28, 2022

Conversation

jnnr
Copy link
Collaborator

@jnnr jnnr commented Nov 24, 2021

Introduces a new rule "plot_scalar_results" that draw scalar result bar plots for single scenarios. You can choose to stack the bars by setting stacked=True in plot_grouped_bar. Needs rl-institut/oemoflex#45

To test it, make sure to use the mentioned branch on oemoflex.

  • Generate some scalar plots with snakemake -j1 results/toy-scenario/plotted/scalars.
  • To test the integration in the report, run snakemake -j1 results/toy-scenario/report.

TODO

  • Nicer appearance
  • Plot other variables (see comment below)
  • Check if and how it can be combined with the plot functions of joined scenarios. Done - there is only one script for both.
  • Problem: Include in reports fails if file is not present. How can we deal with that? Will be addressed in New plots are missing in report #66

Address separately

  • all variable costs by region and technology
  • all storage losses + output by carrier and region (This would need a new functionality: Plotting different var_names together)

@jnnr jnnr requested a review from MaGering January 6, 2022 17:16
@jnnr
Copy link
Collaborator Author

jnnr commented Jan 6, 2022

Short brainstorm on what plot we may need:

  • all flows into electricity bus/heat bus etc
  • all capacities/invest of power into electricity bus/heat bus etc

@jnnr jnnr removed the request for review from MaGering January 6, 2022 17:40
@jnnr jnnr added this to the v0.01 milestone Jan 13, 2022
@jnnr jnnr self-assigned this Jan 13, 2022
@jnnr jnnr requested a review from MaGering January 13, 2022 14:34
Copy link
Collaborator

@MaGering MaGering left a comment

Choose a reason for hiding this comment

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

I get a MissingInputException in line 343 with the following error message running
snakemake -j1 results/toy-scenario/plotted/scalars:

Missing input files for rule plot_scalar_results:
results/toy-scenario/postprocessed/scalars.csv

Also, when I run snakemake -j1 results/toy-scenario/postprocessed, it leads me to AttributeError: 'NoneType' object has no attribute 'is_potentially_variable:

ERROR: Constructing component 'Transformer.relation_build' from data=None
    failed: AttributeError: 'NoneType' object has no attribute
    'is_potentially_variable'
Traceback (most recent call last):
  File "scripts/optimize.py", line 50, in <module>
    m = Model(es)
...

scripts/plot_scalar_results.py Outdated Show resolved Hide resolved
@jnnr
Copy link
Collaborator Author

jnnr commented Jan 17, 2022

I get a MissingInputException in line 343 with the following error message running snakemake -j1 results/toy-scenario/plotted/scalars:

Missing input files for rule plot_scalar_results:
results/toy-scenario/postprocessed/scalars.csv

Resolved in ec05d1e. Now snakemake should trigger a model run when you try to plot results that have not been created.

Also, when I run snakemake -j1 results/toy-scenario/postprocessed, it leads me to AttributeError: 'NoneType' object has no attribute 'is_potentially_variable:

ERROR: Constructing component 'Transformer.relation_build' from data=None
    failed: AttributeError: 'NoneType' object has no attribute
    'is_potentially_variable'
Traceback (most recent call last):
  File "scripts/optimize.py", line 50, in <module>
    m = Model(es)
...

Could not reproduce this. Looks like a component of the model is missing some data?

@MaGering
Copy link
Collaborator

Running snakemake -j1 results/toy-scenario/report leads me to an error because pandoc is missing as package. It should be added to install_requires in setup.py right?

@jnnr
Copy link
Collaborator Author

jnnr commented Jan 27, 2022

Running snakemake -j1 results/toy-scenario/report leads me to an error because pandoc is missing as package. It should be added to install_requires in setup.py right?

You do not install pandoc via pip, so it should not be listed in setup.py. Need to find another way to define these requirements.

@jnnr
Copy link
Collaborator Author

jnnr commented Jan 27, 2022

After installing pandoc I get the following error message running snakemake -j1 results/toy-scenario/report: report_exit_status_99.txt

Yes, the report fails if some images are missing. This is an open todo (see first post).

@SabineHaas
Copy link
Collaborator

You could install pandoc from github https://github.com/jgm/pandoc using the master branch or a specific version (tag).
For a "how-to" see oemof-B3 setup.py where oemoflex ist installed from github, as well.

@jnnr
Copy link
Collaborator Author

jnnr commented Feb 14, 2022

I am not sure if that works? Other than oemoflex, pandoc is written in haskell and needs to be compiled. (https://github.com/jgm/pandoc/blob/master/INSTALL.md#getting-the-pandoc-source-code)

@jnnr jnnr requested a review from SabineHaas February 22, 2022 17:03
Copy link
Collaborator

@SabineHaas SabineHaas left a comment

Choose a reason for hiding this comment

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

@jnnr you have asked my feedback concerning the plots. Thank you, first of all, for improving the plots! They already look very nice.
I have tested the plots with scenario base-2050, toy-scenario ran into an error.

To my mind, my comments are not so urgent that they have to be faced in this PR or for the first release.

scalars:

  • I like that for the y-axis a convenient unit seems to be chosen automatically! A bit strange looks the '0 Whor0 W` to my mind. Maybe there's a solution to force 0 to adapt the unit of the next higher value.
  • It would be useful for readers to add values to the stacked plots. I have added two examples below from Dena-Leitstudie 2021 and Prognos 2021.
  • For the model I think B/BB and the heading are quite right, as they are related to input data and output data. However, for reports I think it would be nice to actually write the full region name and remove the heading as this will be separate in a report. My suggestion is to add a second set of plots for reports without heading and with full region names.
  • For your information: I only got plots for the electricity bus. I guess plots for the other busses will be added in the future.

dispatch:

  • snakemake -j1 results/base-2050/plotted/dispatch gives me ValueError: need at least one array to concatenate in oemoflex/tools/plots.py, line 344, y = np.vstack(y)

Dena2021

Prognos2021


Address separately

* all variable costs by region and technology

* all storage losses + output by carrier and region (This would need a new functionality: Plotting different var_names together)

* Check if and how it can be combined with the plot functions of joined scenarios

Should this be addressed in another PR? Then you could move these points to a new issue.

@jnnr
Copy link
Collaborator Author

jnnr commented Feb 28, 2022

@SabineHaas: Thanks for your review. I opened a new issue #154 to collect all ideas that are still open.

@jnnr jnnr merged commit 7e589b1 into dev Feb 28, 2022
@jnnr jnnr deleted the features/plot-scalar-results branch February 28, 2022 10:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants