-
Notifications
You must be signed in to change notification settings - Fork 1
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
Animation generation #39
Animation generation #39
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution!
I've had a glance over things and left a few comments, though I've not looked too deeply into how things are working here.
One thing to look into are Xarray 'accessors', which allow you to add custom functionality to the datasets themselves. These could be used to add new syntax such as:
import xarray as xr
from sdf_xarray import SDFPreprocess
ds = xr.open_mfdataset("./*.sdf", preprocess=SDFPreprocess())
ds.epoch.animate(...)
# Or maybe:
ds.sdf.animate(...)
src/sdf_xarray/plotting.py
Outdated
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import xarray as xr | ||
from IPython.display import HTML |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the Matplotlib comment above: IPython is not a dependency of the project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably put it in a try: catch
or even better would be to follow the approach you listed below on returning the fig
+ ani
. It is also an optional dependency under the jupyter
flag and gets installed via ipykernel
Line 42 in 1172e6f
jupyter = ["dask[diagnostics]", "ipykernel>=6.29.5"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The solution at the end of this StackOverflow answer looks promising if you want to add some nice functions for use in notebooks but emit sensible errors if the user tries to run them in regular code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we still want to include matplolib
as an optional dependency as the normal plotting function from xarray fails anyways. I think we can leave it as is
Raised a counter-PR to implement the recommendations: ShaunD137#1 If that's merged, the changes should make it to this PR automatically. Feel free to request any changes on the other PR. |
Also moves accessor to use DataArray
…nto xarray-accessors
I'm happy for you to merge these in, thanks for fixing these issues. |
Add Xarray accessor for animation function
@ZedThree can we get an approval for this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could really do with some tests, though I appreciate these are hard for animations!
Agreed, would be nice but already spent way too much time on this! |
Add a generate animation plotting function for displaying videos of 2D simulations, includes option to move window along with simulation (predominatly used in wakefield simulations).