GIF of extrapolation
This commit is contained in:
parent
8d3cbe5f4d
commit
7e7e1a4185
|
|
@ -111,3 +111,39 @@ axs[1].legend()
|
|||
|
||||
plt.tight_layout() # Adjust spacing between panels
|
||||
plt.show()
|
||||
|
||||
# %%
|
||||
# animation of eigenvalues
|
||||
import matplotlib.pyplot as plt
|
||||
from matplotlib.animation import FuncAnimation
|
||||
|
||||
# Prepare figure
|
||||
fig, ax = plt.subplots(figsize=(8, 8))
|
||||
ax.scatter(np.real(train_data['k']), np.imag(train_data['k']), label='training')
|
||||
ax.scatter(np.real(target_data['k']), np.imag(target_data['k']), label='target')
|
||||
sc = ax.scatter([], [], marker='x', label='predicted') # Placeholder for predicted eigenvalues
|
||||
ax.set_xlim(-1, 1) # Adjust limits as needed
|
||||
ax.set_ylim(-1, 1) # Adjust limits as needed
|
||||
ax.set_xlabel('Re(k)')
|
||||
ax.set_ylabel('Im(k)')
|
||||
ax.legend()
|
||||
ax.set_title('c = ?')
|
||||
|
||||
# Animation function
|
||||
def update(c):
|
||||
H = H0 + c * H1
|
||||
evals = torch.linalg.eigvals(H).detach().numpy()
|
||||
sc.set_offsets(np.c_[np.real(evals), np.imag(evals)])
|
||||
ax.set_title(f'c = {c:.2f}')
|
||||
return sc,
|
||||
|
||||
# Create animation
|
||||
no_frames = 100
|
||||
c_steps = np.linspace(min(df['c']), max(df['c']), no_frames)
|
||||
ani = FuncAnimation(fig, update, frames=c_steps, interval=100, blit=True)
|
||||
|
||||
# Save or display the animation
|
||||
ani.save('../temp/PMM.gif', writer='pillow') # Save as a GIF file
|
||||
plt.show() # Display the animation
|
||||
|
||||
# %%
|
||||
|
|
|
|||
Loading…
Reference in New Issue