Modal-Decomposition 0.0.2__tar.gz → 0.0.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/PKG-INFO +1 -1
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/pyproject.toml +1 -1
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/CEEFD.py +51 -3
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/CEEMD.py +8 -7
- modal_decomposition-0.0.3/src/Modal_Decomposition/EEMD.py +35 -0
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/EFD.py +10 -3
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/EMD.py +9 -8
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/EWT.py +5 -2
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/FMD.py +3 -2
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/ICEEMDAN.py +21 -7
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/LMD.py +3 -3
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/MEMD.py +4 -3
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/RPSEMD.py +13 -8
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/SSA.py +9 -8
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/SVMD.py +2 -3
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/VMD.py +9 -2
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/__init__.py +3 -1
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition.egg-info/PKG-INFO +1 -1
- modal_decomposition-0.0.2/src/Modal_Decomposition/EEMD.py +0 -24
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/LICENSE +0 -0
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/README.md +0 -0
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/setup.cfg +0 -0
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/COLOR/__init__.py +0 -0
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/COLOR/color_define.py +0 -0
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/COLOR/colorful_print.py +0 -0
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/help_function.py +0 -0
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition.egg-info/SOURCES.txt +0 -0
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition.egg-info/dependency_links.txt +0 -0
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition.egg-info/requires.txt +0 -0
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition.egg-info/top_level.txt +0 -0
- {modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/tests/test.py +0 -0
|
@@ -16,6 +16,7 @@ Description: (if None write None)
|
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
import numpy as np
|
|
19
|
+
from typing import Union, Tuple
|
|
19
20
|
|
|
20
21
|
class CEEFD:
|
|
21
22
|
"""
|
|
@@ -74,7 +75,32 @@ class CEEFD:
|
|
|
74
75
|
total_power_thr=self.total_power_thr
|
|
75
76
|
)
|
|
76
77
|
|
|
77
|
-
def ceemdan(self, S, T=None, max_imf=-1):
|
|
78
|
+
def ceemdan(self, S: Union[list, np.ndarray], T: Union[list, np.ndarray]=None, max_imf: int=-1, fs=None) -> Tuple[np.ndarray, np.ndarray]:
|
|
79
|
+
"""
|
|
80
|
+
:param S: Signal (1-dim)
|
|
81
|
+
:param T: Time axis (1-dim)
|
|
82
|
+
:param max_imf: the num of the decomposed IMFs. | -1 means all.
|
|
83
|
+
:param fs: the f of Time.f default 1.
|
|
84
|
+
:return: IMFs (2-dim), Res (1-dim)
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
if not isinstance(S, np.ndarray):
|
|
88
|
+
S = np.array(S)
|
|
89
|
+
|
|
90
|
+
N = len(S)
|
|
91
|
+
|
|
92
|
+
if T is None:
|
|
93
|
+
if fs is not None:
|
|
94
|
+
dt = 1.0 / fs # smaple for time axis
|
|
95
|
+
T = np.arange(N) * dt
|
|
96
|
+
else:
|
|
97
|
+
T = np.arange(N) # default fs = 1
|
|
98
|
+
print(f"Warn: T is None,default T = [0, 1, 2, ..., {N - 1}]")
|
|
99
|
+
|
|
100
|
+
else:
|
|
101
|
+
if not isinstance(T, np.ndarray):
|
|
102
|
+
T = np.array(T)
|
|
103
|
+
|
|
78
104
|
CEEMDAN = self.give_ceemdan()
|
|
79
105
|
IMF_Residue = CEEMDAN.ceemdan(S, T, max_imf)
|
|
80
106
|
|
|
@@ -83,13 +109,35 @@ class CEEFD:
|
|
|
83
109
|
|
|
84
110
|
return IMFs, Res
|
|
85
111
|
|
|
86
|
-
def ceefd(self, S, T=None, max_imf=-1):
|
|
112
|
+
def ceefd(self, S: Union[list, np.ndarray], T: Union[list, np.ndarray]=None, max_imf: int=-1, fs=1) -> [np.ndarray, np.ndarray, np.ndarray, np.ndarray]:
|
|
87
113
|
"""
|
|
88
|
-
|
|
114
|
+
Give S, use CEEMDAN(s), get CEEMDAN-IMFs and CEEMDAN-Res, use EFD for the max sample entropy IMF, get EFD-IMFs and EFD-Res.
|
|
115
|
+
:param S: Signal (1-dim)
|
|
116
|
+
:param T: Time axis (1-dim)
|
|
117
|
+
:param max_imf: decomposition's result | if -1, decompose entirely.
|
|
118
|
+
:param fs: the f of Time. default 1.
|
|
119
|
+
:return: CEEMDAN_IMFs (2-dim), EFD_IMFs (2-dim), CEEMDAN_Res (1-dim), EFD_Res (1-dim)
|
|
89
120
|
"""
|
|
90
121
|
from .EFD import EFD
|
|
91
122
|
import antropy as ant
|
|
92
123
|
|
|
124
|
+
if not isinstance(S, np.ndarray):
|
|
125
|
+
S = np.ndarray(S)
|
|
126
|
+
|
|
127
|
+
N = len(S)
|
|
128
|
+
|
|
129
|
+
if T is None:
|
|
130
|
+
if fs is not None:
|
|
131
|
+
dt = 1.0 / fs # smaple for time axis
|
|
132
|
+
T = np.arange(N) * dt
|
|
133
|
+
else:
|
|
134
|
+
T = np.arange(N) # default fs = 1
|
|
135
|
+
print(f"Warn: T is None,default T = [0, 1, 2, ..., {N - 1}]")
|
|
136
|
+
|
|
137
|
+
else:
|
|
138
|
+
if not isinstance(T, np.ndarray):
|
|
139
|
+
T = np.array(T)
|
|
140
|
+
|
|
93
141
|
CEEMDAN = self.give_ceemdan()
|
|
94
142
|
IMF_Residue = CEEMDAN.ceemdan(S, T, max_imf)
|
|
95
143
|
|
|
@@ -17,6 +17,7 @@ Description: (if None write None)
|
|
|
17
17
|
Realize the CEEMD.
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
|
+
from typing import Union, Tuple
|
|
20
21
|
from time import sleep
|
|
21
22
|
import numpy as np
|
|
22
23
|
from .EMD import emd
|
|
@@ -25,17 +26,17 @@ from tqdm import tqdm
|
|
|
25
26
|
import sys
|
|
26
27
|
|
|
27
28
|
|
|
28
|
-
def ceemd(S, T=None, fs=None, beta=0.3, max_imf=None, iterations=30, verbose: bool=False)
|
|
29
|
+
def ceemd(S: Union[list, np.ndarray], T: Union[list, np.ndarray]=None, fs=None, beta=0.3, max_imf=None, iterations=30, verbose: bool=False) \
|
|
30
|
+
-> Tuple[np.ndarray, np.ndarray]:
|
|
29
31
|
"""
|
|
30
|
-
|
|
31
|
-
:param
|
|
32
|
-
:param
|
|
33
|
-
:param fs:
|
|
32
|
+
:param S: Signal (1-dim)
|
|
33
|
+
:param T: the time axis.
|
|
34
|
+
:param fs: the f of Time. default 1.
|
|
34
35
|
:param beta:
|
|
35
|
-
:param max_imf: -1 or other int | 100 is enough, if you choose -1, no one kown when
|
|
36
|
+
:param max_imf: -1 or other int | 100 is enough, if you choose -1, no one kown when finish(^_^)
|
|
36
37
|
:param iterations:
|
|
37
38
|
:param verbose:
|
|
38
|
-
:return:
|
|
39
|
+
:return: IMFs (2-dim), Res (1-dim)
|
|
39
40
|
"""
|
|
40
41
|
N = len(S)
|
|
41
42
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Python version: (must)
|
|
3
|
+
3.10.11
|
|
4
|
+
|
|
5
|
+
Lib and Version: (if None write None)
|
|
6
|
+
EMD-signal - 1.9.0
|
|
7
|
+
|
|
8
|
+
Only accessed by: (must)
|
|
9
|
+
Only __init__.py
|
|
10
|
+
|
|
11
|
+
Modify: (must)
|
|
12
|
+
2026.3.25
|
|
13
|
+
|
|
14
|
+
Description: (if None write None)
|
|
15
|
+
Realize the EEMD.
|
|
16
|
+
"""
|
|
17
|
+
import numpy as np
|
|
18
|
+
from PyEMD import EEMD
|
|
19
|
+
from typing import Union, Tuple
|
|
20
|
+
|
|
21
|
+
Origin_EEMD = EEMD
|
|
22
|
+
|
|
23
|
+
EEMD = EEMD()
|
|
24
|
+
def eemd(S: Union[list, np.ndarray]) -> Tuple[np.ndarray, np.ndarray]:
|
|
25
|
+
"""
|
|
26
|
+
:param S: Signal (1-dim)
|
|
27
|
+
:return: IMFs (2-dim), Res (1-dim)
|
|
28
|
+
"""
|
|
29
|
+
if not isinstance(S, np.ndarray):
|
|
30
|
+
S = np.array(S)
|
|
31
|
+
|
|
32
|
+
IMFs = EEMD.eemd(S)
|
|
33
|
+
Res = EEMD.residue
|
|
34
|
+
|
|
35
|
+
return IMFs, Res
|
|
@@ -20,12 +20,15 @@ Description: (if None write None)
|
|
|
20
20
|
|
|
21
21
|
import numpy as np
|
|
22
22
|
from .COLOR import printc
|
|
23
|
+
from typing import Union, Tuple
|
|
23
24
|
|
|
24
|
-
|
|
25
|
+
|
|
26
|
+
def EFD(S: Union[list, np.ndarray], T: Union[list, np.ndarray]=None, fs=None) -> Tuple[np.ndarray, np.ndarray]:
|
|
25
27
|
"""
|
|
26
28
|
:param S: Signal (1-dim)
|
|
27
|
-
:param T: Time axis (
|
|
28
|
-
:
|
|
29
|
+
:param T: Time axis (1-dim)
|
|
30
|
+
:param fs: the f of T (default fs = 1)
|
|
31
|
+
:return: IMFs 2-dim | Res: 1-dim
|
|
29
32
|
"""
|
|
30
33
|
from scipy.signal import find_peaks
|
|
31
34
|
|
|
@@ -42,6 +45,10 @@ def EFD(S, T=None, fs=None):
|
|
|
42
45
|
T = np.arange(N) # default fs = 1
|
|
43
46
|
printc(f"Warn: T is None,default T = [0, 1, 2, ..., {N - 1}]", color="red")
|
|
44
47
|
|
|
48
|
+
else:
|
|
49
|
+
if not isinstance(T, np.ndarray):
|
|
50
|
+
T = np.array(T)
|
|
51
|
+
|
|
45
52
|
if len(T) != N:
|
|
46
53
|
raise ValueError(f"len of T: ({len(T)}) doesn't match ({N})")
|
|
47
54
|
|
|
@@ -19,19 +19,20 @@ Description: (if None write None)
|
|
|
19
19
|
from PyEMD import EMD
|
|
20
20
|
import numpy as np
|
|
21
21
|
from .COLOR.colorful_print import printc
|
|
22
|
-
from typing import Tuple
|
|
22
|
+
from typing import Tuple, Union
|
|
23
23
|
|
|
24
24
|
EMD_cls = EMD
|
|
25
25
|
|
|
26
|
-
def emd(S, T=None, spline_kind: str = "cubic", nbsym: int = 2, max_imf=-1, fs=None)
|
|
26
|
+
def emd(S: Union[list, np.ndarray], T: Union[list, np.ndarray]=None, spline_kind: str = "cubic", nbsym: int = 2, max_imf=-1, fs=None)\
|
|
27
|
+
-> Tuple[np.ndarray, np.ndarray]:
|
|
27
28
|
"""
|
|
28
|
-
:param S:
|
|
29
|
-
:param T:
|
|
30
|
-
:param spline_kind:
|
|
29
|
+
:param S: Signal (1-dim)
|
|
30
|
+
:param T: Time axis (1-dim)
|
|
31
|
+
:param spline_kind: the kind of spline. default cubic.
|
|
31
32
|
:param nbsym:
|
|
32
|
-
:param max_imf:
|
|
33
|
-
:param fs:
|
|
34
|
-
:return: IMFs (2-dim), Res
|
|
33
|
+
:param max_imf: the max num of IMFs
|
|
34
|
+
:param fs: the f of T. default 1.
|
|
35
|
+
:return: IMFs (2-dim), Res (1-dim)
|
|
35
36
|
"""
|
|
36
37
|
if not isinstance(S, np.ndarray):
|
|
37
38
|
S = np.array(S)
|
|
@@ -21,7 +21,7 @@ import numpy as np
|
|
|
21
21
|
|
|
22
22
|
def ewt \
|
|
23
23
|
(
|
|
24
|
-
S,
|
|
24
|
+
S: Union[list, np.ndarray],
|
|
25
25
|
N: int = 5,
|
|
26
26
|
log: int = 0,
|
|
27
27
|
detect: str = "locmax",
|
|
@@ -32,7 +32,7 @@ def ewt \
|
|
|
32
32
|
need_mfd: bool = False,
|
|
33
33
|
need_boundaries: bool = False) -> Union[Tuple[np.ndarray, np.ndarray], Tuple[np.ndarray, np.ndarray, np.ndarray], Tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray]]:
|
|
34
34
|
"""
|
|
35
|
-
:param S: Signal
|
|
35
|
+
:param S: Signal (1-dim)
|
|
36
36
|
:param N:
|
|
37
37
|
:param log:
|
|
38
38
|
:param detect:
|
|
@@ -44,6 +44,9 @@ def ewt \
|
|
|
44
44
|
"""
|
|
45
45
|
from ewtpy import EWT1D
|
|
46
46
|
|
|
47
|
+
if not isinstance(S, np.ndarray):
|
|
48
|
+
S = np.array(S)
|
|
49
|
+
|
|
47
50
|
ewt, mfb, boundaries = EWT1D(S, N, log, detect, completion, reg, lengthFilter, sigmaFilter)
|
|
48
51
|
ewt = ewt.T
|
|
49
52
|
mfb = mfb.T
|
|
@@ -18,6 +18,7 @@ Description: (if None write None)
|
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
20
|
import numpy as np
|
|
21
|
+
from typing import Union
|
|
21
22
|
|
|
22
23
|
def initialize_filters(L, K):
|
|
23
24
|
from scipy.signal import firwin
|
|
@@ -41,7 +42,7 @@ def estimate_period(signal):
|
|
|
41
42
|
period = len(signal)
|
|
42
43
|
return period
|
|
43
44
|
|
|
44
|
-
def fmd(S, n=10, L=100, max_iters=10):
|
|
45
|
+
def fmd(S: Union[list, np.ndarray], n=10, L=100, max_iters=10) -> np.ndarray:
|
|
45
46
|
"""
|
|
46
47
|
:param S: Signal (2-dim)
|
|
47
48
|
:param n: store n IMFs
|
|
@@ -66,4 +67,4 @@ def fmd(S, n=10, L=100, max_iters=10):
|
|
|
66
67
|
if len(modes) >= n:
|
|
67
68
|
break
|
|
68
69
|
|
|
69
|
-
return modes[:n]
|
|
70
|
+
return np.array(modes[:n])
|
|
@@ -19,27 +19,41 @@ Description: (if None write None)
|
|
|
19
19
|
import numpy as np
|
|
20
20
|
from .EMD import emd
|
|
21
21
|
from .help_function import is_increasing
|
|
22
|
+
from typing import Union, Tuple
|
|
22
23
|
|
|
23
24
|
|
|
24
|
-
def iceemdan(S, T=None, Ne=300, epsilon_0=None, max_imf=None, verbose: bool=False, spline_kind: str = "cubic", nbsym: int = 2, emd_max_imf=-1, fs=None)
|
|
25
|
+
def iceemdan(S: Union[list, np.ndarray], T: Union[list, np.ndarray]=None, Ne=300, epsilon_0=None, max_imf=None, verbose: bool=False, spline_kind: str = "cubic", nbsym: int = 2, emd_max_imf=-1, fs=None)\
|
|
26
|
+
-> Tuple[np.ndarray, np.ndarray]:
|
|
25
27
|
"""
|
|
26
|
-
:param emd_max_imf:
|
|
27
|
-
:param nbsym:
|
|
28
|
-
:param spline_kind:
|
|
29
|
-
:param verbose: is print formation
|
|
30
28
|
:param S: Signal (1-dim)
|
|
29
|
+
:param T: Time axis (1-dim)
|
|
31
30
|
:param Ne: total num of samples (times of add noise), default 300
|
|
32
31
|
:param epsilon_0: initial amplitude of noise,default: 0.2 * std(S) / std(noise)
|
|
33
32
|
:param max_imf: max num of IMFs
|
|
34
|
-
:
|
|
33
|
+
:param verbose: dose print formation
|
|
34
|
+
:param spline_kind: the kind of spline. default cubic
|
|
35
|
+
:param nbsym:
|
|
36
|
+
:param emd_max_imf: the max num of IMFs with EMD
|
|
37
|
+
:param fs: the f of T, default 1.
|
|
38
|
+
:return: IMFs (2-dim), Res (1-dim)
|
|
35
39
|
"""
|
|
36
40
|
|
|
37
41
|
if not isinstance(S, np.ndarray):
|
|
38
42
|
S = np.array(S)
|
|
39
43
|
|
|
40
44
|
T_len = len(S)
|
|
45
|
+
|
|
41
46
|
if T is None:
|
|
42
|
-
|
|
47
|
+
if fs is not None:
|
|
48
|
+
dt = 1.0 / fs # smaple for time axis
|
|
49
|
+
T = np.arange(T_len) * dt
|
|
50
|
+
else:
|
|
51
|
+
T = np.arange(T_len) # default fs = 1
|
|
52
|
+
print(f"Warn: T is None,default T = [0, 1, 2, ..., {T_len - 1}]")
|
|
53
|
+
|
|
54
|
+
else:
|
|
55
|
+
if not isinstance(T, np.ndarray):
|
|
56
|
+
T = np.array(T)
|
|
43
57
|
|
|
44
58
|
white_noise = np.random.randn(Ne, T_len) # generate Ne white nose
|
|
45
59
|
|
|
@@ -22,15 +22,15 @@ Modify:
|
|
|
22
22
|
|
|
23
23
|
import numpy as np
|
|
24
24
|
from .help_function import is_increasing
|
|
25
|
+
from typing import Union, Tuple
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
def lmd(S, max_pf=None, max_iter=37, eps=0.05):
|
|
27
|
+
def lmd(S: Union[list, np.ndarray], max_pf=None, max_iter=37, eps=0.05) -> Tuple[np.ndarray, np.ndarray]:
|
|
28
28
|
"""
|
|
29
29
|
:param S: Signal (1-dim)
|
|
30
30
|
:param max_pf: max num of pfs
|
|
31
31
|
:param max_iter: max iterations of each pf
|
|
32
32
|
:param eps: therhold
|
|
33
|
-
:return: PFs, Res
|
|
33
|
+
:return: PFs (2-dim), Res (1-dim)
|
|
34
34
|
"""
|
|
35
35
|
import scipy.interpolate as ip
|
|
36
36
|
from scipy.signal import argrelextrema
|
|
@@ -17,16 +17,17 @@ Description: (if None write None)
|
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
19
|
import numpy as np
|
|
20
|
+
from typing import Union, Tuple
|
|
20
21
|
|
|
21
|
-
def memd(S, d=None, k=None, max_imf=None, sd_thresh=0.2, max_iter=10):
|
|
22
|
+
def memd(S: Union[list, np.ndarray], d=None, k=None, max_imf=None, sd_thresh=0.2, max_iter=10) -> Tuple[np.ndarray, np.ndarray]:
|
|
22
23
|
"""
|
|
23
|
-
:param S: Signal
|
|
24
|
+
:param S: Signal (2-dim), (d, N) | d -> channels,N -> time points
|
|
24
25
|
:param d: channels or dimensions
|
|
25
26
|
:param k: number of directional vector,default: d * 128
|
|
26
27
|
:param max_imf: max num of IMFs
|
|
27
28
|
:param sd_thresh: therahold
|
|
28
29
|
:param max_iter: max iterations of each IMF
|
|
29
|
-
:return: IMFs
|
|
30
|
+
:return: IMFs (d, N), Res (2-dim)
|
|
30
31
|
"""
|
|
31
32
|
|
|
32
33
|
if not isinstance(S, np.ndarray):
|
|
@@ -19,19 +19,20 @@ import numpy as np
|
|
|
19
19
|
from .help_function import is_increasing
|
|
20
20
|
from .EMD import emd
|
|
21
21
|
from .COLOR import printc
|
|
22
|
+
from typing import Union, Tuple
|
|
22
23
|
|
|
23
|
-
def rpsemd(S, T=None, f=None, M=4, max_imf=None, fs=1.0, spline_kind: str = "cubic", nbsym: int = 2, emd_max_imf=-1):
|
|
24
|
+
def rpsemd(S: Union[list, np.ndarray], T: Union[list, np.ndarray]=None, f=None, M=4, max_imf=None, fs=1.0, spline_kind: str = "cubic", nbsym: int = 2, emd_max_imf=-1) -> Tuple[np.ndarray, np.ndarray]:
|
|
24
25
|
"""
|
|
25
|
-
:param
|
|
26
|
-
:param nbsym:
|
|
27
|
-
:param spline_kind:
|
|
28
|
-
:param fs:
|
|
26
|
+
:param S: Signal (1-dim)
|
|
29
27
|
:param T: time axis
|
|
30
|
-
:param max_imf: max num of IMFs
|
|
31
|
-
:param S: Signal
|
|
32
28
|
:param f: auxiliary sine wave frequency
|
|
33
29
|
:param M: num of phases
|
|
34
|
-
:
|
|
30
|
+
:param max_imf: max num of IMFs
|
|
31
|
+
:param fs: the f of Time. default 1.
|
|
32
|
+
:param spline_kind: the kind of spline. default cubic spline.
|
|
33
|
+
:param nbsym:
|
|
34
|
+
:param emd_max_imf: the max IMFs of EMD
|
|
35
|
+
:return: IMFs (2-dim), Res (1-dim)
|
|
35
36
|
"""
|
|
36
37
|
|
|
37
38
|
if not isinstance(S, np.ndarray):
|
|
@@ -52,6 +53,10 @@ def rpsemd(S, T=None, f=None, M=4, max_imf=None, fs=1.0, spline_kind: str = "cub
|
|
|
52
53
|
T = np.arange(len(S))
|
|
53
54
|
print(f"warn:T is None | deault:T = 0, 1, 2, ..., {len(S) - 1}")
|
|
54
55
|
|
|
56
|
+
else:
|
|
57
|
+
if not isinstance(T, np.ndarray):
|
|
58
|
+
T = np.array(T)
|
|
59
|
+
|
|
55
60
|
phi = np.array([2.0 * np.pi * i / M for i in range(M)])
|
|
56
61
|
|
|
57
62
|
IMFs = []
|
|
@@ -18,7 +18,7 @@ Description: (if None write None)
|
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
20
|
import numpy as np
|
|
21
|
-
from typing import
|
|
21
|
+
from typing import Union
|
|
22
22
|
|
|
23
23
|
class SSA:
|
|
24
24
|
def __init__(self, window_size=None):
|
|
@@ -32,15 +32,16 @@ class SSA:
|
|
|
32
32
|
self.U_ = None
|
|
33
33
|
self.V_ = None
|
|
34
34
|
|
|
35
|
-
def decompose(self, S, groups=None) ->
|
|
35
|
+
def decompose(self, S: Union[list, np.ndarray], groups=None) -> np.ndarray:
|
|
36
36
|
"""
|
|
37
|
-
:
|
|
38
|
-
|
|
39
|
-
groups: group information, such as: [[0], [1,2], [3,4]] means which components will be merged. If None, return all
|
|
37
|
+
:param S: Signal (1-dim)
|
|
38
|
+
:param groups: group information, such as: [[0], [1,2], [3,4]] means which components will be merged. If None, return all
|
|
40
39
|
|
|
41
|
-
:return:
|
|
42
|
-
RCs: IMFs Matrix | each row is a IMF
|
|
40
|
+
:return: IMFs (2-dim)
|
|
43
41
|
"""
|
|
42
|
+
if not isinstance(S, np.ndarray):
|
|
43
|
+
S = np.array(S)
|
|
44
|
+
|
|
44
45
|
series = np.asarray(S).flatten()
|
|
45
46
|
N = len(series)
|
|
46
47
|
|
|
@@ -89,7 +90,7 @@ class SSA:
|
|
|
89
90
|
self.U_ = U
|
|
90
91
|
self.V_ = VT
|
|
91
92
|
|
|
92
|
-
return self.components_
|
|
93
|
+
return self.components_
|
|
93
94
|
|
|
94
95
|
|
|
95
96
|
# def give_fast_SSA() -> Callable:
|
|
@@ -17,7 +17,7 @@ Description: (if None write None)
|
|
|
17
17
|
"""
|
|
18
18
|
|
|
19
19
|
import numpy as np
|
|
20
|
-
from typing import Tuple
|
|
20
|
+
from typing import Tuple, Union
|
|
21
21
|
|
|
22
22
|
class SVMD:
|
|
23
23
|
def __init__(self, num_modes=3, alpha=2000, tol=1e-7):
|
|
@@ -43,9 +43,8 @@ class SVMD:
|
|
|
43
43
|
|
|
44
44
|
return mode
|
|
45
45
|
|
|
46
|
-
def decompose(self, S) -> Tuple[np.ndarray, np.ndarray]:
|
|
46
|
+
def decompose(self, S: Union[list, np.ndarray]) -> Tuple[np.ndarray, np.ndarray]:
|
|
47
47
|
"""
|
|
48
|
-
|
|
49
48
|
:param S: Signal (1-dim)
|
|
50
49
|
:return: IMFs(2-dim), Res(1-dim)
|
|
51
50
|
"""
|
|
@@ -15,7 +15,11 @@ Description: (if None write None)
|
|
|
15
15
|
Realize VMD by using vmdpy lib.
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
|
-
|
|
18
|
+
from typing import Union, Tuple
|
|
19
|
+
import numpy as np
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def vmd(S: Union[list, np.ndarray], alpha = 2000, tau = 0.0, K = 2, DC = 0, init = 1, tol = 1e-7) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
|
|
19
23
|
"""
|
|
20
24
|
:param S: Signal (1-dim)
|
|
21
25
|
:param alpha: broadband constraints
|
|
@@ -24,10 +28,13 @@ def vmd(S, alpha = 2000, tau = 0.0, K = 2, DC = 0, init = 1, tol = 1e-7):
|
|
|
24
28
|
:param DC: is included directional component
|
|
25
29
|
:param init: way of initial
|
|
26
30
|
:param tol: convergence threshold
|
|
27
|
-
:return:
|
|
31
|
+
:return: IMFs (2-dim), u_hat (2-dim), omega (1-dim)
|
|
28
32
|
"""
|
|
29
33
|
from vmdpy import VMD
|
|
30
34
|
|
|
35
|
+
if not isinstance(S, np.ndarray):
|
|
36
|
+
S = np.array(S)
|
|
37
|
+
|
|
31
38
|
u, u_hat, omega = VMD(S, alpha, tau, K, DC, init, tol)
|
|
32
39
|
|
|
33
40
|
return u, u_hat, omega
|
|
@@ -24,7 +24,8 @@ Description: (if None write None)
|
|
|
24
24
|
As the entrance of the lib
|
|
25
25
|
|
|
26
26
|
Modify:
|
|
27
|
-
Optimize the cost of import, from 5.001s to 0.747s. Put some heavy lib into internal of the function
|
|
27
|
+
2026.3.25 - Optimize the cost of import, from 5.001s to 0.747s. Put some heavy lib into internal of the function
|
|
28
|
+
2026.3.26 - Optimize the description of the type of input and output. now, the dim of input and output is more clear.
|
|
28
29
|
"""
|
|
29
30
|
from .help_function import is_increasing
|
|
30
31
|
|
|
@@ -66,6 +67,7 @@ class Class:
|
|
|
66
67
|
|
|
67
68
|
class Function:
|
|
68
69
|
# function | default function for modal decomposition
|
|
70
|
+
# the IMFs (2-dim) means: (K, len(Signal)) (K is the num of IMFs)
|
|
69
71
|
EFD = EFD
|
|
70
72
|
CEEFD = ceefd_real_cls.ceefd
|
|
71
73
|
CEEMDAN = ceefd_real_cls.ceemdan
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Python version: (must)
|
|
3
|
-
3.10.11
|
|
4
|
-
|
|
5
|
-
Lib and Version: (if None write None)
|
|
6
|
-
EMD-signal - 1.9.0
|
|
7
|
-
|
|
8
|
-
Only accessed by: (must)
|
|
9
|
-
Only __init__.py
|
|
10
|
-
|
|
11
|
-
Modify: (must)
|
|
12
|
-
2026.3.25
|
|
13
|
-
|
|
14
|
-
Description: (if None write None)
|
|
15
|
-
Realize the EEMD.
|
|
16
|
-
"""
|
|
17
|
-
|
|
18
|
-
from PyEMD import EEMD
|
|
19
|
-
|
|
20
|
-
Origin_EEMD = EEMD
|
|
21
|
-
|
|
22
|
-
EEMD = EEMD()
|
|
23
|
-
def eemd(S):
|
|
24
|
-
return EEMD.eemd(S)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/COLOR/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition/help_function.py
RENAMED
|
File without changes
|
{modal_decomposition-0.0.2 → modal_decomposition-0.0.3}/src/Modal_Decomposition.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|