Player

class HSTB.kluster.modules.visualizations.Player(fig, func, frames=None, init_func=None, fargs=None, save_count=None, save_pth=None, pos=(0.125, 0.92), **kwargs)

Bases: FuncAnimation

Matplotlib FuncAnimation player that includes the ability to start/stop/speed up/slow down/skip frames. Relies on the frames passed in, frames must be the values of the dimension you want to animate on.

Methods Summary

backward([event])

Start playing the animation in the backwards direction

bind_to(callback)

Pass in a method as callback, method will be triggered on close

clear_observers()

Clear any functions that have been bound to the player

close_event(evt)

Called when the Player is closed, by closing the window.

forward([event])

Start playing the animation in the forward direction

onebackward([event])

Skip backwards one frame, stopping the animation and freezing on that frame

oneforward([event])

Skip forward one frame, stopping the animation and freezing on that frame

onestep()

Stop the animation and freeze on the next frame, direction depends on self.forwards

play()

Return the next frame.

save_event()

Called when the user hits the save button on the Player toolbar.

set_pos(slider_time)

Triggered on clicking within the slider to jump to a specific time.

setup(pos)

Build out the widgets for the player.

slowdown(e)

Decreases the speed of the animation by increasing the time between frames

speedup(e)

Increases the speed of the animation by decreasing the time between frames

start()

Start playing the animation by signaling the funcanimation event_source

stop([event])

Stop playing the animation by signaling the funcanimation event_source

update(i_frame)

Triggered on each tick of the animation.

Methods Documentation

backward(event=None)

Start playing the animation in the backwards direction

bind_to(callback)

Pass in a method as callback, method will be triggered on close

Parameters

callback – method that is run on Player being closed

clear_observers()

Clear any functions that have been bound to the player

close_event(evt)

Called when the Player is closed, by closing the window. Will call any observers that the player has been bound to.

forward(event=None)

Start playing the animation in the forward direction

onebackward(event=None)

Skip backwards one frame, stopping the animation and freezing on that frame

oneforward(event=None)

Skip forward one frame, stopping the animation and freezing on that frame

onestep()

Stop the animation and freeze on the next frame, direction depends on self.forwards

play()

Return the next frame. If self.forwards, that would be the frame after the current one. Otherwise, returns the frame before the current one. If you hit the beginning or end of the dataset, stops the player.

save_event()

Called when the user hits the save button on the Player toolbar. Uses the FFMpegWriter to save each frame to a new animation. Takes forever to run, probably need to thread this later with a progress count.

set_pos(slider_time)

Triggered on clicking within the slider to jump to a specific time. slider_time is not an exact coordinate (not within self.frames), its an interpolated value based on where you click in the slider. Ugh! We have to find the nearest real value to zoom to.

Parameters

slider_time (float) – interpolated value of self.frames based on position of where you click

setup(pos)

Build out the widgets for the player. player widgets are in one horizontal row, include the player controls (start, stop, skip frame, etc.) and the slider bar, which tracks the position in the dataset

Parameters

pos (tuple) – tuple of position (left position, bottom position) to place the player bar

slowdown(e)

Decreases the speed of the animation by increasing the time between frames

speedup(e)

Increases the speed of the animation by decreasing the time between frames

start()

Start playing the animation by signaling the funcanimation event_source

stop(event=None)

Stop playing the animation by signaling the funcanimation event_source

update(i_frame)

Triggered on each tick of the animation. Updates the slider to the actual frame that we are on.

Parameters

i_frame (float) – value of the dim being animated, corresponds to the current value (generally the current time of the animation)