PySDKit 0.4.19__tar.gz → 0.4.20__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.
- {pysdkit-0.4.19 → pysdkit-0.4.20}/PKG-INFO +2 -2
- {pysdkit-0.4.19 → pysdkit-0.4.20}/PySDKit.egg-info/PKG-INFO +2 -2
- {pysdkit-0.4.19 → pysdkit-0.4.20}/PySDKit.egg-info/SOURCES.txt +15 -4
- {pysdkit-0.4.19 → pysdkit-0.4.20}/README.md +1 -1
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/__init__.py +2 -1
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd/ceemdan.py +1 -1
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vncmd/avncmd.py +189 -35
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/data/__init__.py +46 -4
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/data/_generator.py +14 -116
- pysdkit-0.4.20/pysdkit/data/_models.py +33 -0
- pysdkit-0.4.20/pysdkit/data/_test_univariate.py +399 -0
- pysdkit-0.4.20/pysdkit/models/__init__.py +10 -0
- pysdkit-0.4.20/pysdkit/models/_base.py +115 -0
- pysdkit-0.4.20/pysdkit/models/_kmeans.py +6 -0
- {pysdkit-0.4.19/pysdkit/tsa → pysdkit-0.4.20/pysdkit/models}/_knn.py +67 -19
- pysdkit-0.4.20/pysdkit/models/_pca.py +229 -0
- pysdkit-0.4.20/pysdkit/tests/data/__init__.py +6 -0
- {pysdkit-0.4.19/pysdkit/tests → pysdkit-0.4.20/pysdkit/tests/data}/test_generator_signal.py +94 -54
- pysdkit-0.4.20/pysdkit/tests/data/test_generator_univariate_signal.py +152 -0
- pysdkit-0.4.20/pysdkit/tests/models/__init__.py +6 -0
- pysdkit-0.4.20/pysdkit/tests/models/test_knn.py +164 -0
- pysdkit-0.4.20/pysdkit/tests/models/test_pca.py +63 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tsa/__init__.py +2 -2
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/utils/_correlation.py +2 -2
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/utils/_hilbert.py +4 -4
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/utils/_smooth1d.py +1 -1
- {pysdkit-0.4.19 → pysdkit-0.4.20}/setup.py +1 -1
- {pysdkit-0.4.19 → pysdkit-0.4.20}/LICENSE +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/PySDKit.egg-info/dependency_links.txt +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/PySDKit.egg-info/requires.txt +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/PySDKit.egg-info/top_level.txt +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd/_find_extrema.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd/_prepare_points.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd/_splines.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd/eemd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd/efd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd/emd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd/hht/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd/hht/frequency.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd/hht/hht.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd/memd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd/remd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd/tvf_emd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd2d/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd2d/bemd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd2d/bmemd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_emd2d/emd2d.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_esmd/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_esmd/esmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_ewt/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_ewt/ewt.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_ewt/ewt2d.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_faemd/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_faemd/extrema.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_faemd/faemd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_faemd/faemd2d.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_faemd/faemd3d.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_faemd/filter.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_fmd/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_fmd/fmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_fmd/nfmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_hvd/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_hvd/hvd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_ifd/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_itd/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_itd/itd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_jmd/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_jmd/jmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_jmd/mjmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_lmd/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_lmd/lmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_lmd/rlmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_osd/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_ssa/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_ssa/ssa.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vmd/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vmd/acmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vmd/avmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vmd/ba_acmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vmd/base.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vmd/mvmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vmd/svmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vmd/vmd_c.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vmd/vmd_f.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vmd/vme.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vmd2d/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vmd2d/cvmd2d.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vmd2d/vmd2d.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vncmd/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vncmd/incmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vncmd/mncmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/_vncmd/vncmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/data/_add_noise.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/data/_cube.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/data/_image.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/data/_time_series.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/data/texture.txt +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/entropy/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/entropy/_approxiamte_entropy.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/entropy/_permutation_entropy.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/entropy/_sample_entropy.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/plot/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/plot/_fourier_spectra.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/plot/_functions.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/plot/_plot_images.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/plot/_plot_imfs.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/plot/_plot_signal.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tests/__init__.py +0 -0
- {pysdkit-0.4.19/pysdkit/tests → pysdkit-0.4.20/pysdkit/tests/data}/test_generator_cube.py +0 -0
- {pysdkit-0.4.19/pysdkit/tests → pysdkit-0.4.20/pysdkit/tests/data}/test_generator_image.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tests/test_all.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tests/test_ceemdan.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tests/test_emd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tests/test_ewt.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tests/test_faemd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tests/test_faemd2d.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tests/test_faemd3d.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tests/test_lmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tests/test_moving_decomp.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tests/test_rlmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tests/test_vmd.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tests/test_vmd2d.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tsa/_dtw.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tsa/_moving_decomp.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tsa/_mstl.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/tsa/_stl.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/utils/__init__.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/utils/_cite.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/utils/_diagnalization.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/utils/_differ.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/utils/_fft.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/utils/_function.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/utils/_instantaneous.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/utils/_kernel_matrix.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/utils/_mirror.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/pysdkit/utils/_process.py +0 -0
- {pysdkit-0.4.19 → pysdkit-0.4.20}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PySDKit
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.20
|
|
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, changewam, josefinez
|
|
@@ -146,7 +146,7 @@ plot_IMFs_amplitude_spectra(IMFs, smooth="exp") # use exp smooth
|
|
|
146
146
|
| [`ITD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_itd/itd.py) (Intrinsic Time-Scale Decomposition) | [[paper]](https://royalsocietypublishing.org/doi/10.1098/rspa.2006.1761) | [[code]](https://www.mathworks.com/matlabcentral/fileexchange/69380-intrinsic-time-scale-decomposition-itd) | ✔️ |
|
|
147
147
|
| [`ALIF`]() (Adaptive Local Iterative Filtering) | [[paper]](https://arxiv.org/abs/1411.6051) | [[code]](https://ww2.mathworks.cn/matlabcentral/fileexchange/56210-alif) | ✖️ |
|
|
148
148
|
| [`LMD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_lmd/lmd.py) (Local Mean Decomposition) | [[paper]](https://www.sciencedirect.com/science/article/abs/pii/S1051200418308133?via%3Dihub) | [[code]](https://github.com/shownlin/PyLMD/blob/master/PyLMD/LMD.py) | ✔️ |
|
|
149
|
-
| [`RLMD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_lmd/rlmd.py) (Robust Local Mean Decomposition) | [[paper]](https://www.sciencedirect.com/science/article/abs/pii/S0888327017301619) | [[code]](https://www.mathworks.com/matlabcentral/fileexchange/66935-robust-local-mean-decomposition-rlmd) |
|
|
149
|
+
| [`RLMD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_lmd/rlmd.py) (Robust Local Mean Decomposition) | [[paper]](https://www.sciencedirect.com/science/article/abs/pii/S0888327017301619) | [[code]](https://www.mathworks.com/matlabcentral/fileexchange/66935-robust-local-mean-decomposition-rlmd) | ✔️ |
|
|
150
150
|
| [`FMD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_fmd/fmd.py) (Feature Mode Decomposition) | [[paper]](https://ieeexplore.ieee.org/document/9732251) | [[code]](https://www.mathworks.com/matlabcentral/fileexchange/108099-feature-mode-decomposition-fmd) | ✖️ |
|
|
151
151
|
| [`NFMD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_fmd/nfmd.py) (Non-stationary Feature Mode Decomposition) | [[paper]](https://ieeexplore.ieee.org/document/9732251) | [[code]](https://github.com/sheadan/NFMD-ExtractionInstantaneous/blob/master/nfmd/NFMD.py) | ✖️ |
|
|
152
152
|
| [`SSA`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_ssa/ssa.py) (Singular Spectral Analysis) | [[paper]](https://orca.cardiff.ac.uk/id/eprint/15208/1/Zhiglavsky_SSA_encyclopedia.pdf) | [[code]](https://www.mathworks.com/matlabcentral/fileexchange/58967-singular-spectrum-analysis-beginners-guide) | ✔️ |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: PySDKit
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.20
|
|
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, changewam, josefinez
|
|
@@ -146,7 +146,7 @@ plot_IMFs_amplitude_spectra(IMFs, smooth="exp") # use exp smooth
|
|
|
146
146
|
| [`ITD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_itd/itd.py) (Intrinsic Time-Scale Decomposition) | [[paper]](https://royalsocietypublishing.org/doi/10.1098/rspa.2006.1761) | [[code]](https://www.mathworks.com/matlabcentral/fileexchange/69380-intrinsic-time-scale-decomposition-itd) | ✔️ |
|
|
147
147
|
| [`ALIF`]() (Adaptive Local Iterative Filtering) | [[paper]](https://arxiv.org/abs/1411.6051) | [[code]](https://ww2.mathworks.cn/matlabcentral/fileexchange/56210-alif) | ✖️ |
|
|
148
148
|
| [`LMD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_lmd/lmd.py) (Local Mean Decomposition) | [[paper]](https://www.sciencedirect.com/science/article/abs/pii/S1051200418308133?via%3Dihub) | [[code]](https://github.com/shownlin/PyLMD/blob/master/PyLMD/LMD.py) | ✔️ |
|
|
149
|
-
| [`RLMD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_lmd/rlmd.py) (Robust Local Mean Decomposition) | [[paper]](https://www.sciencedirect.com/science/article/abs/pii/S0888327017301619) | [[code]](https://www.mathworks.com/matlabcentral/fileexchange/66935-robust-local-mean-decomposition-rlmd) |
|
|
149
|
+
| [`RLMD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_lmd/rlmd.py) (Robust Local Mean Decomposition) | [[paper]](https://www.sciencedirect.com/science/article/abs/pii/S0888327017301619) | [[code]](https://www.mathworks.com/matlabcentral/fileexchange/66935-robust-local-mean-decomposition-rlmd) | ✔️ |
|
|
150
150
|
| [`FMD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_fmd/fmd.py) (Feature Mode Decomposition) | [[paper]](https://ieeexplore.ieee.org/document/9732251) | [[code]](https://www.mathworks.com/matlabcentral/fileexchange/108099-feature-mode-decomposition-fmd) | ✖️ |
|
|
151
151
|
| [`NFMD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_fmd/nfmd.py) (Non-stationary Feature Mode Decomposition) | [[paper]](https://ieeexplore.ieee.org/document/9732251) | [[code]](https://github.com/sheadan/NFMD-ExtractionInstantaneous/blob/master/nfmd/NFMD.py) | ✖️ |
|
|
152
152
|
| [`SSA`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_ssa/ssa.py) (Singular Spectral Analysis) | [[paper]](https://orca.cardiff.ac.uk/id/eprint/15208/1/Zhiglavsky_SSA_encyclopedia.pdf) | [[code]](https://www.mathworks.com/matlabcentral/fileexchange/58967-singular-spectrum-analysis-beginners-guide) | ✔️ |
|
|
@@ -76,12 +76,19 @@ pysdkit/data/_add_noise.py
|
|
|
76
76
|
pysdkit/data/_cube.py
|
|
77
77
|
pysdkit/data/_generator.py
|
|
78
78
|
pysdkit/data/_image.py
|
|
79
|
+
pysdkit/data/_models.py
|
|
80
|
+
pysdkit/data/_test_univariate.py
|
|
79
81
|
pysdkit/data/_time_series.py
|
|
80
82
|
pysdkit/data/texture.txt
|
|
81
83
|
pysdkit/entropy/__init__.py
|
|
82
84
|
pysdkit/entropy/_approxiamte_entropy.py
|
|
83
85
|
pysdkit/entropy/_permutation_entropy.py
|
|
84
86
|
pysdkit/entropy/_sample_entropy.py
|
|
87
|
+
pysdkit/models/__init__.py
|
|
88
|
+
pysdkit/models/_base.py
|
|
89
|
+
pysdkit/models/_kmeans.py
|
|
90
|
+
pysdkit/models/_knn.py
|
|
91
|
+
pysdkit/models/_pca.py
|
|
85
92
|
pysdkit/plot/__init__.py
|
|
86
93
|
pysdkit/plot/_fourier_spectra.py
|
|
87
94
|
pysdkit/plot/_functions.py
|
|
@@ -96,17 +103,21 @@ pysdkit/tests/test_ewt.py
|
|
|
96
103
|
pysdkit/tests/test_faemd.py
|
|
97
104
|
pysdkit/tests/test_faemd2d.py
|
|
98
105
|
pysdkit/tests/test_faemd3d.py
|
|
99
|
-
pysdkit/tests/test_generator_cube.py
|
|
100
|
-
pysdkit/tests/test_generator_image.py
|
|
101
|
-
pysdkit/tests/test_generator_signal.py
|
|
102
106
|
pysdkit/tests/test_lmd.py
|
|
103
107
|
pysdkit/tests/test_moving_decomp.py
|
|
104
108
|
pysdkit/tests/test_rlmd.py
|
|
105
109
|
pysdkit/tests/test_vmd.py
|
|
106
110
|
pysdkit/tests/test_vmd2d.py
|
|
111
|
+
pysdkit/tests/data/__init__.py
|
|
112
|
+
pysdkit/tests/data/test_generator_cube.py
|
|
113
|
+
pysdkit/tests/data/test_generator_image.py
|
|
114
|
+
pysdkit/tests/data/test_generator_signal.py
|
|
115
|
+
pysdkit/tests/data/test_generator_univariate_signal.py
|
|
116
|
+
pysdkit/tests/models/__init__.py
|
|
117
|
+
pysdkit/tests/models/test_knn.py
|
|
118
|
+
pysdkit/tests/models/test_pca.py
|
|
107
119
|
pysdkit/tsa/__init__.py
|
|
108
120
|
pysdkit/tsa/_dtw.py
|
|
109
|
-
pysdkit/tsa/_knn.py
|
|
110
121
|
pysdkit/tsa/_moving_decomp.py
|
|
111
122
|
pysdkit/tsa/_mstl.py
|
|
112
123
|
pysdkit/tsa/_stl.py
|
|
@@ -107,7 +107,7 @@ plot_IMFs_amplitude_spectra(IMFs, smooth="exp") # use exp smooth
|
|
|
107
107
|
| [`ITD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_itd/itd.py) (Intrinsic Time-Scale Decomposition) | [[paper]](https://royalsocietypublishing.org/doi/10.1098/rspa.2006.1761) | [[code]](https://www.mathworks.com/matlabcentral/fileexchange/69380-intrinsic-time-scale-decomposition-itd) | ✔️ |
|
|
108
108
|
| [`ALIF`]() (Adaptive Local Iterative Filtering) | [[paper]](https://arxiv.org/abs/1411.6051) | [[code]](https://ww2.mathworks.cn/matlabcentral/fileexchange/56210-alif) | ✖️ |
|
|
109
109
|
| [`LMD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_lmd/lmd.py) (Local Mean Decomposition) | [[paper]](https://www.sciencedirect.com/science/article/abs/pii/S1051200418308133?via%3Dihub) | [[code]](https://github.com/shownlin/PyLMD/blob/master/PyLMD/LMD.py) | ✔️ |
|
|
110
|
-
| [`RLMD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_lmd/rlmd.py) (Robust Local Mean Decomposition) | [[paper]](https://www.sciencedirect.com/science/article/abs/pii/S0888327017301619) | [[code]](https://www.mathworks.com/matlabcentral/fileexchange/66935-robust-local-mean-decomposition-rlmd) |
|
|
110
|
+
| [`RLMD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_lmd/rlmd.py) (Robust Local Mean Decomposition) | [[paper]](https://www.sciencedirect.com/science/article/abs/pii/S0888327017301619) | [[code]](https://www.mathworks.com/matlabcentral/fileexchange/66935-robust-local-mean-decomposition-rlmd) | ✔️ |
|
|
111
111
|
| [`FMD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_fmd/fmd.py) (Feature Mode Decomposition) | [[paper]](https://ieeexplore.ieee.org/document/9732251) | [[code]](https://www.mathworks.com/matlabcentral/fileexchange/108099-feature-mode-decomposition-fmd) | ✖️ |
|
|
112
112
|
| [`NFMD`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_fmd/nfmd.py) (Non-stationary Feature Mode Decomposition) | [[paper]](https://ieeexplore.ieee.org/document/9732251) | [[code]](https://github.com/sheadan/NFMD-ExtractionInstantaneous/blob/master/nfmd/NFMD.py) | ✖️ |
|
|
113
113
|
| [`SSA`](https://github.com/wwhenxuan/PySDKit/blob/main/pysdkit/_ssa/ssa.py) (Singular Spectral Analysis) | [[paper]](https://orca.cardiff.ac.uk/id/eprint/15208/1/Zhiglavsky_SSA_encyclopedia.pdf) | [[code]](https://www.mathworks.com/matlabcentral/fileexchange/58967-singular-spectrum-analysis-beginners-guide) | ✔️ |
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
A Python library for signal decomposition algorithms.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
__version__ = "0.4.
|
|
5
|
+
__version__ = "0.4.20"
|
|
6
6
|
|
|
7
7
|
# Empirical Mode Decomposition
|
|
8
8
|
from ._emd import EMD
|
|
@@ -164,6 +164,7 @@ __all__ = [
|
|
|
164
164
|
"EWT",
|
|
165
165
|
"JMD",
|
|
166
166
|
"Moving_Decomp",
|
|
167
|
+
"models",
|
|
167
168
|
"data",
|
|
168
169
|
"entropy",
|
|
169
170
|
"HHT",
|
|
@@ -173,7 +173,7 @@ class CEEMDAN(object):
|
|
|
173
173
|
|
|
174
174
|
# Normalize the decomposed noise sequences
|
|
175
175
|
if self.beta_progress:
|
|
176
|
-
all_stds = [np.
|
|
176
|
+
all_stds = [np.var(imfs[0]) for imfs in all_noise_EMD]
|
|
177
177
|
all_noise_EMD = [
|
|
178
178
|
imfs / imfs_std for (imfs, imfs_std) in zip(all_noise_EMD, all_stds)
|
|
179
179
|
]
|
|
@@ -5,7 +5,10 @@
|
|
|
5
5
|
# @email: wwhenxuan@gmail.com
|
|
6
6
|
# """
|
|
7
7
|
# import numpy as np
|
|
8
|
+
# from scipy.sparse import diags
|
|
8
9
|
# from scipy.sparse import block_diag
|
|
10
|
+
# from scipy.sparse import spdiags
|
|
11
|
+
# from scipy.linalg import solve
|
|
9
12
|
#
|
|
10
13
|
# try:
|
|
11
14
|
# from scipy.integrate import cumulative_trapezoid
|
|
@@ -32,7 +35,7 @@
|
|
|
32
35
|
# tol: Optional[float] = 1e-5,
|
|
33
36
|
# max_iter: Optional[int] = 300,
|
|
34
37
|
# random_state: Optional[int] = 42,
|
|
35
|
-
# dtype: np.dtype = np.float64, ):
|
|
38
|
+
# dtype: np.dtype = np.float64, ) -> None:
|
|
36
39
|
# """
|
|
37
40
|
# :param max_imfs:
|
|
38
41
|
# :param beta: filter parameter
|
|
@@ -60,9 +63,9 @@
|
|
|
60
63
|
# if iniIF is None:
|
|
61
64
|
# # 如果用户未传入初始化的本征函数
|
|
62
65
|
# iniIF = np.ones(shape=(self.max_imfs, length))
|
|
63
|
-
# for row in range(
|
|
66
|
+
# for row in range(self.max_imfs):
|
|
64
67
|
# # 遍历其中的每一行信息表示一个本征模态函数
|
|
65
|
-
# iniIF[row, :] = self.rng.randint(10, 500)
|
|
68
|
+
# iniIF[row, :] = iniIF[row, :] * self.rng.randint(10, 500)
|
|
66
69
|
# elif iniIF is not None and isinstance(iniIF, np.ndarray):
|
|
67
70
|
# # 如果用户传入了初始化的本征函数并且不为空
|
|
68
71
|
# num_imfs, len_iniIF = iniIF.shape
|
|
@@ -123,8 +126,12 @@
|
|
|
123
126
|
# # Construct the second-order difference matrix H
|
|
124
127
|
# H, HtH = build_second_order_diff(N=length)
|
|
125
128
|
#
|
|
129
|
+
# print("H", H.shape)
|
|
130
|
+
# print("HtH", HtH.shape)
|
|
131
|
+
#
|
|
126
132
|
# # Form the 2K block second-order difference matrix D
|
|
127
133
|
# D = build_block_second_order_diff(H=H, K=max_imfs)
|
|
134
|
+
# print("D", D.shape)
|
|
128
135
|
#
|
|
129
136
|
# # Initialization
|
|
130
137
|
# sinm, cosm = np.zeros(shape=(max_imfs, length)), np.zeros(shape=(max_imfs, length))
|
|
@@ -157,17 +164,7 @@
|
|
|
157
164
|
# beta_thin = self.beta
|
|
158
165
|
#
|
|
159
166
|
# # Estimating the Nonlinear Chirp Signal
|
|
160
|
-
#
|
|
161
|
-
#
|
|
162
|
-
# # if __name__ == '__main__':
|
|
163
|
-
# # a = np.ones((2, 10))
|
|
164
|
-
# # print(np.hstack([a, a]).shape)
|
|
165
|
-
# # print(a * np.array([[1], [2]]))
|
|
166
|
-
# # print(np.array([[1], [2]]).shape)
|
|
167
|
-
#
|
|
168
|
-
#
|
|
169
|
-
# import numpy as np
|
|
170
|
-
# from scipy.sparse import spdiags
|
|
167
|
+
# x = estimate_NCS(A=A, D=D, g=signal, K=max_imfs, N=length)
|
|
171
168
|
#
|
|
172
169
|
#
|
|
173
170
|
# def build_second_order_diff(N: int) -> Tuple[np.ndarray, np.ndarray]:
|
|
@@ -184,10 +181,10 @@
|
|
|
184
181
|
# ones = np.ones(N)
|
|
185
182
|
# twos = -2 * ones
|
|
186
183
|
# data = np.vstack((ones, twos, ones)) # 3 × N
|
|
187
|
-
#
|
|
184
|
+
# diags_ = np.array([0, 1, 2]) # 对应 0, 1, 2 对角线
|
|
188
185
|
#
|
|
189
186
|
# # spdiags 在 SciPy 中的顺序是 (data, diags, m, n)
|
|
190
|
-
# H = spdiags(data,
|
|
187
|
+
# H = spdiags(data, diags_, N - 2, N, format='csr')
|
|
191
188
|
#
|
|
192
189
|
# HtH = H.T @ H
|
|
193
190
|
# return H, HtH
|
|
@@ -212,10 +209,9 @@
|
|
|
212
209
|
# # 将 H 重复 2*K 次,然后沿对角线拼接
|
|
213
210
|
# blocks = [H] * (2 * K)
|
|
214
211
|
# D = block_diag(blocks, format='csr')
|
|
215
|
-
# return D
|
|
216
212
|
#
|
|
217
|
-
#
|
|
218
|
-
#
|
|
213
|
+
# # 将系数矩阵转化为稠密矩阵并返回
|
|
214
|
+
# return D.toarray()
|
|
219
215
|
#
|
|
220
216
|
#
|
|
221
217
|
# def initialize_A(t, iniIF, sinm, cosm, N, K):
|
|
@@ -264,19 +260,53 @@
|
|
|
264
260
|
# return A, sinm, cosm
|
|
265
261
|
#
|
|
266
262
|
#
|
|
267
|
-
#
|
|
268
|
-
#
|
|
269
|
-
#
|
|
270
|
-
#
|
|
271
|
-
#
|
|
272
|
-
#
|
|
273
|
-
#
|
|
274
|
-
#
|
|
275
|
-
#
|
|
276
|
-
#
|
|
277
|
-
#
|
|
278
|
-
#
|
|
279
|
-
#
|
|
263
|
+
# def estimate_NCS(A: np.ndarray, D: np.ndarray, g: np.ndarray, K: int, N: int):
|
|
264
|
+
# """
|
|
265
|
+
# This code implements the Section 3.1 "Estimating the Nonlinear Chirp Signal"
|
|
266
|
+
# The optimization problem may be expressed as
|
|
267
|
+
# minimize alpha*|| g - Ax ||_2^2 + || Dx ||_2^2
|
|
268
|
+
#
|
|
269
|
+
# :param A: dictionary.
|
|
270
|
+
# :param D: 2K block second-order difference matrix.
|
|
271
|
+
# :param g: sampled signal.
|
|
272
|
+
# :param K: number of modes.
|
|
273
|
+
# :param N: number of samples.
|
|
274
|
+
# :return: x: solution of the above optimization problem.
|
|
275
|
+
# """
|
|
276
|
+
# # Find a matrix M whose rows are orthogonal to those in D
|
|
277
|
+
# M = np.zeros(shape=(4 * K, 2 * K * N))
|
|
278
|
+
# ii = 0
|
|
279
|
+
#
|
|
280
|
+
# # TODO: 这里注意索引的起始位置
|
|
281
|
+
# for i in range(1, 2 * K):
|
|
282
|
+
# M[ii, i * N - 1 - 1] = 1
|
|
283
|
+
# M[ii + 1, i * N - 1] = 1
|
|
284
|
+
# ii += 2
|
|
285
|
+
#
|
|
286
|
+
# # Construct a full rank matrix D_title
|
|
287
|
+
# D_tilde = np.concatenate([D, M], axis=0) # TODO: 注意这里是列向量合并
|
|
288
|
+
#
|
|
289
|
+
# # Parameter Setting
|
|
290
|
+
# print("A", A.shape)
|
|
291
|
+
# print("D_tilde", D_tilde.shape)
|
|
292
|
+
#
|
|
293
|
+
# print(A)
|
|
294
|
+
#
|
|
295
|
+
# Lambda = solve(D_tilde.T, A.T).T # TODO: 这里进行的是矩阵的除法
|
|
296
|
+
#
|
|
297
|
+
# print(Lambda.shape)
|
|
298
|
+
#
|
|
299
|
+
# Lambda1 = Lambda[:, :2 * K * (N - 2)]
|
|
300
|
+
# Lambda2 = Lambda[:, 2 * K * (N - 2):]
|
|
301
|
+
# theta_matrix = solve(a=np.matmul(Lambda1.T, Lambda2), b=Lambda2.T)
|
|
302
|
+
#
|
|
303
|
+
# w_matrix = np.eye(N, N) - np.matmul(Lambda2, theta_matrix)
|
|
304
|
+
# y = np.matmul(w_matrix, g)
|
|
305
|
+
#
|
|
306
|
+
# Phi = np.matmul(w_matrix, Lambda1)
|
|
307
|
+
#
|
|
308
|
+
# # Update w
|
|
309
|
+
# w = bayesian_strategy(Phi, y)
|
|
280
310
|
#
|
|
281
311
|
#
|
|
282
312
|
# def bayesian_strategy(Phi, y):
|
|
@@ -325,23 +355,147 @@
|
|
|
325
355
|
# S = PHI2 / gamma_0 - Sig * (left ** 2)
|
|
326
356
|
# Q = PHIt / gamma_0 - Sig * PHIt[index] / gamma_0 * left
|
|
327
357
|
#
|
|
358
|
+
# ML = []
|
|
359
|
+
#
|
|
328
360
|
# for count in range(maxIter):
|
|
329
361
|
# # Calculate si and qi
|
|
330
|
-
# s, q = S, Q
|
|
362
|
+
# s, q = S.copy(), Q.copy()
|
|
331
363
|
#
|
|
332
364
|
# s[index] = gamma * S[index] / (gamma - S[index])
|
|
333
365
|
# q[index] = gamma * Q[index] / (gamma - Q[index])
|
|
334
366
|
# theta = q ** 2 - s
|
|
335
367
|
#
|
|
336
368
|
# # Choice the next alpha that maximizes marginal likelihood
|
|
337
|
-
# ml = -np.inf * np.ones(m)
|
|
338
|
-
#
|
|
369
|
+
# # ml = -np.inf * np.ones(m)
|
|
370
|
+
# ml = np.full(m, -np.inf)
|
|
371
|
+
# ig0 = np.where(theta > 0)[1] # TODO: 这里注意是1还是0
|
|
339
372
|
#
|
|
340
373
|
# # Index for re-estimate
|
|
374
|
+
# ire, _, which = intersect_mimic(a=ig0, b=index)
|
|
375
|
+
#
|
|
376
|
+
# if np.size(ire) > 0:
|
|
377
|
+
# # if not empty
|
|
378
|
+
# Gamma = s[ire] ** 2 / theta[ire]
|
|
379
|
+
# delta = (gamma[which] - Gamma) / (Gamma * gamma[which])
|
|
380
|
+
# ml[ire] = Q[ire] ** 2 * delta / (S[ire] * delta + 1) - np.log(1 + S[ire] * delta)
|
|
381
|
+
#
|
|
382
|
+
# # Index for adding
|
|
383
|
+
# iad = np.setdiff1d(ig0, ire)
|
|
384
|
+
#
|
|
385
|
+
# if np.size(iad) > 0:
|
|
386
|
+
# ml[iad] = (Q[iad] ** 2 - S[iad]) / S[iad] + np.log(S[iad] / (Q[iad] ** 2))
|
|
387
|
+
#
|
|
388
|
+
# is0 = np.setdiff1d(range(m), ig0)
|
|
389
|
+
#
|
|
390
|
+
# # Index for deleting
|
|
391
|
+
# ide, _, which = intersect_mimic(a=is0, b=index)
|
|
392
|
+
# if np.size(ide) > 0:
|
|
393
|
+
# ml[ide] = Q[ide] ** 2 / (S[ide] - gamma[which]) - np.log(1 - S[ide] / gamma[which])
|
|
394
|
+
#
|
|
395
|
+
# idx = np.argmax(ml)
|
|
396
|
+
# ML.append(idx)
|
|
397
|
+
#
|
|
398
|
+
# # Stopping criteria
|
|
399
|
+
# if count > 2 and np.abs(ML[count] - ML[count - 1]) < np.abs(ML[count] - ML[0]) * eta:
|
|
400
|
+
# break
|
|
401
|
+
#
|
|
402
|
+
# # Update gamma
|
|
403
|
+
# which = np.where(index == idx)[1] # TODO: 这里注意一下索引位置
|
|
404
|
+
#
|
|
405
|
+
# if theta[idx] > 0:
|
|
406
|
+
# if np.size(which) > 0:
|
|
407
|
+
# # Re-estimate
|
|
408
|
+
# Gamma = s[idx] ** 2 / theta[idx]
|
|
409
|
+
# Sigii = Sig[which, which]
|
|
410
|
+
# mui = mu[which]
|
|
411
|
+
# Sigi = Sig[:, which]
|
|
412
|
+
#
|
|
413
|
+
# delta = Gamma - gamma[which]
|
|
414
|
+
# ki = delta / (1 + Sigii @ delta) # TODO: 这里是否是矩阵的乘法
|
|
415
|
+
#
|
|
416
|
+
# mu = mu - ki * (mui @ Sigi)
|
|
417
|
+
# Sig = Sig - ki * (Sigi @ Sigi.T)
|
|
418
|
+
# comm = Phi.T @ (np.matmul(phi * Sigi)) / gamma_0
|
|
419
|
+
#
|
|
420
|
+
# S = S + ki * comm ** 2
|
|
421
|
+
# Q = Q + ki * mui @ comm
|
|
422
|
+
#
|
|
423
|
+
# gamma[which] = Gamma
|
|
424
|
+
#
|
|
425
|
+
# else:
|
|
426
|
+
# # Adding
|
|
427
|
+
# Gamma = s[idx] ** 2 / theta[idx]
|
|
428
|
+
# phii = Phi[:, idx]
|
|
429
|
+
# Sigii = 1 / (Gamma + S[idx])
|
|
430
|
+
# mui = Sigii @ Q[idx]
|
|
431
|
+
# comm1 = Sig @ (phi.T @ phii) / gamma_0
|
|
432
|
+
#
|
|
433
|
+
# ei = phii - np.matmul(phi * comm1)
|
|
434
|
+
# off = - Sigii * comm1
|
|
435
|
+
#
|
|
436
|
+
# Sigii_comm1 = np.hstack([Sig + Sigii @ (comm1 @ comm1.T), off])
|
|
437
|
+
# off_Sigii = np.hstack([off.T, Sigii])
|
|
438
|
+
#
|
|
439
|
+
# Sig = np.vstack([Sigii_comm1, off_Sigii])
|
|
440
|
+
#
|
|
441
|
+
# mu = np.vstack([mu - mu * comm1, mui])
|
|
442
|
+
#
|
|
443
|
+
#
|
|
444
|
+
# def intersect_mimic(a: np.ndarray, b: np.ndarray, assume_unique: Optional[bool] = False) -> Tuple[
|
|
445
|
+
# np.ndarray, np.ndarray, np.ndarray]:
|
|
446
|
+
# """
|
|
447
|
+
# MATLAB 风格 intersect(A,B) 的 Python 复现。
|
|
448
|
+
# 返回 (c, ia, ib),其中
|
|
449
|
+
# c : 公共元素(升序、去重)
|
|
450
|
+
# ia : 这些元素在 a 中的下标
|
|
451
|
+
# ib : 这些元素在 b 中的下标
|
|
452
|
+
# 与 [C,ia,ib] = intersect(A,B) 在 MATLAB 中的行为一致。
|
|
453
|
+
# """
|
|
454
|
+
# a = np.asarray(a).ravel()
|
|
455
|
+
# b = np.asarray(b).ravel()
|
|
456
|
+
#
|
|
457
|
+
# if not assume_unique:
|
|
458
|
+
# # 先拿到去重+排序后的数组,并记录“反向索引”
|
|
459
|
+
# a_u, a_ind = np.unique(a, return_index=True)
|
|
460
|
+
# b_u, b_ind = np.unique(b, return_index=True)
|
|
461
|
+
# else:
|
|
462
|
+
# a_u, a_ind = a, np.arange(a.size)
|
|
463
|
+
# b_u, b_ind = b, np.arange(b.size)
|
|
464
|
+
#
|
|
465
|
+
# # 求交集
|
|
466
|
+
# mask = np.in1d(a_u, b_u, assume_unique=True)
|
|
467
|
+
# c = a_u[mask] # 公共元素,已升序
|
|
468
|
+
# ia_orig = a_ind[mask] # 在原始 a 中的下标
|
|
469
|
+
#
|
|
470
|
+
# # 同样的操作对 b
|
|
471
|
+
# mask_b = np.in1d(b_u, a_u, assume_unique=True)
|
|
472
|
+
# ib_orig = b_ind[mask_b]
|
|
473
|
+
#
|
|
474
|
+
# return c, ia_orig, ib_orig
|
|
475
|
+
#
|
|
476
|
+
#
|
|
477
|
+
# if __name__ == "__main__":
|
|
478
|
+
# T = 1
|
|
479
|
+
# fs = 2001
|
|
480
|
+
# t = np.arange(0, fs) / fs
|
|
341
481
|
#
|
|
482
|
+
# a1 = np.exp(-0.03 * t)
|
|
483
|
+
# a2 = np.exp(-0.06 * t)
|
|
342
484
|
#
|
|
485
|
+
# f_1t = 25 + 8 * t - 3 * t ** 2 + 0.4 * t ** 3
|
|
486
|
+
# f_2t = 40 + 16 * t - 6 * t ** 2 + 0.4 * t ** 3
|
|
343
487
|
#
|
|
488
|
+
# g_1t = a1 * np.cos(2 * np.pi * (0.8 + 25 * t + 4 * t ** 2 - 1 * t ** 3 + 0.1 * t ** 4))
|
|
489
|
+
# g_2t = a2 * np.cos(2 * np.pi * (1 + 40 * t + 8 * t ** 2 - 2 * t ** 3 + 0.1 * t ** 4))
|
|
490
|
+
# g = g_1t + g_2t
|
|
344
491
|
#
|
|
492
|
+
# print(g.shape)
|
|
345
493
|
#
|
|
494
|
+
# beta = 1e-6
|
|
495
|
+
# tol = 1e-5
|
|
346
496
|
#
|
|
497
|
+
# iniIF = np.vstack([28 * np.ones(len(t)), 48 * np.ones(len(t))])
|
|
347
498
|
#
|
|
499
|
+
# avncmd = AVNCMD(max_imfs=2, beta=beta,
|
|
500
|
+
# tol=tol)
|
|
501
|
+
# avncmd.fit_transform(g, fs)
|
|
@@ -4,9 +4,37 @@ Created on 2024/7/22 22:56
|
|
|
4
4
|
@author: Whenxuan Wang
|
|
5
5
|
@email: wwhenxuan@gmail.com
|
|
6
6
|
"""
|
|
7
|
+
__all__ = [
|
|
8
|
+
"generate_sin_signal",
|
|
9
|
+
"generate_cos_signal",
|
|
10
|
+
"generate_time_series",
|
|
11
|
+
"generate_square_wave",
|
|
12
|
+
"generate_triangle_wave",
|
|
13
|
+
"generate_sawtooth_wave",
|
|
14
|
+
"generate_am_signal",
|
|
15
|
+
"generate_exponential_signal",
|
|
16
|
+
"test_emd",
|
|
17
|
+
"test_hht",
|
|
18
|
+
"add_noise",
|
|
19
|
+
"test_univariate_signal",
|
|
20
|
+
"test_univariate_nonlinear_chip",
|
|
21
|
+
"test_univariate_gaussamp_quadfm",
|
|
22
|
+
"test_univariate_duffing",
|
|
23
|
+
"test_univariate_logistic_am",
|
|
24
|
+
"test_univariate_cubic_quad",
|
|
25
|
+
"test_multivariate_signal",
|
|
26
|
+
"get_meshgrid_2D",
|
|
27
|
+
"test_grayscale",
|
|
28
|
+
"test_univariate_image",
|
|
29
|
+
"test_multivariate_image",
|
|
30
|
+
"test_univariate_cube",
|
|
31
|
+
"test_multivariate_cube",
|
|
32
|
+
"test_pca",
|
|
33
|
+
]
|
|
7
34
|
|
|
8
35
|
# A series of functions for generating 1D NumPy signals
|
|
9
36
|
from ._generator import generate_sin_signal, generate_cos_signal
|
|
37
|
+
|
|
10
38
|
from ._generator import (
|
|
11
39
|
generate_square_wave,
|
|
12
40
|
generate_triangle_wave,
|
|
@@ -23,15 +51,26 @@ from ._generator import test_emd
|
|
|
23
51
|
# Generate the test function for HHT
|
|
24
52
|
from ._generator import test_hht
|
|
25
53
|
|
|
54
|
+
# add Gaussian noise
|
|
55
|
+
from ._add_noise import add_noise
|
|
56
|
+
|
|
26
57
|
# Generator for 1D univariate
|
|
27
|
-
from .
|
|
58
|
+
from ._test_univariate import test_univariate_signal
|
|
59
|
+
|
|
60
|
+
# Generator for 1D univariate nonlinear chip signal
|
|
61
|
+
from ._test_univariate import test_univariate_nonlinear_chip
|
|
62
|
+
|
|
63
|
+
# Generator for other univariate with different characterization
|
|
64
|
+
from ._test_univariate import (
|
|
65
|
+
test_univariate_gaussamp_quadfm,
|
|
66
|
+
test_univariate_duffing,
|
|
67
|
+
test_univariate_logistic_am,
|
|
68
|
+
test_univariate_cubic_quad,
|
|
69
|
+
)
|
|
28
70
|
|
|
29
71
|
# Generator for 1D multivariate
|
|
30
72
|
from ._generator import test_multivariate_signal
|
|
31
73
|
|
|
32
|
-
# add Gaussian noise
|
|
33
|
-
from ._add_noise import add_noise
|
|
34
|
-
|
|
35
74
|
# Generate a grid matrix given an input and output range
|
|
36
75
|
from ._image import get_meshgrid_2D
|
|
37
76
|
|
|
@@ -49,3 +88,6 @@ from ._cube import test_univariate_cube
|
|
|
49
88
|
|
|
50
89
|
# Test case for multivariate 3D cube
|
|
51
90
|
from ._cube import test_multivariate_cube
|
|
91
|
+
|
|
92
|
+
# Test case for Principal Component Analysis
|
|
93
|
+
from ._models import test_pca
|
|
@@ -212,108 +212,6 @@ def generate_exponential_signal(
|
|
|
212
212
|
return t, noisy_exp_signal
|
|
213
213
|
|
|
214
214
|
|
|
215
|
-
def test_univariate_signal(
|
|
216
|
-
case: int = 1,
|
|
217
|
-
duration: float = 1.0,
|
|
218
|
-
sampling_rate: int = 1000,
|
|
219
|
-
) -> Tuple[np.array, np.array]:
|
|
220
|
-
"""
|
|
221
|
-
Select a test case for a one-dimensional univariate signal based on the input `case`
|
|
222
|
-
|
|
223
|
-
:param case: the test number in [1, 2, 3]
|
|
224
|
-
:param duration: Length of the signal in seconds.
|
|
225
|
-
:param sampling_rate: Number of samples per second.
|
|
226
|
-
|
|
227
|
-
:return: Tuple containing time array and the generated signal.
|
|
228
|
-
:return: the generated signal for univariate 1D.
|
|
229
|
-
"""
|
|
230
|
-
if case == 1:
|
|
231
|
-
return test_1D_1(duration, sampling_rate)
|
|
232
|
-
elif case == 2:
|
|
233
|
-
return test_1D_2(duration, sampling_rate)
|
|
234
|
-
elif case == 3:
|
|
235
|
-
return test_1D_3(duration, sampling_rate)
|
|
236
|
-
else:
|
|
237
|
-
# 当没有这个测试实例是返回`test_emd`这个函数
|
|
238
|
-
print(f"There is no case {case}, so it will return test_emd!")
|
|
239
|
-
return test_emd(duration, sampling_rate)
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
def test_1D_1(
|
|
243
|
-
duration: float = 1.0, sampling_rate: int = 1000
|
|
244
|
-
) -> Tuple[np.array, np.array]:
|
|
245
|
-
"""
|
|
246
|
-
4 / np.pi * (np.sin(2 * np.pi * 10 * t) + np.sin(2 * np.pi * 30 * t) / 3 + np.sin(2 * np.pi * (50 * t + 20 * t ** 2)) / 2)
|
|
247
|
-
|
|
248
|
-
:param duration: Length of the signal in seconds.
|
|
249
|
-
:param sampling_rate: Number of samples per second.
|
|
250
|
-
|
|
251
|
-
:return: Tuple containing time array and the generated signal.
|
|
252
|
-
"""
|
|
253
|
-
t = np.linspace(0, duration, int(sampling_rate * duration), endpoint=False)
|
|
254
|
-
signal = (
|
|
255
|
-
4
|
|
256
|
-
/ np.pi
|
|
257
|
-
* (
|
|
258
|
-
np.sin(2 * np.pi * 10 * t)
|
|
259
|
-
+ np.sin(2 * np.pi * 30 * t) / 3
|
|
260
|
-
+ np.sin(2 * np.pi * (50 * t + 20 * t**2)) / 2
|
|
261
|
-
)
|
|
262
|
-
)
|
|
263
|
-
return t, signal
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
def test_1D_2(
|
|
267
|
-
duration: float = 10.0, sampling_rate: int = 128
|
|
268
|
-
) -> Tuple[np.array, np.array]:
|
|
269
|
-
"""
|
|
270
|
-
Generate 3 * 2 ^ (-t) * sin(sin(2 * pi * t))
|
|
271
|
-
|
|
272
|
-
:param duration: Length of the signal in seconds.
|
|
273
|
-
:param sampling_rate: Number of samples per second.
|
|
274
|
-
|
|
275
|
-
:return: Tuple containing time array and the 3 * 2 ^ (-t) * sin(sin(2 * pi * t)) signal.
|
|
276
|
-
"""
|
|
277
|
-
t = np.linspace(0, duration, int(sampling_rate * duration), endpoint=False)
|
|
278
|
-
signal = (
|
|
279
|
-
3 * 2 ** (-t) * np.sin(np.sin(2 * np.pi * t))
|
|
280
|
-
+ np.cos(2 * np.pi * t * 5)
|
|
281
|
-
+ np.sin(2 * np.pi * (t + 2 * t**2))
|
|
282
|
-
+ np.sin(2 * np.pi * t * 30)
|
|
283
|
-
)
|
|
284
|
-
return t, signal
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
def test_1D_3(
|
|
288
|
-
duration: float = 6.0,
|
|
289
|
-
sampling_rate: int = 128,
|
|
290
|
-
noise_level: float = 0.0,
|
|
291
|
-
random_state: int = 42,
|
|
292
|
-
) -> Tuple[np.array, np.array]:
|
|
293
|
-
"""
|
|
294
|
-
Generate 5 * sin(2 * pi * t) + 3 * sin(2 * pi * t)
|
|
295
|
-
|
|
296
|
-
:param duration: Length of the signal in seconds.
|
|
297
|
-
:param sampling_rate: Number of samples per second.
|
|
298
|
-
:param noise_level: Standard deviation of the Gaussian noise.
|
|
299
|
-
:param random_state: Random seed for the noise generation.
|
|
300
|
-
|
|
301
|
-
:return: Tuple containing time array and the 5 * sin(2 * pi * t) + 3 * sin(2 * pi * t) signal with noise.
|
|
302
|
-
"""
|
|
303
|
-
np.random.seed(seed=random_state)
|
|
304
|
-
t = np.linspace(0, duration, int(sampling_rate * duration), endpoint=False)
|
|
305
|
-
signal = (
|
|
306
|
-
5 * np.sin(2 * np.pi * t)
|
|
307
|
-
+ 3 * np.cos(2 * np.pi * t)
|
|
308
|
-
+ 2 * np.cos(2 * np.pi * t**2)
|
|
309
|
-
+ np.sin(2 * np.pi * t**3)
|
|
310
|
-
+ np.sin(2 * np.pi * (t * 30 + t**2 * 2))
|
|
311
|
-
)
|
|
312
|
-
noise = np.random.normal(0, noise_level, signal.shape)
|
|
313
|
-
noise_signal = signal + noise
|
|
314
|
-
return t, noise_signal
|
|
315
|
-
|
|
316
|
-
|
|
317
215
|
def test_emd(
|
|
318
216
|
duration: float = 1.0,
|
|
319
217
|
sampling_rate: int = 1000,
|
|
@@ -506,17 +404,17 @@ def test_multivariate_1D_3(
|
|
|
506
404
|
return t, f
|
|
507
405
|
|
|
508
406
|
|
|
509
|
-
if __name__ == "__main__":
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
407
|
+
# if __name__ == "__main__":
|
|
408
|
+
# from pysdkit.data import test_emd, test_multivariate_signal
|
|
409
|
+
# from pysdkit.plot import plot_signal
|
|
410
|
+
#
|
|
411
|
+
# t, signal = test_univariate_signal(case=1)
|
|
412
|
+
# print(signal.shape)
|
|
413
|
+
#
|
|
414
|
+
# fig = plot_signal(t, signal)
|
|
415
|
+
#
|
|
416
|
+
# t, signal = test_multivariate_signal(case=2)
|
|
417
|
+
# print(signal.shape)
|
|
418
|
+
#
|
|
419
|
+
# fig = plot_signal(t, signal, save=False)
|
|
420
|
+
# plt.show()
|