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

NEW FEATURE: Animation support #11

Closed
MuellerSeb opened this issue Dec 4, 2019 · 8 comments
Closed

NEW FEATURE: Animation support #11

MuellerSeb opened this issue Dec 4, 2019 · 8 comments

Comments

@MuellerSeb
Copy link

Summary

Animation when time axis present.

Reason

To compete with ncview, it would be nice to show the time-evolution of a netcdf variable within a mapplot.

Detailed explanation

Matplotlib provides animations, so it shouldn't be to hard to make a simple interface like ncview provides, with next/previous frame, play forward/backward and delay.

Example

ncview-example

Thanks for the great package!
Cheers, Sebastian

@Chilipp
Copy link
Member

Chilipp commented Dec 5, 2019

Hi @MuellerSeb! Thanks for your input! Yes, indeed I already thought several times about implementing an animation framework. It is, in fact, quite straight-forward within the psyplot framework, e.g. doing something like

import psyplot.project as psy
from matplotlib.animation import FuncAnimation

ds = psy.open_dataset('my-data.nc')

sp = ds.psy.plot.mapplot()

def update(time):
    for arr in sp:
        arr.psy.update(time=time, draw=False)
    # sp.update(time=time) does not work at the moment within matplotlibs FuncAnimation
    sp.draw()


ani = FuncAnimation(list(sp.figs)[0], update, ds.dims['time'], sp.draw)
ani.save('movie.mp4', writer='ffmpeg')

But yes, I also thought about adding an animate method that directly formalizes the above methodology, e.g. via sp.animate('movie.mp4', time=[0,1,2,3]).

However, your example of ncview is rather an issue for the psyplot-gui package and would need to work without matplotlibs FuncAnimation. Therefore I opened another issue at the corresponding project: https://github.com/Chilipp/psyplot-gui/issues/7

What exactly what be your priority? The implementation in the GUI or the animate method?

@MuellerSeb
Copy link
Author

MuellerSeb commented Dec 6, 2019

@Chilipp : Hey there! I guess this goes hand in hand. Animation could be made an universal tool for adding the option to include another dimension into the actual plot. Of course the time-dimension would be the most obvious. In the gui, there could be a new small area above the Formatoptions area, called Animation, where you can select the dimension for animation and where the play-buttons are located.

@Chilipp Chilipp transferred this issue from psyplot/psyplot Apr 14, 2020
@Chilipp
Copy link
Member

Chilipp commented Apr 14, 2020

Hey @MuellerSeb! I finally now work on psy-view, an ncview-like interface to psyplot. Here I also implement these animation features and more. It would be great if you could give it a try. You can either try it in the browser by clicking on Binder or install it on your own machine via conda to test it with your own files (see the installation instructions). When installed, this widget is also available in the general psyplot-gui.

This package is under heavy development at the moment and not yet in its beta phase, but I am nevertheless highly appreciating any feature requests or bug reports.

@MuellerSeb
Copy link
Author

Neat! I'll give it a try ;-)

stay healthy!

@MuellerSeb
Copy link
Author

Looks good! One problem with the animation at this point is, that the colormap boundaries are changing for each time-step. I think, it should be rescaled to use the bounds of the whole time-frame.

@Chilipp
Copy link
Member

Chilipp commented Apr 14, 2020

True, I thought about the same. The challenge is to handle very large data files (or remote data files), particularly when the user decides to use percentiles (e.g. the first to 99th percentile) for the colormap boundary, rather than only minimum and maximum. For very large files, one should rather use dask and a distributed processing and I think it's too much to implement such a framework in psyplot just to calculate some colormap boundaries.

Maybe I'd rather fix the color boundaries when starting the animation and add a formatoption that controls whether the entire data is used, or only the data shown. What do you think about this option?

@MuellerSeb
Copy link
Author

that sounds good. another option could be to only update the lower/upper bounds if the bounds of the current time-step exceed the current limits.

@Chilipp
Copy link
Member

Chilipp commented Apr 17, 2020

The animation is implemented, I am closing this issue here in favor of psyplot/psyplot#21 and psyplot/psy-simple#12 where I will work on the two aspects mentioned in #11 (comment) and #11 (comment).

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

No branches or pull requests

2 participants