diff --git a/PyEMD/EMD.py b/PyEMD/EMD.py index 7d98555..43bd2d1 100644 --- a/PyEMD/EMD.py +++ b/PyEMD/EMD.py @@ -822,6 +822,7 @@ def emd(self, S: np.ndarray, T: Optional[np.ndarray] = None, max_imf: int = -1) # Create arrays imfNo = 0 + extNo = -1 IMF = np.empty((imfNo, N)) # Numpy container for IMF finished = False @@ -911,11 +912,17 @@ def emd(self, S: np.ndarray, T: Optional[np.ndarray] = None, max_imf: int = -1) finished = True break - # Saving residuum - self.residue = residue = S - np.sum(IMF, axis=0) + # If the last sifting had 2 or less extrema then that's a trend (residue) + if extNo <= 2: + IMF = IMF[:-1] + + # Saving imfs and residue for external references self.imfs = IMF.copy() - if not np.allclose(residue, 0): - IMF = np.vstack((IMF, residue)) + self.residue = S - np.sum(self.imfs, axis=0) + + # If residue isn't 0 then add it to the output + if not np.allclose(self.residue, 0): + IMF = np.vstack((IMF, self.residue)) return IMF diff --git a/PyEMD/__init__.py b/PyEMD/__init__.py index b85b616..68f4747 100644 --- a/PyEMD/__init__.py +++ b/PyEMD/__init__.py @@ -1,6 +1,6 @@ import logging -__version__ = "1.0.0" +__version__ = "1.1.0" logger = logging.getLogger("pyemd") from PyEMD.EMD import EMD diff --git a/requirements.txt b/requirements.txt index fda6a7b..0da175e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -numpy>=1.12 -numpydoc -scipy>=0.19 +numpy>=1.12,<=1.20 +scipy>=0.19,<=1.18 pathos>=0.2.1 diff --git a/setup.py b/setup.py index c8f8ab0..dd216ed 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from setuptools import find_packages, setup -VERSION = "1.0.1" +VERSION = "1.1.0" DESCRIPTION = "Implementation of the Empirical Mode Decomposition (EMD) and its variations"