PySDKit 0.4.18__tar.gz → 0.4.19__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.
Files changed (131) hide show
  1. {pysdkit-0.4.18 → pysdkit-0.4.19}/PKG-INFO +4 -3
  2. {pysdkit-0.4.18 → pysdkit-0.4.19}/PySDKit.egg-info/PKG-INFO +4 -3
  3. {pysdkit-0.4.18 → pysdkit-0.4.19}/PySDKit.egg-info/SOURCES.txt +3 -3
  4. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/__init__.py +2 -1
  5. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd/ceemdan.py +54 -38
  6. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd/efd.py +1 -1
  7. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd/emd.py +16 -1
  8. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_itd/itd.py +9 -17
  9. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_lmd/lmd.py +14 -0
  10. pysdkit-0.4.19/pysdkit/_lmd/rlmd.py +739 -0
  11. pysdkit-0.4.19/pysdkit/_vncmd/avncmd.py +347 -0
  12. pysdkit-0.4.19/pysdkit/tests/test_lmd.py +66 -0
  13. pysdkit-0.4.19/pysdkit/tests/test_rlmd.py +66 -0
  14. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tsa/_stl.py +3 -0
  15. {pysdkit-0.4.18 → pysdkit-0.4.19}/setup.py +2 -2
  16. pysdkit-0.4.18/pysdkit/_lmd/rlmd.py +0 -33
  17. pysdkit-0.4.18/pysdkit/_vncmd/anvcmd.py +0 -13
  18. pysdkit-0.4.18/pysdkit/hht/__init__.py +0 -6
  19. pysdkit-0.4.18/pysdkit/hht/hht.py +0 -14
  20. {pysdkit-0.4.18 → pysdkit-0.4.19}/LICENSE +0 -0
  21. {pysdkit-0.4.18 → pysdkit-0.4.19}/PySDKit.egg-info/dependency_links.txt +0 -0
  22. {pysdkit-0.4.18 → pysdkit-0.4.19}/PySDKit.egg-info/requires.txt +0 -0
  23. {pysdkit-0.4.18 → pysdkit-0.4.19}/PySDKit.egg-info/top_level.txt +0 -0
  24. {pysdkit-0.4.18 → pysdkit-0.4.19}/README.md +0 -0
  25. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd/__init__.py +0 -0
  26. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd/_find_extrema.py +0 -0
  27. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd/_prepare_points.py +0 -0
  28. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd/_splines.py +0 -0
  29. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd/eemd.py +0 -0
  30. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd/hht/__init__.py +0 -0
  31. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd/hht/frequency.py +0 -0
  32. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd/hht/hht.py +0 -0
  33. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd/memd.py +0 -0
  34. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd/remd.py +0 -0
  35. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd/tvf_emd.py +0 -0
  36. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd2d/__init__.py +0 -0
  37. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd2d/bemd.py +0 -0
  38. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd2d/bmemd.py +0 -0
  39. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_emd2d/emd2d.py +0 -0
  40. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_esmd/__init__.py +0 -0
  41. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_esmd/esmd.py +0 -0
  42. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_ewt/__init__.py +0 -0
  43. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_ewt/ewt.py +0 -0
  44. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_ewt/ewt2d.py +0 -0
  45. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_faemd/__init__.py +0 -0
  46. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_faemd/extrema.py +0 -0
  47. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_faemd/faemd.py +0 -0
  48. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_faemd/faemd2d.py +0 -0
  49. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_faemd/faemd3d.py +0 -0
  50. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_faemd/filter.py +0 -0
  51. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_fmd/__init__.py +0 -0
  52. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_fmd/fmd.py +0 -0
  53. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_fmd/nfmd.py +0 -0
  54. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_hvd/__init__.py +0 -0
  55. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_hvd/hvd.py +0 -0
  56. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_ifd/__init__.py +0 -0
  57. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_itd/__init__.py +0 -0
  58. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_jmd/__init__.py +0 -0
  59. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_jmd/jmd.py +0 -0
  60. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_jmd/mjmd.py +0 -0
  61. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_lmd/__init__.py +0 -0
  62. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_osd/__init__.py +0 -0
  63. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_ssa/__init__.py +0 -0
  64. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_ssa/ssa.py +0 -0
  65. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vmd/__init__.py +0 -0
  66. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vmd/acmd.py +0 -0
  67. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vmd/avmd.py +0 -0
  68. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vmd/ba_acmd.py +0 -0
  69. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vmd/base.py +0 -0
  70. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vmd/mvmd.py +0 -0
  71. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vmd/svmd.py +0 -0
  72. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vmd/vmd_c.py +0 -0
  73. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vmd/vmd_f.py +0 -0
  74. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vmd/vme.py +0 -0
  75. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vmd2d/__init__.py +0 -0
  76. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vmd2d/cvmd2d.py +0 -0
  77. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vmd2d/vmd2d.py +0 -0
  78. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vncmd/__init__.py +0 -0
  79. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vncmd/incmd.py +0 -0
  80. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vncmd/mncmd.py +0 -0
  81. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/_vncmd/vncmd.py +0 -0
  82. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/data/__init__.py +0 -0
  83. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/data/_add_noise.py +0 -0
  84. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/data/_cube.py +0 -0
  85. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/data/_generator.py +0 -0
  86. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/data/_image.py +0 -0
  87. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/data/_time_series.py +0 -0
  88. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/data/texture.txt +0 -0
  89. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/entropy/__init__.py +0 -0
  90. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/entropy/_approxiamte_entropy.py +0 -0
  91. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/entropy/_permutation_entropy.py +0 -0
  92. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/entropy/_sample_entropy.py +0 -0
  93. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/plot/__init__.py +0 -0
  94. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/plot/_fourier_spectra.py +0 -0
  95. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/plot/_functions.py +0 -0
  96. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/plot/_plot_images.py +0 -0
  97. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/plot/_plot_imfs.py +0 -0
  98. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/plot/_plot_signal.py +0 -0
  99. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tests/__init__.py +0 -0
  100. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tests/test_all.py +0 -0
  101. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tests/test_ceemdan.py +0 -0
  102. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tests/test_emd.py +0 -0
  103. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tests/test_ewt.py +0 -0
  104. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tests/test_faemd.py +0 -0
  105. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tests/test_faemd2d.py +0 -0
  106. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tests/test_faemd3d.py +0 -0
  107. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tests/test_generator_cube.py +0 -0
  108. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tests/test_generator_image.py +0 -0
  109. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tests/test_generator_signal.py +0 -0
  110. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tests/test_moving_decomp.py +0 -0
  111. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tests/test_vmd.py +0 -0
  112. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tests/test_vmd2d.py +0 -0
  113. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tsa/__init__.py +0 -0
  114. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tsa/_dtw.py +0 -0
  115. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tsa/_knn.py +0 -0
  116. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tsa/_moving_decomp.py +0 -0
  117. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/tsa/_mstl.py +0 -0
  118. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/utils/__init__.py +0 -0
  119. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/utils/_cite.py +0 -0
  120. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/utils/_correlation.py +0 -0
  121. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/utils/_diagnalization.py +0 -0
  122. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/utils/_differ.py +0 -0
  123. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/utils/_fft.py +0 -0
  124. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/utils/_function.py +0 -0
  125. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/utils/_hilbert.py +0 -0
  126. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/utils/_instantaneous.py +0 -0
  127. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/utils/_kernel_matrix.py +0 -0
  128. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/utils/_mirror.py +0 -0
  129. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/utils/_process.py +0 -0
  130. {pysdkit-0.4.18 → pysdkit-0.4.19}/pysdkit/utils/_smooth1d.py +0 -0
  131. {pysdkit-0.4.18 → pysdkit-0.4.19}/setup.cfg +0 -0
@@ -1,9 +1,9 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: PySDKit
3
- Version: 0.4.18
3
+ Version: 0.4.19
4
4
  Summary: A Python library for signal decomposition algorithms with a unified interface.
5
5
  Home-page: https://github.com/wwhenxuan/PySDKit
6
- Author: whenxuan
6
+ Author: whenxuan, changewam, josefinez
7
7
  Author-email: wwhenxuan@gmail.com
8
8
  Keywords: signal decomposition,signal processing,machine learning
9
9
  Classifier: Development Status :: 3 - Alpha
@@ -32,6 +32,7 @@ Dynamic: description
32
32
  Dynamic: description-content-type
33
33
  Dynamic: home-page
34
34
  Dynamic: keywords
35
+ Dynamic: license-file
35
36
  Dynamic: requires-dist
36
37
  Dynamic: requires-python
37
38
  Dynamic: summary
@@ -1,9 +1,9 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: PySDKit
3
- Version: 0.4.18
3
+ Version: 0.4.19
4
4
  Summary: A Python library for signal decomposition algorithms with a unified interface.
5
5
  Home-page: https://github.com/wwhenxuan/PySDKit
6
- Author: whenxuan
6
+ Author: whenxuan, changewam, josefinez
7
7
  Author-email: wwhenxuan@gmail.com
8
8
  Keywords: signal decomposition,signal processing,machine learning
9
9
  Classifier: Development Status :: 3 - Alpha
@@ -32,6 +32,7 @@ Dynamic: description
32
32
  Dynamic: description-content-type
33
33
  Dynamic: home-page
34
34
  Dynamic: keywords
35
+ Dynamic: license-file
35
36
  Dynamic: requires-dist
36
37
  Dynamic: requires-python
37
38
  Dynamic: summary
@@ -67,7 +67,7 @@ pysdkit/_vmd2d/__init__.py
67
67
  pysdkit/_vmd2d/cvmd2d.py
68
68
  pysdkit/_vmd2d/vmd2d.py
69
69
  pysdkit/_vncmd/__init__.py
70
- pysdkit/_vncmd/anvcmd.py
70
+ pysdkit/_vncmd/avncmd.py
71
71
  pysdkit/_vncmd/incmd.py
72
72
  pysdkit/_vncmd/mncmd.py
73
73
  pysdkit/_vncmd/vncmd.py
@@ -82,8 +82,6 @@ pysdkit/entropy/__init__.py
82
82
  pysdkit/entropy/_approxiamte_entropy.py
83
83
  pysdkit/entropy/_permutation_entropy.py
84
84
  pysdkit/entropy/_sample_entropy.py
85
- pysdkit/hht/__init__.py
86
- pysdkit/hht/hht.py
87
85
  pysdkit/plot/__init__.py
88
86
  pysdkit/plot/_fourier_spectra.py
89
87
  pysdkit/plot/_functions.py
@@ -101,7 +99,9 @@ pysdkit/tests/test_faemd3d.py
101
99
  pysdkit/tests/test_generator_cube.py
102
100
  pysdkit/tests/test_generator_image.py
103
101
  pysdkit/tests/test_generator_signal.py
102
+ pysdkit/tests/test_lmd.py
104
103
  pysdkit/tests/test_moving_decomp.py
104
+ pysdkit/tests/test_rlmd.py
105
105
  pysdkit/tests/test_vmd.py
106
106
  pysdkit/tests/test_vmd2d.py
107
107
  pysdkit/tsa/__init__.py
@@ -2,7 +2,7 @@
2
2
  A Python library for signal decomposition algorithms.
3
3
  """
4
4
 
5
- __version__ = "0.4.18"
5
+ __version__ = "0.4.19"
6
6
 
7
7
  # Empirical Mode Decomposition
8
8
  from ._emd import EMD
@@ -156,6 +156,7 @@ __all__ = [
156
156
  "ACMD",
157
157
  "MVMD",
158
158
  "VME",
159
+ "VMD2D",
159
160
  "CVMD2D",
160
161
  "VNCMD",
161
162
  "INCMD",
@@ -71,24 +71,24 @@ class CEEMDAN(object):
71
71
  :param max_iter: maximum number of decomposition iterations
72
72
  :param random_seed: create a random seed for the random number generator
73
73
  """
74
- # EMD算法的固定配置
74
+ # Fixed configuration of the EMD algorithm
75
75
  self.max_imfs = max_imfs
76
76
  self.trials = trials
77
77
  self.epsilon = epsilon
78
78
  self.max_iter = max_iter
79
79
 
80
- # 与多进程相关的配置参数
80
+ # Configuration parameters related to multi-process
81
81
  self.parallel = parallel
82
82
  self.processes = processes
83
83
 
84
- # 创建噪声的参数
84
+ # Parameters for creating noise
85
85
  self.noise_scale = noise_scale
86
86
  self.noise_kind = noise_kind
87
87
  self.noise_list = ["normal", "uniform"]
88
- # 是否对分解的噪声进行标准化
88
+ # Whether to normalize the decomposed noise
89
89
  self.beta_progress = beta_progress
90
90
 
91
- # 与算法停止有关的阈值
91
+ # Thresholds related to algorithm stopping
92
92
  self.range_thr = range_thr
93
93
  self.total_power_thr = total_power_thr
94
94
 
@@ -99,16 +99,17 @@ class CEEMDAN(object):
99
99
  else ext_EMD
100
100
  )
101
101
 
102
- # 创建随机数生成器
102
+ # Creating a random number generator
103
+ self.random_seed = random_seed
103
104
  self.rng = np.random.RandomState(seed=random_seed)
104
105
 
105
- # 生成的噪声序列
106
+ # Generated noise sequence
106
107
  self.all_noises = None
107
108
 
108
- # 存放用于分解的噪声的列表
109
+ # List of noises to be decomposed
109
110
  self.all_noise_EMD = []
110
111
 
111
- # 记录本次算法分解的结果
112
+ # Record the results of this algorithm decomposition
112
113
  self.imfs = None
113
114
  self.residue = None
114
115
 
@@ -119,7 +120,7 @@ class CEEMDAN(object):
119
120
  self,
120
121
  signal: np.ndarray,
121
122
  time: Optional[np.ndarray] = None,
122
- max_imfs: Optional[int] = -1,
123
+ max_imfs: Optional[int] = None,
123
124
  progress: bool = False,
124
125
  ) -> np.ndarray:
125
126
  """allow instances to be called like functions"""
@@ -131,7 +132,13 @@ class CEEMDAN(object):
131
132
  """Get the full name and abbreviation of the algorithm"""
132
133
  return "Complete Ensemble Empirical Mode Decomposition with Adaptive Noise (CEEMDAN)"
133
134
 
134
- def generate_noise(
135
+ def update_random_seed(self, random_seed: int) -> None:
136
+ """Update the random seed for random number generator to generate noise"""
137
+ self.random_seed = random_seed
138
+ # Create the random state generate
139
+ self.rng = np.random.RandomState(seed=random_seed)
140
+
141
+ def _generate_noise(
135
142
  self, scale: float, size: Union[int, Sequence[int]]
136
143
  ) -> np.ndarray:
137
144
  """
@@ -177,7 +184,7 @@ class CEEMDAN(object):
177
184
  self,
178
185
  signal: np.ndarray,
179
186
  time: Optional[np.ndarray] = None,
180
- max_imfs: Optional[int] = -1,
187
+ max_imfs: Optional[int] = None,
181
188
  progress: Optional[bool] = True,
182
189
  ) -> np.ndarray:
183
190
  """Perform the specified EEMD algorithm to obtain the corresponding signal decomposition results."""
@@ -231,20 +238,26 @@ class CEEMDAN(object):
231
238
  noise = self.epsilon * self.all_noise_EMD[trial][0]
232
239
 
233
240
  # Return the result of a single EMD execution
234
- return self.emd(self._signal + noise, self._time, self.max_imfs)
241
+ return self._run_emd(self._signal + noise, self._time, self.max_imfs)
235
242
 
236
- def emd(
243
+ def _run_emd(
237
244
  self,
238
245
  signal: np.ndarray,
239
246
  time: Optional[np.ndarray] = None,
240
- max_imfs: Optional[int] = -1,
247
+ max_imfs: Optional[int] = None,
241
248
  ) -> np.ndarray:
242
249
  """
243
- Vanilla Empirical Mode Decomposition method
250
+ Vanilla Empirical Mode Decomposition method.
244
251
 
245
- Perform the specified EMD algorithm to obtain the corresponding signal decomposition results.
252
+ :param signal: the input 1D ndarray signal.
253
+ :param time: the time array.
254
+ :param max_imfs: the maximum number of IMFs to be decomposed.
255
+ :return: the decomposed IMFs of the input signal.
246
256
  """
247
- return self.EMD.fit_transform(signal=signal, time=time, max_imfs=max_imfs)
257
+ # Perform the specified EMD algorithm to obtain the corresponding signal decomposition results.
258
+ imfs = self.EMD.fit_transform(signal=signal, time=time, max_imfs=max_imfs)
259
+
260
+ return imfs
248
261
 
249
262
  def get_imfs_and_residue(self) -> Tuple[np.ndarray, np.ndarray]:
250
263
  """
@@ -277,6 +290,7 @@ class CEEMDAN(object):
277
290
 
278
291
  # Get the intrinsic mode function and residual respectively
279
292
  imfs, residue = self.get_imfs_and_residue()
293
+
280
294
  if np.allclose(residue, 0):
281
295
  return imfs[:-1].copy(), imfs[-1].copy()
282
296
  else:
@@ -304,12 +318,13 @@ class CEEMDAN(object):
304
318
 
305
319
  # Compute the Empirical Mode Decomposition (EMD) for the residue
306
320
  R = signal - np.sum(cIMFs, axis=0)
307
- _test_imfs = self.emd(signal=R, time=None, max_imfs=1)
308
-
309
- # Check if the residue is an IMF or has no extrema
310
- if _test_imfs.shape[0] == 1:
311
- print("Not enough extrema")
312
- return True
321
+ # _test_imfs = self._emd(signal=R, time=None, max_imfs=2)
322
+ # print("test imfs", _test_imfs.shape)
323
+ #
324
+ # # Check if the residue is an IMF or has no extrema
325
+ # if _test_imfs.shape[0] == 1:
326
+ # print("Not enough extrema")
327
+ # return True
313
328
 
314
329
  # Check for range threshold
315
330
  if np.max(R) - np.min(R) < self.range_thr:
@@ -328,7 +343,7 @@ class CEEMDAN(object):
328
343
  self,
329
344
  signal: np.ndarray,
330
345
  time: Optional[np.ndarray] = None,
331
- max_imfs: Optional[int] = -1,
346
+ max_imfs: Optional[int] = None,
332
347
  progress: bool = False,
333
348
  ) -> np.ndarray:
334
349
  """
@@ -344,11 +359,12 @@ class CEEMDAN(object):
344
359
  scale_s = np.std(signal)
345
360
  signal = signal / scale_s
346
361
 
347
- if max_imfs is not None:
348
- self.max_imfs = max_imfs
362
+ # Begin executing the specific decomposition algorithm
363
+ max_imfs = self.max_imfs if max_imfs is None else max_imfs
364
+ total = (max_imfs - 1) if max_imfs != -1 else None
349
365
 
350
366
  # Define the noise sequences to be added
351
- self.all_noises = self.generate_noise(
367
+ self.all_noises = self._generate_noise(
352
368
  self.noise_scale, size=(self.trials, signal.size)
353
369
  )
354
370
 
@@ -357,13 +373,10 @@ class CEEMDAN(object):
357
373
 
358
374
  # Create the first IMF
359
375
  last_imf = self._run_eemd(signal, time, max_imfs=1, progress=progress)[0]
360
- res = np.empty(signal.size)
361
376
 
362
377
  all_cimfs = last_imf.reshape((-1, last_imf.size))
363
378
  prev_res = signal - last_imf
364
379
 
365
- # Begin executing the specific decomposition algorithm
366
- total = (max_imfs - 1) if max_imfs != -1 else None
367
380
  # Create an iterator object for signal decomposition
368
381
  it = (
369
382
  iter
@@ -372,8 +385,7 @@ class CEEMDAN(object):
372
385
  )
373
386
 
374
387
  # Begin the algorithm's iteration
375
- for _ in it(range(self.max_imfs)):
376
-
388
+ for _ in it(range(max_imfs - 1)):
377
389
  # Number of IMFs currently decomposed
378
390
  imf_number = all_cimfs.shape[0]
379
391
 
@@ -385,31 +397,35 @@ class CEEMDAN(object):
385
397
  # Skip if noise[trial] didn't have k'th mode
386
398
  noise_imf = self.all_noise_EMD[trial]
387
399
  res = prev_res.copy()
400
+
401
+ # add noise for every imf to be decomposed.
388
402
  if len(noise_imf) > imf_number:
389
403
  res += beta * noise_imf[imf_number]
390
404
 
391
405
  # Extract the local mean, which is at the 2nd position
392
- imfs = self.emd(res, time, max_imfs=1)
406
+ imfs = self._run_emd(res, time, max_imfs=1)
393
407
  local_mean += imfs[-1] / self.trials
394
408
 
395
409
  # Record the results of this decomposition
396
410
  last_imf = prev_res - local_mean
411
+ # vstack the new imf
397
412
  all_cimfs = np.vstack((all_cimfs, last_imf))
398
413
  prev_res = local_mean.copy()
399
414
 
400
415
  # Determine whether the decomposition algorithm should stop iterating
401
- if self.end_condition(
402
- signal=signal, cIMFs=all_cimfs, max_imf=self.max_imfs
403
- ):
416
+ if self.end_condition(signal=signal, cIMFs=all_cimfs, max_imf=max_imfs):
404
417
  # Reached the stopping condition
405
- print("End Decomposition")
418
+ # print("End Decomposition")
406
419
  break
407
420
 
408
421
  # Clear all IMF noise
422
+ # The noise will be initialized for the new input signal
409
423
  del self.all_noise_EMD[:]
410
424
 
411
425
  # Record the results of this decomposition
412
426
  self.imfs = all_cimfs
427
+
428
+ # Calculate the remaining residual components
413
429
  self.residue = signal * scale_s - np.sum(self.imfs, axis=0)
414
430
 
415
431
  return all_cimfs
@@ -89,7 +89,7 @@ class EFD(object):
89
89
  imfs = np.zeros(shape=(number, len(signal)))
90
90
 
91
91
  # The results are stored in the frequency domain
92
- ft = np.zeros([number, len(ff)])
92
+ ft = np.zeros([number, len(ff)], dtype=complex)
93
93
 
94
94
  # We define an ideal functions and extract components
95
95
  for k in range(0, number):
@@ -510,7 +510,8 @@ class EMD(object):
510
510
  if f1 and f2:
511
511
  break
512
512
 
513
- else: # Less than 2 ext, i.e. trend
513
+ else:
514
+ # Less than 2 ext, i.e. trend
514
515
  finished = True
515
516
  break
516
517
 
@@ -535,3 +536,17 @@ class EMD(object):
535
536
  IMF = np.vstack((IMF, self.residue))
536
537
 
537
538
  return IMF
539
+
540
+
541
+ if __name__ == "__main__":
542
+ from pysdkit.data import test_hht, test_univariate_signal
543
+ from matplotlib import pyplot as plt
544
+ from pysdkit.plot import plot_IMFs
545
+
546
+ time, signal = test_univariate_signal(case=1)
547
+ emd = EMD(max_imfs=5)
548
+ imfs = emd.fit_transform(signal, max_imfs=6)
549
+ print(imfs.shape)
550
+
551
+ plot_IMFs(signal, imfs)
552
+ plt.show()
@@ -106,6 +106,8 @@ class ITD(object):
106
106
  LK1 = np.append(idx_min.reshape(-1, 1), LK1.reshape(-1, 1))
107
107
  LK2 = np.append(idx_max.reshape(-1, 1), LK2.reshape(-1, 1))
108
108
 
109
+ print(LK1.shape, LK2.shape)
110
+
109
111
  LK = np.vstack((LK1, LK2)).T
110
112
 
111
113
  LK_col_2 = np.argsort(LK[:, 0])
@@ -151,24 +153,14 @@ class ITD(object):
151
153
 
152
154
 
153
155
  if __name__ == "__main__":
154
- from matplotlib import pyplot as plt
155
-
156
- fs = 1000
157
- N = 3000
158
- t = np.arange(0, N) / fs
159
- x1 = (2 + np.cos(2 * np.pi * 0.5 * t)) * np.cos(2 * np.pi * 5 * t + 15 * t**2)
160
- x2 = np.cos(2 * np.pi * 2 * t)
156
+ from pysdkit.data import test_univariate_signal
157
+ from pysdkit.plot import plot_IMFs
161
158
 
162
- signal = x1 + x2
159
+ time, signal = test_univariate_signal()
163
160
 
164
- itd = ITD(N_max=100)
165
- IMFs = itd.fit_transform(signal)
166
- row, length = IMFs.shape
167
- print(IMFs.shape)
161
+ print(signal.shape)
168
162
 
169
- fig, ax = plt.subplots(row + 1, 1, figsize=(10, 8))
170
- ax[0].plot(t, signal)
171
- for index, i in enumerate(range(row), 1):
172
- ax[index].plot(t[:300], IMFs[i, :300])
163
+ itd = ITD()
164
+ imfs = itd.fit_transform(signal=signal)
173
165
 
174
- fig.show()
166
+ plot_IMFs(signal, IMFs=imfs)
@@ -307,3 +307,17 @@ class LMD(object):
307
307
  pf.append(residue)
308
308
 
309
309
  return np.array(pf)
310
+
311
+
312
+ if __name__ == "__main__":
313
+ from pysdkit.data import test_univariate_signal
314
+ from pysdkit.plot import plot_IMFs
315
+ from matplotlib import pyplot as plt
316
+
317
+ time, signal = test_univariate_signal()
318
+
319
+ rlmd = LMD()
320
+ imfs = rlmd.fit_transform(signal)
321
+
322
+ plot_IMFs(signal, imfs)
323
+ plt.show()