Skip to content

Conversation

@krisvanneste
Copy link
Collaborator

This PR contains some modifications to make interactive plotting in a notebook work.

The main change is the transfer of code writing information to the run_info attribute of the sourcespec output object, from the write_output function in ssp_output.py to a dedicated _update_run_info function. This function is then called at the end of the ssp_run function in source_spec.py rather than in write_output.

I also considered writing the end_of_run and end_of_run_tz info to run_info instead of config, but this would require additional changes in ssp_plot_spectra.py, ssp_plot_stacked_spectra.py, ssp_plot_stations.py and ssp_html_report.py, where this information is used in functions creating subelements of the plot/output. Instead of relying on the global config object, the run_info object should be passed to these functions. I'm not sure if you would want to do that.

With these changes, it is possible to plot figures interactively in a notebook, by setting:

config.plot_show = True
config.plot_save = False

This works for traces, spectra, stacked spectra and the boxplot.
I had to make some modifications in ssp_plot_stations to make it work for the station plots as well. This is partly due to the older versions of pyproj and matplotlib that I use. With these changes, plot_stations works without errors, but there may still be a problem: I obtain 4 plots, 1 with stations colored by magnitude, and 3 identical plots without stations. According to the code I would expect 2 plots, the second one with stations colored by fc. Could you test this too?
Another idea could be to add an option to plot_stations to choose between coloring by magnitude, fc or both?

Let me know what you think.

…n to separate _update_run_info function in ssp_output.py.

Call new _update_run_info function at end of ssp_run function in source_spec.py.
Avoid error in _savefig function when config.options.outdir is not defined (when plotting interactively).
Added workaround in plot_stations function for (presumably) older matplotlib versions.
@claudiodsf
Copy link
Member

Hi Kris,
thanks for this PR!

I checked it on the notebook you sent me a while ago, and I can confirm you that it works, with the only problem on the station map.

I can look into this problem in the next days.

@claudiodsf
Copy link
Member

Hi Kris,
unfortunately, I didn't have time to look into this today.

I'm taking one week off and will back to business on Nov 3.

@krisvanneste
Copy link
Collaborator Author

Hi Kris, unfortunately, I didn't have time to look into this today.

I'm taking one week off and will back to business on Nov 3.

No problem Claudio, have a nice week off!

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.

2 participants