File size: 617 Bytes
849505e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation

data_path = 'dam_data.npy'

data = np.load(data_path)

sample_data = data[-1]

fig, ax = plt.subplots()
vmin = np.min(sample_data)
vmax = np.max(sample_data)
cax = ax.imshow(sample_data[0], cmap='viridis', animated=True, vmin=vmin, vmax=vmax)
fig.colorbar(cax, ax=ax)

def update(frame):
    cax.set_array(sample_data[frame])
    ax.set_title(f'Time Step: {frame}')
    return cax,

ani = animation.FuncAnimation(fig, update, frames=sample_data.shape[0], blit=True)

ani.save('dam.gif', writer='pillow', fps=50)

plt.close()