Modal-Decomposition 0.2.1__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/MANIFEST.in +1 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/PKG-INFO +79 -15
- Modal-Decomposition-0.2.1/src/Modal_Decomposition.egg-info/PKG-INFO → modal_decomposition-0.3.0/README.md +66 -37
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/pyproject.toml +2 -4
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/setup.py +21 -1
- modal_decomposition-0.3.0/src/Modal_Decomposition/Base/ConstDefine.py +237 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Base/TextDefine.py +2 -0
- modal_decomposition-0.3.0/src/Modal_Decomposition/Base/__init__.py +59 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/EMD.py +3 -3
- modal_decomposition-0.3.0/src/Modal_Decomposition/EWT.py +1034 -0
- modal_decomposition-0.3.0/src/Modal_Decomposition/EWTpy.py +196 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/LMD.py +1 -1
- modal_decomposition-0.3.0/src/Modal_Decomposition/Operator/Daubechies_polynomial.py +29 -0
- modal_decomposition-0.3.0/src/Modal_Decomposition/Operator/Empirical_wavelet.py +36 -0
- modal_decomposition-0.3.0/src/Modal_Decomposition/Operator/__init__.py +2 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/Chunk.py +96 -41
- modal_decomposition-0.3.0/src/Modal_Decomposition/Utils/FFT.py +418 -0
- modal_decomposition-0.3.0/src/Modal_Decomposition/Utils/Memory.py +346 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/Mirror.py +93 -1
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/Peaks.py +1 -1
- modal_decomposition-0.3.0/src/Modal_Decomposition/Utils/Slepian.py +468 -0
- modal_decomposition-0.3.0/src/Modal_Decomposition/Utils/_Slepian/C.py +228 -0
- modal_decomposition-0.3.0/src/Modal_Decomposition/Utils/_Slepian/_C/slepian_core.c +608 -0
- modal_decomposition-0.3.0/src/Modal_Decomposition/Utils/_Slepian/_C/slepian_dpss.h +67 -0
- modal_decomposition-0.3.0/src/Modal_Decomposition/Utils/_Slepian/__init__.py +1 -0
- modal_decomposition-0.3.0/src/Modal_Decomposition/Utils/_Slepian/numpy_slepian.py +295 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/__init__.py +60 -1
- modal_decomposition-0.3.0/src/Modal_Decomposition/VMD.py +931 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/__init__.py +22 -2
- Modal-Decomposition-0.2.1/README.md → modal_decomposition-0.3.0/src/Modal_Decomposition.egg-info/PKG-INFO +101 -6
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition.egg-info/SOURCES.txt +17 -3
- modal_decomposition-0.3.0/src/Modal_Decomposition.egg-info/requires.txt +19 -0
- modal_decomposition-0.3.0/tests/test_ewt.py +312 -0
- modal_decomposition-0.3.0/tests/test_ewtpy_adapter.py +220 -0
- modal_decomposition-0.3.0/tests/test_slepian.py +411 -0
- modal_decomposition-0.3.0/tests/test_vmd.py +193 -0
- Modal-Decomposition-0.2.1/src/Modal_Decomposition/Base/ConstDefine.py +0 -51
- Modal-Decomposition-0.2.1/src/Modal_Decomposition/Base/__init__.py +0 -24
- Modal-Decomposition-0.2.1/src/Modal_Decomposition/EWT.py +0 -110
- Modal-Decomposition-0.2.1/src/Modal_Decomposition/EWT_new.py +0 -110
- Modal-Decomposition-0.2.1/src/Modal_Decomposition/Utils/Memory.py +0 -160
- Modal-Decomposition-0.2.1/src/Modal_Decomposition/VMD.py +0 -99
- Modal-Decomposition-0.2.1/src/Modal_Decomposition/VMD_new.py +0 -108
- Modal-Decomposition-0.2.1/src/Modal_Decomposition.egg-info/requires.txt +0 -13
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/LICENSE +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/setup.cfg +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Base/Cache.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Base/ClassDefine.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Base/ConfigDefine.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Base/PathDefine.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/CEEFD.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/CEEMD.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/CEEMDAN.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/EEMD.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/EFD.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Error/RealizationError.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Error/__init__.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/FMD.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/ICEEMDAN.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/MEMD.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/RPSEMD.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/SSA.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/SVMD.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/Check.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/Envelope.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/Hilbert.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/Monotonicity.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/Seed.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/Spline.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/_Hilbert/_C/_fht/am_sysdep.c +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/_Hilbert/_C/_fht/am_sysdep.h +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/_Hilbert/_C/_fht/math_const.h +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/_Hilbert/_C/_fht/transforms.c +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/_Hilbert/_C/_fht/transforms.h +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/_Hilbert/__init__.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/_Hilbert/_fft.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/_Hilbert/_fht.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/_Hilbert/_fht_native.pyx +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/_Hilbert/_fir.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/_Hilbert/_forth_order_wave.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/_Hilbert/_kramers_kronig.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/_Hilbert/_scipy_backend.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Utils/_Hilbert/_wave.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/_Registry.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/_SVMD_numba.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition.egg-info/dependency_links.txt +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition.egg-info/top_level.txt +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_cache.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_chunk.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_contract.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_emd.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_envelope.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_facade.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_fht.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_fmd_lmd_refactor.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_import.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_montonic.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_peaks.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_reconstruction.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_registry.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_seed.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_spline.py +0 -0
- {Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/tests/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: Modal-Decomposition
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: a package for modal decomposition
|
|
5
5
|
Author-email: Mao_HaoChuan <2215269365@qq.com>
|
|
6
6
|
License: Apache-2.0
|
|
@@ -19,15 +19,19 @@ Description-Content-Type: text/markdown
|
|
|
19
19
|
License-File: LICENSE
|
|
20
20
|
Requires-Dist: numpy
|
|
21
21
|
Requires-Dist: EMD-signal
|
|
22
|
-
Requires-Dist: ewtpy
|
|
23
22
|
Requires-Dist: scipy
|
|
24
|
-
Requires-Dist: vmdpy
|
|
25
23
|
Requires-Dist: psutil
|
|
26
|
-
Provides-Extra:
|
|
27
|
-
Requires-Dist:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
Provides-Extra: cupy
|
|
25
|
+
Requires-Dist: cupy-cuda12x; extra == "cupy"
|
|
26
|
+
Provides-Extra: pyfftw
|
|
27
|
+
Requires-Dist: pyfftw; extra == "pyfftw"
|
|
28
|
+
Provides-Extra: vmdpy
|
|
29
|
+
Requires-Dist: vmdpy; extra == "vmdpy"
|
|
30
|
+
Provides-Extra: scipy
|
|
31
|
+
Requires-Dist: scipy; extra == "scipy"
|
|
32
|
+
Provides-Extra: ewtpy
|
|
33
|
+
Requires-Dist: ewtpy; extra == "ewtpy"
|
|
34
|
+
Dynamic: license-file
|
|
31
35
|
|
|
32
36
|
# Modal-Decomposition
|
|
33
37
|
|
|
@@ -52,6 +56,7 @@ algorithms (or benchmarking them against each other) is a one-line change.
|
|
|
52
56
|
| EFD | Empirical Fourier Decomposition | `Function.EFD(S)` | [10.1016/j.ymssp.2021.108155](https://www.sciencedirect.com/science/article/abs/pii/S0888327021005355?via%3Dihub) |
|
|
53
57
|
| EMD | Empirical Mode Decomposition | `Function.EMD(S)` | [10.1098/rspa.1998.0193](https://www.semanticscholar.org/paper/The-empirical-mode-decomposition-and-the-Hilbert-Huang-Shen/3842d81b0375dae8ae92734aa2a5d4aeed7a91d1) |
|
|
54
58
|
| EWT | Empirical Wavelet Transform | `Function.EWT(S)` | [10.48550/arXiv.2304.06274](https://arxiv.org/abs/2304.06274) |
|
|
59
|
+
| EWTpy | Empirical Wavelet Transform (optional `ewtpy` backend) | `Function.EWTpy(S)` | [10.48550/arXiv.2304.06274](https://arxiv.org/abs/2304.06274) |
|
|
55
60
|
| FMD | Filtered Mode Decomposition | `Function.FMD(S)` | [10.1109/TIE.2022.3156156](https://ieeexplore.ieee.org/document/9732251) |
|
|
56
61
|
| ICEEMDAN | Improved Complete Ensemble Empirical Mode Decomposition with Adaptive Noise | `Function.ICEEMDAN(S)` | [10.1007/s10470-021-01901-3](https://link.springer.com/article/10.1007/s10470-021-01901-3#citeas) |
|
|
57
62
|
| LMD | Local Mean Decomposition | `Function.LMD(S)` | [10.1098/rsif.2005.0058](https://royalsocietypublishing.org/doi/10.1098/rsif.2005.0058) |
|
|
@@ -95,18 +100,41 @@ Requires **Python >= 3.10**.
|
|
|
95
100
|
|-------------|-----------------------------------------------------|
|
|
96
101
|
| numpy | core arrays and vectorized kernels |
|
|
97
102
|
| scipy | splines, envelope / Hilbert, filtering, peaks, FFT |
|
|
98
|
-
| EMD-signal (PyEMD) |
|
|
99
|
-
| ewtpy | EWT |
|
|
100
|
-
| vmdpy | VMD |
|
|
103
|
+
| EMD-signal (PyEMD) | **EEMD and CEEMDAN only** — the last remaining third-party decomposition dependency |
|
|
101
104
|
| psutil | available-memory reading for the memmap policy |
|
|
102
105
|
|
|
103
106
|
> Please install `EMD-signal`, not `PyEMD` (the latter is an unrelated older package).
|
|
104
107
|
|
|
108
|
+
**PyEMD is the only third-party decomposition backend left.** Every other
|
|
109
|
+
method — `EMD`, `CEEMD`, `ICEEMDAN`, `RPSEMD`, `VMD`, `EWT`, `LMD`, `FMD`,
|
|
110
|
+
`EFD`, `CEEFD`, `SSA`, `SVMD`, `MEMD` — is implemented inside this library and
|
|
111
|
+
needs nothing beyond numpy/scipy. Only `EEMD` and `CEEMDAN` still delegate to
|
|
112
|
+
PyEMD, and **that dependency is being removed**: the `0.3.x` line exists
|
|
113
|
+
precisely to finish porting those two remaining branches, after which the
|
|
114
|
+
library stands on its own (see [Roadmap](#roadmap)).
|
|
115
|
+
|
|
116
|
+
`vmdpy` and `ewtpy` are **not** required: the native `VMD` / `EWT` replace them
|
|
117
|
+
entirely. `vmdpy` survives only as an optional parity-check backend
|
|
118
|
+
(`Class.VMD(vmdpy=True)`) and `EWTpy` / `ewtpy` only as an optional
|
|
119
|
+
reference-implementation adapter. Both are imported lazily, so neither is a
|
|
120
|
+
runtime dependency.
|
|
121
|
+
|
|
122
|
+
`EWT` (Empirical Wavelet Transform) is implemented **inside this library** and
|
|
123
|
+
needs no third-party package. The ewtpy-backed variant `EWTpy` is **optional**:
|
|
124
|
+
`ewtpy` is imported lazily (via `cache.import_module`) only when you actually
|
|
125
|
+
call `Function.EWTpy` / `Class.EWTpy(...).decompose(...)`, so a missing `ewtpy`
|
|
126
|
+
never affects the rest of the library — install it with
|
|
127
|
+
`pip install Modal-Decomposition[ewtpy]` (or plain `pip install ewtpy`) if you
|
|
128
|
+
want that entry.
|
|
129
|
+
|
|
105
130
|
Optional extras (not required at runtime): `[dev]` (pytest, black) and
|
|
106
131
|
`[plot]` (matplotlib). `numba` may be installed to activate the optional
|
|
107
132
|
`"numba"` backend of `Utils.Peaks` / `SVMD`; everything degrades gracefully
|
|
108
133
|
without it.
|
|
109
134
|
|
|
135
|
+
Accessing any method other than `EEMD` / `CEEMDAN` therefore never triggers a
|
|
136
|
+
PyEMD import at all — `EMD` in particular is the native sifting engine.
|
|
137
|
+
|
|
110
138
|
## Quick Start
|
|
111
139
|
|
|
112
140
|
```python
|
|
@@ -200,19 +228,55 @@ src/Modal_Decomposition/
|
|
|
200
228
|
├── __init__.py Class / Function namespaces + global API
|
|
201
229
|
├── <METHOD>.py 1 Config dataclass + 1 Decomposer per method
|
|
202
230
|
├── EMD.py native EMD engine (PyEMD-free; original EMD_new,
|
|
203
|
-
│ registered as the public "EMD")
|
|
231
|
+
│ registered as the public "EMD"). Only EEMD / CEEMDAN
|
|
232
|
+
│ still reach PyEMD; the 0.3.x line removes that too
|
|
204
233
|
├── _Registry.py class registry (registration at import time)
|
|
205
234
|
├── Base/ Decomposer ABC, DecompositionResult, Config,
|
|
206
235
|
│ import Cache, metadata tables, size constants
|
|
207
236
|
└── Utils/ Check / Chunk / Peaks / Mirror / Spline / Envelope /
|
|
208
|
-
Hilbert / Monotonicity / Memory / Seed
|
|
209
|
-
(+ _Hilbert FHT backends)
|
|
237
|
+
Hilbert / Monotonicity / Memory / Seed / FFT / Slepian
|
|
238
|
+
(+ _Hilbert FHT and _Slepian C backends)
|
|
210
239
|
tests/ pytest suite + benchmarking harnesses (comparison/,
|
|
211
240
|
ssa/, test_memory/) against PyEMD and PySDKit
|
|
212
241
|
```
|
|
213
242
|
|
|
243
|
+
## Roadmap
|
|
244
|
+
|
|
245
|
+
**`0.3.0` is the current release.** PyEMD is the only third-party
|
|
246
|
+
decomposition backend still in use, and it is on the way out; the version
|
|
247
|
+
plan splits the remaining work into two lines:
|
|
248
|
+
|
|
249
|
+
| Line | Scope |
|
|
250
|
+
|------|-------|
|
|
251
|
+
| **`0.3.x`** | **Finish removing PyEMD.** Port the two remaining PyEMD-backed branches (`EEMD`, `CEEMDAN`) onto the native engine, so the whole package runs on numpy/scipy alone. Nothing else is planned for this line — bug fixups are deliberately deferred. |
|
|
252
|
+
| **`0.4.0`** | **First fully self-developed release.** With every method native, this line takes on the remaining bug fixups and correctness work across the library. |
|
|
253
|
+
|
|
214
254
|
## Changelog
|
|
215
255
|
|
|
256
|
+
### 0.3.0
|
|
257
|
+
|
|
258
|
+
- **Version line opened.** PyEMD is now the *only* third-party decomposition
|
|
259
|
+
dependency: `EEMD` and `CEEMDAN` are the sole methods still backed by it,
|
|
260
|
+
and removing that dependency is the entire scope of the `0.3.x` line.
|
|
261
|
+
Everything else — `EMD`, `CEEMD`, `ICEEMDAN`, `RPSEMD`, `VMD`, `EWT`,
|
|
262
|
+
`LMD`, `FMD`, `EFD`, `CEEFD`, `SSA`, `SVMD`, `MEMD` — is already native.
|
|
263
|
+
- `vmdpy` and `ewtpy` are demoted to optional parity-check / reference
|
|
264
|
+
backends (`Class.VMD(vmdpy=True)`, `Class.EWTpy`), no longer runtime
|
|
265
|
+
dependencies of `VMD` / `EWT`.
|
|
266
|
+
- `EWT` is fully re-implemented in-library (boundary detection, filter bank,
|
|
267
|
+
transform and inverse) and no longer requires `ewtpy`; the `Operator`
|
|
268
|
+
package supplies the Daubechies transition functions.
|
|
269
|
+
- New `Utils.Slepian` (DPSS / Slepian sequences) with three backends —
|
|
270
|
+
`scipy` (default), `C` (self-contained compiled core, loaded via `ctypes`)
|
|
271
|
+
and `numpy` — plus a bounded process-wide LRU cache; used by the EWT
|
|
272
|
+
`pre_deal="Slepian-Optimize"` multitaper branch.
|
|
273
|
+
- `Utils.FFT` gained a backend dispatcher (`numpy` / `scipy` / `pyfftw` /
|
|
274
|
+
`tiled` / `cupy`, with `auto` splitting on `BIG_ARRAY`); all backends
|
|
275
|
+
remain optional and fall back to numpy.
|
|
276
|
+
- **Remaining work for this line:** port `EEMD` / `CEEMDAN` off PyEMD
|
|
277
|
+
(tracked as the `0.3.x` scope above). Bug fixups are out of scope until
|
|
278
|
+
`0.4.0`.
|
|
279
|
+
|
|
216
280
|
### 0.2.1
|
|
217
281
|
|
|
218
282
|
- `EMD` is now the native self-implemented sifting engine (ex-`EMD_new`,
|
|
@@ -1,34 +1,3 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: Modal-Decomposition
|
|
3
|
-
Version: 0.2.1
|
|
4
|
-
Summary: a package for modal decomposition
|
|
5
|
-
Author-email: Mao_HaoChuan <2215269365@qq.com>
|
|
6
|
-
License: Apache-2.0
|
|
7
|
-
Project-URL: homepage, https://github.com/a-raining-day/Modal-Decomposition
|
|
8
|
-
Project-URL: repository, https://github.com/a-raining-day/Modal-Decomposition.git
|
|
9
|
-
Classifier: Programming Language :: Python :: 3
|
|
10
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
|
14
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
15
|
-
Classifier: Operating System :: MacOS :: MacOS X
|
|
16
|
-
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
-
Requires-Python: >=3.10
|
|
18
|
-
Description-Content-Type: text/markdown
|
|
19
|
-
License-File: LICENSE
|
|
20
|
-
Requires-Dist: numpy
|
|
21
|
-
Requires-Dist: EMD-signal
|
|
22
|
-
Requires-Dist: ewtpy
|
|
23
|
-
Requires-Dist: scipy
|
|
24
|
-
Requires-Dist: vmdpy
|
|
25
|
-
Requires-Dist: psutil
|
|
26
|
-
Provides-Extra: dev
|
|
27
|
-
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
28
|
-
Requires-Dist: black; extra == "dev"
|
|
29
|
-
Provides-Extra: plot
|
|
30
|
-
Requires-Dist: matplotlib; extra == "plot"
|
|
31
|
-
|
|
32
1
|
# Modal-Decomposition
|
|
33
2
|
|
|
34
3
|
> A unified library of modal decomposition methods — 15 classical and modern
|
|
@@ -52,6 +21,7 @@ algorithms (or benchmarking them against each other) is a one-line change.
|
|
|
52
21
|
| EFD | Empirical Fourier Decomposition | `Function.EFD(S)` | [10.1016/j.ymssp.2021.108155](https://www.sciencedirect.com/science/article/abs/pii/S0888327021005355?via%3Dihub) |
|
|
53
22
|
| EMD | Empirical Mode Decomposition | `Function.EMD(S)` | [10.1098/rspa.1998.0193](https://www.semanticscholar.org/paper/The-empirical-mode-decomposition-and-the-Hilbert-Huang-Shen/3842d81b0375dae8ae92734aa2a5d4aeed7a91d1) |
|
|
54
23
|
| EWT | Empirical Wavelet Transform | `Function.EWT(S)` | [10.48550/arXiv.2304.06274](https://arxiv.org/abs/2304.06274) |
|
|
24
|
+
| EWTpy | Empirical Wavelet Transform (optional `ewtpy` backend) | `Function.EWTpy(S)` | [10.48550/arXiv.2304.06274](https://arxiv.org/abs/2304.06274) |
|
|
55
25
|
| FMD | Filtered Mode Decomposition | `Function.FMD(S)` | [10.1109/TIE.2022.3156156](https://ieeexplore.ieee.org/document/9732251) |
|
|
56
26
|
| ICEEMDAN | Improved Complete Ensemble Empirical Mode Decomposition with Adaptive Noise | `Function.ICEEMDAN(S)` | [10.1007/s10470-021-01901-3](https://link.springer.com/article/10.1007/s10470-021-01901-3#citeas) |
|
|
57
27
|
| LMD | Local Mean Decomposition | `Function.LMD(S)` | [10.1098/rsif.2005.0058](https://royalsocietypublishing.org/doi/10.1098/rsif.2005.0058) |
|
|
@@ -95,18 +65,41 @@ Requires **Python >= 3.10**.
|
|
|
95
65
|
|-------------|-----------------------------------------------------|
|
|
96
66
|
| numpy | core arrays and vectorized kernels |
|
|
97
67
|
| scipy | splines, envelope / Hilbert, filtering, peaks, FFT |
|
|
98
|
-
| EMD-signal (PyEMD) |
|
|
99
|
-
| ewtpy | EWT |
|
|
100
|
-
| vmdpy | VMD |
|
|
68
|
+
| EMD-signal (PyEMD) | **EEMD and CEEMDAN only** — the last remaining third-party decomposition dependency |
|
|
101
69
|
| psutil | available-memory reading for the memmap policy |
|
|
102
70
|
|
|
103
71
|
> Please install `EMD-signal`, not `PyEMD` (the latter is an unrelated older package).
|
|
104
72
|
|
|
73
|
+
**PyEMD is the only third-party decomposition backend left.** Every other
|
|
74
|
+
method — `EMD`, `CEEMD`, `ICEEMDAN`, `RPSEMD`, `VMD`, `EWT`, `LMD`, `FMD`,
|
|
75
|
+
`EFD`, `CEEFD`, `SSA`, `SVMD`, `MEMD` — is implemented inside this library and
|
|
76
|
+
needs nothing beyond numpy/scipy. Only `EEMD` and `CEEMDAN` still delegate to
|
|
77
|
+
PyEMD, and **that dependency is being removed**: the `0.3.x` line exists
|
|
78
|
+
precisely to finish porting those two remaining branches, after which the
|
|
79
|
+
library stands on its own (see [Roadmap](#roadmap)).
|
|
80
|
+
|
|
81
|
+
`vmdpy` and `ewtpy` are **not** required: the native `VMD` / `EWT` replace them
|
|
82
|
+
entirely. `vmdpy` survives only as an optional parity-check backend
|
|
83
|
+
(`Class.VMD(vmdpy=True)`) and `EWTpy` / `ewtpy` only as an optional
|
|
84
|
+
reference-implementation adapter. Both are imported lazily, so neither is a
|
|
85
|
+
runtime dependency.
|
|
86
|
+
|
|
87
|
+
`EWT` (Empirical Wavelet Transform) is implemented **inside this library** and
|
|
88
|
+
needs no third-party package. The ewtpy-backed variant `EWTpy` is **optional**:
|
|
89
|
+
`ewtpy` is imported lazily (via `cache.import_module`) only when you actually
|
|
90
|
+
call `Function.EWTpy` / `Class.EWTpy(...).decompose(...)`, so a missing `ewtpy`
|
|
91
|
+
never affects the rest of the library — install it with
|
|
92
|
+
`pip install Modal-Decomposition[ewtpy]` (or plain `pip install ewtpy`) if you
|
|
93
|
+
want that entry.
|
|
94
|
+
|
|
105
95
|
Optional extras (not required at runtime): `[dev]` (pytest, black) and
|
|
106
96
|
`[plot]` (matplotlib). `numba` may be installed to activate the optional
|
|
107
97
|
`"numba"` backend of `Utils.Peaks` / `SVMD`; everything degrades gracefully
|
|
108
98
|
without it.
|
|
109
99
|
|
|
100
|
+
Accessing any method other than `EEMD` / `CEEMDAN` therefore never triggers a
|
|
101
|
+
PyEMD import at all — `EMD` in particular is the native sifting engine.
|
|
102
|
+
|
|
110
103
|
## Quick Start
|
|
111
104
|
|
|
112
105
|
```python
|
|
@@ -200,19 +193,55 @@ src/Modal_Decomposition/
|
|
|
200
193
|
├── __init__.py Class / Function namespaces + global API
|
|
201
194
|
├── <METHOD>.py 1 Config dataclass + 1 Decomposer per method
|
|
202
195
|
├── EMD.py native EMD engine (PyEMD-free; original EMD_new,
|
|
203
|
-
│ registered as the public "EMD")
|
|
196
|
+
│ registered as the public "EMD"). Only EEMD / CEEMDAN
|
|
197
|
+
│ still reach PyEMD; the 0.3.x line removes that too
|
|
204
198
|
├── _Registry.py class registry (registration at import time)
|
|
205
199
|
├── Base/ Decomposer ABC, DecompositionResult, Config,
|
|
206
200
|
│ import Cache, metadata tables, size constants
|
|
207
201
|
└── Utils/ Check / Chunk / Peaks / Mirror / Spline / Envelope /
|
|
208
|
-
Hilbert / Monotonicity / Memory / Seed
|
|
209
|
-
(+ _Hilbert FHT backends)
|
|
202
|
+
Hilbert / Monotonicity / Memory / Seed / FFT / Slepian
|
|
203
|
+
(+ _Hilbert FHT and _Slepian C backends)
|
|
210
204
|
tests/ pytest suite + benchmarking harnesses (comparison/,
|
|
211
205
|
ssa/, test_memory/) against PyEMD and PySDKit
|
|
212
206
|
```
|
|
213
207
|
|
|
208
|
+
## Roadmap
|
|
209
|
+
|
|
210
|
+
**`0.3.0` is the current release.** PyEMD is the only third-party
|
|
211
|
+
decomposition backend still in use, and it is on the way out; the version
|
|
212
|
+
plan splits the remaining work into two lines:
|
|
213
|
+
|
|
214
|
+
| Line | Scope |
|
|
215
|
+
|------|-------|
|
|
216
|
+
| **`0.3.x`** | **Finish removing PyEMD.** Port the two remaining PyEMD-backed branches (`EEMD`, `CEEMDAN`) onto the native engine, so the whole package runs on numpy/scipy alone. Nothing else is planned for this line — bug fixups are deliberately deferred. |
|
|
217
|
+
| **`0.4.0`** | **First fully self-developed release.** With every method native, this line takes on the remaining bug fixups and correctness work across the library. |
|
|
218
|
+
|
|
214
219
|
## Changelog
|
|
215
220
|
|
|
221
|
+
### 0.3.0
|
|
222
|
+
|
|
223
|
+
- **Version line opened.** PyEMD is now the *only* third-party decomposition
|
|
224
|
+
dependency: `EEMD` and `CEEMDAN` are the sole methods still backed by it,
|
|
225
|
+
and removing that dependency is the entire scope of the `0.3.x` line.
|
|
226
|
+
Everything else — `EMD`, `CEEMD`, `ICEEMDAN`, `RPSEMD`, `VMD`, `EWT`,
|
|
227
|
+
`LMD`, `FMD`, `EFD`, `CEEFD`, `SSA`, `SVMD`, `MEMD` — is already native.
|
|
228
|
+
- `vmdpy` and `ewtpy` are demoted to optional parity-check / reference
|
|
229
|
+
backends (`Class.VMD(vmdpy=True)`, `Class.EWTpy`), no longer runtime
|
|
230
|
+
dependencies of `VMD` / `EWT`.
|
|
231
|
+
- `EWT` is fully re-implemented in-library (boundary detection, filter bank,
|
|
232
|
+
transform and inverse) and no longer requires `ewtpy`; the `Operator`
|
|
233
|
+
package supplies the Daubechies transition functions.
|
|
234
|
+
- New `Utils.Slepian` (DPSS / Slepian sequences) with three backends —
|
|
235
|
+
`scipy` (default), `C` (self-contained compiled core, loaded via `ctypes`)
|
|
236
|
+
and `numpy` — plus a bounded process-wide LRU cache; used by the EWT
|
|
237
|
+
`pre_deal="Slepian-Optimize"` multitaper branch.
|
|
238
|
+
- `Utils.FFT` gained a backend dispatcher (`numpy` / `scipy` / `pyfftw` /
|
|
239
|
+
`tiled` / `cupy`, with `auto` splitting on `BIG_ARRAY`); all backends
|
|
240
|
+
remain optional and fall back to numpy.
|
|
241
|
+
- **Remaining work for this line:** port `EEMD` / `CEEMDAN` off PyEMD
|
|
242
|
+
(tracked as the `0.3.x` scope above). Bug fixups are out of scope until
|
|
243
|
+
`0.4.0`.
|
|
244
|
+
|
|
216
245
|
### 0.2.1
|
|
217
246
|
|
|
218
247
|
- `EMD` is now the native self-implemented sifting engine (ex-`EMD_new`,
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "Modal-Decomposition"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
requires-python = ">=3.10"
|
|
9
9
|
|
|
10
10
|
authors = [
|
|
@@ -27,13 +27,11 @@ classifiers = [
|
|
|
27
27
|
dependencies = [
|
|
28
28
|
"numpy",
|
|
29
29
|
"EMD-signal",
|
|
30
|
-
"ewtpy",
|
|
31
30
|
"scipy",
|
|
32
|
-
"vmdpy",
|
|
33
31
|
"psutil"
|
|
34
32
|
]
|
|
35
33
|
|
|
36
|
-
optional-dependencies = {"
|
|
34
|
+
optional-dependencies = {"cupy"=["cupy-cuda12x"], "pyfftw"=["pyfftw"], "vmdpy"=["vmdpy"], "scipy"=["scipy"], "ewtpy"=["ewtpy"]}
|
|
37
35
|
|
|
38
36
|
[project.urls]
|
|
39
37
|
homepage = "https://github.com/a-raining-day/Modal-Decomposition"
|
|
@@ -22,6 +22,26 @@ from setuptools.command.build_ext import build_ext as _build_ext
|
|
|
22
22
|
|
|
23
23
|
_FHT_DIR = "src/Modal_Decomposition/Utils/_Hilbert"
|
|
24
24
|
_FHT_C_DIR = _FHT_DIR + "/_C/_fht"
|
|
25
|
+
_SLEPIAN_C_DIR = "src/Modal_Decomposition/Utils/_Slepian/_C"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _slepian_extension() -> Extension:
|
|
29
|
+
"""_slepian_native: Slepian(DPSS) 的 C 核心 (三对角 + 对称折半 + 二分/反迭代)。
|
|
30
|
+
|
|
31
|
+
纯 C (不引用 Python API), 由 ``Utils/_Slepian/C.py`` 用 ctypes 装载; 找不到时
|
|
32
|
+
``Utils.Slepian`` 自动降级到 numpy 后端, 故同样是可选加速而非必需依赖。
|
|
33
|
+
MSVC 需 ``/utf-8``: 源码注释含中文, 否则按本地代码页(如 GBK)解析会产生告警。
|
|
34
|
+
"""
|
|
35
|
+
if sys.platform == "win32":
|
|
36
|
+
compile_args = ["/O2", "/utf-8"]
|
|
37
|
+
else:
|
|
38
|
+
compile_args = ["-O3", "-std=c99"]
|
|
39
|
+
return Extension(
|
|
40
|
+
"Modal_Decomposition.Utils._Slepian._C._slepian_native",
|
|
41
|
+
sources=[_SLEPIAN_C_DIR + "/slepian_core.c"],
|
|
42
|
+
include_dirs=[_SLEPIAN_C_DIR],
|
|
43
|
+
extra_compile_args=compile_args,
|
|
44
|
+
)
|
|
25
45
|
|
|
26
46
|
|
|
27
47
|
def _native_extension() -> Extension:
|
|
@@ -66,6 +86,6 @@ class _LazyCythonBuildExt(_build_ext):
|
|
|
66
86
|
|
|
67
87
|
|
|
68
88
|
setup(
|
|
69
|
-
ext_modules=[_native_extension()],
|
|
89
|
+
ext_modules=[_native_extension(), _slepian_extension()],
|
|
70
90
|
cmdclass={"build_ext": _LazyCythonBuildExt},
|
|
71
91
|
)
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Size constants shared by the whole package.
|
|
3
|
+
|
|
4
|
+
所有涉及分块 / 内存策略的大小常量统一从本字典取用
|
|
5
|
+
(见 ``Utils.Chunk`` / ``Utils.Check`` / ``Utils.Memory`` /
|
|
6
|
+
``Utils.Monotonicity``), 避免各模块各自书写魔数。
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
__all__ = [
|
|
10
|
+
"SIZE",
|
|
11
|
+
"SPLINE_KIND",
|
|
12
|
+
"DEFAULT_NUMPY_TYPE",
|
|
13
|
+
"CACHE_KEY",
|
|
14
|
+
"HILBERT_BACKEND",
|
|
15
|
+
"BIG_ARRAY",
|
|
16
|
+
"FFT_BACKEND",
|
|
17
|
+
"FFT_BACKEND_SMALL",
|
|
18
|
+
"FFT_BACKEND_BIG",
|
|
19
|
+
"FFT_BACKEND_LIST",
|
|
20
|
+
"FFT_BACKEND_ALIAS",
|
|
21
|
+
"FFT_PIP_PACKAGE",
|
|
22
|
+
"FFT_THREAD_MIN_ELEMS",
|
|
23
|
+
"FFT_TILED_MIN_ELEMS",
|
|
24
|
+
"MIN_CHUNK_ELEMS",
|
|
25
|
+
"ADAPT_MIN_BYTES",
|
|
26
|
+
"DEFAULT_FILL_CHUNK_ELEMS",
|
|
27
|
+
"VMD_MIN_SAMPLES",
|
|
28
|
+
"VMD_UHAT_INFO_LIMIT",
|
|
29
|
+
"VMD_PEAK_INIT_LIMIT",
|
|
30
|
+
"VMD_CHUNK_WORK_BYTES",
|
|
31
|
+
"EWT_CHUNK_WORK_BYTES",
|
|
32
|
+
"EWT_SLEPIAN_MAX_SAMPLES",
|
|
33
|
+
"SLEPIAN_BACKEND_LIST",
|
|
34
|
+
"SLEPIAN_BACKEND",
|
|
35
|
+
"SLEPIAN_NUMPY_MAX_BYTES",
|
|
36
|
+
"SLEPIAN_SMALL_N_ORDER",
|
|
37
|
+
"SLEPIAN_CACHE",
|
|
38
|
+
"SLEPIAN_CACHE_SIZE",
|
|
39
|
+
"SLEPIAN_CACHE_MAX_BYTES",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
import numpy as np
|
|
43
|
+
|
|
44
|
+
"""
|
|
45
|
+
definition: size of arr
|
|
46
|
+
"""
|
|
47
|
+
SIZE = \
|
|
48
|
+
{
|
|
49
|
+
"1KB": 1024, # 2**10 bytes
|
|
50
|
+
"1MB": 1024 ** 2, # 2**20 bytes
|
|
51
|
+
"1GB": 1024 ** 3, # 2**30 bytes
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
"""
|
|
55
|
+
definition: big array
|
|
56
|
+
"""
|
|
57
|
+
#: 大数组分界 (字节)。凡"是否按大数组处理"的判断一律引用本常量, 不再各自写魔数
|
|
58
|
+
BIG_ARRAY = 300 * SIZE["1MB"] # 314572800 bytes
|
|
59
|
+
|
|
60
|
+
"""
|
|
61
|
+
definition: for FFT
|
|
62
|
+
"""
|
|
63
|
+
#: FFT 后端 canonical 名单 (``Utils.FFT`` 的 ``mod`` 取值; "auto" 额外允许)。
|
|
64
|
+
FFT_BACKEND_LIST = \
|
|
65
|
+
[
|
|
66
|
+
"numpy",
|
|
67
|
+
"scipy",
|
|
68
|
+
"pyfftw",
|
|
69
|
+
"tiled",
|
|
70
|
+
"cupy",
|
|
71
|
+
]
|
|
72
|
+
|
|
73
|
+
#: 默认 FFT 后端。"auto" = 按数组体积分流: ``< BIG_ARRAY`` 用 ``FFT_BACKEND_SMALL``, 否则用 ``FFT_BACKEND_BIG``。
|
|
74
|
+
FFT_BACKEND = "auto"
|
|
75
|
+
|
|
76
|
+
#: "auto" 在小数组 (< BIG_ARRAY) 上选用的后端。默认 numpy: 零可选依赖、冷态最快;
|
|
77
|
+
#: pyfftw 暖态更快但不是声明依赖, 需要时显式传 mod="pyfftw" (见 docs/FFT_Backend_Report.md)。
|
|
78
|
+
FFT_BACKEND_SMALL = "numpy"
|
|
79
|
+
|
|
80
|
+
#: "auto" 在大数组 (>= BIG_ARRAY) 上选用的后端。实测 >=500MB 时 numpy 既更快更省内存
|
|
81
|
+
#: (1GB: 2.87s/4106MB vs pyfftw 5.71s/6796MB)。
|
|
82
|
+
FFT_BACKEND_BIG = "numpy"
|
|
83
|
+
|
|
84
|
+
#: FFT 后端别名 → canonical 名 (Utils.FFT 接受这些写法)。
|
|
85
|
+
FFT_BACKEND_ALIAS = \
|
|
86
|
+
{
|
|
87
|
+
"np": "numpy",
|
|
88
|
+
"fftw": "pyfftw",
|
|
89
|
+
"chunked": "tiled",
|
|
90
|
+
"gpu": "cupy",
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
#: FFT 后端缺库时提示安装的 pip 包名 (导入名 != 包名: cupy 的 wheel 叫 cupy-cudaXXx)。
|
|
94
|
+
FFT_PIP_PACKAGE = \
|
|
95
|
+
{
|
|
96
|
+
"scipy": "scipy",
|
|
97
|
+
"pyfftw": "pyfftw",
|
|
98
|
+
"cupy": "cupy-cuda12x",
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
#: FFT 尺寸阈值 (元素数): 低于 FFT_THREAD_MIN_ELEMS 不起多线程 (线程开销盖过收益);
|
|
102
|
+
#: 低于 FFT_TILED_MIN_ELEMS 不走四步分块 (不如直算)。
|
|
103
|
+
FFT_THREAD_MIN_ELEMS = 1 << 20 # 1M 元素
|
|
104
|
+
FFT_TILED_MIN_ELEMS = 1 << 18 # 256K 元素
|
|
105
|
+
|
|
106
|
+
"""
|
|
107
|
+
definition: for VMD
|
|
108
|
+
"""
|
|
109
|
+
#: VMD 最短信号长度 (再短则镜像延拓与 K 个非退化模态都无意义)。
|
|
110
|
+
VMD_MIN_SAMPLES = 8
|
|
111
|
+
|
|
112
|
+
#: VMD 诊断谱 ``info["u_hat"]`` 的体积上限: 超过则不再计算 (它是 K·N 复数)。
|
|
113
|
+
VMD_UHAT_INFO_LIMIT = 64 * SIZE["1MB"]
|
|
114
|
+
|
|
115
|
+
#: VMD ``init_mod="peak"`` 需要的整谱幅度上限: 超过则退化为 uniform 初值。
|
|
116
|
+
VMD_PEAK_INIT_LIMIT = 256 * SIZE["1MB"]
|
|
117
|
+
|
|
118
|
+
#: VMD 分块引擎的目标单块工作集 (字节): 据此按 K 反推默认块长。
|
|
119
|
+
VMD_CHUNK_WORK_BYTES = 64 * SIZE["1MB"]
|
|
120
|
+
|
|
121
|
+
"""
|
|
122
|
+
definition: for EWT
|
|
123
|
+
"""
|
|
124
|
+
#: EWT 分块滤波的目标单块工作集 (字节): 据此按算子每元素临时量反推默认块长
|
|
125
|
+
#: (滤波器组体积达到 ``BIG_ARRAY`` 时启用分块路径, 见 ``EWT``)。
|
|
126
|
+
EWT_CHUNK_WORK_BYTES = 64 * SIZE["1MB"]
|
|
127
|
+
|
|
128
|
+
#: EWT ``pre_deal="Slepian-Optimize"`` 的样本数上限: ``scipy.signal.windows.dpss``
|
|
129
|
+
#: 的代价随 N 增长过快 (构造 N×N 三对角矩阵的特征分解), 超过该长度时该分支降级
|
|
130
|
+
#: 为普通 ``|rfft|`` (并在 ``info["slepian_degraded"]`` 标记)。
|
|
131
|
+
EWT_SLEPIAN_MAX_SAMPLES = 1 << 15 # 32768 样本
|
|
132
|
+
|
|
133
|
+
"""
|
|
134
|
+
definition: for slepian
|
|
135
|
+
"""
|
|
136
|
+
#: Slepian 后端 canonical 名单 (``Utils.Slepian`` 的 ``mod`` 取值; "auto" 额外允许)。
|
|
137
|
+
SLEPIAN_BACKEND_LIST = \
|
|
138
|
+
[
|
|
139
|
+
"numpy",
|
|
140
|
+
"scipy",
|
|
141
|
+
"C",
|
|
142
|
+
]
|
|
143
|
+
|
|
144
|
+
#: 默认后端: 实测最优者 (稳态最快 + 峰值内存最低 + 零构建), 见
|
|
145
|
+
#: docs/Slepian_Backend_Report.md §6。备选: "C" (冷启动最快、调用路径不依赖 scipy,
|
|
146
|
+
#: 自研实现) 与 "numpy" (无 scipy 依赖, 但有 N 上限); 用 mod="C"/"auto" 可切换。
|
|
147
|
+
SLEPIAN_BACKEND = "scipy"
|
|
148
|
+
|
|
149
|
+
#: numpy 后端的稠密矩阵内存预算 (字节)。折半后需对 (N/2)×(N/2) 稠密矩阵做 eigh,
|
|
150
|
+
#: 故 N 稍大就会 GB 级分配 (N=65536 → 8.6 GB); 超过该预算时 numpy 后端直接报错并
|
|
151
|
+
#: 提示改用 "C"/"scipy" (两者的内存都是 O(N))。对应样本上限 N_max = 2*sqrt(B/8)。
|
|
152
|
+
SLEPIAN_NUMPY_MAX_BYTES = 256 * SIZE["1MB"] # 256 MB -> N_max = 8192
|
|
153
|
+
|
|
154
|
+
#: scipy 后端的固有规模限制 ``scipy.signal.windows.dpss`` 要求 ``NW < M/2``
|
|
155
|
+
#: (即 ``2*halfBW < N``); 不满足时该后端必然抛 ValueError, 此时按下面的顺序改用
|
|
156
|
+
#: 其他后端 (默认参数 NW=3.0 时即 N <= 6)。
|
|
157
|
+
SLEPIAN_SMALL_N_ORDER = \
|
|
158
|
+
[
|
|
159
|
+
"C", # 小 N 实测 4.5-6.7 us / 2.3-3.2 KB, 比 numpy 快 7-10x、内存小 2.4x
|
|
160
|
+
"numpy",
|
|
161
|
+
]
|
|
162
|
+
|
|
163
|
+
#: Slepian 的 **Tier-1 进程内缓存** (纯函数记忆化): 相同 (后端, N, NW 精确位, 阶数,
|
|
164
|
+
#: sym, norm, 是否需要集中比) 的结果直接复用。命中返回副本, 主副本只读。
|
|
165
|
+
SLEPIAN_CACHE = True
|
|
166
|
+
|
|
167
|
+
#: 缓存条数上限 (LRU)。
|
|
168
|
+
SLEPIAN_CACHE_SIZE = 8
|
|
169
|
+
|
|
170
|
+
#: 缓存总字节上限: 超出按 LRU 淘汰; 单条超过该值则不缓存 (只算不存)。
|
|
171
|
+
SLEPIAN_CACHE_MAX_BYTES = 256 * SIZE["1MB"]
|
|
172
|
+
|
|
173
|
+
"""
|
|
174
|
+
definition: for spline
|
|
175
|
+
"""
|
|
176
|
+
SPLINE_KIND = \
|
|
177
|
+
[
|
|
178
|
+
"UnivariateSpline",
|
|
179
|
+
"CubicSpline",
|
|
180
|
+
"PCHIP",
|
|
181
|
+
"Akima",
|
|
182
|
+
]
|
|
183
|
+
|
|
184
|
+
"""
|
|
185
|
+
definition: default type of numpy type
|
|
186
|
+
"""
|
|
187
|
+
DEFAULT_NUMPY_TYPE = np.float64
|
|
188
|
+
|
|
189
|
+
"""
|
|
190
|
+
definition: cache
|
|
191
|
+
"""
|
|
192
|
+
CACHE_KEY = \
|
|
193
|
+
{
|
|
194
|
+
"scipy": \
|
|
195
|
+
{
|
|
196
|
+
"signal": "scipy.signal",
|
|
197
|
+
"interpolate": "scipy.interpolate",
|
|
198
|
+
},
|
|
199
|
+
"fft": \
|
|
200
|
+
{
|
|
201
|
+
"scipy": "scipy.fft",
|
|
202
|
+
"pyfftw": "pyfftw.interfaces.numpy_fft",
|
|
203
|
+
"pyfftw_cache": "pyfftw.interfaces.cache",
|
|
204
|
+
"cupy": "cupy",
|
|
205
|
+
},
|
|
206
|
+
# 可选第三方后端: EWTpy 适配层用它经 cache.import_module 惰性导入 ewtpy
|
|
207
|
+
# (未安装时只有 EWTpy 入口不可用, EWT 自研实现不受影响)。
|
|
208
|
+
"ewtpy": "ewtpy",
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
"""
|
|
212
|
+
definition: for hilbert
|
|
213
|
+
"""
|
|
214
|
+
HILBERT_BACKEND = \
|
|
215
|
+
[
|
|
216
|
+
"Scipy",
|
|
217
|
+
"Fourth-order Wave",
|
|
218
|
+
"FHT",
|
|
219
|
+
"SB-Hilbert",
|
|
220
|
+
"Kramers-Kronig",
|
|
221
|
+
"FIR",
|
|
222
|
+
"HST",
|
|
223
|
+
"FFT",
|
|
224
|
+
"Optional-order FIR",
|
|
225
|
+
]
|
|
226
|
+
|
|
227
|
+
"""
|
|
228
|
+
defintion: chunk
|
|
229
|
+
"""
|
|
230
|
+
#: 自适应收缩的块大小下限 (元素数) = 4KB 元素。
|
|
231
|
+
MIN_CHUNK_ELEMS = 4 * SIZE["1KB"]
|
|
232
|
+
|
|
233
|
+
#: 输入低于该字节数时不咨询全局内存策略 (直接沿用调用方块大小)。
|
|
234
|
+
ADAPT_MIN_BYTES = 64 * SIZE["1MB"]
|
|
235
|
+
|
|
236
|
+
#: 流式填充的默认块大小 (元素数) = 8M 元素。
|
|
237
|
+
DEFAULT_FILL_CHUNK_ELEMS = 8 * SIZE["1MB"]
|
{Modal-Decomposition-0.2.1 → modal_decomposition-0.3.0}/src/Modal_Decomposition/Base/TextDefine.py
RENAMED
|
@@ -13,6 +13,7 @@ Name = \
|
|
|
13
13
|
"EFD": "Empirical Fourier Decomposition",
|
|
14
14
|
"EMD": "Empirical Mode Decomposition",
|
|
15
15
|
"EWT": "Empirical Wavelet Transform",
|
|
16
|
+
"EWTpy": "Empirical Wavelet Transform (optional ewtpy backend)",
|
|
16
17
|
"FMD": "Filtered Mode Decomposition",
|
|
17
18
|
"ICEEMDAN": "Improved Complete Ensemble Empirical Mode Decomposition with Adaptive Noise",
|
|
18
19
|
"LMD": "Local Mean Decomposition",
|
|
@@ -32,6 +33,7 @@ Reference = \
|
|
|
32
33
|
"EFD": "10.1016/j.ymssp.2021.108155",
|
|
33
34
|
"EMD": "10.1098/rspa.1998.0193",
|
|
34
35
|
"EWT": "10.48550/arXiv.2304.06274",
|
|
36
|
+
"EWTpy": "10.48550/arXiv.2304.06274",
|
|
35
37
|
"FMD": "10.1109/TIE.2022.3156156",
|
|
36
38
|
"ICEEMDAN": "10.1007/s10470-021-01901-3",
|
|
37
39
|
"LMD": "10.1098/rsif.2005.0058",
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Base package: contracts, metadata tables, the config base class, and the
|
|
3
|
+
import cache.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from .Cache import Cache, cache
|
|
7
|
+
from .ClassDefine import Decomposer, DecompositionResult
|
|
8
|
+
from .ConfigDefine import Config
|
|
9
|
+
from .ConstDefine import (
|
|
10
|
+
SIZE,
|
|
11
|
+
SPLINE_KIND,
|
|
12
|
+
DEFAULT_NUMPY_TYPE,
|
|
13
|
+
CACHE_KEY,
|
|
14
|
+
HILBERT_BACKEND,
|
|
15
|
+
BIG_ARRAY,
|
|
16
|
+
FFT_BACKEND,
|
|
17
|
+
FFT_BACKEND_SMALL,
|
|
18
|
+
FFT_BACKEND_BIG,
|
|
19
|
+
FFT_BACKEND_LIST,
|
|
20
|
+
FFT_BACKEND_ALIAS,
|
|
21
|
+
FFT_PIP_PACKAGE,
|
|
22
|
+
FFT_THREAD_MIN_ELEMS,
|
|
23
|
+
FFT_TILED_MIN_ELEMS,
|
|
24
|
+
MIN_CHUNK_ELEMS,
|
|
25
|
+
ADAPT_MIN_BYTES,
|
|
26
|
+
DEFAULT_FILL_CHUNK_ELEMS,
|
|
27
|
+
VMD_MIN_SAMPLES,
|
|
28
|
+
VMD_UHAT_INFO_LIMIT,
|
|
29
|
+
VMD_PEAK_INIT_LIMIT,
|
|
30
|
+
VMD_CHUNK_WORK_BYTES,
|
|
31
|
+
)
|
|
32
|
+
from .TextDefine import Name, Reference
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"Decomposer",
|
|
36
|
+
"DecompositionResult",
|
|
37
|
+
"Config",
|
|
38
|
+
"Name",
|
|
39
|
+
"Reference",
|
|
40
|
+
"Cache",
|
|
41
|
+
"SIZE",
|
|
42
|
+
"SPLINE_KIND",
|
|
43
|
+
"DEFAULT_NUMPY_TYPE",
|
|
44
|
+
"CACHE_KEY",
|
|
45
|
+
"HILBERT_BACKEND",
|
|
46
|
+
"BIG_ARRAY",
|
|
47
|
+
"FFT_BACKEND",
|
|
48
|
+
"FFT_BACKEND_SMALL",
|
|
49
|
+
"FFT_BACKEND_BIG",
|
|
50
|
+
"FFT_BACKEND_LIST",
|
|
51
|
+
"FFT_BACKEND_ALIAS",
|
|
52
|
+
"FFT_PIP_PACKAGE",
|
|
53
|
+
"FFT_THREAD_MIN_ELEMS",
|
|
54
|
+
"FFT_TILED_MIN_ELEMS",
|
|
55
|
+
"VMD_MIN_SAMPLES",
|
|
56
|
+
"VMD_UHAT_INFO_LIMIT",
|
|
57
|
+
"VMD_PEAK_INIT_LIMIT",
|
|
58
|
+
"VMD_CHUNK_WORK_BYTES",
|
|
59
|
+
]
|