windnode / WindNODE_ABW

Region Anhalt-Bitterfeld-Wittenberg
GNU Affero General Public License v3.0
3 stars 0 forks source link

Feature/#160 export figures in comparative NB #171

Closed nesnoj closed 3 years ago

nesnoj commented 4 years ago

Fix #160

Allows to export figues in comparative nb, figure title is used as filename. The figs are stored in a dict (title: fig obj) and exported in the end (see template).

Usage:

create_comparative_notebook(scenarios, run_id,
                            template="scenario_analysis_comparative_template.ipynb",
                            output_path=os.path.join(wn_path[0], 'jupy'),
                            kernel_name=None,
                            force_new_results=False,
                            export_figures=False,
                            figures_output_path=None,
                            figures_file_ext='svg'):

Params: export_figures: Set to True if you want export figures_output_path: Defaults to output_path figures_file_ext: png/svg/eps (defaults to 'svg')

Note: package orca is required but not available via pip. Available options are e.g. conda package, npm or standalone binaries. I did the latter for testing but we maybe should switch to conda or docker windnode_abw-wide later on.

Executing results in some errors

11:42:04-INFO: Creating comparative notebook for 39 scenarios in /home/nesnoj/git-repos/windnode/WindNODE_ABW/windnode_abw/jupy/xxxxxx/ ...
Executing:  98%|█████████▊| 44/45 [00:53<00:00,  1.35cell/s]../../sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc:**CRASHING**:seccomp-bpf failure in syscall 0230
../../sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc:**CRASHING**:seccomp-bpf failure in syscall 0230
../../sandbox/linux/seccomp-bpf-helpers/sigsys_handlers.cc:**CRASHING**:seccomp-bpf failure in syscall 0230
Executing: 100%|██████████| 45/45 [01:05<00:00,  1.46s/cell]
DONE
11:43:10-INFO: Comparative notebook successfully created!

but the figures are exported, example:

Installed_Capacity_Heat_Supply

2 things remain:

  1. The layout of some plots is kind of broken, this needs to be fixed maybe using params of plotly's write_image(). Some fine tuning is required here..
  2. The export of pair grid plot is not implemented yet as it's a matplotlib figure, not plotly and therefore write_image() doesn't work here. I'd recommend to return the plt instances of the 3 plots to the nb and check the obj type in the export loop at the end of the template (use plt functionalities in this case)

@gplssm: If you like, you can go on. If not, I'll take care later on..

gplssm commented 4 years ago

Maybe I pick it up later! Thanks for starting here!