|
230 | 230 | " step_size_array=step_sizes,\n",
|
231 | 231 | " global_svd_array=global_svd_array,\n",
|
232 | 232 | " cluster_sweep=True,\n",
|
233 |
| - " transform_method='absolute',\n", |
| 233 | + " transform_method=\"absolute\",\n", |
234 | 234 | " )\n",
|
235 | 235 | "\n",
|
236 | 236 | " mrc.fit(data, np.atleast_2d(ts))"
|
|
803 | 803 | "source": [
|
804 | 804 | "da = mrc._da_omega\n",
|
805 | 805 | "x = da.values\n",
|
806 |
| - "x = x.reshape(len(da.window_length), len(da.window_time_means) * len(da.svd_rank))\n", |
| 806 | + "x = x.reshape(\n", |
| 807 | + " len(da.window_length), len(da.window_time_means) * len(da.svd_rank)\n", |
| 808 | + ")\n", |
807 | 809 | "\n",
|
808 | 810 | "# Squared frequencies\n",
|
809 | 811 | "x_trans = np.abs(x.imag) ** 2 / (2 * np.pi)\n",
|
810 | 812 | "plt.figure(figsize=(5, 2.5))\n",
|
811 | 813 | "plt.hist(\n",
|
812 | 814 | " x=x_trans.T,\n",
|
813 | 815 | " bins=np.linspace(0, 0.005, 100),\n",
|
814 |
| - " histtype='barstacked',\n", |
| 816 | + " histtype=\"barstacked\",\n", |
815 | 817 | " density=True,\n",
|
816 | 818 | " label=range(mrc.n_decompositions),\n",
|
817 |
| - ");\n", |
| 819 | + ")\n", |
818 | 820 | "plt.gca().set_title(\"Global histogram; Interpolated decomposition levels\")\n",
|
819 | 821 | "plt.gca().set_xlabel(r\"$Im(\\omega)^2 (2 \\pi)^{-1}$ (s$^2$)\")\n",
|
820 |
| - "plt.legend(title='decomposition level')\n", |
| 822 | + "plt.legend(title=\"decomposition level\")\n", |
821 | 823 | "\n",
|
822 | 824 | "# Frequency\n",
|
823 | 825 | "plt.figure(figsize=(5, 2.5))\n",
|
824 | 826 | "x_trans = np.abs(x.imag) / (2 * np.pi)\n",
|
825 | 827 | "plt.hist(\n",
|
826 | 828 | " x=x_trans.T,\n",
|
827 | 829 | " bins=100,\n",
|
828 |
| - " histtype='barstacked',\n", |
| 830 | + " histtype=\"barstacked\",\n", |
829 | 831 | " density=True,\n",
|
830 | 832 | " label=range(mrc.n_decompositions),\n",
|
831 |
| - ");\n", |
| 833 | + ")\n", |
832 | 834 | "plt.gca().set_title(\"Global histogram; Interpolated decomposition levels\")\n",
|
833 | 835 | "plt.gca().set_xlabel(r\"$Im(|\\omega|) (2 \\pi)^{-1}$ (s$^{-1}$)\")\n",
|
834 |
| - "plt.legend(title='decomposition level')\n", |
| 836 | + "plt.legend(title=\"decomposition level\")\n", |
835 | 837 | "\n",
|
836 | 838 | "# Period\n",
|
837 | 839 | "plt.figure(figsize=(5, 2.5))\n",
|
838 | 840 | "x_trans = (2 * np.pi) / np.abs(x.imag)\n",
|
839 | 841 | "plt.hist(\n",
|
840 | 842 | " x=x_trans.T,\n",
|
841 | 843 | " bins=100,\n",
|
842 |
| - " histtype='barstacked',\n", |
| 844 | + " histtype=\"barstacked\",\n", |
843 | 845 | " density=True,\n",
|
844 | 846 | " label=range(mrc.n_decompositions),\n",
|
845 |
| - ");\n", |
846 |
| - "plt.legend(title='decomposition level')\n", |
| 847 | + ")\n", |
| 848 | + "plt.legend(title=\"decomposition level\")\n", |
847 | 849 | "plt.gca().set_title(\"Global histogram; Interpolated decomposition levels\")\n",
|
848 | 850 | "plt.gca().set_xlabel(r\"Period; $(2 \\pi) / Im(|\\omega|)$ (s)\")"
|
849 | 851 | ]
|
|
911 | 913 | "plt.hist(\n",
|
912 | 914 | " x=x_trans.T,\n",
|
913 | 915 | " bins=np.logspace(start=np.log10(20), stop=np.log10(1300), num=100),\n",
|
914 |
| - " histtype='barstacked',\n", |
| 916 | + " histtype=\"barstacked\",\n", |
915 | 917 | " label=range(mrc.n_decompositions),\n",
|
916 | 918 | " weights=weights.T,\n",
|
917 |
| - ");\n", |
918 |
| - "plt.xscale('log')\n", |
919 |
| - "plt.legend(title='decomposition level')\n", |
| 919 | + ")\n", |
| 920 | + "plt.xscale(\"log\")\n", |
| 921 | + "plt.legend(title=\"decomposition level\")\n", |
920 | 922 | "plt.gca().set_title(\"Global histogram; Interpolated decomposition levels\")\n",
|
921 | 923 | "plt.gca().set_xlabel(r\"Period; $(2 \\pi) / Im(|\\omega|)$ (s)\")\n",
|
922 |
| - "plt.gca().set_ylabel('Weighted Count (-)')" |
| 924 | + "plt.gca().set_ylabel(\"Weighted Count (-)\")" |
923 | 925 | ]
|
924 | 926 | },
|
925 | 927 | {
|
|
1054 | 1056 | },
|
1055 | 1057 | "outputs": [],
|
1056 | 1058 | "source": [
|
1057 |
| - "x_trans = (2 * np.pi / 10**omega_array)\n", |
| 1059 | + "x_trans = 2 * np.pi / 10**omega_array\n", |
1058 | 1060 | "unique_labels, label_counts = np.unique(omega_classes, return_counts=True)\n",
|
1059 | 1061 | "weights = label_counts.max() / label_counts\n",
|
1060 | 1062 | "x_trans_labels = [x_trans[omega_classes == label] for label in unique_labels]\n",
|
|
1067 | 1069 | " w = weights[ind_array]\n",
|
1068 | 1070 | " x_w = x_trans_labels[ind_list]\n",
|
1069 | 1071 | " w_broadcast = np.broadcast_to(w, (x_w.shape))\n",
|
1070 |
| - " weights_labels.append(w_broadcast)\n" |
| 1072 | + " weights_labels.append(w_broadcast)" |
1071 | 1073 | ]
|
1072 | 1074 | },
|
1073 | 1075 | {
|
|
1099 | 1101 | "plt.hist(\n",
|
1100 | 1102 | " x=x_trans_labels,\n",
|
1101 | 1103 | " bins=np.logspace(start=np.log10(20), stop=np.log10(1300), num=100),\n",
|
1102 |
| - " histtype='barstacked',\n", |
1103 |
| - " weights=weights_labels\n", |
1104 |
| - ");\n", |
| 1104 | + " histtype=\"barstacked\",\n", |
| 1105 | + " weights=weights_labels,\n", |
| 1106 | + ")\n", |
1105 | 1107 | "\n",
|
1106 | 1108 | "ax = plt.gca()\n",
|
1107 |
| - "ax.set_xscale('log')\n", |
| 1109 | + "ax.set_xscale(\"log\")\n", |
1108 | 1110 | "ax.set_title(\n",
|
1109 | 1111 | " \"Global histogram of frequencies; Interpolated decomposition levels\"\n",
|
1110 | 1112 | ")\n",
|
1111 | 1113 | "ax.set_xlabel(r\"Period; $(2 \\pi) / Im(|\\omega|)$ (s)\")\n",
|
1112 |
| - "ax.set_ylabel('Density (-)')\n", |
| 1114 | + "ax.set_ylabel(\"Density (-)\")\n", |
1113 | 1115 | "[\n",
|
1114 | 1116 | " ax.axvline(2 * np.pi / (10**c), color=\"k\", ls=\"--\")\n",
|
1115 | 1117 | " for nc, c in enumerate(cluster_centroids)\n",
|
1116 |
| - "];\n", |
| 1118 | + "]\n", |
1117 | 1119 | "\n",
|
1118 | 1120 | "ylim_bottom, ylim_top = ax.get_ylim()\n",
|
1119 | 1121 | "[\n",
|
|
1126 | 1128 | " ha=\"right\",\n",
|
1127 | 1129 | " )\n",
|
1128 | 1130 | " for c in cluster_centroids\n",
|
1129 |
| - "];\n" |
| 1131 | + "];" |
1130 | 1132 | ]
|
1131 | 1133 | },
|
1132 | 1134 | {
|
|
0 commit comments