Skip to content

Commit

Permalink
Animation of a clock to understand the parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
h-mayorquin committed Aug 15, 2016
1 parent 68d6849 commit 80a91f6
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
29 changes: 29 additions & 0 deletions animation_script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation


fig = plt.figure(figsize=(16, 12))
ax = fig.add_subplot(111)
# You can initialize this with whatever
im = ax.imshow(np.random.rand(6, 10), cmap='bone_r', interpolation='nearest')


def animate(i):
aux = np.zeros(60)
aux[i] = 1
image_clock = np.reshape(aux, (6, 10))
im.set_array(image_clock)

ani = animation.FuncAnimation(fig, animate, frames=60, interval=2000)
ani.save('clock.mp4', fps=1.0, dpi=200)
plt.show()

"""Interval is for the printing animation. So in this case, the animation that will be reproduced
that is, the one that is not saved, by changing the image every 2 seconds (interval=2000 (ms))*[]:
The fps (frames per second) in the other hand is for the image that will be saved.
"""



9 changes: 6 additions & 3 deletions digit_recall.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
data[data >= 8] = 1

# Let's get two images and learn them as a pattern
number_of_patterns = 10
number_of_patterns = 2
patterns = []
for i in range(number_of_patterns):
patterns.append(data[i])
Expand All @@ -36,7 +36,7 @@
beta = get_beta(p)

# Here we have the evolution
T = 100
T = 10
dt = 0.1
tau_m = 1.0
G = 1.0
Expand Down Expand Up @@ -87,5 +87,8 @@ def update_system():
ax11.set_title('Final image')
ax11.set_axis_off()

fig.subplots_adjust(right=0.8)
cbar_ax = fig.add_axes([0.85, 0.15, 0.05, 0.7])
fig.colorbar(im11, cax=cbar_ax)

fig.show()
plt.show()
3 changes: 2 additions & 1 deletion digit_recall_animation.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
beta = get_beta(p)

# Here we have the evolution
T = 1000
T = 10
dt = 0.1
tau_m = 1.0
G = 1.0
Expand Down Expand Up @@ -76,3 +76,4 @@ def update(*args):

ani = animation.FuncAnimation(fig, update, frames=40, interval=200, blit=True)
ani.save('animation.mp4', fps=2, dpi=200)
plt.show()

0 comments on commit 80a91f6

Please sign in to comment.