Closed MuellerSeb closed 4 years ago
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?
@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.
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 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.
Neat! I'll give it a try ;-)
stay healthy!
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.
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?
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.
The animation is implemented, I am closing this issue here in favor of https://github.com/psyplot/psyplot/issues/21 and https://github.com/psyplot/psy-simple/issues/12 where I will work on the two aspects mentioned in https://github.com/psyplot/psy-view/issues/11#issuecomment-613536436 and https://github.com/psyplot/psy-view/issues/11#issuecomment-613550823.
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
Thanks for the great package! Cheers, Sebastian