Download dam/visual.py from BruceYuan/KoopmanDA: direct link, hf CLI and curl.
- Browser
- Download file 617 Bytes
-
https://huggingface.co/datasets/BruceYuan/KoopmanDA/resolve/main/dam/visual.py
- Command line
-
hf download hf://datasets/BruceYuan/KoopmanDA/dam/visual.py
-
curl -L -o visual.py https://huggingface.co/datasets/BruceYuan/KoopmanDA/resolve/main/dam/visual.py
617 Bytes
| 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() |