EMD-signal


NameEMD-signal JSON
Version 1.6.0 PyPI version JSON
download
home_pagehttps://github.com/laszukdawid/PyEMD
SummaryImplementation of the Empirical Mode Decomposition (EMD) and its variations
upload_time2024-03-21 04:48:35
maintainerNone
docs_urlNone
authorDawid Laszuk
requires_python<4,>=3.6
licenseApache-2.0
keywords signal decomposition data analysis
VCS
bugtrack_url
requirements numpy scipy pathos
Travis-CI No Travis.
coveralls test coverage
            [![codecov](https://codecov.io/gh/laszukdawid/PyEMD/branch/master/graph/badge.svg)](https://codecov.io/gh/laszukdawid/PyEMD)
[![DocStatus](https://readthedocs.org/projects/pyemd/badge/?version=latest)](https://pyemd.readthedocs.io/)
[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f56b6fc3f855476dbaebd3c02ae88f3e)](https://www.codacy.com/gh/laszukdawid/PyEMD/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=laszukdawid/PyEMD&amp;utm_campaign=Badge_Grade)
[![DOI](https://zenodo.org/badge/65324353.svg)](https://zenodo.org/badge/latestdoi/65324353)

# PyEMD

## Links

- Online documentation: <https://pyemd.readthedocs.org>
- Issue tracker: <https://github.com/laszukdawid/pyemd/issues>
- Source code repository: <https://github.com/laszukdawid/pyemd>

## Introduction

Python implementation of the Empirical Mode
Decomposition (EMD). The package contains multiple EMD variations and
intends to deliver more in time.

### EMD variations

-  Ensemble EMD (EEMD),
-  "Complete Ensemble EMD" (CEEMDAN)
-  different settings and configurations of vanilla EMD.
-  Image decomposition (EMD2D & BEMD) (experimental, no support)
-  Just-in-time compiled EMD (JitEMD)

*PyEMD* allows you to use different splines for envelopes, stopping criteria
and extrema interpolations.

### Available splines

-  Natural cubic (**default**)
-  Pointwise cubic
-  Hermite cubic
-  Akima
-  PChip
-  Linear

### Available stopping criteria

-  Cauchy convergence (**default**)
-  Fixed number of iterations
-  Number of consecutive proto-imfs

### Extrema detection

-  Discrete extrema (**default**)
-  Parabolic interpolation

## Installation

### PyPi (recommended)

The quickest way to install package is through `pip`.

> \$ pip install EMD-signal

### From source

In case, if you only want to *use* EMD and its variations, the best way to install PyEMD is through `pip`.
However, if you want to modify the code, anyhow you might want to download the code and build package yourself.
The source is publicaly available and hosted on [GitHub](https://github.com/laszukdawid/PyEMD).
To download the code you can either go to the source code page and click `Code -> Download ZIP`, or use **git** command line

> \$ git clone <https://github.com/laszukdawid/PyEMD>

Installing package from source is done using command line:

> \$ python setup.py install

**Note**, however, that this will install it in your current environment. If you are working on many projects, or sharing reources with others, we suggest using [virtual environments](https://docs.python.org/3/library/venv.html).

## Example

More detailed examples are included in the
[documentation](https://pyemd.readthedocs.io/en/latest/examples.html) or
in the
[PyEMD/examples](https://github.com/laszukdawid/PyEMD/tree/master/example).

### EMD

In most cases default settings are enough. Simply import `EMD` and pass
your signal to instance or to `emd()` method.

```python
from PyEMD import EMD
import numpy as np

s = np.random.random(100)
emd = EMD()
IMFs = emd(s)
```

The Figure below was produced with input:
$S(t) = cos(22 \pi t^2) + 6t^2$

![simpleExample](https://github.com/laszukdawid/PyEMD/raw/master/example/simple_example.png?raw=true)

### EEMD

Simplest case of using Ensemble EMD (EEMD) is by importing `EEMD` and
passing your signal to the instance or `eemd()` method.

**Windows**: Please don't skip the `if __name__ == "__main__"` section. 

```python
from PyEMD import EEMD
import numpy as np

if __name__ == "__main__":
    s = np.random.random(100)
    eemd = EEMD()
    eIMFs = eemd(s)
```

### CEEMDAN

As with previous methods, also there is a simple way to use `CEEMDAN`.

**Windows**: Please don't skip the `if __name__ == "__main__"` section. 

```python
from PyEMD import CEEMDAN
import numpy as np

if __name__ == "__main__":
    s = np.random.random(100)
    ceemdan = CEEMDAN()
    cIMFs = ceemdan(s)
```

### Visualisation

The package contains a simple visualisation helper that can help, e.g., with time series and instantaneous frequencies.

```python
import numpy as np
from PyEMD import EMD, Visualisation

t = np.arange(0, 3, 0.01)
S = np.sin(13*t + 0.2*t**1.4) - np.cos(3*t)

# Extract imfs and residue
# In case of EMD
emd = EMD()
emd.emd(S)
imfs, res = emd.get_imfs_and_residue()

# In general:
#components = EEMD()(S)
#imfs, res = components[:-1], components[-1]

vis = Visualisation()
vis.plot_imfs(imfs=imfs, residue=res, t=t, include_residue=True)
vis.plot_instant_freq(t, imfs=imfs)
vis.show()
```

## Experimental

### JitEMD

Just-in-time (JIT) compiled EMD is a version of EMD which exceed on very large signals
or reusing the same instance multiple times. It's strongly sugested to be used in
Jupyter notebooks when experimenting by modifyig input rather than the method itself.

The problem with JIT is that the compilation happens on the first execution and it can be
quite costly. With small signals, or performing decomposition just once, the extra time
for compilation will be significantly larger than the decomposition, making it less performant.

Please see documentation for more information or [examples](./example/) for how to use the code.
This is experimental as it's value is still questionable, and the author (me) isn't proficient
in JIT optimization so mistakes could've been made.

Any feedback is welcomed. Happy to improve if there's intrest. Please open tickets with questions
and suggestions.

To enable JIT in your PyEMD, please install with `jit` option, i.e.

> \$ pip install EMD-signal[jit]

###  EMD2D/BEMD

*Unfortunately, this is Experimental and we can't guarantee that the output is meaningful.*
The simplest use is to pass image as monochromatic numpy 2D array. Sample as
with the other modules one can use the default setting of an instance or, more explicitly,
use the `emd2d()` method.

```python
from PyEMD.EMD2d import EMD2D  #, BEMD
import numpy as np

x, y = np.arange(128), np.arange(128).reshape((-1,1))
img = np.sin(0.1*x)*np.cos(0.2*y)
emd2d = EMD2D()  # BEMD() also works
IMFs_2D = emd2d(img)
```

## F.A.Q

### Why is EEMD/CEEMDAN so slow?
Unfortunately, that's their nature. They execute EMD multiple times every time with slightly modified version. Added noise can cause a creation of many extrema which will decrease performance of the natural cubic spline. For some tweaks on how to deal with that please see [Speedup tricks](https://pyemd.readthedocs.io/en/latest/speedup.html) in the documentation.

## Contact

Feel free to contact me with any questions, requests or simply to say *hi*.
It's always nice to know that I've helped someone or made their work easier. 
Contributing to the project is also acceptable and warmly welcomed.

### Citation

If you found this package useful and would like to cite it in your work
please use the following structure:

```latex
@misc{pyemd,
  author = {Laszuk, Dawid},
  title = {Python implementation of Empirical Mode Decomposition algorithm},
  year = {2017},
  publisher = {GitHub},
  journal = {GitHub Repository},
  howpublished = {\url{https://github.com/laszukdawid/PyEMD}},
  doi = {10.5281/zenodo.5459184}
}
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/laszukdawid/PyEMD",
    "name": "EMD-signal",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.6",
    "maintainer_email": null,
    "keywords": "signal decomposition data analysis",
    "author": "Dawid Laszuk",
    "author_email": "pyemd@dawid.lasz.uk",
    "download_url": "https://files.pythonhosted.org/packages/7a/3a/dca8ecc2f8449230582233109e8b858ff96e8c1160cd5cb2f3af02b94d8e/EMD-signal-1.6.0.tar.gz",
    "platform": null,
    "description": "[![codecov](https://codecov.io/gh/laszukdawid/PyEMD/branch/master/graph/badge.svg)](https://codecov.io/gh/laszukdawid/PyEMD)\n[![DocStatus](https://readthedocs.org/projects/pyemd/badge/?version=latest)](https://pyemd.readthedocs.io/)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/f56b6fc3f855476dbaebd3c02ae88f3e)](https://www.codacy.com/gh/laszukdawid/PyEMD/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=laszukdawid/PyEMD&amp;utm_campaign=Badge_Grade)\n[![DOI](https://zenodo.org/badge/65324353.svg)](https://zenodo.org/badge/latestdoi/65324353)\n\n# PyEMD\n\n## Links\n\n- Online documentation: <https://pyemd.readthedocs.org>\n- Issue tracker: <https://github.com/laszukdawid/pyemd/issues>\n- Source code repository: <https://github.com/laszukdawid/pyemd>\n\n## Introduction\n\nPython implementation of the Empirical Mode\nDecomposition (EMD). The package contains multiple EMD variations and\nintends to deliver more in time.\n\n### EMD variations\n\n-  Ensemble EMD (EEMD),\n-  \"Complete Ensemble EMD\" (CEEMDAN)\n-  different settings and configurations of vanilla EMD.\n-  Image decomposition (EMD2D & BEMD) (experimental, no support)\n-  Just-in-time compiled EMD (JitEMD)\n\n*PyEMD* allows you to use different splines for envelopes, stopping criteria\nand extrema interpolations.\n\n### Available splines\n\n-  Natural cubic (**default**)\n-  Pointwise cubic\n-  Hermite cubic\n-  Akima\n-  PChip\n-  Linear\n\n### Available stopping criteria\n\n-  Cauchy convergence (**default**)\n-  Fixed number of iterations\n-  Number of consecutive proto-imfs\n\n### Extrema detection\n\n-  Discrete extrema (**default**)\n-  Parabolic interpolation\n\n## Installation\n\n### PyPi (recommended)\n\nThe quickest way to install package is through `pip`.\n\n> \\$ pip install EMD-signal\n\n### From source\n\nIn case, if you only want to *use* EMD and its variations, the best way to install PyEMD is through `pip`.\nHowever, if you want to modify the code, anyhow you might want to download the code and build package yourself.\nThe source is publicaly available and hosted on [GitHub](https://github.com/laszukdawid/PyEMD).\nTo download the code you can either go to the source code page and click `Code -> Download ZIP`, or use **git** command line\n\n> \\$ git clone <https://github.com/laszukdawid/PyEMD>\n\nInstalling package from source is done using command line:\n\n> \\$ python setup.py install\n\n**Note**, however, that this will install it in your current environment. If you are working on many projects, or sharing reources with others, we suggest using [virtual environments](https://docs.python.org/3/library/venv.html).\n\n## Example\n\nMore detailed examples are included in the\n[documentation](https://pyemd.readthedocs.io/en/latest/examples.html) or\nin the\n[PyEMD/examples](https://github.com/laszukdawid/PyEMD/tree/master/example).\n\n### EMD\n\nIn most cases default settings are enough. Simply import `EMD` and pass\nyour signal to instance or to `emd()` method.\n\n```python\nfrom PyEMD import EMD\nimport numpy as np\n\ns = np.random.random(100)\nemd = EMD()\nIMFs = emd(s)\n```\n\nThe Figure below was produced with input:\n$S(t) = cos(22 \\pi t^2) + 6t^2$\n\n![simpleExample](https://github.com/laszukdawid/PyEMD/raw/master/example/simple_example.png?raw=true)\n\n### EEMD\n\nSimplest case of using Ensemble EMD (EEMD) is by importing `EEMD` and\npassing your signal to the instance or `eemd()` method.\n\n**Windows**: Please don't skip the `if __name__ == \"__main__\"` section. \n\n```python\nfrom PyEMD import EEMD\nimport numpy as np\n\nif __name__ == \"__main__\":\n    s = np.random.random(100)\n    eemd = EEMD()\n    eIMFs = eemd(s)\n```\n\n### CEEMDAN\n\nAs with previous methods, also there is a simple way to use `CEEMDAN`.\n\n**Windows**: Please don't skip the `if __name__ == \"__main__\"` section. \n\n```python\nfrom PyEMD import CEEMDAN\nimport numpy as np\n\nif __name__ == \"__main__\":\n    s = np.random.random(100)\n    ceemdan = CEEMDAN()\n    cIMFs = ceemdan(s)\n```\n\n### Visualisation\n\nThe package contains a simple visualisation helper that can help, e.g., with time series and instantaneous frequencies.\n\n```python\nimport numpy as np\nfrom PyEMD import EMD, Visualisation\n\nt = np.arange(0, 3, 0.01)\nS = np.sin(13*t + 0.2*t**1.4) - np.cos(3*t)\n\n# Extract imfs and residue\n# In case of EMD\nemd = EMD()\nemd.emd(S)\nimfs, res = emd.get_imfs_and_residue()\n\n# In general:\n#components = EEMD()(S)\n#imfs, res = components[:-1], components[-1]\n\nvis = Visualisation()\nvis.plot_imfs(imfs=imfs, residue=res, t=t, include_residue=True)\nvis.plot_instant_freq(t, imfs=imfs)\nvis.show()\n```\n\n## Experimental\n\n### JitEMD\n\nJust-in-time (JIT) compiled EMD is a version of EMD which exceed on very large signals\nor reusing the same instance multiple times. It's strongly sugested to be used in\nJupyter notebooks when experimenting by modifyig input rather than the method itself.\n\nThe problem with JIT is that the compilation happens on the first execution and it can be\nquite costly. With small signals, or performing decomposition just once, the extra time\nfor compilation will be significantly larger than the decomposition, making it less performant.\n\nPlease see documentation for more information or [examples](./example/) for how to use the code.\nThis is experimental as it's value is still questionable, and the author (me) isn't proficient\nin JIT optimization so mistakes could've been made.\n\nAny feedback is welcomed. Happy to improve if there's intrest. Please open tickets with questions\nand suggestions.\n\nTo enable JIT in your PyEMD, please install with `jit` option, i.e.\n\n> \\$ pip install EMD-signal[jit]\n\n###  EMD2D/BEMD\n\n*Unfortunately, this is Experimental and we can't guarantee that the output is meaningful.*\nThe simplest use is to pass image as monochromatic numpy 2D array. Sample as\nwith the other modules one can use the default setting of an instance or, more explicitly,\nuse the `emd2d()` method.\n\n```python\nfrom PyEMD.EMD2d import EMD2D  #, BEMD\nimport numpy as np\n\nx, y = np.arange(128), np.arange(128).reshape((-1,1))\nimg = np.sin(0.1*x)*np.cos(0.2*y)\nemd2d = EMD2D()  # BEMD() also works\nIMFs_2D = emd2d(img)\n```\n\n## F.A.Q\n\n### Why is EEMD/CEEMDAN so slow?\nUnfortunately, that's their nature. They execute EMD multiple times every time with slightly modified version. Added noise can cause a creation of many extrema which will decrease performance of the natural cubic spline. For some tweaks on how to deal with that please see [Speedup tricks](https://pyemd.readthedocs.io/en/latest/speedup.html) in the documentation.\n\n## Contact\n\nFeel free to contact me with any questions, requests or simply to say *hi*.\nIt's always nice to know that I've helped someone or made their work easier. \nContributing to the project is also acceptable and warmly welcomed.\n\n### Citation\n\nIf you found this package useful and would like to cite it in your work\nplease use the following structure:\n\n```latex\n@misc{pyemd,\n  author = {Laszuk, Dawid},\n  title = {Python implementation of Empirical Mode Decomposition algorithm},\n  year = {2017},\n  publisher = {GitHub},\n  journal = {GitHub Repository},\n  howpublished = {\\url{https://github.com/laszukdawid/PyEMD}},\n  doi = {10.5281/zenodo.5459184}\n}\n```\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "Implementation of the Empirical Mode Decomposition (EMD) and its variations",
    "version": "1.6.0",
    "project_urls": {
        "Homepage": "https://github.com/laszukdawid/PyEMD"
    },
    "split_keywords": [
        "signal",
        "decomposition",
        "data",
        "analysis"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "33f81f0dd1ddc9bd0f5ad311e52a6d3b9d118ad23433bb611b45db4b794f07ca",
                "md5": "b32237df026dca909cca250f32c83a37",
                "sha256": "cd0e6c0bf29fb776fd222c71d56ebabb76cff34724e2cf25882eff0c2e9533d9"
            },
            "downloads": -1,
            "filename": "EMD_signal-1.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b32237df026dca909cca250f32c83a37",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.6",
            "size": 74582,
            "upload_time": "2024-03-21T04:48:33",
            "upload_time_iso_8601": "2024-03-21T04:48:33.452032Z",
            "url": "https://files.pythonhosted.org/packages/33/f8/1f0dd1ddc9bd0f5ad311e52a6d3b9d118ad23433bb611b45db4b794f07ca/EMD_signal-1.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7a3adca8ecc2f8449230582233109e8b858ff96e8c1160cd5cb2f3af02b94d8e",
                "md5": "cb352fca222a6f4e6c48966f8eae055a",
                "sha256": "fd20ec894205075625a1ae51bda53196afe0750118f4e606ba08b9653774cfd5"
            },
            "downloads": -1,
            "filename": "EMD-signal-1.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "cb352fca222a6f4e6c48966f8eae055a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.6",
            "size": 71726,
            "upload_time": "2024-03-21T04:48:35",
            "upload_time_iso_8601": "2024-03-21T04:48:35.611379Z",
            "url": "https://files.pythonhosted.org/packages/7a/3a/dca8ecc2f8449230582233109e8b858ff96e8c1160cd5cb2f3af02b94d8e/EMD-signal-1.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-21 04:48:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "laszukdawid",
    "github_project": "PyEMD",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "requirements": [
        {
            "name": "numpy",
            "specs": [
                [
                    ">=",
                    "1.12"
                ]
            ]
        },
        {
            "name": "scipy",
            "specs": [
                [
                    ">=",
                    "0.19"
                ]
            ]
        },
        {
            "name": "pathos",
            "specs": [
                [
                    ">=",
                    "0.2.1"
                ]
            ]
        }
    ],
    "lcname": "emd-signal"
}
        
Elapsed time: 0.20881s