|
35 | 35 | "outputs": [], |
36 | 36 | "source": [ |
37 | 37 | "import warnings\n", |
| 38 | + "\n", |
38 | 39 | "warnings.filterwarnings(\"ignore\")\n", |
39 | 40 | "\n", |
40 | 41 | "import numpy as np\n", |
|
74 | 75 | "def f1(x, t):\n", |
75 | 76 | " return 1.0 / np.cosh(x + 3) * np.cos(2.3 * t)\n", |
76 | 77 | "\n", |
| 78 | + "\n", |
77 | 79 | "def f2(x, t):\n", |
78 | 80 | " return 2.0 / np.cosh(x) * np.tanh(x) * np.sin(2.8 * t)\n", |
79 | 81 | "\n", |
| 82 | + "\n", |
80 | 83 | "nx = 65 # number of grid points along space dimension\n", |
81 | 84 | "nt = 129 # number of grid points along time dimension\n", |
82 | 85 | "\n", |
|
267 | 270 | "\n", |
268 | 271 | "# Print computed eigenvalues (frequencies are given by imaginary components).\n", |
269 | 272 | "# Also plot the resulting data reconstruction.\n", |
270 | | - "print(f\"Frequencies (imaginary component): {np.round(delay_optdmd.eigs, decimals=3)}\")\n", |
| 273 | + "print(\n", |
| 274 | + " f\"Frequencies (imaginary component): {np.round(delay_optdmd.eigs, decimals=3)}\"\n", |
| 275 | + ")\n", |
271 | 276 | "plt.title(\"Reconstructed Data\")\n", |
272 | 277 | "plt.imshow(delay_optdmd.reconstructed_data.real)\n", |
273 | 278 | "plt.show()\n", |
|
437 | 442 | "# Imaginary + Conjugate: constrain to imaginary axis and as complex conjugates.\n", |
438 | 443 | "# bopdmd = BOPDMD(eig_constraints={\"imag\", \"conjugate_pairs\"})\n", |
439 | 444 | "\n", |
440 | | - "optdmd = BOPDMD(svd_rank=4, num_trials=0, eig_constraints={\"imag\", \"conjugate_pairs\"})\n", |
| 445 | + "optdmd = BOPDMD(\n", |
| 446 | + " svd_rank=4, num_trials=0, eig_constraints={\"imag\", \"conjugate_pairs\"}\n", |
| 447 | + ")\n", |
441 | 448 | "delay_optdmd = hankel_preprocessing(optdmd, d=delays)\n", |
442 | 449 | "delay_optdmd.fit(Xn.T, t=t[:num_t])\n", |
443 | 450 | "plot_summary(delay_optdmd, d=delays)\n", |
444 | 451 | "\n", |
445 | | - "print(f\"Frequencies (imaginary component): {np.round(delay_optdmd.eigs, decimals=3)}\")\n", |
| 452 | + "print(\n", |
| 453 | + " f\"Frequencies (imaginary component): {np.round(delay_optdmd.eigs, decimals=3)}\"\n", |
| 454 | + ")\n", |
446 | 455 | "plt.title(\"Reconstructed Data\")\n", |
447 | 456 | "plt.imshow(delay_optdmd.reconstructed_data.real)\n", |
448 | 457 | "plt.show()\n", |
|
516 | 525 | "delay_dmd.fit(Xn.T)\n", |
517 | 526 | "plot_summary(delay_dmd, d=delays)\n", |
518 | 527 | "\n", |
519 | | - "print(f\"Frequencies (imaginary component): {np.round(np.log(delay_dmd.eigs) / dt, decimals=3)}\")\n", |
| 528 | + "print(\n", |
| 529 | + " f\"Frequencies (imaginary component): {np.round(np.log(delay_dmd.eigs) / dt, decimals=3)}\"\n", |
| 530 | + ")\n", |
520 | 531 | "plt.title(\"Reconstructed Data\")\n", |
521 | 532 | "plt.imshow(delay_dmd.reconstructed_data.real)\n", |
522 | 533 | "plt.show()\n", |
|
593 | 604 | "dmd.fit(X.T)\n", |
594 | 605 | "plot_summary(dmd)\n", |
595 | 606 | "\n", |
596 | | - "print(f\"Frequencies (imaginary component): {np.round(np.log(dmd.eigs) / dt, decimals=3)}\")\n", |
| 607 | + "print(\n", |
| 608 | + " f\"Frequencies (imaginary component): {np.round(np.log(dmd.eigs) / dt, decimals=3)}\"\n", |
| 609 | + ")\n", |
597 | 610 | "plt.title(\"Reconstructed Data\")\n", |
598 | 611 | "plt.imshow(dmd.reconstructed_data.real)\n", |
599 | 612 | "plt.show()\n", |
|
658 | 671 | "delay_dmd.fit(X.T)\n", |
659 | 672 | "plot_summary(delay_dmd, d=2)\n", |
660 | 673 | "\n", |
661 | | - "print(f\"Frequencies (imaginary component): {np.round(np.log(delay_dmd.eigs) / dt, decimals=3)}\")\n", |
| 674 | + "print(\n", |
| 675 | + " f\"Frequencies (imaginary component): {np.round(np.log(delay_dmd.eigs) / dt, decimals=3)}\"\n", |
| 676 | + ")\n", |
662 | 677 | "plt.title(\"Reconstructed Data\")\n", |
663 | 678 | "plt.imshow(delay_dmd.reconstructed_data.real)\n", |
664 | 679 | "plt.show()\n", |
|
0 commit comments