Skip to content

Commit 089ecbc

Browse files
authored
Merge pull request #45 from wwhenxuan/master
Update PySDKit 0.4.23 for FMD
2 parents 7ce839f + 5b0c32d commit 089ecbc

File tree

22 files changed

+421
-275
lines changed

22 files changed

+421
-275
lines changed

example/data_generator.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@
291291
"cell_type": "code",
292292
"source": [
293293
"# Adjust the visualization method through the `view` variable\n",
294-
"plot_IMFs(signal, IMFs, view='3d')"
294+
"plot_IMFs(signal, IMFs, view=\"3d\")"
295295
],
296296
"id": "f95df9777178ea16",
297297
"outputs": [
@@ -375,7 +375,7 @@
375375
"cell_type": "code",
376376
"source": [
377377
"# Adjust the visualization via the `view` variable\n",
378-
"plot_IMFs(signal, IMFs, view='3d')"
378+
"plot_IMFs(signal, IMFs, view=\"3d\")"
379379
],
380380
"id": "8f17486b6e647d2",
381381
"outputs": [

example/demo.ipynb

Lines changed: 47 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"metadata": {
77
"collapsed": true,
88
"ExecuteTime": {
9-
"end_time": "2025-08-13T03:30:57.173409Z",
10-
"start_time": "2025-08-13T03:30:55.759152Z"
9+
"end_time": "2025-09-25T12:27:56.007889Z",
10+
"start_time": "2025-09-25T12:27:54.104682Z"
1111
}
1212
},
1313
"source": [
@@ -21,20 +21,20 @@
2121
},
2222
{
2323
"cell_type": "code",
24+
"id": "1af048fdecdd07b5",
25+
"metadata": {
26+
"collapsed": false,
27+
"ExecuteTime": {
28+
"end_time": "2025-09-25T12:27:56.892626Z",
29+
"start_time": "2025-09-25T12:27:56.799160Z"
30+
}
31+
},
2432
"source": [
2533
"# create an example signal\n",
2634
"t, signal = test_emd()\n",
2735
"# print(signal.shape)\n",
2836
"fig = plot_signal(t, signal)"
2937
],
30-
"metadata": {
31-
"collapsed": false,
32-
"ExecuteTime": {
33-
"end_time": "2025-08-13T03:30:57.352329Z",
34-
"start_time": "2025-08-13T03:30:57.193032Z"
35-
}
36-
},
37-
"id": "1af048fdecdd07b5",
3838
"outputs": [
3939
{
4040
"data": {
@@ -51,20 +51,20 @@
5151
},
5252
{
5353
"cell_type": "code",
54+
"id": "65e9ea5b377df1a4",
55+
"metadata": {
56+
"collapsed": false,
57+
"ExecuteTime": {
58+
"end_time": "2025-09-25T12:28:03.022235Z",
59+
"start_time": "2025-09-25T12:28:02.833098Z"
60+
}
61+
},
5462
"source": [
5563
"# create an instance for signal decomposition\n",
5664
"emd = EMD()\n",
5765
"IMFs = emd.fit_transform(signal, max_imfs=2)\n",
5866
"plot_IMFs(signal, IMFs)"
5967
],
60-
"metadata": {
61-
"collapsed": false,
62-
"ExecuteTime": {
63-
"end_time": "2025-08-13T03:30:57.878889Z",
64-
"start_time": "2025-08-13T03:30:57.554232Z"
65-
}
66-
},
67-
"id": "65e9ea5b377df1a4",
6868
"outputs": [
6969
{
7070
"data": {
@@ -77,24 +77,24 @@
7777
"output_type": "display_data"
7878
}
7979
],
80-
"execution_count": 3
80+
"execution_count": 4
8181
},
8282
{
83+
"cell_type": "code",
84+
"id": "da12b15cebe128fb",
8385
"metadata": {
8486
"ExecuteTime": {
85-
"end_time": "2025-08-13T03:30:58.355629Z",
86-
"start_time": "2025-08-13T03:30:57.933150Z"
87+
"end_time": "2025-09-25T12:28:03.722792Z",
88+
"start_time": "2025-09-25T12:28:03.499695Z"
8789
}
8890
},
89-
"cell_type": "code",
9091
"source": [
9192
"from pysdkit import EWT\n",
9293
"\n",
9394
"ewt = EWT(K=3)\n",
9495
"IMFs = ewt.fit_transform(signal)\n",
9596
"plot_IMFs(signal, IMFs)"
9697
],
97-
"id": "da12b15cebe128fb",
9898
"outputs": [
9999
{
100100
"data": {
@@ -107,10 +107,18 @@
107107
"output_type": "display_data"
108108
}
109109
],
110-
"execution_count": 4
110+
"execution_count": 5
111111
},
112112
{
113113
"cell_type": "code",
114+
"id": "36cd37054ec6ba22",
115+
"metadata": {
116+
"collapsed": false,
117+
"ExecuteTime": {
118+
"end_time": "2025-09-25T12:28:04.805946Z",
119+
"start_time": "2025-09-25T12:28:04.239604Z"
120+
}
121+
},
114122
"source": [
115123
"from pysdkit import VMD\n",
116124
"\n",
@@ -124,14 +132,6 @@
124132
"\n",
125133
"vmd.plot_IMFs(save_figure=True, dpi=600)"
126134
],
127-
"metadata": {
128-
"collapsed": false,
129-
"ExecuteTime": {
130-
"end_time": "2025-08-13T03:30:59.181836Z",
131-
"start_time": "2025-08-13T03:30:58.370269Z"
132-
}
133-
},
134-
"id": "36cd37054ec6ba22",
135135
"outputs": [
136136
{
137137
"name": "stdout",
@@ -151,24 +151,24 @@
151151
"output_type": "display_data"
152152
}
153153
],
154-
"execution_count": 5
154+
"execution_count": 6
155155
},
156156
{
157157
"cell_type": "code",
158-
"source": [
159-
"from pysdkit.plot import plot_IMFs_amplitude_spectra\n",
160-
"\n",
161-
"# frequency domain visualization\n",
162-
"plot_IMFs_amplitude_spectra(IMFs, smooth=\"exp\") # use exp smooth"
163-
],
158+
"id": "d066e800d5dd681a",
164159
"metadata": {
165160
"collapsed": false,
166161
"ExecuteTime": {
167-
"end_time": "2025-08-13T03:30:59.532683Z",
168-
"start_time": "2025-08-13T03:30:59.197549Z"
162+
"end_time": "2025-09-25T12:28:05.776299Z",
163+
"start_time": "2025-09-25T12:28:05.482323Z"
169164
}
170165
},
171-
"id": "d066e800d5dd681a",
166+
"source": [
167+
"from pysdkit.plot import plot_IMFs_amplitude_spectra\n",
168+
"\n",
169+
"# frequency domain visualization\n",
170+
"plot_IMFs_amplitude_spectra(IMFs, smooth=\"exp\") # use exp smooth"
171+
],
172172
"outputs": [
173173
{
174174
"name": "stdout",
@@ -188,60 +188,26 @@
188188
"output_type": "display_data"
189189
}
190190
],
191-
"execution_count": 6
192-
},
193-
{
194-
"metadata": {
195-
"ExecuteTime": {
196-
"end_time": "2025-08-13T03:30:59.542167Z",
197-
"start_time": "2025-08-13T03:30:59.539689Z"
198-
}
199-
},
200-
"cell_type": "code",
201-
"source": "",
202-
"id": "90b80872d654572e",
203-
"outputs": [],
204-
"execution_count": null
205-
},
206-
{
207-
"metadata": {
208-
"ExecuteTime": {
209-
"end_time": "2025-08-13T03:30:59.577504Z",
210-
"start_time": "2025-08-13T03:30:59.575177Z"
211-
}
212-
},
213-
"cell_type": "code",
214-
"source": "",
215-
"id": "3413958f0630f43a",
216-
"outputs": [],
217-
"execution_count": null
218-
},
219-
{
220-
"metadata": {},
221-
"cell_type": "code",
222-
"outputs": [],
223-
"execution_count": null,
224-
"source": "",
225-
"id": "8c71740dde571d35"
191+
"execution_count": 7
226192
}
227193
],
228194
"metadata": {
229195
"kernelspec": {
230-
"display_name": "Python 3",
196+
"display_name": "pysdkit",
231197
"language": "python",
232198
"name": "python3"
233199
},
234200
"language_info": {
235201
"codemirror_mode": {
236202
"name": "ipython",
237-
"version": 2
203+
"version": 3
238204
},
239205
"file_extension": ".py",
240206
"mimetype": "text/x-python",
241207
"name": "python",
242208
"nbconvert_exporter": "python",
243-
"pygments_lexer": "ipython2",
244-
"version": "2.7.6"
209+
"pygments_lexer": "ipython3",
210+
"version": "3.11.0"
245211
}
246212
},
247213
"nbformat": 4,

example/example_zh/data_generator.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@
290290
"cell_type": "code",
291291
"source": [
292292
"# 通过`view`变量来调整可视化的方式\n",
293-
"plot_IMFs(signal, IMFs, view='3d')"
293+
"plot_IMFs(signal, IMFs, view=\"3d\")"
294294
],
295295
"id": "f95df9777178ea16",
296296
"outputs": [
@@ -374,7 +374,7 @@
374374
"cell_type": "code",
375375
"source": [
376376
"# 通过`view`变量调整可视化方式\n",
377-
"plot_IMFs(signal, IMFs, view='3d')"
377+
"plot_IMFs(signal, IMFs, view=\"3d\")"
378378
],
379379
"id": "8f17486b6e647d2",
380380
"outputs": [

example/example_zh/models/PCA.ipynb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,10 @@
206206
"source": [
207207
"def draw_vector(v0, v1, ax=None):\n",
208208
" ax = ax or plt.gca()\n",
209-
" arrowprops = dict(arrowstyle=\"->\",\n",
210-
" linewidth=2,\n",
211-
" shrinkA=0,\n",
212-
" shrinkB=0)\n",
209+
" arrowprops = dict(arrowstyle=\"->\", linewidth=2, shrinkA=0, shrinkB=0)\n",
213210
" ax.annotate(\"\", v1, v0, arrowprops=arrowprops)\n",
214211
"\n",
212+
"\n",
215213
"plt.scatter(X[:, 0], X[:, 1], color=\"royalblue\")\n",
216214
"for length, vector in zip(pca.explained_variance_ratio_, pca.components_):\n",
217215
" v = np.array(vector) * 3 * np.sqrt(length)\n",

example/example_zh/models/knn.ipynb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@
5555
" return X_rot\n",
5656
"\n",
5757
"\n",
58-
"def test_knn_data(n_classes: int = 5, number: int = 10, length: int = 256, random_state: int = 42) -> Tuple[\n",
59-
" np.ndarray, np.ndarray]:\n",
58+
"def test_knn_data(\n",
59+
" n_classes: int = 5, number: int = 10, length: int = 256, random_state: int = 42\n",
60+
") -> Tuple[np.ndarray, np.ndarray]:\n",
6061
" \"\"\"\n",
6162
" 生成用于测试K近邻算法的函数\n",
6263
"\n",
@@ -86,7 +87,9 @@
8687
"print(\"training y\", labels.shape)\n",
8788
"\n",
8889
"# 生成用于测试的数据\n",
89-
"test_samples, test_labels = test_knn_data(n_classes=2, number=1, length=128, random_state=42)\n",
90+
"test_samples, test_labels = test_knn_data(\n",
91+
" n_classes=2, number=1, length=128, random_state=42\n",
92+
")\n",
9093
"# 打印测试数据的形状\n",
9194
"print(\"testing X\", test_samples.shape)\n",
9295
"print(\"testing y\", test_labels.shape)"

pysdkit/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@
7676
# Jump Plus AM-FM Mode Decomposition
7777
from ._jmd import JMD
7878

79+
# Feature Mode Decomposition
80+
from ._fmd import FMD
81+
7982
# Moving Average Decomposition
8083
from .tsa import Moving_Decomp
8184

@@ -132,6 +135,7 @@ def print_functions():
132135
Iterative Nonlinear Chirp Mode Decomposition | INCMD
133136
Empirical Wavelet Transform | EWT
134137
Jump Plus AM-FM Mode Decomposition | JMD
138+
Feature Mode Decomposition | FMD
135139
Moving Average Decomposition | Moving
136140
Seasonal-Trend decomposition using LOESS | STL
137141
Hilbert-Huang Transform | HHT
@@ -167,6 +171,7 @@ def print_functions():
167171
"ewt",
168172
"EWT",
169173
"JMD",
174+
"FMD",
170175
"Moving_Decomp",
171176
"STL",
172177
"models",

pysdkit/_ewt/ewt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,9 @@ def EWT_Boundaries_Detect(
251251

252252
elif reg == "gaussian":
253253
regFilter = np.zeros(lengthFilter)
254-
regFilter[
255-
regFilter.size // 2
256-
] = 1 # Ensure center is set for Gaussian filtering
254+
regFilter[regFilter.size // 2] = (
255+
1 # Ensure center is set for Gaussian filtering
256+
)
257257
presig = np.convolve(
258258
ff, gaussian_filter(regFilter, sigmaFilter), mode="same"
259259
) # Gaussian filter

pysdkit/_fmd/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
@author: Whenxuan Wang
55
@email: wwhenxuan@gmail.com
66
"""
7+
from .fmd import FMD

0 commit comments

Comments
 (0)