PySDKit 0.4.13__tar.gz → 0.4.14__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 (99) hide show
  1. {pysdkit-0.4.13 → pysdkit-0.4.14}/PKG-INFO +1 -1
  2. {pysdkit-0.4.13 → pysdkit-0.4.14}/PySDKit.egg-info/PKG-INFO +1 -1
  3. {pysdkit-0.4.13 → pysdkit-0.4.14}/PySDKit.egg-info/SOURCES.txt +5 -0
  4. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/data/__init__.py +14 -11
  5. pysdkit-0.4.14/pysdkit/data/_cube.py +276 -0
  6. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/data/_generator.py +27 -86
  7. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/data/_image.py +12 -12
  8. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/emd/emd.py +1 -1
  9. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/emd/remd.py +2 -2
  10. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/plot/__init__.py +3 -0
  11. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/plot/_plot_images.py +5 -5
  12. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/plot/_plot_imfs.py +86 -42
  13. pysdkit-0.4.14/pysdkit/plot/_plot_signal.py +134 -0
  14. pysdkit-0.4.14/pysdkit/tsa/_dtw.py +264 -0
  15. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/tsa/_moving_decomp.py +12 -4
  16. pysdkit-0.4.14/pysdkit/tsa/mstl.py +24 -0
  17. pysdkit-0.4.14/pysdkit/tsa/stl.py +28 -0
  18. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/vmd/vmd_c.py +0 -3
  19. {pysdkit-0.4.13 → pysdkit-0.4.14}/setup.py +1 -1
  20. {pysdkit-0.4.13 → pysdkit-0.4.14}/PySDKit.egg-info/dependency_links.txt +0 -0
  21. {pysdkit-0.4.13 → pysdkit-0.4.14}/PySDKit.egg-info/requires.txt +0 -0
  22. {pysdkit-0.4.13 → pysdkit-0.4.14}/PySDKit.egg-info/top_level.txt +0 -0
  23. {pysdkit-0.4.13 → pysdkit-0.4.14}/README.md +0 -0
  24. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/__init__.py +0 -0
  25. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/data/_add_noise.py +0 -0
  26. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/data/_time_series.py +0 -0
  27. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/data/texture.txt +0 -0
  28. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/emd/__init__.py +0 -0
  29. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/emd/_find_extrema.py +0 -0
  30. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/emd/_prepare_points.py +0 -0
  31. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/emd/_splines.py +0 -0
  32. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/emd/ceemdan.py +0 -0
  33. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/emd/eemd.py +0 -0
  34. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/emd/memd.py +0 -0
  35. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/emd/tvf_emd.py +0 -0
  36. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/emd2d/__init__.py +0 -0
  37. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/emd2d/bemd.py +0 -0
  38. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/emd2d/bmemd.py +0 -0
  39. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/emd2d/emd2d.py +0 -0
  40. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/esmd/__init__.py +0 -0
  41. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/esmd/esmd.py +0 -0
  42. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/ewt/__init__.py +0 -0
  43. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/ewt/ewt.py +0 -0
  44. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/ewt/ewt2d.py +0 -0
  45. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/faemd/__init__.py +0 -0
  46. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/faemd/faemd.py +0 -0
  47. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/faemd/md_faemd.py +0 -0
  48. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/faemd/mv_faemd.py +0 -0
  49. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/fmd/__init__.py +0 -0
  50. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/fmd/fmd.py +0 -0
  51. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/hht/__init__.py +0 -0
  52. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/hht/hht.py +0 -0
  53. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/hvd/__init__.py +0 -0
  54. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/hvd/hvd.py +0 -0
  55. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/ifd/__init__.py +0 -0
  56. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/itd/__init__.py +0 -0
  57. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/itd/itd.py +0 -0
  58. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/jmd/__init__.py +0 -0
  59. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/jmd/jmd.py +0 -0
  60. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/jmd/mjmd.py +0 -0
  61. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/lmd/__init__.py +0 -0
  62. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/lmd/lmd.py +0 -0
  63. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/lmd/rlmd.py +0 -0
  64. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/plot/_fourier_spectra.py +0 -0
  65. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/plot/_functions.py +0 -0
  66. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/ssa/__init__.py +0 -0
  67. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/ssa/ssa.py +0 -0
  68. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/tsa/__init__.py +0 -0
  69. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/_Index_of_Orthogonality.py +0 -0
  70. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/__init__.py +0 -0
  71. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/_cite.py +0 -0
  72. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/_correlation.py +0 -0
  73. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/_diagnalization.py +0 -0
  74. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/_differ.py +0 -0
  75. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/_fft.py +0 -0
  76. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/_function.py +0 -0
  77. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/_hilbert.py +0 -0
  78. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/_instantaneous.py +0 -0
  79. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/_kernel_matrix.py +0 -0
  80. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/_lags.py +0 -0
  81. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/_mirror.py +0 -0
  82. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/_process.py +0 -0
  83. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/_smooth1d.py +0 -0
  84. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/utils/_types.py +0 -0
  85. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/vmd/__init__.py +0 -0
  86. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/vmd/acmd.py +0 -0
  87. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/vmd/avmd.py +0 -0
  88. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/vmd/ba_acmd.py +0 -0
  89. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/vmd/base.py +0 -0
  90. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/vmd/mvmd.py +0 -0
  91. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/vmd/svmd.py +0 -0
  92. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/vmd/vmd_f.py +0 -0
  93. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/vmd2d/__init__.py +0 -0
  94. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/vmd2d/vmd2d.py +0 -0
  95. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/vncmd/__init__.py +0 -0
  96. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/vncmd/anvcmd.py +0 -0
  97. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/vncmd/mncmd.py +0 -0
  98. {pysdkit-0.4.13 → pysdkit-0.4.14}/pysdkit/vncmd/vncmd.py +0 -0
  99. {pysdkit-0.4.13 → pysdkit-0.4.14}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: PySDKit
3
- Version: 0.4.13
3
+ Version: 0.4.14
4
4
  Summary: A Python library for signal decomposition algorithms with a unified interface.
5
5
  Home-page: https://github.com/wwhenxuan/PySDKit
6
6
  Author: whenxuan
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: PySDKit
3
- Version: 0.4.13
3
+ Version: 0.4.14
4
4
  Summary: A Python library for signal decomposition algorithms with a unified interface.
5
5
  Home-page: https://github.com/wwhenxuan/PySDKit
6
6
  Author: whenxuan
@@ -8,6 +8,7 @@ PySDKit.egg-info/top_level.txt
8
8
  pysdkit/__init__.py
9
9
  pysdkit/data/__init__.py
10
10
  pysdkit/data/_add_noise.py
11
+ pysdkit/data/_cube.py
11
12
  pysdkit/data/_generator.py
12
13
  pysdkit/data/_image.py
13
14
  pysdkit/data/_time_series.py
@@ -55,10 +56,14 @@ pysdkit/plot/_fourier_spectra.py
55
56
  pysdkit/plot/_functions.py
56
57
  pysdkit/plot/_plot_images.py
57
58
  pysdkit/plot/_plot_imfs.py
59
+ pysdkit/plot/_plot_signal.py
58
60
  pysdkit/ssa/__init__.py
59
61
  pysdkit/ssa/ssa.py
60
62
  pysdkit/tsa/__init__.py
63
+ pysdkit/tsa/_dtw.py
61
64
  pysdkit/tsa/_moving_decomp.py
65
+ pysdkit/tsa/mstl.py
66
+ pysdkit/tsa/stl.py
62
67
  pysdkit/utils/_Index_of_Orthogonality.py
63
68
  pysdkit/utils/__init__.py
64
69
  pysdkit/utils/_cite.py
@@ -14,17 +14,17 @@ from ._generator import (
14
14
  )
15
15
  from ._generator import generate_am_signal, generate_exponential_signal
16
16
 
17
+ # Generator for 1D univariate time series data
18
+ from ._time_series import generate_time_series
19
+
17
20
  # Generates the main test sample signal
18
21
  from ._generator import test_emd
19
22
 
20
23
  # Generator for 1D univariate
21
- from ._generator import test_uni_signal
24
+ from ._generator import test_univariate_signal
22
25
 
23
26
  # Generator for 1D multivariate
24
- from ._generator import test_multi_signal
25
-
26
- # Functions that generate signal visualizations
27
- from ._generator import plot_signal
27
+ from ._generator import test_multivariate_signal
28
28
 
29
29
  # add Gaussian noise
30
30
  from ._add_noise import add_noise
@@ -32,11 +32,14 @@ from ._add_noise import add_noise
32
32
  # Test case for loading a 2D grayscale image
33
33
  from ._image import test_grayscale
34
34
 
35
- # Test case for univariate image
36
- from ._image import test_uni_image
35
+ # Test case for univariate 2D image
36
+ from ._image import test_univariate_image
37
37
 
38
- # Test case for multivariate image
39
- from ._image import test_multi_image
38
+ # Test case for multivariate 2D image
39
+ from ._image import test_multivariate_image
40
40
 
41
- # Generator for 1D univariate time series data
42
- from ._time_series import generate_time_series
41
+ # Test case for univariate 3D cube
42
+ from ._cube import test_univariate_cube
43
+
44
+ # Test case for multivariate 3D cube
45
+ from ._cube import test_multivariate_cube
@@ -0,0 +1,276 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ Created on 2025/02/11 00:19:03
4
+ @author: Whenxuan Wang
5
+ @email: wwhenxuan@gmail.com
6
+ Generate 3D cube test sample
7
+ """
8
+ import numpy as np
9
+
10
+ from typing import Optional, Union, Tuple, List
11
+
12
+
13
+ def get_meshgrid_3D(
14
+ low: Union[int, np.ndarray], high: Union[int, np.ndarray], sampling_rate: int = 30
15
+ ) -> Tuple[np.ndarray, np.ndarray, np.ndarray]:
16
+ """
17
+ Generate a grid 3D cube given an input and output range
18
+ :param low: Minimum value of grid matrix,
19
+ If it is a ndarray array, its length must be 3 to indicate the range of three dimensions.
20
+ :param high: Maximum value of grid matrix,
21
+ If it is a ndarray array, its length must be 3 to indicate the range of three dimensions.
22
+ :param sampling_rate: The sampling rate of the grid matrix, which is the number of points in the matrix
23
+ :return: A grid matrix generated from a range in the form of a tuple
24
+ """
25
+ # First obtain a one-dimensional range array by specifying the ranges `low` and `high`
26
+ if isinstance(low, np.ndarray) and isinstance(high, np.ndarray):
27
+ # Both range parameters are Numpy arrays
28
+ X = np.linspace(low[0], high[0], sampling_rate)
29
+ Y = np.linspace(low[1], high[1], sampling_rate)
30
+ Z = np.linspace(low[2], high[2], sampling_rate)
31
+
32
+ elif isinstance(low, np.ndarray) and isinstance(high, int):
33
+ # `low` is a Numpy array `high` is a constant
34
+ X = np.linspace(low[0], high, sampling_rate)
35
+ Y = np.linspace(low[1], high, sampling_rate)
36
+ Z = np.linspace(low[2], high, sampling_rate)
37
+
38
+ elif isinstance(low, int) and isinstance(high, np.ndarray):
39
+ # `low` is a constant `high` is a Numpy array
40
+ X = np.linspace(low, high[0], sampling_rate)
41
+ Y = np.linspace(low, high[1], sampling_rate)
42
+ Z = np.linspace(low, high[2], sampling_rate)
43
+
44
+ elif isinstance(low, int) and isinstance(high, int):
45
+ # Both range parameters are constants
46
+ X = np.linspace(low, high, sampling_rate)
47
+ Y = np.linspace(low, high, sampling_rate)
48
+ Z = np.linspace(low, high, sampling_rate)
49
+
50
+ else:
51
+ raise TypeError("The params `low` and `high` must be int or ndarray of numpy!")
52
+
53
+ # Further generate network cube
54
+ x, y, z = np.meshgrid(X, Y, Z)
55
+
56
+ return x, y, z
57
+
58
+
59
+ def test_univariate_cube(
60
+ case: int = 1,
61
+ low: Union[int, np.ndarray] = 0,
62
+ high: Union[int, np.ndarray] = 10,
63
+ sampling_rate: int = 30,
64
+ ) -> np.ndarray:
65
+ """
66
+ Generate a 3D cube data for testing 3D univariate signal decomposition algorithms
67
+
68
+ :param case: Test case, range in [1, 2, 3, 4, 5, 6]
69
+ :param low: Minimum value of grid matrix,
70
+ If it is a ndarray array, its length must be 3 to indicate the range of three dimensions.
71
+ :param high: Maximum value of grid matrix,
72
+ If it is a ndarray array, its length must be 3 to indicate the range of three dimensions.
73
+ :param sampling_rate: The sampling rate of the grid matrix, which is the number of points in the matrix
74
+ :return: Get a 3D cube data of a specified range
75
+ """
76
+ # Generate data based on the input test sample number
77
+ if case == 1:
78
+ return test_cube_1(low=low, high=high, sampling_rate=sampling_rate)
79
+ elif case == 2:
80
+ return test_cube_2(low=low, high=high, sampling_rate=sampling_rate)
81
+ elif case == 3:
82
+ return test_cube_3(low=low, high=high, sampling_rate=sampling_rate)
83
+ elif case == 4:
84
+ return test_cube_4(low=low, high=high, sampling_rate=sampling_rate)
85
+ elif case == 5:
86
+ return test_cube_5(low=low, high=high, sampling_rate=sampling_rate)
87
+ elif case == 6:
88
+ return test_cube_6(low=low, high=high, sampling_rate=sampling_rate)
89
+ else:
90
+ raise TypeError("The params `case` must be in the range of [1, 2, 3, 4, 5, 6]")
91
+
92
+
93
+ def test_multivariate_cube(
94
+ case: Union[List[int], Tuple[int], np.ndarray] = None,
95
+ low: Union[int, np.ndarray] = 0,
96
+ high: Union[int, np.ndarray] = 10,
97
+ sampling_rate: int = 30,
98
+ ) -> np.ndarray:
99
+ """
100
+ Generate 3D cubes data for testing 3D multivariate signal decomposition algorithms
101
+ :param case: The test cases to use are specified by inputting a list or tuple or ndarray in the range [1, 2, 3, 4, 5, 6],
102
+ The default parameter settings are [1, 2, 3].
103
+ :param low: Minimum value of grid matrix,
104
+ If it is a ndarray array, its length must be 3 to indicate the range of three dimensions.
105
+ :param high: Maximum value of grid matrix,
106
+ If it is a ndarray array, its length must be 3 to indicate the range of three dimensions.
107
+ :param sampling_rate: The sampling rate of the grid matrix, which is the number of points in the matrix
108
+ :return: Get 3D cube data of multiple different channels
109
+ """
110
+ # Default Parameters
111
+ if case is None:
112
+ case = [1, 2, 3]
113
+ # Make sure it is the correct data type
114
+ if (
115
+ isinstance(case, tuple)
116
+ or isinstance(case, list)
117
+ or isinstance(case, np.ndarray)
118
+ ):
119
+ # Make sure there is content
120
+ if len(case) >= 1:
121
+ cubes = np.vstack(
122
+ [
123
+ test_univariate_cube(
124
+ case=c, low=low, high=high, sampling_rate=sampling_rate
125
+ )
126
+ for c in case
127
+ ]
128
+ )
129
+ return cubes
130
+ else:
131
+ raise ValueError("The number in `case` must be greater than 1!")
132
+ else:
133
+ raise TypeError("The params `case` should be a list or tuple or ndarray!")
134
+
135
+
136
+ def test_cube_1(
137
+ low: Union[int, np.ndarray], high: Union[int, np.ndarray], sampling_rate: int = 30
138
+ ) -> np.ndarray:
139
+ """
140
+ Generate a 3D cube test example 1
141
+ :param low: Minimum value of grid matrix
142
+ :param high: Maximum value of grid matrix
143
+ :param sampling_rate: The sampling rate of the grid matrix, which is the number of points in the matrix
144
+ :return: Cube generated by sine and cosine functions
145
+ """
146
+ # First generate the grid array
147
+ x, y, z = get_meshgrid_3D(low=low, high=high, sampling_rate=sampling_rate)
148
+ # Generate cubes of different frequencies
149
+ uc1 = np.sin(3.5 * x) + np.sin(3.5 * y) + np.sin(3.5 * z)
150
+ uc2 = np.sin(x) + np.sin(y) + np.sin(z)
151
+ ru = np.cos(x / 24) + np.cos(y / 24) + np.cos(z / 24)
152
+ # Fusion of different modalities
153
+ u = uc1 + uc2 + ru
154
+ # Standardize the results of the integration
155
+ u = (u - np.mean(u)) / np.std(u + 0.01)
156
+ return u
157
+
158
+
159
+ def test_cube_2(
160
+ low: Union[int, np.ndarray], high: Union[int, np.ndarray], sampling_rate: int = 30
161
+ ) -> np.ndarray:
162
+ """
163
+ Generate a 3D cube test example 2
164
+ :param low: Minimum value of grid matrix
165
+ :param high: Maximum value of grid matrix
166
+ :param sampling_rate: The sampling rate of the grid matrix, which is the number of points in the matrix
167
+ :return: Cube generated by sine and cosine functions
168
+ """
169
+ # First generate the grid array
170
+ x, y, z = get_meshgrid_3D(low=low, high=high, sampling_rate=sampling_rate)
171
+ # Generate cubes of different frequencies
172
+ uc1 = np.sin(5 * x) + np.sin(5 * y) + np.sin(5 * z)
173
+ uc2 = np.sin(x) + np.sin(y) + np.sin(z)
174
+ ru = np.cos(x / 16) + np.cos(y / 16) + np.cos(z / 16)
175
+ # Fusion of different modalities
176
+ u = uc1 + uc2 + ru
177
+ # Standardize the results of the integration
178
+ u = (u - np.mean(u)) / np.std(u + 0.001)
179
+ return u
180
+
181
+
182
+ def test_cube_3(
183
+ low: Union[int, np.ndarray], high: Union[int, np.ndarray], sampling_rate: int = 30
184
+ ) -> np.ndarray:
185
+ """
186
+ Generate a 3D cube test example 3
187
+ :param low: Minimum value of grid matrix
188
+ :param high: Maximum value of grid matrix
189
+ :param sampling_rate: The sampling rate of the grid matrix, which is the number of points in the matrix
190
+ :return: Cube generated by sine and cosine functions
191
+ """
192
+ # First generate the grid array
193
+ x, y, z = get_meshgrid_3D(low=low, high=high, sampling_rate=sampling_rate)
194
+ # Generate cubes of different frequencies
195
+ uc1 = np.sin(2 * x) + np.sin(2 * y) + np.sin(2 * z)
196
+ uc2 = np.sin(4 * x) + np.sin(4 * y) + np.sin(4 * z)
197
+ ru = np.cos(x / 24) + np.cos(y / 24) + np.cos(z / 24)
198
+ # Fusion of different modalities
199
+ u = uc1 + uc2 + ru
200
+ # Standardize the results of the integration
201
+ u = (u - np.mean(u)) / np.std(u + 0.001)
202
+ return u
203
+
204
+
205
+ def test_cube_4(
206
+ low: Union[int, np.ndarray], high: Union[int, np.ndarray], sampling_rate: int = 30
207
+ ) -> np.ndarray:
208
+ """
209
+ Generate a 3D cube test example 4
210
+ :param low: Minimum value of grid matrix
211
+ :param high: Maximum value of grid matrix
212
+ :param sampling_rate: The sampling rate of the grid matrix, which is the number of points in the matrix
213
+ :return: Cube generated by sine and cosine functions
214
+ """
215
+ # First generate the grid array
216
+ x, y, z = get_meshgrid_3D(low=low, high=high, sampling_rate=sampling_rate)
217
+ # Generate cubes of different frequencies
218
+ uc1 = np.sin(2 * x**1.5) + np.sin(2 * y**1.5) + np.sin(2 * z * 1.5)
219
+ uc2 = np.sin(5 * x) + np.sin(5 * y) + np.sin(5 * z)
220
+ ru = np.cos(x / 24) + np.cos(y / 24) + np.cos(z / 24)
221
+ # Fusion of different modalities
222
+ u = uc1 + uc2 + ru
223
+ # Standardize the results of the integration
224
+ u = (u - np.mean(u)) / np.std(u + 0.001)
225
+ return u
226
+
227
+
228
+ def test_cube_5(
229
+ low: Union[int, np.ndarray], high: Union[int, np.ndarray], sampling_rate: int = 30
230
+ ) -> np.ndarray:
231
+ """
232
+ Generate a 3D cube test example 5
233
+ :param low: Minimum value of grid matrix
234
+ :param high: Maximum value of grid matrix
235
+ :param sampling_rate: The sampling rate of the grid matrix, which is the number of points in the matrix
236
+ :return: Cube generated by sine and cosine functions
237
+ """
238
+ # First generate the grid array
239
+ x, y, z = get_meshgrid_3D(low=low, high=high, sampling_rate=sampling_rate)
240
+ # Generate cubes of different frequencies
241
+ uc1 = np.cos(x**2) + np.cos(y**2) + np.cos(z * 2)
242
+ uc2 = np.sin(5 * x) + np.sin(5 * y) + np.sin(5 * z)
243
+ ru = np.cos(x / 24) + np.cos(y / 24) + np.cos(z / 24)
244
+ # Fusion of different modalities
245
+ u = uc1 + uc2 + ru
246
+ # Standardize the results of the integration
247
+ u = (u - np.mean(u)) / np.std(u + 0.001)
248
+ return u
249
+
250
+
251
+ def test_cube_6(
252
+ low: Union[int, np.ndarray], high: Union[int, np.ndarray], sampling_rate: int = 30
253
+ ) -> np.ndarray:
254
+ """
255
+ Generate a 3D cube test example 6
256
+ :param low: Minimum value of grid matrix
257
+ :param high: Maximum value of grid matrix
258
+ :param sampling_rate: The sampling rate of the grid matrix, which is the number of points in the matrix
259
+ :return: Cube generated by sine and cosine functions
260
+ """
261
+ # First generate the grid array
262
+ x, y, z = get_meshgrid_3D(low=low, high=high, sampling_rate=sampling_rate)
263
+ # Generate cubes of different frequencies
264
+ uc1 = np.cos(x**2) + np.cos(y**2) + np.cos(z * 2)
265
+ uc2 = np.sin(5 * x) + np.sin(5 * y) + np.sin(5 * z)
266
+ ru = np.cos(x / 24) + np.cos(y / 24) + np.cos(z / 24)
267
+ # Fusion of different modalities
268
+ u = uc1 + uc2 + ru
269
+ # Standardize the results of the integration
270
+ u = (u - np.mean(u)) / np.std(u + 0.001)
271
+ return u
272
+
273
+
274
+ if __name__ == "__main__":
275
+ print(test_univariate_cube().shape)
276
+ print(test_univariate_cube())
@@ -8,7 +8,7 @@ import numpy as np
8
8
  from scipy.signal import sawtooth
9
9
  from matplotlib import pyplot as plt
10
10
 
11
- from typing import Tuple
11
+ from typing import Tuple, Optional
12
12
 
13
13
 
14
14
  def generate_sin_signal(
@@ -198,7 +198,7 @@ def generate_exponential_signal(
198
198
  return t, noisy_exp_signal
199
199
 
200
200
 
201
- def test_uni_signal(
201
+ def test_univariate_signal(
202
202
  case: int = 1,
203
203
  duration: float = 1.0,
204
204
  sampling_rate: int = 1000,
@@ -254,7 +254,12 @@ def test_1D_2(
254
254
  :return: Tuple containing time array and the 3 * 2 ^ (-t) * sin(sin(2 * pi * t)) signal.
255
255
  """
256
256
  t = np.linspace(0, duration, int(sampling_rate * duration), endpoint=False)
257
- signal = 3 * 2 ^ (-t) * np.sin(np.sin(2 * np.pi * t))
257
+ signal = (
258
+ 3 * 2 ** (-t) * np.sin(np.sin(2 * np.pi * t))
259
+ + np.cos(2 * np.pi * t * 5)
260
+ + np.sin(2 * np.pi * (t + 2 * t**2))
261
+ + np.sin(2 * np.pi * t * 30)
262
+ )
258
263
  return t, signal
259
264
 
260
265
 
@@ -274,7 +279,13 @@ def test_1D_3(
274
279
  """
275
280
  np.random.seed(seed=random_state)
276
281
  t = np.linspace(0, duration, int(sampling_rate * duration), endpoint=False)
277
- signal = 5 * np.sin(2 * np.pi * t) + 3 * np.sin(2 * np.pi * t)
282
+ signal = (
283
+ 5 * np.sin(2 * np.pi * t)
284
+ + 3 * np.cos(2 * np.pi * t)
285
+ + 2 * np.cos(2 * np.pi * t**2)
286
+ + np.sin(2 * np.pi * t**3)
287
+ + np.sin(2 * np.pi * (t * 30 + t**2 * 2))
288
+ )
278
289
  noise = np.random.normal(0, noise_level, signal.shape)
279
290
  noise_signal = signal + noise
280
291
  return t, noise_signal
@@ -302,7 +313,7 @@ def test_emd(
302
313
  return t, noise_signal
303
314
 
304
315
 
305
- def test_multi_signal(
316
+ def test_multivariate_signal(
306
317
  case: int = 1,
307
318
  duration: float = 1.0,
308
319
  sampling_rate: int = 1000,
@@ -316,18 +327,18 @@ def test_multi_signal(
316
327
  :return: the generated signal for multivariate 1D.
317
328
  """
318
329
  if case == 1:
319
- return test_multi_1D_1(duration=duration, sampling_rate=sampling_rate)
330
+ return test_multivariate_1D_1(duration=duration, sampling_rate=sampling_rate)
320
331
  elif case == 2:
321
- return test_multi_1D_2(duration=duration, sampling_rate=sampling_rate)
332
+ return test_multivariate_1D_2(duration=duration, sampling_rate=sampling_rate)
322
333
  elif case == 3:
323
- return test_multi_1D_3(duration=duration, sampling_rate=sampling_rate)
334
+ return test_multivariate_1D_3(duration=duration, sampling_rate=sampling_rate)
324
335
  else:
325
336
  # When there is no such test instance, the function returns `case==1`
326
337
  print(f"There is no case {case}, so it will return case==1!")
327
- return test_multi_1D_1(duration=duration, sampling_rate=sampling_rate)
338
+ return test_multivariate_1D_1(duration=duration, sampling_rate=sampling_rate)
328
339
 
329
340
 
330
- def test_multi_1D_1(
341
+ def test_multivariate_1D_1(
331
342
  duration: float = 1.0, sampling_rate: int = 1000
332
343
  ) -> Tuple[np.array, np.array]:
333
344
  """
@@ -350,7 +361,7 @@ def test_multi_1D_1(
350
361
  return t, signal
351
362
 
352
363
 
353
- def test_multi_1D_2(
364
+ def test_multivariate_1D_2(
354
365
  duration: float = 1.0, sampling_rate: int = 1000
355
366
  ) -> Tuple[np.array, np.array]:
356
367
  """
@@ -361,7 +372,6 @@ def test_multi_1D_2(
361
372
  """
362
373
  np.random.seed(seed=42)
363
374
  t = np.linspace(0, duration, int(sampling_rate * duration), endpoint=False)
364
- t = np.linspace(0, duration, int(sampling_rate * duration), endpoint=False)
365
375
 
366
376
  # Generate the multi-channels signals
367
377
  signal_1 = (
@@ -391,7 +401,7 @@ def test_multi_1D_2(
391
401
  return t, signal
392
402
 
393
403
 
394
- def test_multi_1D_3(
404
+ def test_multivariate_1D_3(
395
405
  duration: float = 1.0,
396
406
  sampling_rate: int = 1000,
397
407
  noise_level: float = 0.1,
@@ -445,85 +455,16 @@ def test_multi_1D_3(
445
455
  return t, f
446
456
 
447
457
 
448
- def plot_signal(
449
- t: np.array,
450
- signal: np.array,
451
- color: str = "royalblue",
452
- save: bool = False,
453
- dpi: int = 128,
454
- fontsize: int = 12,
455
- ) -> plt.figure:
456
- """
457
- Plot and optionally save an amplitude modulated (AM) signal with time on the x-axis and amplitude on the y-axis.
458
- :param t: Array of time points corresponding to the signal.
459
- :param signal: Array containing the signal data to be plotted.
460
- :param color: Color of the plot line.
461
- :param save: Boolean flag to indicate whether the plot should be saved to a file.
462
- :param dpi: Dots per inch (resolution) of the figure, if saved.
463
- :param fontsize: Font size of the axis labels.
464
- :return: The figure object containing the plot.
465
- """
466
-
467
- # Determine the number of input signals
468
- n_dim = len(signal.shape)
469
-
470
- if n_dim == 1:
471
- # Create a figure and a single subplot
472
- fig, ax = plt.subplots(figsize=(8, 3))
473
-
474
- # Plot the signal against time with specified line color
475
- ax.plot(t, signal, color=color)
476
-
477
- # Set the x-axis label with specified font size
478
- ax.set_xlabel("Time (seconds)", fontsize=fontsize)
479
-
480
- # Set the y-axis label with default font size
481
- ax.set_ylabel("Amplitude", fontsize=fontsize)
482
-
483
- # Enable grid for better readability
484
- ax.grid(True)
485
-
486
- elif n_dim == 2:
487
- # Determining the number of multivariate signals
488
- n_vars = signal.shape[0]
489
-
490
- # Create a figure and a single subplot
491
- fig, ax = plt.subplots(nrows=n_vars, figsize=(10, 1 + 2 * n_vars), sharex=True)
492
-
493
- for i in range(n_vars):
494
- # Plot the signal against time with specified line color
495
- ax[i].plot(t, signal[i, :], color=color)
496
-
497
- # Set the y-axis label with default font size
498
- ax[i].set_ylabel("Amplitude", fontsize=fontsize)
499
-
500
- # Enable grid for better readability
501
- ax[i].grid(True)
502
-
503
- # Set the x-axis label with specified font size
504
- ax[-1].set_xlabel("Time (seconds)", fontsize=fontsize)
505
-
506
- else:
507
- raise ValueError("Wrong input signal, please input the 1D signal.")
508
-
509
- # Check if the figure needs to be saved
510
- if save:
511
- # Save the figure with the specified dpi and bounding box tightly around the figure
512
- fig.savefig("generate_signal.jpg", dpi=dpi, bbox_inches="tight")
513
-
514
- # Return the figure object
515
- return fig
516
-
517
-
518
458
  if __name__ == "__main__":
519
- from pysdkit.data import test_emd, plot_signal, test_multi_signal
459
+ from pysdkit.data import test_emd, test_multivariate_signal
460
+ from pysdkit.plot import plot_signal
520
461
 
521
- t, signal = test_uni_signal(case=1)
462
+ t, signal = test_univariate_signal(case=1)
522
463
  print(signal.shape)
523
464
 
524
465
  fig = plot_signal(t, signal)
525
466
 
526
- t, signal = test_multi_signal(case=2)
467
+ t, signal = test_multivariate_signal(case=2)
527
468
  print(signal.shape)
528
469
 
529
470
  fig = plot_signal(t, signal, save=False)
@@ -46,7 +46,7 @@ def test_grayscale() -> np.ndarray | None:
46
46
  return None
47
47
 
48
48
 
49
- def get_meshgrid(
49
+ def get_meshgrid_2D(
50
50
  low: int = 0, high: int = 10, sampling_rate: Optional[int] = 256
51
51
  ) -> Tuple[np.ndarray, np.ndarray]:
52
52
  """
@@ -66,7 +66,7 @@ def get_meshgrid(
66
66
  return x, y
67
67
 
68
68
 
69
- def test_uni_image(
69
+ def test_univariate_image(
70
70
  case: int = 1, low: int = 0, high: int = 10, sampling_rate: Optional[int] = 256
71
71
  ) -> np.ndarray:
72
72
  """
@@ -99,7 +99,7 @@ def test_uni_image(
99
99
  return test_grayscale()
100
100
 
101
101
 
102
- def test_multi_image(
102
+ def test_multivariate_image(
103
103
  case: Tuple = (1, 2, 3),
104
104
  low: int = 0,
105
105
  high: int = 10,
@@ -139,7 +139,7 @@ def test_multi_image(
139
139
 
140
140
  # Get multivariate image by sampling univariate function
141
141
  images = [
142
- test_uni_image(case=c, low=low, high=high, sampling_rate=sampling_rate)[
142
+ test_univariate_image(case=c, low=low, high=high, sampling_rate=sampling_rate)[
143
143
  np.newaxis, :, :
144
144
  ]
145
145
  for c in c_list
@@ -164,7 +164,7 @@ def test_image_1(
164
164
  :return: Generate a 2D image using sin(4x), sin(x) and cos(x/24)
165
165
  """
166
166
  # Construct the two dim grid matrix
167
- x, y = get_meshgrid(low, high, sampling_rate)
167
+ x, y = get_meshgrid_2D(low, high, sampling_rate)
168
168
 
169
169
  # Generate a function according to the specified method
170
170
  uc1 = np.sin(4 * x) + np.sin(4 * y)
@@ -193,7 +193,7 @@ def test_image_2(
193
193
  :return: Generate a mixed image using two-dimensional sine and cosine functions
194
194
  """
195
195
  # Construct the two dim grid matrix
196
- x, y = get_meshgrid(low, high, sampling_rate)
196
+ x, y = get_meshgrid_2D(low, high, sampling_rate)
197
197
 
198
198
  # Generate a function according to the specified method
199
199
  uc1 = np.sin(x) + np.sin(y)
@@ -222,7 +222,7 @@ def test_image_3(
222
222
  :return: Generate a mixed image using two-dimensional sine and cosine functions
223
223
  """
224
224
  # Construct the two dim grid matrix
225
- x, y = get_meshgrid(low, high, sampling_rate)
225
+ x, y = get_meshgrid_2D(low, high, sampling_rate)
226
226
 
227
227
  # Generate a function according to the specified method
228
228
  uc1 = np.sin(x / 24) + np.sin(y / 24)
@@ -251,7 +251,7 @@ def test_image_4(
251
251
  :return: Generate a mixed image using two-dimensional sine and cosine functions
252
252
  """
253
253
  # Construct the two dim grid matrix
254
- x, y = get_meshgrid(low, high, sampling_rate)
254
+ x, y = get_meshgrid_2D(low, high, sampling_rate)
255
255
 
256
256
  # Generate a function according to the specified method
257
257
  uc1 = np.sin(x / 60) + np.sin(y / 60)
@@ -280,7 +280,7 @@ def test_image_5(
280
280
  :return: Generate a mixed image using two-dimensional sine and cosine functions
281
281
  """
282
282
  # Construct the two dim grid matrix
283
- x, y = get_meshgrid(low, high, sampling_rate)
283
+ x, y = get_meshgrid_2D(low, high, sampling_rate)
284
284
 
285
285
  # Generate a function according to the specified method
286
286
  uc1 = np.sin(x * 8) + np.sin(y * 8)
@@ -309,7 +309,7 @@ def test_image_6(
309
309
  :return: Generate a mixed image using two-dimensional sine and cosine functions
310
310
  """
311
311
  # Construct the two dim grid matrix
312
- x, y = get_meshgrid(low, high, sampling_rate)
312
+ x, y = get_meshgrid_2D(low, high, sampling_rate)
313
313
 
314
314
  # Generate a function according to the specified method
315
315
  uc1 = np.cos(x**1.2 * 8) + np.sin(y**1.2 * 8)
@@ -338,7 +338,7 @@ def test_uni_image_7(
338
338
  :return: Generate a mixed image using two-dimensional sine and cosine functions
339
339
  """
340
340
  # Construct the two dim grid matrix
341
- x, y = get_meshgrid(low, high, sampling_rate)
341
+ x, y = get_meshgrid_2D(low, high, sampling_rate)
342
342
 
343
343
  # Generate a function according to the specified method
344
344
  uc1 = np.cos(x**1.2 * 8) + np.sin(y**1.2 * 8)
@@ -361,4 +361,4 @@ if __name__ == "__main__":
361
361
  plot_grayscale_image(test_uni_image_7())
362
362
  plt.show()
363
363
 
364
- print(test_multi_image().shape)
364
+ print(test_multivariate_image().shape)
@@ -380,7 +380,7 @@ class EMD(object):
380
380
  self,
381
381
  signal: np.ndarray,
382
382
  time: Optional[np.ndarray] = None,
383
- max_imfs: Optional[int] = 4,
383
+ max_imfs: Optional[int] = None,
384
384
  ) -> np.ndarray:
385
385
  """
386
386
  Signal decomposition using EMD algorithm
@@ -525,10 +525,10 @@ class REMD(object):
525
525
 
526
526
  if __name__ == "__main__":
527
527
  from matplotlib import pyplot as plt
528
- from pysdkit.data import test_emd, test_uni_signal
528
+ from pysdkit.data import test_emd, test_univariate_signal
529
529
  from pysdkit.plot import plot_IMFs
530
530
 
531
- time, signal = test_uni_signal()
531
+ time, signal = test_univariate_signal()
532
532
 
533
533
  remd = REMD(max_imfs=4, ext_ratio=0.0)
534
534
 
@@ -17,3 +17,6 @@ from ._plot_images import plot_grayscale_image, plot_grayscale_spectrum
17
17
  # 通用的图像可视化函数
18
18
  # 可以选择是否绘制频域图谱以及是否添加颜色条
19
19
  from ._plot_images import plot_images
20
+
21
+ # Functions that generate signal visualizations
22
+ from ._plot_signal import plot_signal