Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add plot_interactive method for 3D maps #1543
You need to have the ipywidgets installed. They are usually installed by defaults by you might wanna check.
Can people try this on their machine to see if it works.
Thanks @facero for working on this. I've quickly tested it and it seems to work well, even for large datasets such as the Fermi-LAT galactic diffuse model. I've left a few inline comments.
In addition I have a few general comments, we should discuss about:
- Even if I like plotting the spectrum in addition, I think it does not generalize very well to other axes, such as time or event id. So I'm leaning towards removing it again.
- With the interactive visualization the plot method is really large and some functionality, such as passing and returning a
WCSAxesobject is not possible anymore. So I tend to rather introduce a separate
plot_interactive()method and keep the
.plot()method unchanged. Ideally it can be even reused in
@facero - Thanks!
Agree with all comments by @adonath .
Separate methods are better for the user (each a simpler API) and for us to maintain (e.g. review, test).
For the spectrum line plot: I would also tend to maybe not add it.
Often one wants it for a region, and that's harder to configure. I'm pretty sure that things like https://js9.si.edu/ or http://aladin.u-strasbg.fr/AladinLite/ or http://ginga.readthedocs.io/ or new astro visualisers will develop really nice Jupyter Lab plugins and become a great interactive environment. It will just take a year or two. So for now, I'd suggest to keep it really simple concerning code additions to Gammapy, and maybe put the line plot or other interactive things into a tutorial notebook. Note that there's no need to have those as methods attached to the class, one can always put them as standalone functions and take the map object as input.
That said, @facero - if you really want this feature in, if it's a separate
Thanks for the quick review. All comennts by axel are easy to implement. The only one for which I haven't found a solution is the handling of **kwargs with interact.
The two main points raised are whether to keep the 2nd plot and whether to put this function in .plot() or .plot_XXX().
This looks nice @facero !
I have no strong opinion regarding point (1), ie, whether it should be one function or two separate functions. If the user is not in a jypyter notebook, but running a normal ipython session, trying to plot 3D maps will also give weird errors, no? Maybe then it would be better to have it as separate functions?
referenced this pull request
Jul 19, 2018
I've modified the routine to separate the 2D and 3D parts. **kwargs can now be handled.