-
Notifications
You must be signed in to change notification settings - Fork 48
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
[WIP] Ipython animation #100
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I wrote something similar to this in a notebook I was working on. I was apparently only thinking about 2D plots however it still might be useful: def add_animation(title, cbar_label, cmap, var, limits, figsize=(8,6)):
fig = plt.figure(figsize=figsize)
if isinstance(var, list) or isinstance(var, tuple):
ax_list = [fig.add_subplot(1,2,1), fig.add_subplot(1,2,2)]
else:
ax_list = [fig.add_subplot(1,1,1)]
var = [var]
title = [title]
cbar_label = [cbar_label]
x, y = claw.frames[0].state.grid.p_centers
im_list = []
for (n,ax) in enumerate(ax_list):
im_list.append( ax.imshow(var[n](0).T, cmap=cmap, extent=[x.min(), x.max(), y.min(), y.max()],
vmin=limits[0], vmax=limits[1], interpolation='nearest', origin='lower') )
ax.set_title(title[n])
ax.set_xlabel('x')
ax.set_ylabel('y')
cbar = fig.colorbar(im_list[n], ax=ax)
cbar.set_label(cbar_label[n])
def fplot(frame_number):
for (n,im) in enumerate(im_list):
im.set_data(var[n](frame_number).T)
return im
return fig, fplot |
refer to plotdir rather than assuming _plots
…thon_animation * 'ipython_animation' of github.com:ketch/visclaw: Fix typos. Add ianimate function for JSAnimations in the notebook. Improve generality by passing controller and not assuming ascii. Conflicts: src/python/visclaw/ianimate.py
ketch
added a commit
to ketch/clawapps
that referenced
this pull request
Nov 3, 2014
ketch
added a commit
that referenced
this pull request
Nov 6, 2014
Ipython animation. Usage: claw = setup() claw.run() from clawpack.visclaw import ianimate ianimate.ianimate(claw)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is work in progress. It's a very basic implementation to allow creation of animations from PyClaw output in the IPython notebook without a lot of code. Indeed, all you have to do is something like
Obviously there aren't a lot of options yet. I included an optional plotdata argument, because ideally I'd like this function to be able to accept one and animate the plots that would usually come out of visclaw. The complication is that the animator needs a handle to a line or an image (for instance) in order to call set_data at later frames. I think it would be best to refactor frametools.plot_frame to return such a handle, but that looks like a substantial amount of work.