Skip to content

Commit 108989e

Browse files
committed
Make the update function going to animate_polygon_list from animate_polygon fully encapsulated, use the t dimension to set the number of frames.
1 parent bc4d9eb commit 108989e

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

xbout/boutdataset.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,7 @@ def is_list(variable):
15421542

15431543
if ndims == 3:
15441544
if this_poloidal_plot:
1545-
polys, da, update_func = animate_polygon(
1545+
update_func = animate_polygon(
15461546
data,
15471547
ax=ax,
15481548
cax=cax,
@@ -1552,7 +1552,7 @@ def is_list(variable):
15521552
animate=False,
15531553
**this_kwargs,
15541554
)
1555-
animate_data.append([polys,da,update_func])
1555+
animate_data.append(update_func)
15561556
else:
15571557
raise ValueError(
15581558
"Unsupported option "
@@ -1572,15 +1572,14 @@ def is_list(variable):
15721572
ax.set_title(this_title)
15731573

15741574
def update(frame):
1575-
for list in animate_data:
1576-
(polys, da, update_func) = list
1575+
for update_func in animate_data:
15771576
# call update function for each axes
1578-
update_func(frame,polys,da)
1577+
update_func(frame)
15791578

15801579
# make the animation for all the subplots simultaneously
1581-
# use the last data array da to choose the number of frames
1580+
# use time data array "t" to choose the number of frames
15821581
# assumes time dimension same length for all variables
1583-
anim = FuncAnimation(fig=fig, func=update, frames=np.shape(da.data)[0], interval=30)
1582+
anim = FuncAnimation(fig=fig, func=update, frames=self.data["t"].data.size, interval=30)
15841583
if tight_layout:
15851584
if subplots_adjust is not None:
15861585
warnings.warn(

xbout/plotting/animate.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -868,9 +868,6 @@ def update(frame):
868868
ani = matplotlib.animation.FuncAnimation(fig=fig, func=update, frames=np.shape(da.data)[0], interval=30)
869869
return ani
870870
else:
871-
# return function and data for making the animation
872-
def update_out(frame,polys,da):
873-
colors = da.data[frame,:,:].flatten()
874-
polys.set_array(colors)
875-
return polys, da, update_out
871+
# return function for making the animation
872+
return update
876873

0 commit comments

Comments
 (0)