ny = 100 x_grid = 1. - np.cos(np.linspace(0, np.pi, nx)) y_grid = np.linspace(0, 1., ny)**2 Y, X = np.meshgrid(y_grid, x_grid) # Create random snapshot data num_vecs = 100 snapshots = [ mr.VecHandlePickle('%s/vec%d.pkl' % (out_dir, i)) for i in mr.range(num_vecs) ] if parallel.is_rank_zero(): for i, snap in enumerate(snapshots): snap.put(np.sin(X * i) + np.cos(Y * i)) parallel.barrier() # Calculate DMD modes and save them to pickle files weighted_IP = mr.InnerProductTrapz(x_grid, y_grid) my_DMD = mr.DMDHandles(inner_product=weighted_IP) my_DMD.compute_decomp(snapshots) my_DMD.put_decomp('%s/eigvals.txt' % out_dir, '%s/R_low_order_eigvecs.txt' % out_dir, '%s/L_low_order_eigvecs.txt' % out_dir, '%s/correlation_array_eigvals.txt' % out_dir, '%s/correlation_array_eigvecs.txt' % out_dir) mode_indices = [1, 4, 5, 0, 10] modes = [ mr.VecHandlePickle('%s/mode%d.pkl' % (out_dir, i)) for i in mode_indices ] my_DMD.compute_exact_modes(mode_indices, modes)
def __init__(self, grids, data_array): self.grids = grids self.data_array = data_array self.weighted_ip = mr.InnerProductTrapz(*self.grids)