def main(): # when on cylon to test on full vid fdir = '../data/vid.tif' # when local test use 'short_vid.tif' vid = ca_data_utils.load_vid() X1 = flatten[:, :-1] X2 = flatten[:, 1:] print('start dmd') dmd = DMD(svd_rank=10) dmd.fit(flatten.T) print('finished fitting data') for eig in dmd.eigs: print('Eigenvalue {}: distance from unit circle {}'.format( eig, np.abs(eig.imag**2 + eig.real**2 - 1))) dmd.plot_eigs(show_axes=True, show_unit_circle=True) self_re = np.load('reconstructed.npy') diff = dmd.reconstructed_data.T - self_re print(len(np.where(np.abs(diff) > 1e-3)[0])) print(diff.max()) print(diff.min())
fbdmd = FbDMD(exact=True) fbdmd.fit(snapshots) fbdmd.reconstructed_data.shape dmd = DMD(exact=True) dmd.fit(snapshots) print('[DMD ] Total distance between eigenvalues and unit circle: {}'.format( np.sum(np.abs(dmd.eigs.real**2 + dmd.eigs.imag**2 - 1)) )) print('[FbDMD] Total distance between eigenvalues and unit circle: {}'.format( np.sum(np.abs(fbdmd.eigs.real**2 + fbdmd.eigs.imag**2 - 1)) )) dmd.plot_eigs() fbdmd.plot_eigs() fbdmd.dmd_time['dt'] *= .5 fbdmd.dmd_time['tend'] += 10 plt.plot(fbdmd.dmd_timesteps, fbdmd.dynamics.T.real) plt.show() def plot_state(time): i = int((time - fbdmd.dmd_time['t0']) / fbdmd.dmd_time['dt']) plt.figure(figsize=(8, 8)) plt.scatter(pts[:, 0], pts[:, 1], c=fbdmd.reconstructed_data[:, i].real, marker='.') plt.show()
ax.set_ylabel("right singular value") plt.xlim(0, 1) plt.ylim(X[:, :r].min(), X[:, :r].max()) plt.savefig(path + "DMD8Modes.png", dpi=250) plt.close() dmd = DMD(svd_rank=r) dmd.fit(X.T) # expected shape = (65, 129) = (spacial, time) for eig in dmd.eigs: print('Eigenvalue {}: distance from unit circle {}'.format( eig, np.abs(np.sqrt(eig.imag**2 + eig.real**2) - 1))) fig, ax = plt.subplots() dmd.plot_eigs(show_axes=True, show_unit_circle=True) plt.savefig(path + "DMDeigs.png", dpi=250) plt.close() fig, ax = plt.subplots() for i, mode in enumerate(dmd.modes.T): # print(i) if i < 10: plt.plot(x, mode.real) plt.title('Modes') plt.savefig(path + "DMDModes.png", dpi=250) plt.close() # plt.show() for i, dynamic in enumerate(dmd.dynamics): if i < 10: