├── PyEMD-master ├── __init__.py ├── PyEMD │ ├── tests │ │ ├── __init__.py │ │ ├── test_all.py │ │ ├── test_splines.py │ │ └── test_bemd.py │ ├── .gitignore │ ├── __init__.py │ └── splines.py ├── .gitignore ├── setup.cfg ├── requirements.txt ├── example │ ├── eemd_example.png │ ├── hht_example.png │ ├── image_decomp.png │ ├── simple_example.png │ ├── simple_example.py │ ├── eemd_example.py │ ├── image_example.py │ └── hht_example.py ├── requirements-extra.txt ├── doc │ ├── visualisation.rst │ ├── emd.rst │ ├── ceemdan.rst │ ├── contact.rst │ ├── eemd.rst │ ├── emd2d.rst │ ├── index.rst │ ├── bemd.rst │ ├── #Makefile# │ ├── Makefile │ ├── intro.rst │ ├── usage.rst │ └── examples.rst ├── MANIFEST.in ├── .travis.yml ├── codecov.yml ├── LICENSE.txt ├── .coveragerc └── setup.py ├── pywt-master ├── util │ ├── __init__.py │ ├── readthedocs │ │ └── requirements.txt │ ├── setenv_build32.bat │ ├── setenv_build64.bat │ ├── travis_osx_install.sh │ └── appveyor │ │ └── build.cmd ├── pywt │ ├── _extensions │ │ ├── __init__.py │ │ ├── c │ │ │ ├── templating.h │ │ │ ├── cwt.c │ │ │ ├── cwt.h │ │ │ ├── wavelets_coeffs.h │ │ │ ├── wt.c │ │ │ ├── convolution.c │ │ │ ├── convolution.h │ │ │ ├── wt.h │ │ │ ├── cwt.template.h │ │ │ ├── common.c │ │ │ ├── wavelets.h │ │ │ ├── convolution.template.h │ │ │ └── wt.template.h │ │ ├── _dwt.pxd │ │ ├── _cwt.pxd │ │ ├── _pywt.pxd │ │ ├── common.pxd │ │ └── wavelet.pxd │ ├── data │ │ ├── aero.npz │ │ ├── ecg.npy │ │ ├── ascent.npz │ │ ├── camera.npz │ │ ├── sst_nino3.npz │ │ ├── __init__.py │ │ └── create_dat.py │ ├── tests │ │ ├── data │ │ │ ├── wavelab_test_signals.npz │ │ │ ├── cwt_matlabR2015b_result.npz │ │ │ ├── dwt_matlabR2012a_result.npz │ │ │ └── generate_matlab_data_cwt.py │ │ ├── test_doc.py │ │ ├── test_functions.py │ │ ├── test_perfect_reconstruction.py │ │ ├── test_data.py │ │ └── test_deprecations.py │ ├── conftest.py │ ├── __init__.py │ ├── _pytest.py │ └── _utils.py ├── benchmarks │ ├── benchmarks │ │ ├── __init__.py │ │ ├── cwt_benchmarks.py │ │ └── swt_benchmarks.py │ ├── README.rst │ └── asv.conf.json ├── doc │ ├── doc2html.bat │ ├── source │ │ ├── release.0.3.0.rst │ │ ├── release.0.4.0.rst │ │ ├── release.0.5.0.rst │ │ ├── release.1.0.0.rst │ │ ├── release.1.1.0.rst │ │ ├── _static │ │ │ ├── wave.png │ │ │ ├── comments.png │ │ │ ├── favicon.ico │ │ │ ├── github.png │ │ │ ├── twitter.png │ │ │ └── page_edit.png │ │ ├── substitutions.rst │ │ ├── releasenotes.rst │ │ ├── ref │ │ │ ├── index.rst │ │ │ ├── idwt-inverse-discrete-wavelet-transform.rst │ │ │ ├── iswt-inverse-stationary-wavelet-transform.rst │ │ │ ├── thresholding-functions.rst │ │ │ ├── swt-stationary-wavelet-transform.rst │ │ │ ├── nd-dwt-and-idwt.rst │ │ │ ├── dwt-coefficient-handling.rst │ │ │ ├── dwt-discrete-wavelet-transform.rst │ │ │ ├── other-functions.rst │ │ │ └── 2d-dwt-and-idwt.rst │ │ ├── _templates │ │ │ ├── quicklinks.html │ │ │ ├── editdocument.html │ │ │ └── page.html │ │ ├── regression │ │ │ ├── index.rst │ │ │ ├── gotchas.rst │ │ │ ├── multilevel.rst │ │ │ └── modes.rst │ │ ├── pyplots │ │ │ ├── camera_approx_detail.py │ │ │ ├── plot_thresholds.py │ │ │ ├── plot_boundary_modes.py │ │ │ ├── plot_mallat_2d.py │ │ │ ├── plot_2d_bases.py │ │ │ └── cwt_scaling_demo.py │ │ ├── dev │ │ │ ├── preparing_linux_build_environment.rst │ │ │ ├── index.rst │ │ │ ├── building_extension.rst │ │ │ ├── testing.rst │ │ │ ├── installing_build_dependencies.rst │ │ │ └── how_to_release.rst │ │ ├── common_refs.rst │ │ ├── contributing.rst │ │ ├── install.rst │ │ └── index.rst │ ├── release │ │ └── 1.1.0-notes.rst │ ├── Makefile │ ├── make.bat │ └── paper │ │ └── paper.bib ├── codecov.yml ├── .coveragerc ├── pytest.ini ├── .gitignore ├── MANIFEST.in ├── demo │ ├── swt2.py │ ├── fswavedecn.py │ ├── wp_visualize_coeffs_distribution.py │ ├── cwt_analysis.py │ ├── _dwt_decompose.c │ ├── wp_2d.py │ ├── plot_demo_signals.py │ ├── wp_scalogram.py │ ├── plot_wavelets_pyqtgraph.py │ ├── dwt2_dwtn_image.py │ ├── swt_variance.py │ ├── dwt_signal_decomposition.py │ ├── benchmark.py │ ├── waveinfo.py │ ├── dwt_swt_show_coeffs.py │ ├── plot_wavelets.py │ ├── fswavedecn_mondrian.py │ └── batch_processing.py ├── .mailmap ├── community_guidelines.rst ├── tox.ini ├── LICENSE ├── appveyor.yml ├── CONTRIBUTING.rst └── .travis.yml └── README.md /PyEMD-master/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pywt-master/util/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /PyEMD-master/PyEMD/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /PyEMD-master/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | dist 3 | *.swp 4 | -------------------------------------------------------------------------------- /pywt-master/benchmarks/benchmarks/__init__.py: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /PyEMD-master/PyEMD/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/* 2 | *.pyc 3 | -------------------------------------------------------------------------------- /PyEMD-master/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=1 3 | -------------------------------------------------------------------------------- /pywt-master/doc/doc2html.bat: -------------------------------------------------------------------------------- 1 | sphinx-build -b html -a -E source build\html 2 | -------------------------------------------------------------------------------- /pywt-master/doc/source/release.0.3.0.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../release/0.3.0-notes.rst 2 | -------------------------------------------------------------------------------- /pywt-master/doc/source/release.0.4.0.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../release/0.4.0-notes.rst 2 | -------------------------------------------------------------------------------- /pywt-master/doc/source/release.0.5.0.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../release/0.5.0-notes.rst 2 | -------------------------------------------------------------------------------- /pywt-master/doc/source/release.1.0.0.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../release/1.0.0-notes.rst 2 | -------------------------------------------------------------------------------- /pywt-master/doc/source/release.1.1.0.rst: -------------------------------------------------------------------------------- 1 | .. include:: ../release/1.1.0-notes.rst 2 | -------------------------------------------------------------------------------- /PyEMD-master/requirements.txt: -------------------------------------------------------------------------------- 1 | numpy>=1.12 2 | numpydoc 3 | scipy>=0.19 4 | pathos>=0.2.1 5 | -------------------------------------------------------------------------------- /pywt-master/pywt/data/aero.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/pywt-master/pywt/data/aero.npz -------------------------------------------------------------------------------- /pywt-master/pywt/data/ecg.npy: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/pywt-master/pywt/data/ecg.npy -------------------------------------------------------------------------------- /pywt-master/codecov.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - "_doc_utils.py" # utilities only used for creating documentation figures 3 | -------------------------------------------------------------------------------- /pywt-master/pywt/data/ascent.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/pywt-master/pywt/data/ascent.npz -------------------------------------------------------------------------------- /pywt-master/pywt/data/camera.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/pywt-master/pywt/data/camera.npz -------------------------------------------------------------------------------- /pywt-master/util/readthedocs/requirements.txt: -------------------------------------------------------------------------------- 1 | numpy 2 | cython 3 | pytest 4 | wheel 5 | numpydoc 6 | matplotlib 7 | -------------------------------------------------------------------------------- /pywt-master/pywt/data/sst_nino3.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/pywt-master/pywt/data/sst_nino3.npz -------------------------------------------------------------------------------- /PyEMD-master/example/eemd_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/PyEMD-master/example/eemd_example.png -------------------------------------------------------------------------------- /PyEMD-master/example/hht_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/PyEMD-master/example/hht_example.png -------------------------------------------------------------------------------- /PyEMD-master/example/image_decomp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/PyEMD-master/example/image_decomp.png -------------------------------------------------------------------------------- /PyEMD-master/example/simple_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/PyEMD-master/example/simple_example.png -------------------------------------------------------------------------------- /pywt-master/doc/source/_static/wave.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/pywt-master/doc/source/_static/wave.png -------------------------------------------------------------------------------- /PyEMD-master/requirements-extra.txt: -------------------------------------------------------------------------------- 1 | numpy>=1.12 2 | numpydoc 3 | scipy>=0.19 4 | matplotlib 5 | pathos>=0.2.1 6 | scikit-image>=0.13 7 | -------------------------------------------------------------------------------- /pywt-master/doc/source/_static/comments.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/pywt-master/doc/source/_static/comments.png -------------------------------------------------------------------------------- /pywt-master/doc/source/_static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/pywt-master/doc/source/_static/favicon.ico -------------------------------------------------------------------------------- /pywt-master/doc/source/_static/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/pywt-master/doc/source/_static/github.png -------------------------------------------------------------------------------- /pywt-master/doc/source/_static/twitter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/pywt-master/doc/source/_static/twitter.png -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/c/templating.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define CAT_HELPER(A, B) A##B 4 | #define CAT(A, B) CAT_HELPER(A, B) 5 | -------------------------------------------------------------------------------- /pywt-master/pywt/data/__init__.py: -------------------------------------------------------------------------------- 1 | from ._readers import ascent, aero, ecg, camera, nino 2 | from ._wavelab_signals import demo_signal 3 | -------------------------------------------------------------------------------- /pywt-master/doc/source/_static/page_edit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/pywt-master/doc/source/_static/page_edit.png -------------------------------------------------------------------------------- /pywt-master/pywt/tests/data/wavelab_test_signals.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/pywt-master/pywt/tests/data/wavelab_test_signals.npz -------------------------------------------------------------------------------- /pywt-master/pywt/tests/data/cwt_matlabR2015b_result.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/pywt-master/pywt/tests/data/cwt_matlabR2015b_result.npz -------------------------------------------------------------------------------- /pywt-master/pywt/tests/data/dwt_matlabR2012a_result.npz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zengguobing/SpO2/HEAD/pywt-master/pywt/tests/data/dwt_matlabR2012a_result.npz -------------------------------------------------------------------------------- /PyEMD-master/doc/visualisation.rst: -------------------------------------------------------------------------------- 1 | Visualisation 2 | ============= 3 | 4 | A simple visualisation helper. 5 | 6 | .. autoclass:: PyEMD.Visualisation 7 | :members: 8 | -------------------------------------------------------------------------------- /pywt-master/pywt/conftest.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | 4 | def pytest_configure(config): 5 | config.addinivalue_line("markers", 6 | "slow: Tests that are slow.") 7 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/_dwt.pxd: -------------------------------------------------------------------------------- 1 | from ._pywt cimport Wavelet, cdata_t 2 | 3 | 4 | cpdef upcoef(bint do_rec_a, cdata_t[::1] coeffs, Wavelet wavelet, int level, 5 | size_t take) 6 | -------------------------------------------------------------------------------- /pywt-master/doc/source/substitutions.rst: -------------------------------------------------------------------------------- 1 | .. |wavelet| replace:: 2 | Wavelet to use in the transform. This can be a name of the wavelet from the :func:`wavelist` list or a :class:`Wavelet` object instance. 3 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/_cwt.pxd: -------------------------------------------------------------------------------- 1 | from ._pywt cimport ContinuousWavelet, data_t 2 | cimport numpy as np 3 | import numpy as np 4 | 5 | cpdef cwt_psi_single(data_t[::1] data, ContinuousWavelet wavelet, size_t output_len) 6 | 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # SpO2 2 | this is a project for oxygen saturation meassuring by photoplethysmograph 3 | 4 | INF.txt and RED.txt supply the data which are needed for running SpO2.py 5 | 6 | dependency: PyEMD,PyWavelets,matplotlib,numpy. 7 | -------------------------------------------------------------------------------- /pywt-master/doc/source/releasenotes.rst: -------------------------------------------------------------------------------- 1 | Release Notes 2 | ============= 3 | 4 | .. toctree:: 5 | :maxdepth: 1 6 | 7 | release.0.3.0 8 | release.0.4.0 9 | release.0.5.0 10 | release.1.0.0 11 | release.1.1.0 12 | -------------------------------------------------------------------------------- /PyEMD-master/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include *.md 2 | include *.py 3 | include setup.cfg 4 | include MANIFEST.in 5 | include README.md 6 | include LICENCE.txt 7 | include requirements.txt 8 | recursive-include PyEMD *.py 9 | recursive-include example *.py 10 | -------------------------------------------------------------------------------- /PyEMD-master/PyEMD/__init__.py: -------------------------------------------------------------------------------- 1 | import logging 2 | 3 | logger = logging.getLogger('pyemd') 4 | 5 | from PyEMD.EMD import EMD 6 | from PyEMD.EEMD import EEMD 7 | from PyEMD.CEEMDAN import CEEMDAN 8 | from PyEMD.visualisation import Visualisation 9 | 10 | -------------------------------------------------------------------------------- /PyEMD-master/doc/emd.rst: -------------------------------------------------------------------------------- 1 | EMD 2 | === 3 | 4 | *Empirical Mode Decomposition (EMD)* is an iterative procedure which decomposes signal into a set of oscillatory components, called *Intrisic Mode Functions* (IMFs). 5 | 6 | .. autoclass:: PyEMD.EMD 7 | :members: 8 | :special-members: 9 | -------------------------------------------------------------------------------- /pywt-master/.coveragerc: -------------------------------------------------------------------------------- 1 | [run] 2 | branch = True 3 | include = */pywt/* 4 | # Not sure what stringsource is 5 | omit = 6 | */version.py 7 | */pywt/tests/* 8 | */pywt/_doc_utils.py* 9 | */pywt/data/create_dat.py 10 | *.pxd 11 | stringsource 12 | plugins = Cython.Coverage -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/c/cwt.c: -------------------------------------------------------------------------------- 1 | #include "cwt.h" 2 | 3 | #ifdef TYPE 4 | #error TYPE should not be defined here. 5 | #else 6 | 7 | 8 | #define TYPE float 9 | #include "cwt.template.c" 10 | #undef TYPE 11 | 12 | #define TYPE double 13 | #include "cwt.template.c" 14 | #undef TYPE 15 | 16 | #endif /* TYPE */ 17 | -------------------------------------------------------------------------------- /pywt-master/util/setenv_build32.bat: -------------------------------------------------------------------------------- 1 | rem Configure the environment for 32-bit builds. 2 | rem Use "vcvars32.bat" for a 32-bit build. 3 | "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat" 4 | setenv /x86 /release 5 | rem Convince setup.py to use the SDK tools. 6 | set MSSdk=1 7 | set DISTUTILS_USE_SDK=1 8 | -------------------------------------------------------------------------------- /pywt-master/util/setenv_build64.bat: -------------------------------------------------------------------------------- 1 | rem Configure the environment for 64-bit builds. 2 | rem Use "vcvars32.bat" for a 32-bit build. 3 | "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin\vcvars64.bat" 4 | setenv /x64 /release 5 | rem Convince setup.py to use the SDK tools. 6 | set MSSdk=1 7 | set DISTUTILS_USE_SDK=1 8 | -------------------------------------------------------------------------------- /PyEMD-master/PyEMD/tests/test_all.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import sys 3 | 4 | if __name__ == '__main__': 5 | test_suite = unittest.defaultTestLoader.discover('.', '*test*.py') 6 | test_runner = unittest.TextTestRunner(resultclass=unittest.TextTestResult) 7 | result = test_runner.run(test_suite) 8 | sys.exit(not result.wasSuccessful()) 9 | -------------------------------------------------------------------------------- /pywt-master/util/travis_osx_install.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | brew update 3 | brew install ccache 4 | 5 | git clone https://github.com/MacPython/terryfy.git ~/terryfy 6 | source ~/terryfy/travis_tools.sh 7 | get_python_environment macpython $TRAVIS_PYTHON_VERSION ~/macpython_venv 8 | source ~/macpython_venv/bin/activate 9 | pip install virtualenv 10 | 11 | -------------------------------------------------------------------------------- /PyEMD-master/doc/ceemdan.rst: -------------------------------------------------------------------------------- 1 | CEEMDAN 2 | ======= 3 | 4 | Info 5 | ---- 6 | 7 | Complete ensembe EMD with adaptive noise (CEEMDAN) performs an EEMD with 8 | the difference that the information about the noise is shared among all workers. 9 | 10 | Class 11 | ----- 12 | 13 | .. autoclass:: PyEMD.CEEMDAN 14 | :members: 15 | :special-members: 16 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/c/cwt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | #include "convolution.h" 5 | #include "wavelets.h" 6 | 7 | 8 | #ifdef TYPE 9 | #error TYPE should not be defined here. 10 | #else 11 | 12 | 13 | #define TYPE float 14 | #include "cwt.template.h" 15 | #undef TYPE 16 | 17 | #define TYPE double 18 | #include "cwt.template.h" 19 | #undef TYPE 20 | 21 | #endif /* TYPE */ 22 | -------------------------------------------------------------------------------- /PyEMD-master/doc/contact.rst: -------------------------------------------------------------------------------- 1 | Contact 2 | ======= 3 | 4 | Feel free to send email with any questions, concerns or for whatever reason you feel like. 5 | 6 | **Email** 7 | \\laszuk\\dawid\\@\\gmail.com (remove slashes \\). 8 | 9 | **Homepage** 10 | http://www.laszukdawid.com 11 | 12 | **GitHub** 13 | You can also visit `PyEMD GitHub project `_ page for this project. 14 | 15 | -------------------------------------------------------------------------------- /PyEMD-master/doc/eemd.rst: -------------------------------------------------------------------------------- 1 | EEMD 2 | ==== 3 | 4 | Info 5 | ---- 6 | Ensemble empirical mode decomposition (EEMD) creates an ensemble of worker each 7 | of which performs an EMD on a copy of the input signal with added noise. 8 | When all workers finish their work a mean over all workers is considered as 9 | the true result. 10 | 11 | Class 12 | ----- 13 | 14 | .. autoclass:: PyEMD.EEMD 15 | :members: 16 | :special-members: 17 | -------------------------------------------------------------------------------- /pywt-master/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | addopts = -l 3 | norecursedirs = doc tools pywt/_extensions 4 | doctest_optionflags = NORMALIZE_WHITESPACE ELLIPSIS ALLOW_UNICODE ALLOW_BYTES 5 | 6 | filterwarnings = 7 | error 8 | # Filter out annoying import messages. 9 | ignore:Not importing directory 10 | ignore:numpy.dtype size changed 11 | ignore:numpy.ufunc size changed 12 | ignore::UserWarning:cpuinfo, 13 | 14 | env = 15 | PYTHONHASHSEED=0 16 | -------------------------------------------------------------------------------- /PyEMD-master/.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: python 3 | python: 4 | - 2.7 5 | - 3.5 6 | - 3.6 7 | # command to run tests 8 | before_install: 9 | - pip install --upgrade pip setuptools wheel 10 | install: 11 | - pip install --only-binary=numpy,scipy numpy scipy 12 | - pip install -r requirements.txt 13 | - pip install -r requirements-extra.txt 14 | - pip install codecov 15 | script: 16 | - python -m PyEMD.tests.test_all 17 | - coverage run PyEMD/tests/test_all.py 18 | after_success: 19 | - codecov 20 | -------------------------------------------------------------------------------- /PyEMD-master/codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | notify: 3 | require_ci_to_pass: yes 4 | 5 | coverage: 6 | precision: 2 7 | round: down 8 | range: "50...100" 9 | 10 | status: 11 | project: yes 12 | 13 | patch: yes 14 | 15 | changes: yes 16 | 17 | ignore: 18 | - "__init__.py" 19 | - "PyEMD/tests" 20 | - "PyEMD/BEMD.py" 21 | - "PyEMD/EMD2d.py" 22 | - "PyEMD/visualisation.py" 23 | - "doc" 24 | - "example" 25 | 26 | comment: 27 | layout: "header, diff, changes" 28 | behavior: default 29 | 30 | -------------------------------------------------------------------------------- /PyEMD-master/doc/emd2d.rst: -------------------------------------------------------------------------------- 1 | EMD2D 2 | ===== 3 | 4 | Warning 5 | ------- 6 | 7 | Important This is an experimental module. Please use it with care as no 8 | guarantee can be given for obtaining reasonable results, or that they will be 9 | computed index the most computation optimal way. 10 | 11 | Info 12 | ---- 13 | 14 | **EMD** performed on images. This version uses for envelopes 2D splines, 15 | which are span on extrema defined through maximum filter. 16 | 17 | Class 18 | ----- 19 | 20 | .. autoclass:: PyEMD.EMD2D 21 | :members: 22 | :special-members: 23 | -------------------------------------------------------------------------------- /pywt-master/doc/source/ref/index.rst: -------------------------------------------------------------------------------- 1 | .. _ref-index: 2 | 3 | API Reference 4 | ============= 5 | 6 | .. toctree:: 7 | :maxdepth: 2 8 | 9 | wavelets 10 | signal-extension-modes 11 | dwt-discrete-wavelet-transform 12 | idwt-inverse-discrete-wavelet-transform 13 | 2d-decompositions-overview 14 | 2d-dwt-and-idwt 15 | nd-dwt-and-idwt 16 | dwt-coefficient-handling 17 | swt-stationary-wavelet-transform 18 | iswt-inverse-stationary-wavelet-transform 19 | wavelet-packets 20 | cwt 21 | thresholding-functions 22 | other-functions 23 | -------------------------------------------------------------------------------- /pywt-master/doc/source/_templates/quicklinks.html: -------------------------------------------------------------------------------- 1 |
2 |

Quick links

3 | 8 |
9 | -------------------------------------------------------------------------------- /PyEMD-master/doc/index.rst: -------------------------------------------------------------------------------- 1 | 2 | PyEMD's documentation 3 | ===================== 4 | 5 | Writing documentation is hard. If more clarifications are needed, or you 6 | think others might benefit from extra explanation, don't hesitate to contact 7 | me through contact page. 8 | 9 | .. toctree:: 10 | :maxdepth: 2 11 | :caption: Table of Content 12 | 13 | intro 14 | usage 15 | examples 16 | emd 17 | eemd 18 | bemd 19 | ceemdan 20 | visualisation 21 | contact 22 | 23 | Indices and tables 24 | ================== 25 | 26 | * :ref:`genindex` 27 | * :ref:`search` 28 | -------------------------------------------------------------------------------- /pywt-master/.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__ 2 | *.py[co] 3 | *.pyd 4 | *.so 5 | 6 | # Packages 7 | *.egg 8 | *.egg-info 9 | dist 10 | build 11 | .installed.cfg 12 | 13 | # Installer logs 14 | pip-log.txt 15 | 16 | # Unit test / coverage reports 17 | .coverage 18 | .tox 19 | 20 | # Editors 21 | .idea 22 | .project 23 | .pydevproject 24 | .settings 25 | 26 | # Project working files 27 | # Expanded Cython 28 | pywt/_extensions/*.[ch] 29 | pywt/_c99_config.py 30 | pywt/_extensions/config.pxi 31 | cythonize.dat 32 | pywt/version.py 33 | build.log 34 | 35 | # asv files 36 | asv/env 37 | asv/html 38 | asv/pywt 39 | asv/results 40 | -------------------------------------------------------------------------------- /PyEMD-master/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright 2017 Dawid Laszuk 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. 14 | -------------------------------------------------------------------------------- /pywt-master/doc/source/ref/idwt-inverse-discrete-wavelet-transform.rst: -------------------------------------------------------------------------------- 1 | .. _ref-idwt: 2 | 3 | .. currentmodule:: pywt 4 | 5 | ========================================= 6 | Inverse Discrete Wavelet Transform (IDWT) 7 | ========================================= 8 | 9 | 10 | Single level ``idwt`` 11 | --------------------- 12 | 13 | .. autofunction:: idwt 14 | 15 | 16 | Multilevel reconstruction using ``waverec`` 17 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 18 | 19 | .. autofunction:: waverec 20 | 21 | 22 | Direct reconstruction with ``upcoef`` 23 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 24 | 25 | .. autofunction:: upcoef 26 | -------------------------------------------------------------------------------- /PyEMD-master/doc/bemd.rst: -------------------------------------------------------------------------------- 1 | BEMD 2 | ===== 3 | 4 | Warning 5 | ------- 6 | 7 | Important This is an experimental module. Please use it with care as no 8 | guarantee can be given for obtaining reasonable results, or that they will be 9 | computed index the most computation optimal way. 10 | 11 | Info 12 | ---- 13 | 14 | **BEMD** performed on bidimensional data such as images. 15 | This procedure uses morphological operators to detect regional maxima 16 | which are then used to span surface envelope with a radial basis function. 17 | 18 | Class 19 | ----- 20 | 21 | .. autoclass:: PyEMD.BEMD 22 | :members: 23 | :special-members: 24 | -------------------------------------------------------------------------------- /pywt-master/MANIFEST.in: -------------------------------------------------------------------------------- 1 | include setup.py 2 | include pyproject.toml 3 | include README.rst 4 | include LICENSE 5 | include *.txt 6 | include MANIFEST.in 7 | 8 | # All source files 9 | recursive-include pywt * 10 | # All documentation 11 | recursive-include doc * 12 | recursive-include demo * 13 | 14 | # Cached Cython signatures 15 | include cythonize.dat 16 | 17 | # Add build and testing tools 18 | include tox.ini pytest.ini 19 | recursive-include util * 20 | 21 | # Exclude what we don't want to include 22 | prune build 23 | prune doc/build 24 | prune */__pycache__ 25 | 26 | global-exclude *.py[cod] *.egg *.egg-info 27 | global-exclude *~ *.bak *.swp 28 | -------------------------------------------------------------------------------- /pywt-master/doc/source/regression/index.rst: -------------------------------------------------------------------------------- 1 | .. _reg-index: 2 | 3 | .. currentmodule:: pywt 4 | 5 | Usage examples 6 | ============== 7 | 8 | The following examples are used as doctest regression tests written using reST 9 | markup. They are included in the documentation since they contain various useful 10 | examples illustrating how to use and how not to use PyWavelets. 11 | 12 | For more usage examples see the `demo`_ directory in the source package. 13 | 14 | .. toctree:: 15 | :maxdepth: 1 16 | 17 | wavelet 18 | modes 19 | dwt-idwt 20 | multilevel 21 | wp 22 | wp2d 23 | gotchas 24 | 25 | .. include:: ../common_refs.rst 26 | -------------------------------------------------------------------------------- /PyEMD-master/.coveragerc: -------------------------------------------------------------------------------- 1 | # .coveragerc to control coverage.py 2 | [run] 3 | branch = True 4 | 5 | [report] 6 | # Regexes for lines to exclude from consideration 7 | exclude_lines = 8 | # Have to re-enable the standard pragma 9 | pragma: no cover 10 | 11 | # Don't complain about missing debug-only code: 12 | def __repr__ 13 | if self\.debug 14 | 15 | # Don't complain if tests don't hit defensive assertion code: 16 | raise AssertionError 17 | raise NotImplementedError 18 | 19 | # Don't complain if non-runnable code isn't run: 20 | if 0: 21 | if __name__ == .__main__.: 22 | 23 | ignore_errors = True 24 | 25 | [html] 26 | directory = coverage_html_report 27 | -------------------------------------------------------------------------------- /PyEMD-master/doc/#Makefile#: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = python -msphinx 7 | SPHINXPROJ = PyEMD 8 | SOURCEDIR = . 9 | BUILDDIR = .build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /PyEMD-master/doc/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = python -msphinx 7 | SPHINXPROJ = PyEMD 8 | SOURCEDIR = . 9 | BUILDDIR = .build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) -------------------------------------------------------------------------------- /pywt-master/doc/release/1.1.0-notes.rst: -------------------------------------------------------------------------------- 1 | ============================== 2 | PyWavelets 1.1.0 Release Notes 3 | ============================== 4 | 5 | .. contents:: 6 | 7 | We are very pleased to announce the release of PyWavelets 1.1. 8 | 9 | This release requires Python >=3.5 and has dropped Python 2.7 support. 10 | 11 | New features 12 | ============ 13 | 14 | Deprecated features 15 | =================== 16 | 17 | Backwards incompatible changes 18 | ============================== 19 | 20 | Bugs Fixed 21 | ========== 22 | 23 | Other changes 24 | ============= 25 | 26 | Authors 27 | ======= 28 | 29 | Issues closed for v1.1.0 30 | ------------------------ 31 | 32 | Pull requests for v1.1.0 33 | ------------------------ 34 | -------------------------------------------------------------------------------- /pywt-master/doc/source/regression/gotchas.rst: -------------------------------------------------------------------------------- 1 | .. _reg-gotchas: 2 | 3 | .. currentmodule:: pywt 4 | 5 | 6 | ======= 7 | Gotchas 8 | ======= 9 | 10 | PyWavelets utilizes ``NumPy`` under the hood. That's why handling the data 11 | containing ``None`` values can be surprising. ``None`` values are converted to 12 | 'not a number' (``numpy.NaN``) values: 13 | 14 | >>> import numpy, pywt 15 | >>> x = [None, None] 16 | >>> mode = 'symmetric' 17 | >>> wavelet = 'db1' 18 | >>> cA, cD = pywt.dwt(x, wavelet, mode) 19 | >>> numpy.all(numpy.isnan(cA)) 20 | True 21 | >>> numpy.all(numpy.isnan(cD)) 22 | True 23 | >>> rec = pywt.idwt(cA, cD, wavelet, mode) 24 | >>> numpy.all(numpy.isnan(rec)) 25 | True 26 | -------------------------------------------------------------------------------- /pywt-master/doc/source/ref/iswt-inverse-stationary-wavelet-transform.rst: -------------------------------------------------------------------------------- 1 | .. _ref-iswt: 2 | 3 | .. currentmodule:: pywt 4 | 5 | Inverse Stationary Wavelet Transform 6 | ------------------------------------ 7 | 8 | Inverse :ref:`stationary wavelet transforms ` are provided. 9 | 10 | **Note**: These inverse transforms are not yet optimized for speed. Only, the 11 | n-dimensional inverse transform currently has ``axes`` support. 12 | 13 | Multilevel 1D ``iswt`` 14 | ~~~~~~~~~~~~~~~~~~~~~~ 15 | 16 | .. autofunction:: iswt 17 | 18 | Multilevel 2D ``iswt2`` 19 | ~~~~~~~~~~~~~~~~~~~~~~~ 20 | 21 | .. autofunction:: iswt2 22 | 23 | Multilevel n-dimensional ``iswtn`` 24 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 25 | 26 | .. autofunction:: iswtn 27 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/c/wavelets_coeffs.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef TYPE 4 | #error TYPE should not be defined here. 5 | #else 6 | 7 | /* ignore warning about initializing floats from double values */ 8 | #if defined _MSC_VER 9 | #pragma warning (push) 10 | #pragma warning (disable:4305) 11 | #elif defined __GNUC__ 12 | #pragma GCC diagnostic push 13 | #pragma GCC diagnostic ignored "-Wconversion" 14 | #endif 15 | 16 | #define TYPE float 17 | #include "wavelets_coeffs.template.h" 18 | #undef TYPE 19 | 20 | #if defined _MSC_VER 21 | #pragma warning (pop) 22 | #elif defined __GNUC__ 23 | #pragma GCC diagnostic pop 24 | #endif 25 | 26 | #define TYPE double 27 | #include "wavelets_coeffs.template.h" 28 | #undef TYPE 29 | 30 | #endif /* TYPE */ 31 | -------------------------------------------------------------------------------- /pywt-master/pywt/tests/test_doc.py: -------------------------------------------------------------------------------- 1 | from __future__ import division, print_function, absolute_import 2 | 3 | import doctest 4 | import glob 5 | import os 6 | import unittest 7 | 8 | try: 9 | import numpy as np 10 | np.set_printoptions(legacy='1.13') 11 | except TypeError: 12 | pass 13 | 14 | pdir = os.path.pardir 15 | docs_base = os.path.abspath(os.path.join(os.path.dirname(__file__), 16 | pdir, pdir, "doc", "source")) 17 | 18 | files = glob.glob(os.path.join(docs_base, "*.rst")) + \ 19 | glob.glob(os.path.join(docs_base, "*", "*.rst")) 20 | 21 | suite = doctest.DocFileSuite(*files, module_relative=False, encoding="utf-8") 22 | 23 | 24 | if __name__ == "__main__": 25 | unittest.TextTestRunner().run(suite) 26 | -------------------------------------------------------------------------------- /pywt-master/doc/source/pyplots/camera_approx_detail.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | 4 | import pywt 5 | import pywt.data 6 | 7 | 8 | # Load image 9 | original = pywt.data.camera() 10 | 11 | # Wavelet transform of image, and plot approximation and details 12 | titles = ['Approximation', ' Horizontal detail', 13 | 'Vertical detail', 'Diagonal detail'] 14 | coeffs2 = pywt.dwt2(original, 'bior1.3') 15 | LL, (LH, HL, HH) = coeffs2 16 | fig = plt.figure(figsize=(12, 3)) 17 | for i, a in enumerate([LL, LH, HL, HH]): 18 | ax = fig.add_subplot(1, 4, i + 1) 19 | ax.imshow(a, interpolation="nearest", cmap=plt.cm.gray) 20 | ax.set_title(titles[i], fontsize=10) 21 | ax.set_xticks([]) 22 | ax.set_yticks([]) 23 | 24 | fig.tight_layout() 25 | plt.show() 26 | -------------------------------------------------------------------------------- /PyEMD-master/example/simple_example.py: -------------------------------------------------------------------------------- 1 | # Author: Dawid Laszuk 2 | # Last update: 7/07/2017 3 | from __future__ import division, print_function 4 | 5 | import numpy as np 6 | import pylab as plt 7 | from PyEMD import EMD 8 | 9 | # Define signal 10 | t = np.linspace(0, 1, 200) 11 | s = np.cos(11*2*np.pi*t*t) + 6*t*t 12 | 13 | # Execute EMD on signal 14 | IMF = EMD().emd(s,t) 15 | N = IMF.shape[0]+1 16 | 17 | # Plot results 18 | plt.subplot(N,1,1) 19 | plt.plot(t, s, 'r') 20 | plt.title("Input signal: $S(t)=cos(22\pi t^2) + 6t^2$") 21 | plt.xlabel("Time [s]") 22 | 23 | for n, imf in enumerate(IMF): 24 | plt.subplot(N,1,n+2) 25 | plt.plot(t, imf, 'g') 26 | plt.title("IMF "+str(n+1)) 27 | plt.xlabel("Time [s]") 28 | 29 | plt.tight_layout() 30 | plt.savefig('simple_example') 31 | plt.show() 32 | -------------------------------------------------------------------------------- /pywt-master/doc/source/ref/thresholding-functions.rst: -------------------------------------------------------------------------------- 1 | .. _ref-thresholding: 2 | .. currentmodule:: pywt 3 | 4 | Thresholding functions 5 | ====================== 6 | 7 | The :mod:`~pywt.thresholding` helper module implements the most popular signal 8 | thresholding functions. 9 | 10 | Thresholding 11 | ------------ 12 | 13 | .. autofunction:: threshold 14 | .. autofunction:: threshold_firm 15 | 16 | The left panel of the figure below illustrates that non-negative Garotte 17 | thresholding is intermediate between soft and hard thresholding. Firm 18 | thresholding transitions between soft and hard thresholding behavior. It 19 | requires a pair of threshold values that define the width of the transition 20 | region. 21 | 22 | .. plot:: pyplots/plot_thresholds.py 23 | 24 | .. include:: ../common_refs.rst 25 | -------------------------------------------------------------------------------- /pywt-master/pywt/data/create_dat.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """Helper script for creating image .dat files by numpy.save 4 | 5 | Usage: 6 | 7 | python create_dat.py 8 | 9 | Example (to create aero.dat): 10 | 11 | python create_dat.py aero.png aero.dat 12 | 13 | Requires Scipy and PIL. 14 | """ 15 | 16 | from __future__ import print_function 17 | 18 | import sys 19 | 20 | import numpy as np 21 | 22 | 23 | def main(): 24 | from scipy.misc import imread 25 | 26 | if len(sys.argv) != 3: 27 | print(__doc__) 28 | exit() 29 | 30 | image_fname = sys.argv[1] 31 | dat_fname = sys.argv[2] 32 | 33 | data = imread(image_fname) 34 | 35 | np.savez_compressed(dat_fname, data=data) 36 | 37 | 38 | if __name__ == "__main__": 39 | main() 40 | -------------------------------------------------------------------------------- /pywt-master/demo/swt2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import matplotlib.pyplot as plt 5 | 6 | import pywt 7 | import pywt.data 8 | 9 | 10 | arr = pywt.data.aero() 11 | 12 | plt.imshow(arr, interpolation="nearest", cmap=plt.cm.gray) 13 | 14 | level = 0 15 | titles = ['Approximation', ' Horizontal detail', 16 | 'Vertical detail', 'Diagonal detail'] 17 | for LL, (LH, HL, HH) in pywt.swt2(arr, 'bior1.3', level=3, start_level=0): 18 | fig = plt.figure() 19 | for i, a in enumerate([LL, LH, HL, HH]): 20 | ax = fig.add_subplot(2, 2, i + 1) 21 | ax.imshow(a, origin='image', interpolation="nearest", cmap=plt.cm.gray) 22 | ax.set_title(titles[i], fontsize=12) 23 | 24 | fig.suptitle("SWT2 coefficients, level %s" % level, fontsize=14) 25 | level += 1 26 | 27 | 28 | plt.show() 29 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/c/wt.c: -------------------------------------------------------------------------------- 1 | #include "wt.h" 2 | 3 | #ifdef TYPE 4 | #error TYPE should not be defined here. 5 | #else 6 | 7 | #ifdef REAL_TYPE 8 | #error REAL_TYPE should not be defined here. 9 | #else 10 | 11 | #define TYPE float 12 | #define REAL_TYPE float 13 | #include "wt.template.c" 14 | #undef REAL_TYPE 15 | #undef TYPE 16 | 17 | #define TYPE double 18 | #define REAL_TYPE double 19 | #include "wt.template.c" 20 | #undef REAL_TYPE 21 | #undef TYPE 22 | 23 | #ifdef HAVE_C99_COMPLEX 24 | #define TYPE float_complex 25 | #define REAL_TYPE float 26 | #include "wt.template.c" 27 | #undef REAL_TYPE 28 | #undef TYPE 29 | 30 | #define TYPE double_complex 31 | #define REAL_TYPE double 32 | #include "wt.template.c" 33 | #undef REAL_TYPE 34 | #undef TYPE 35 | #endif 36 | 37 | #endif /* REAL_TYPE */ 38 | #endif /* TYPE */ 39 | -------------------------------------------------------------------------------- /pywt-master/doc/source/dev/preparing_linux_build_environment.rst: -------------------------------------------------------------------------------- 1 | .. _dev-preparing-linux-build-environment: 2 | 3 | 4 | Preparing Linux build environment 5 | ================================= 6 | 7 | There is a good chance that you already have a working build environment. 8 | Just skip steps that you don't need to execute. 9 | 10 | 11 | Installing basic build tools 12 | ---------------------------- 13 | 14 | Note that the example below uses ``aptitude`` package manager, which is 15 | specific to Debian and Ubuntu Linux distributions. Use your favourite package 16 | manager to install these packages on your OS. 17 | 18 | :: 19 | 20 | aptitude install build-essential gcc python-dev git-core 21 | 22 | 23 | Next steps 24 | ---------- 25 | 26 | After completing these steps continue with 27 | :ref:`Installing build dependencies `. 28 | -------------------------------------------------------------------------------- /pywt-master/doc/source/dev/index.rst: -------------------------------------------------------------------------------- 1 | .. _dev-index: 2 | 3 | 4 | Development guide 5 | ================= 6 | 7 | This section contains information on building and installing PyWavelets 8 | from source code as well as instructions for preparing the build environment 9 | on Windows and Linux. 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | preparing_windows_build_environment 15 | preparing_linux_build_environment 16 | installing_build_dependencies 17 | building_extension 18 | testing 19 | how_to_release 20 | 21 | Something not working? 22 | ---------------------- 23 | 24 | If these instructions are not clear or you need help setting up your 25 | development environment, go ahead and ask on the PyWavelets discussion 26 | group at http://groups.google.com/group/pywavelets or open a ticket on GitHub_. 27 | 28 | .. _GitHub: https://github.com/PyWavelets/pywt 29 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/c/convolution.c: -------------------------------------------------------------------------------- 1 | #include "convolution.h" 2 | 3 | #ifdef TYPE 4 | #error TYPE should not be defined here. 5 | #else 6 | 7 | #ifdef REAL_TYPE 8 | #error REAL_TYPE should not be defined here. 9 | #else 10 | 11 | #define TYPE float 12 | #define REAL_TYPE float 13 | #include "convolution.template.c" 14 | #undef REAL_TYPE 15 | #undef TYPE 16 | 17 | #define TYPE double 18 | #define REAL_TYPE double 19 | #include "convolution.template.c" 20 | #undef REAL_TYPE 21 | #undef TYPE 22 | 23 | #ifdef HAVE_C99_COMPLEX 24 | #define TYPE float_complex 25 | #define REAL_TYPE float 26 | #include "convolution.template.c" 27 | #undef REAL_TYPE 28 | #undef TYPE 29 | 30 | #define TYPE double_complex 31 | #define REAL_TYPE double 32 | #include "convolution.template.c" 33 | #undef REAL_TYPE 34 | #undef TYPE 35 | #endif 36 | 37 | #endif /* REAL_TYPE */ 38 | #endif /* TYPE */ 39 | -------------------------------------------------------------------------------- /pywt-master/util/appveyor/build.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | :: To build extensions for 64 bit Python 3, we need to configure environment 3 | :: variables to use the MSVC 2010 C++ compilers from GRMSDKX_EN_DVD.iso of: 4 | :: MS Windows SDK for Windows 7 and .NET Framework 4 5 | :: 6 | :: More details at: 7 | :: https://packaging.python.org/appveyor/ 8 | 9 | IF "%DISTUTILS_USE_SDK%"=="1" ( 10 | ECHO Configuring environment to build with MSVC on a 64bit architecture 11 | ECHO Using Windows SDK 7.1 12 | "C:\Program Files\Microsoft SDKs\Windows\v7.1\Setup\WindowsSdkVer.exe" -q -version:v7.1 13 | CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64 /release 14 | SET MSSdk=1 15 | REM Need the following to allow tox to see the SDK compiler 16 | SET TOX_TESTENV_PASSENV=DISTUTILS_USE_SDK MSSdk INCLUDE LIB 17 | ) ELSE ( 18 | ECHO Using default MSVC build environment 19 | ) 20 | 21 | CALL %* 22 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/c/convolution.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | 5 | #ifdef TYPE 6 | #error TYPE should not be defined here. 7 | #else 8 | 9 | #ifdef REAL_TYPE 10 | #error REAL_TYPE should not be defined here. 11 | #else 12 | 13 | #define TYPE float 14 | #define REAL_TYPE float 15 | #include "convolution.template.h" 16 | #undef REAL_TYPE 17 | #undef TYPE 18 | 19 | #define TYPE double 20 | #define REAL_TYPE double 21 | #include "convolution.template.h" 22 | #undef REAL_TYPE 23 | #undef TYPE 24 | 25 | #ifdef HAVE_C99_COMPLEX 26 | #define TYPE float_complex 27 | #define REAL_TYPE float 28 | #include "convolution.template.h" 29 | #undef REAL_TYPE 30 | #undef TYPE 31 | 32 | #define TYPE double_complex 33 | #define REAL_TYPE double 34 | #include "convolution.template.h" 35 | #undef REAL_TYPE 36 | #undef TYPE 37 | #endif 38 | 39 | #endif /* REAL_TYPE */ 40 | #endif /* TYPE */ 41 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/c/wt.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "common.h" 4 | #include "convolution.h" 5 | #include "wavelets.h" 6 | 7 | #ifdef TYPE 8 | #error TYPE should not be defined here. 9 | #else 10 | 11 | #ifdef REAL_TYPE 12 | #error REAL_TYPE should not be defined here. 13 | #else 14 | 15 | #define TYPE float 16 | #define REAL_TYPE float 17 | #include "wt.template.h" 18 | #undef REAL_TYPE 19 | #undef TYPE 20 | 21 | #define TYPE double 22 | #define REAL_TYPE double 23 | #include "wt.template.h" 24 | #undef REAL_TYPE 25 | #undef TYPE 26 | 27 | #ifdef HAVE_C99_COMPLEX 28 | #define TYPE float_complex 29 | #define REAL_TYPE float 30 | #include "wt.template.h" 31 | #undef REAL_TYPE 32 | #undef TYPE 33 | 34 | #define TYPE double_complex 35 | #define REAL_TYPE double 36 | #include "wt.template.h" 37 | #undef REAL_TYPE 38 | #undef TYPE 39 | #endif 40 | 41 | #endif /* REAL_TYPE */ 42 | #endif /* TYPE */ 43 | -------------------------------------------------------------------------------- /pywt-master/demo/fswavedecn.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | from matplotlib import pyplot as plt 3 | import pywt 4 | 5 | img = pywt.data.camera().astype(float) 6 | 7 | # Fully separable transform 8 | fswavedecn_result = pywt.fswavedecn(img, 'db2', 'periodization', levels=4) 9 | 10 | # Standard DWT 11 | coefs = pywt.wavedec2(img, 'db2', 'periodization', level=4) 12 | # convert DWT coefficients to a 2D array 13 | mallat_array, mallat_slices = pywt.coeffs_to_array(coefs) 14 | 15 | 16 | fig, (ax1, ax2) = plt.subplots(1, 2) 17 | 18 | ax1.imshow(np.abs(mallat_array)**0.25, 19 | cmap=plt.cm.gray, 20 | interpolation='nearest') 21 | ax1.set_axis_off() 22 | ax1.set_title('Mallat decomposition\n(wavedec2)') 23 | 24 | ax2.imshow(np.abs(fswavedecn_result.coeffs)**0.25, 25 | cmap=plt.cm.gray, 26 | interpolation='nearest') 27 | ax2.set_axis_off() 28 | ax2.set_title('Fully separable decomposition\n(fswt)') 29 | 30 | plt.show() 31 | -------------------------------------------------------------------------------- /pywt-master/doc/source/ref/swt-stationary-wavelet-transform.rst: -------------------------------------------------------------------------------- 1 | .. _ref-swt: 2 | 3 | .. currentmodule:: pywt 4 | 5 | Stationary Wavelet Transform 6 | ---------------------------- 7 | 8 | `Stationary Wavelet Transform (SWT) 9 | `_, 10 | also known as *Undecimated wavelet transform* or *Algorithme à trous* is a translation-invariance modification of the *Discrete Wavelet Transform* that 11 | does not decimate coefficients at every transformation level. 12 | 13 | Multilevel 1D ``swt`` 14 | ~~~~~~~~~~~~~~~~~~~~~ 15 | 16 | .. autofunction:: swt 17 | 18 | Multilevel 2D ``swt2`` 19 | ~~~~~~~~~~~~~~~~~~~~~~ 20 | 21 | .. autofunction:: swt2 22 | 23 | Multilevel n-dimensional ``swtn`` 24 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 25 | 26 | .. autofunction:: swtn 27 | 28 | Maximum decomposition level - ``swt_max_level`` 29 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 30 | 31 | .. autofunction:: swt_max_level 32 | -------------------------------------------------------------------------------- /pywt-master/.mailmap: -------------------------------------------------------------------------------- 1 | Aaron O'Leary 2 | Alexandre Saint asnt 3 | Arthur Roullier <36152494+0-tree@users.noreply.github.com> 0-tree <36152494+0-tree@users.noreply.github.com> 4 | Daniel M. Pelt Daniel M Pelt 5 | Gregory R. Lee Gregory R. Lee 6 | Gregory R. Lee Gregory Lee 7 | Helder Oliveira Helder 8 | Holger Nahrstaedt Holger Nahrstaedt 9 | Kai Wohlfahrt 10 | Kai Wohlfahrt 11 | Kai Wohlfahrt Kai 12 | Ralf Gommers 13 | Sylvain Lannuzel SylvainLan 14 | -------------------------------------------------------------------------------- /pywt-master/community_guidelines.rst: -------------------------------------------------------------------------------- 1 | Community Guidelines 2 | ==================== 3 | 4 | or How We Work (Together) 5 | ------------------------- 6 | 7 | PyWavelets has adopted a set of community guidelines in common with the 8 | scikit-image project. 9 | 10 | We welcome each and every contributor to PyWavelets. Our aim is 11 | enthusiastic and productive collaboration, to build an excellent 12 | software library, and to have a ton of fun doing it. We encourage one 13 | another to be gentle in criticism of others' work, humble in 14 | acknowledging our own mistakes, and generous in our praise. 15 | 16 | If you ever feel like you are not being treated as well as you should, please 17 | get in touch with one of the project leads (our email addresses are available 18 | through our GitHub profiles). We are committed to making this community a 19 | safe and welcome space. 20 | 21 | You can learn more about contributing to PyWavelets at 22 | http://pywavelets.readthedocs.io/en/latest/#state-of-development-contributing 23 | -------------------------------------------------------------------------------- /pywt-master/demo/wp_visualize_coeffs_distribution.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | 6 | import numpy as np 7 | import matplotlib.pyplot as plt 8 | 9 | from pywt import WaveletPacket 10 | import pywt.data 11 | 12 | 13 | ecg = pywt.data.ecg() 14 | 15 | wp = WaveletPacket(ecg, 'sym5', maxlevel=4) 16 | 17 | fig = plt.figure() 18 | plt.set_cmap('bone') 19 | ax = fig.add_subplot(wp.maxlevel + 1, 1, 1) 20 | ax.plot(ecg, 'k') 21 | ax.set_xlim(0, len(ecg) - 1) 22 | ax.set_title("Wavelet packet coefficients") 23 | 24 | for level in range(1, wp.maxlevel + 1): 25 | ax = fig.add_subplot(wp.maxlevel + 1, 1, level + 1) 26 | nodes = wp.get_level(level, "freq") 27 | nodes.reverse() 28 | labels = [n.path for n in nodes] 29 | values = -abs(np.array([n.data for n in nodes])) 30 | ax.imshow(values, interpolation='nearest', aspect='auto') 31 | ax.set_yticks(np.arange(len(labels) - 0.5, -0.5, -1), labels) 32 | plt.setp(ax.get_xticklabels(), visible=False) 33 | 34 | plt.show() 35 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/_pywt.pxd: -------------------------------------------------------------------------------- 1 | from . cimport wavelet 2 | cimport numpy as np 3 | include "config.pxi" 4 | 5 | ctypedef Py_ssize_t pywt_index_t 6 | 7 | ctypedef fused data_t: 8 | np.float32_t 9 | np.float64_t 10 | 11 | cdef int have_c99_complex 12 | IF HAVE_C99_CPLX: 13 | ctypedef fused cdata_t: 14 | np.float32_t 15 | np.float64_t 16 | np.complex64_t 17 | np.complex128_t 18 | have_c99_complex = 1 19 | ELSE: 20 | ctypedef data_t cdata_t 21 | have_c99_complex = 0 22 | 23 | cdef public class Wavelet [type WaveletType, object WaveletObject]: 24 | cdef wavelet.DiscreteWavelet* w 25 | 26 | cdef readonly name 27 | cdef readonly number 28 | 29 | cdef public class ContinuousWavelet [type ContinuousWaveletType, object ContinuousWaveletObject]: 30 | cdef wavelet.ContinuousWavelet* w 31 | 32 | cdef readonly name 33 | cdef readonly number 34 | cdef readonly dt 35 | 36 | cpdef np.dtype _check_dtype(data) 37 | 38 | # FIXME: To be removed 39 | cdef c_wavelet_from_object(wavelet) 40 | -------------------------------------------------------------------------------- /pywt-master/demo/cwt_analysis.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import numpy as np 5 | import matplotlib.pyplot as plt 6 | 7 | import pywt 8 | 9 | time, sst = pywt.data.nino() 10 | dt = time[1] - time[0] 11 | 12 | # Taken from http://nicolasfauchereau.github.io/climatecode/posts/wavelet-analysis-in-python/ 13 | wavelet = 'cmor1.5-1.0' 14 | scales = np.arange(1, 128) 15 | 16 | [cfs, frequencies] = pywt.cwt(sst, scales, wavelet, dt) 17 | power = (abs(cfs)) ** 2 18 | 19 | period = 1. / frequencies 20 | levels = [0.0625, 0.125, 0.25, 0.5, 1, 2, 4, 8] 21 | f, ax = plt.subplots(figsize=(15, 10)) 22 | ax.contourf(time, np.log2(period), np.log2(power), np.log2(levels), 23 | extend='both') 24 | 25 | ax.set_title('%s Wavelet Power Spectrum (%s)' % ('Nino1+2', wavelet)) 26 | ax.set_ylabel('Period (years)') 27 | Yticks = 2 ** np.arange(np.ceil(np.log2(period.min())), 28 | np.ceil(np.log2(period.max()))) 29 | ax.set_yticks(np.log2(Yticks)) 30 | ax.set_yticklabels(Yticks) 31 | ax.invert_yaxis() 32 | ylim = ax.get_ylim() 33 | ax.set_ylim(ylim[0], -1) 34 | 35 | plt.show() 36 | -------------------------------------------------------------------------------- /PyEMD-master/example/eemd_example.py: -------------------------------------------------------------------------------- 1 | # Author: Dawid Laszuk 2 | # Last update: 7/07/2017 3 | from __future__ import division, print_function 4 | 5 | from PyEMD import EEMD 6 | import numpy as np 7 | import pylab as plt 8 | 9 | # Define signal 10 | t = np.linspace(0, 1, 200) 11 | 12 | sin = lambda x,p: np.sin(2*np.pi*x*t+p) 13 | S = 3*sin(18,0.2)*(t-0.2)**2 14 | S += 5*sin(11,2.7) 15 | S += 3*sin(14,1.6) 16 | S += 1*np.sin(4*2*np.pi*(t-0.8)**2) 17 | S += t**2.1 -t 18 | 19 | # Assign EEMD to `eemd` variable 20 | eemd = EEMD() 21 | 22 | # Say we want detect extrema using parabolic method 23 | emd = eemd.EMD 24 | emd.extrema_detection="parabol" 25 | 26 | # Execute EEMD on S 27 | eIMFs = eemd.eemd(S, t) 28 | nIMFs = eIMFs.shape[0] 29 | 30 | # Plot results 31 | plt.figure(figsize=(12,9)) 32 | plt.subplot(nIMFs+1, 1, 1) 33 | plt.plot(t, S, 'r') 34 | 35 | for n in range(nIMFs): 36 | plt.subplot(nIMFs+1, 1, n+2) 37 | plt.plot(t, eIMFs[n], 'g') 38 | plt.ylabel("eIMF %i" %(n+1)) 39 | plt.locator_params(axis='y', nbins=5) 40 | 41 | plt.xlabel("Time [s]") 42 | plt.tight_layout() 43 | plt.savefig('eemd_example', dpi=120) 44 | plt.show() 45 | -------------------------------------------------------------------------------- /pywt-master/doc/source/pyplots/plot_thresholds.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import matplotlib.pyplot as plt 3 | import pywt 4 | 5 | s = np.linspace(-4, 4, 1000) 6 | 7 | s_soft = pywt.threshold(s, value=0.5, mode='soft') 8 | s_hard = pywt.threshold(s, value=0.5, mode='hard') 9 | s_garrote = pywt.threshold(s, value=0.5, mode='garrote') 10 | s_firm1 = pywt.threshold_firm(s, value_low=0.5, value_high=1) 11 | s_firm2 = pywt.threshold_firm(s, value_low=0.5, value_high=2) 12 | s_firm3 = pywt.threshold_firm(s, value_low=0.5, value_high=4) 13 | 14 | fig, ax = plt.subplots(1, 2, figsize=(10, 4)) 15 | ax[0].plot(s, s_soft) 16 | ax[0].plot(s, s_hard) 17 | ax[0].plot(s, s_garrote) 18 | ax[0].legend(['soft (0.5)', 'hard (0.5)', 'non-neg. garrote (0.5)']) 19 | ax[0].set_xlabel('input value') 20 | ax[0].set_ylabel('thresholded value') 21 | 22 | ax[1].plot(s, s_soft) 23 | ax[1].plot(s, s_hard) 24 | ax[1].plot(s, s_firm1) 25 | ax[1].plot(s, s_firm2) 26 | ax[1].plot(s, s_firm3) 27 | ax[1].legend(['soft (0.5)', 'hard (0.5)', 'firm(0.5, 1)', 'firm(0.5, 2)', 28 | 'firm(0.5, 4)']) 29 | ax[1].set_xlabel('input value') 30 | ax[1].set_ylabel('thresholded value') 31 | plt.show() 32 | -------------------------------------------------------------------------------- /pywt-master/doc/source/common_refs.rst: -------------------------------------------------------------------------------- 1 | .. _built-in wavelet filters: http://wavelets.pybytes.com/ 2 | .. _Cython: http://cython.org/ 3 | .. _demo: https://github.com/PyWavelets/pywt/tree/master/demo 4 | .. _Anaconda: https://www.continuum.io 5 | .. _GitHub: https://github.com/PyWavelets/pywt 6 | .. _GitHub repository: https://github.com/PyWavelets/pywt 7 | .. _GitHub Issues: https://github.com/PyWavelets/pywt/issues 8 | .. _NumPy: https://www.numpy.org 9 | .. _SciPy: https://www.scipy.org 10 | .. _original developer: http://en.ig.ma 11 | .. _Python: http://python.org/ 12 | .. _Python Package Index: http://pypi.python.org/pypi/PyWavelets/ 13 | .. _PyPI: http://pypi.python.org/pypi/PyWavelets/ 14 | .. _PyWavelets discussions group: http://groups.google.com/group/pywavelets 15 | .. _Releases Page: https://github.com/PyWavelets/pywt/releases 16 | .. _Matplotlib: http://matplotlib.org 17 | .. _guidelines for pull requests: https://github.com/PyWavelets/pywt/tree/master/CONTRIBUTING.rst 18 | .. _community guidelines: https://github.com/PyWavelets/pywt/tree/master/community_guidelines.rst 19 | .. _StackOverflow: https://stackoverflow.com 20 | .. _wavelets.pybytes.com: http://wavelets.pybytes.com/ 21 | -------------------------------------------------------------------------------- /pywt-master/doc/source/ref/nd-dwt-and-idwt.rst: -------------------------------------------------------------------------------- 1 | .. _ref-dwtn: 2 | 3 | ================================================= 4 | nD Forward and Inverse Discrete Wavelet Transform 5 | ================================================= 6 | 7 | .. currentmodule:: pywt 8 | 9 | .. autosummary:: _multilevel 10 | 11 | Single level - ``dwtn`` 12 | ----------------------- 13 | .. autofunction:: dwtn 14 | 15 | Single level - ``idwtn`` 16 | ------------------------ 17 | .. autofunction:: idwtn 18 | 19 | Multilevel decomposition - ``wavedecn`` 20 | --------------------------------------- 21 | .. autofunction:: wavedecn 22 | 23 | Multilevel reconstruction - ``waverecn`` 24 | ---------------------------------------- 25 | .. autofunction:: waverecn 26 | 27 | Multilevel fully separable decomposition - ``fswavedecn`` 28 | --------------------------------------------------------- 29 | .. autofunction:: fswavedecn 30 | 31 | Multilevel fully separable reconstruction - ``fswaverecn`` 32 | ---------------------------------------------------------- 33 | .. autofunction:: fswaverecn 34 | 35 | Multilevel fully separable reconstruction coeffs - ``FswavedecnResult`` 36 | ----------------------------------------------------------------------- 37 | .. autoclass:: FswavedecnResult 38 | -------------------------------------------------------------------------------- /pywt-master/doc/source/contributing.rst: -------------------------------------------------------------------------------- 1 | Contributing 2 | ============ 3 | 4 | All contributions including bug reports, bug fixes, new feature implementations 5 | and documentation improvements are welcome. Moreover, developers with an 6 | interest in PyWavelets are very welcome to join the development team! Please 7 | see our `guidelines for pull requests`_ for more information. 8 | 9 | Contributors are expected to behave in a productive and respectful manner in 10 | accordance with our `community guidelines`_. 11 | 12 | 13 | History 14 | ------- 15 | 16 | PyWavelets started in 2006 as an academic project for a masters thesis 17 | on `Analysis and Classification of Medical Signals using Wavelet Transforms` 18 | and was maintained until 2012 by its `original developer`_. In 2013 19 | maintenance was taken over in a `new repo `_) 20 | by a larger development team - a move supported by the original developer. 21 | The repo move doesn't mean that this is a fork - the package continues to be 22 | developed under the name "PyWavelets", and released on PyPI and Github (see 23 | `this issue `_ for the discussion 24 | where that was decided). 25 | 26 | .. include:: common_refs.rst 27 | -------------------------------------------------------------------------------- /pywt-master/doc/source/ref/dwt-coefficient-handling.rst: -------------------------------------------------------------------------------- 1 | .. _ref-dwt-coef: 2 | 3 | ========================= 4 | Handling DWT Coefficients 5 | ========================= 6 | 7 | Convenience routines are available for converting the outputs of the multilevel 8 | dwt functions (``wavedec``, ``wavedec2`` and ``wavedecn``) to and from a 9 | single, concatenated coefficient array. 10 | 11 | .. currentmodule:: pywt 12 | 13 | Concatenating all coefficients into a single n-d array 14 | ------------------------------------------------------ 15 | .. autofunction:: coeffs_to_array 16 | 17 | Splitting concatenated coefficient array back into its components 18 | ----------------------------------------------------------------- 19 | .. autofunction:: array_to_coeffs 20 | 21 | Raveling and unraveling coefficients to/from a 1D array 22 | ------------------------------------------------------- 23 | .. autofunction:: ravel_coeffs 24 | .. autofunction:: unravel_coeffs 25 | 26 | Multilevel: Total size of all coefficients - ``wavedecn_size`` 27 | -------------------------------------------------------------- 28 | .. autofunction:: wavedecn_size 29 | 30 | Multilevel: n-d coefficient shapes - ``wavedecn_shapes`` 31 | -------------------------------------------------------- 32 | .. autofunction:: wavedecn_shapes 33 | -------------------------------------------------------------------------------- /pywt-master/pywt/__init__.py: -------------------------------------------------------------------------------- 1 | # flake8: noqa 2 | 3 | # Copyright (c) 2006-2012 Filip Wasilewski 4 | # Copyright (c) 2012-2016 The PyWavelets Developers 5 | # 6 | # See COPYING for license details. 7 | 8 | """ 9 | Discrete forward and inverse wavelet transform, stationary wavelet transform, 10 | wavelet packets signal decomposition and reconstruction module. 11 | """ 12 | 13 | from __future__ import division, print_function, absolute_import 14 | from distutils.version import LooseVersion 15 | 16 | from ._extensions._pywt import * 17 | from ._functions import * 18 | from ._multilevel import * 19 | from ._multidim import * 20 | from ._thresholding import * 21 | from ._wavelet_packets import * 22 | from ._dwt import * 23 | from ._swt import * 24 | from ._cwt import * 25 | 26 | from . import data 27 | 28 | __all__ = [s for s in dir() if not s.startswith('_')] 29 | try: 30 | # In Python 2.x the name of the tempvar leaks out of the list 31 | # comprehension. Delete it to not make it show up in the main namespace. 32 | del s 33 | except NameError: 34 | pass 35 | 36 | from pywt.version import version as __version__ 37 | 38 | from ._pytesttester import PytestTester 39 | test = PytestTester(__name__) 40 | del PytestTester 41 | -------------------------------------------------------------------------------- /PyEMD-master/example/image_example.py: -------------------------------------------------------------------------------- 1 | # Author: Dawid Laszuk 2 | # Last update: 7/07/2017 3 | from __future__ import division, print_function 4 | 5 | import numpy as np 6 | import pylab as plt 7 | from PyEMD import EMD2D 8 | 9 | # Generate image 10 | print("Generating image... ", end="") 11 | rows, cols = 1024, 1024 12 | row_scale, col_scale = 256, 256 13 | x = np.arange(rows)/float(row_scale) 14 | y = np.arange(cols).reshape((-1,1))/float(col_scale) 15 | 16 | pi2 = 2*np.pi 17 | img = np.zeros((rows,cols)) 18 | img = img + np.sin(2*pi2*x)*np.cos(y*4*pi2+4*x*pi2) 19 | img = img + 3*np.sin(2*pi2*x)+2 20 | img = img + 5*x*y + 2*(y-0.2)*y 21 | print("Done") 22 | 23 | # Perform decomposition 24 | print("Performing decomposition... ", end="") 25 | emd2d = EMD2D() 26 | #emd2d.FIXE_H = 5 27 | IMFs = emd2d.emd(img, max_imf=4) 28 | imfNo = IMFs.shape[0] 29 | print("Done") 30 | 31 | print("Plotting results... ", end="") 32 | 33 | # Save image for preview 34 | plt.figure(figsize=(4,4*(imfNo+1))) 35 | plt.subplot(imfNo+1, 1, 1) 36 | plt.imshow(img) 37 | plt.colorbar() 38 | plt.title("Input image") 39 | 40 | # Save reconstruction 41 | for n, imf in enumerate(IMFs): 42 | plt.subplot(imfNo+1, 1, n+2) 43 | plt.imshow(imf) 44 | plt.colorbar() 45 | plt.title("IMF %i"%(n+1)) 46 | 47 | plt.savefig("image_decomp") 48 | print("Done") 49 | 50 | -------------------------------------------------------------------------------- /pywt-master/doc/source/dev/building_extension.rst: -------------------------------------------------------------------------------- 1 | .. _dev-building-extension: 2 | 3 | Building and installing PyWavelets 4 | ================================== 5 | 6 | Installing from source code 7 | --------------------------- 8 | 9 | Go to https://github.com/PyWavelets/pywt GitHub project page, fork and clone the 10 | repository or use the upstream repository to get the source code:: 11 | 12 | git clone https://github.com/PyWavelets/pywt.git PyWavelets 13 | 14 | Activate your Python virtual environment, go to the cloned source directory 15 | and type the following commands to build and install the package:: 16 | 17 | python setup.py build 18 | python setup.py install 19 | 20 | To verify the installation run the following command:: 21 | 22 | python setup.py test 23 | 24 | To build docs:: 25 | 26 | cd doc 27 | make html 28 | 29 | Installing a development version 30 | -------------------------------- 31 | 32 | You can also install directly from the source repository:: 33 | 34 | pip install -e git+https://github.com/PyWavelets/pywt.git#egg=PyWavelets 35 | 36 | or:: 37 | 38 | pip install PyWavelets==dev 39 | 40 | 41 | Installing a regular release from PyPi 42 | -------------------------------------- 43 | 44 | A regular release can be installed with pip or easy_install:: 45 | 46 | pip install PyWavelets 47 | 48 | -------------------------------------------------------------------------------- /pywt-master/pywt/tests/test_functions.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | from __future__ import division, print_function, absolute_import 3 | 4 | from numpy.testing import assert_almost_equal, assert_allclose 5 | 6 | import pywt 7 | 8 | 9 | def test_centrfreq(): 10 | # db1 is Haar function, frequency=1 11 | w = pywt.Wavelet('db1') 12 | expected = 1 13 | result = pywt.central_frequency(w, precision=12) 14 | assert_almost_equal(result, expected, decimal=3) 15 | # db2, frequency=2/3 16 | w = pywt.Wavelet('db2') 17 | expected = 2/3. 18 | result = pywt.central_frequency(w, precision=12) 19 | assert_almost_equal(result, expected) 20 | 21 | 22 | def test_scal2frq_scale(): 23 | scale = 2 24 | w = pywt.Wavelet('db1') 25 | expected = 1. / scale 26 | result = pywt.scale2frequency(w, scale, precision=12) 27 | assert_almost_equal(result, expected, decimal=3) 28 | 29 | 30 | def test_intwave_orthogonal(): 31 | w = pywt.Wavelet('db1') 32 | int_psi, x = pywt.integrate_wavelet(w, precision=12) 33 | ix = x < 0.5 34 | # For x < 0.5, the integral is equal to x 35 | assert_allclose(int_psi[ix], x[ix]) 36 | # For x > 0.5, the integral is equal to (1 - x) 37 | # Ignore last point here, there x > 1 and something goes wrong 38 | assert_allclose(int_psi[~ix][:-1], 1 - x[~ix][:-1], atol=1e-10) 39 | -------------------------------------------------------------------------------- /PyEMD-master/PyEMD/splines.py: -------------------------------------------------------------------------------- 1 | from __future__ import division 2 | import numpy as np 3 | from scipy.interpolate import Akima1DInterpolator 4 | 5 | def cubic_spline_3pts(x, y, T): 6 | """ 7 | Apperently scipy.interpolate.interp1d does not support 8 | cubic spline for less than 4 points. 9 | """ 10 | 11 | x0, x1, x2 = x 12 | y0, y1, y2 = y 13 | 14 | x1x0, x2x1 = x1-x0, x2-x1 15 | y1y0, y2y1 = y1-y0, y2-y1 16 | _x1x0, _x2x1 = 1./x1x0, 1./x2x1 17 | 18 | m11, m12, m13= 2*_x1x0, _x1x0, 0 19 | m21, m22, m23 = _x1x0, 2.*(_x1x0+_x2x1), _x2x1 20 | m31, m32, m33 = 0, _x2x1, 2.*_x2x1 21 | 22 | v1 = 3*y1y0*_x1x0*_x1x0 23 | v3 = 3*y2y1*_x2x1*_x2x1 24 | v2 = v1+v3 25 | 26 | M = np.array([[m11,m12,m13],[m21,m22,m23],[m31,m32,m33]]) 27 | v = np.array([v1,v2,v3]).T 28 | k = np.array(np.linalg.inv(M).dot(v)) 29 | 30 | a1 = k[0]*x1x0 - y1y0 31 | b1 =-k[1]*x1x0 + y1y0 32 | a2 = k[1]*x2x1 - y2y1 33 | b2 =-k[2]*x2x1 + y2y1 34 | 35 | t = T[np.r_[T>=x0] & np.r_[T<=x2]] 36 | t1 = (T[np.r_[T>=x0]&np.r_[T< x1]] - x0)/x1x0 37 | t2 = (T[np.r_[T>=x1]&np.r_[T<=x2]] - x1)/x2x1 38 | t11, t22 = 1.-t1, 1.-t2 39 | 40 | q1 = t11*y0 + t1*y1 + t1*t11*(a1*t11 + b1*t1) 41 | q2 = t22*y1 + t2*y2 + t2*t22*(a2*t22 + b2*t2) 42 | q = np.append(q1,q2) 43 | 44 | return t, q 45 | 46 | def akima(X, Y, x): 47 | 48 | spl = Akima1DInterpolator(X,Y) 49 | return spl(x) 50 | 51 | -------------------------------------------------------------------------------- /pywt-master/tox.ini: -------------------------------------------------------------------------------- 1 | # Tox (http://tox.testrun.org/) is a tool for running tests 2 | # in multiple virtualenvs. This configuration file will run the 3 | # test suite on all supported python versions. To use it, "pip install tox" 4 | # and then run "tox" from this directory. 5 | 6 | # Running the command 'tox' while in the root of the pywt source 7 | # directory will: 8 | # - Create a pywt source distribution (setup.py sdist) 9 | # - Then for every supported version of Python: 10 | # - Create a virtualenv in {homedir}/.tox/pywt/py$VERSION and 11 | # install dependencies. (These virtualenvs are cached across 12 | # runs unless you use --recreate.) 13 | # - Use pip to install the pywt sdist into the virtualenv 14 | # - Run the pywt tests 15 | # To run against a specific subset of Python versions, use: 16 | # tox -e py36,py37 17 | 18 | # Tox assumes that you have appropriate Python interpreters already 19 | # installed and that they can be run as 'python3.6', 'python3.7', etc. 20 | 21 | [tox] 22 | toxworkdir = {homedir}/.tox/pywt/ 23 | envlist = py35, py36, py37 24 | 25 | [testenv] 26 | deps = 27 | flake8 28 | pytest 29 | coverage 30 | cython 31 | numpy 32 | matplotlib 33 | changedir = {envdir} 34 | commands = 35 | pytest {toxinidir}/pywt/tests -v 36 | # flake8 --exit-zero pywt 37 | 38 | [pep8] 39 | max_line_length = 79 40 | statistics = True 41 | ignore = E121,E122,E123,E125,E126,E127,E128,E226,E231,E501,E712 42 | -------------------------------------------------------------------------------- /pywt-master/demo/_dwt_decompose.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Note: this currently doesn't get installed. There's also no way to query 3 | * the location of wt.h. Conclusion: there is no C API. 4 | */ 5 | 6 | #include 7 | 8 | #include "wt.h" 9 | 10 | int main(){ 11 | 12 | // Using C API to decompose 1D signal. 13 | // Results equivalent to pywt.dwt([1,2,3,4,5,6,7,8], 'db2', 'zpd'). 14 | // Compile: gcc -I../src dwt_decompose.c ../src/wt.c ../src/wavelets.c ../src/common.c ../src/convolution.c 15 | 16 | Wavelet *w = wavelet('d', 2); 17 | MODE mode = MODE_ZEROPAD; 18 | 19 | int i; 20 | float input[] = {1,2,3,4,5,6,7,8,9}; 21 | float *cA, *cD; 22 | pywt_index_t input_len, output_len; 23 | 24 | input_len = sizeof input / sizeof input[0]; 25 | output_len = dwt_buffer_length(input_len, w->dec_len, mode); 26 | 27 | cA = wtcalloc(output_len, sizeof(float)); 28 | cD = wtcalloc(output_len, sizeof(float)); 29 | 30 | printf("Wavelet: %s %d\n\n", w->family_name, w->vanishing_moments_psi); 31 | 32 | float_dec_a(input, input_len, w, cA, output_len, mode); 33 | float_dec_d(input, input_len, w, cD, output_len, mode); 34 | 35 | for(i=0; i 2 | Copyright (c) 2012-2019 The PyWavelets Developers 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy of 5 | this software and associated documentation files (the "Software"), to deal in 6 | the Software without restriction, including without limitation the rights to 7 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 8 | of the Software, and to permit persons to whom the Software is furnished to do 9 | so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in all 12 | copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 20 | SOFTWARE. 21 | 22 | 23 | The PyWavelets repository and source distributions bundle some code that is 24 | adapted from compatibly licensed projects. We list these here. 25 | 26 | Name: NumPy 27 | Files: pywt/_pytesttester.py 28 | License: 3-clause BSD 29 | 30 | Name: SciPy 31 | Files: setup.py, util/* 32 | License: 3-clause BSD 33 | -------------------------------------------------------------------------------- /pywt-master/demo/plot_demo_signals.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | """Plot the set of 1D demo signals available in `pywt.data.demo_signal`.""" 5 | 6 | import numpy as np 7 | 8 | import matplotlib.pyplot as plt 9 | 10 | import pywt 11 | 12 | # use 'list' to get a list of all available 1d demo signals 13 | signals = pywt.data.demo_signal('list') 14 | 15 | subplots_per_fig = 5 16 | signal_length = 1024 17 | i_fig = 0 18 | n_figures = int(np.ceil(len(signals)/subplots_per_fig)) 19 | for i_fig in range(n_figures): 20 | # Select a subset of functions for the current plot 21 | func_subset = signals[ 22 | i_fig * subplots_per_fig:(i_fig + 1) * subplots_per_fig] 23 | 24 | # create a figure to hold this subset of the functions 25 | fig, axes = plt.subplots(subplots_per_fig, 1) 26 | axes = axes.ravel() 27 | for n, signal in enumerate(func_subset): 28 | if signal in ['Gabor', 'sineoneoverx']: 29 | # user cannot specify a length for these two 30 | x = pywt.data.demo_signal(signal) 31 | else: 32 | x = pywt.data.demo_signal(signal, signal_length) 33 | ax = axes[n] 34 | ax.plot(x.real) 35 | if signal == 'Gabor': 36 | # The Gabor signal is complex-valued 37 | ax.plot(x.imag) 38 | ax.legend(['Gabor (Re)', 'Gabor (Im)'], loc='upper left') 39 | else: 40 | ax.legend([signal, ], loc='upper left') 41 | # omit axes for any unused subplots 42 | for n in range(n + 1, len(axes)): 43 | axes[n].set_axis_off() 44 | plt.show() 45 | -------------------------------------------------------------------------------- /pywt-master/appveyor.yml: -------------------------------------------------------------------------------- 1 | # AppVeyor.com is a Continuous Integration service to build and run tests under 2 | # Windows 3 | # https://ci.appveyor.com/project/PyWavelets/pywt 4 | 5 | # This file is built on the template here: 6 | # http://python-packaging-user-guide.readthedocs.org/en/latest/appveyor/ 7 | 8 | environment: 9 | matrix: 10 | - PYTHON: "C:\\Python34" 11 | - PYTHON: "C:\\Python34-x64" 12 | DISTUTILS_USE_SDK: "1" 13 | - PYTHON: "C:\\Python35" 14 | - PYTHON: "C:\\Python35-x64" 15 | - PYTHON: "C:\\Python36" 16 | - PYTHON: "C:\\Python36-x64" 17 | 18 | build: off 19 | 20 | install: 21 | - "util\\appveyor\\build.cmd %PYTHON%\\python.exe -m pip install --upgrade pip" 22 | - "util\\appveyor\\build.cmd %PYTHON%\\python.exe -m pip install --upgrade wheel" 23 | - "util\\appveyor\\build.cmd %PYTHON%\\python.exe -m pip install 24 | numpy --cache-dir c:\\tmp\\pip-cache" 25 | - "util\\appveyor\\build.cmd %PYTHON%\\python.exe -m pip install 26 | Cython pytest coverage matplotlib futures --cache-dir c:\\tmp\\pip-cache" 27 | 28 | test_script: 29 | - "util\\appveyor\\build.cmd %PYTHON%\\python.exe -m pip install -e . -v" 30 | - "cd demo" 31 | - "%PYTHON%\\Scripts\\pytest --pyargs pywt" 32 | - "cd .." 33 | 34 | after_test: 35 | - "util\\appveyor\\build.cmd %PYTHON%\\python.exe setup.py bdist_wheel" 36 | 37 | artifacts: 38 | # Archive the generated wheel package in the ci.appveyor.com build report. 39 | - path: dist\* 40 | 41 | cache: 42 | # Cache can be manuall cleared like this: 43 | # https://github.com/appveyor/ci/issues/207 44 | - "c:\\tmp\\pip-cache" 45 | -------------------------------------------------------------------------------- /pywt-master/doc/source/pyplots/plot_boundary_modes.py: -------------------------------------------------------------------------------- 1 | """A visual illustration of the various signal extension modes supported in 2 | PyWavelets. For efficiency, in the C routines the array is not actually 3 | extended as is done here. This is just a demo for easier visual explanation of 4 | the behavior of the various boundary modes. 5 | 6 | In practice, which signal extension mode is beneficial will depend on the 7 | signal characteristics. For this particular signal, some modes such as 8 | "periodic", "antisymmetric" and "zeros" result in large discontinuities that 9 | would lead to large amplitude boundary coefficients in the detail coefficients 10 | of a discrete wavelet transform. 11 | """ 12 | import numpy as np 13 | from matplotlib import pyplot as plt 14 | from pywt._doc_utils import boundary_mode_subplot 15 | 16 | # synthetic test signal 17 | x = 5 - np.linspace(-1.9, 1.1, 9)**2 18 | 19 | # Create a figure with one subplots per boundary mode 20 | fig, axes = plt.subplots(3, 3, figsize=(10, 6)) 21 | plt.subplots_adjust(hspace=0.5) 22 | axes = axes.ravel() 23 | boundary_mode_subplot(x, 'symmetric', axes[0], symw=False) 24 | boundary_mode_subplot(x, 'reflect', axes[1], symw=True) 25 | boundary_mode_subplot(x, 'periodic', axes[2], symw=False) 26 | boundary_mode_subplot(x, 'antisymmetric', axes[3], symw=False) 27 | boundary_mode_subplot(x, 'antireflect', axes[4], symw=True) 28 | boundary_mode_subplot(x, 'periodization', axes[5], symw=False) 29 | boundary_mode_subplot(x, 'smooth', axes[6], symw=False) 30 | boundary_mode_subplot(x, 'constant', axes[7], symw=False) 31 | boundary_mode_subplot(x, 'zeros', axes[8], symw=False) 32 | plt.show() 33 | -------------------------------------------------------------------------------- /pywt-master/doc/source/dev/testing.rst: -------------------------------------------------------------------------------- 1 | .. _dev-testing: 2 | 3 | Testing 4 | ======= 5 | 6 | Continous integration with Travis-CI 7 | ------------------------------------ 8 | 9 | The project is using `Travis-CI `_ service 10 | for continuous integration and testing. 11 | 12 | Current build status is: 13 | 14 | .. image:: 15 | https://secure.travis-ci.org/PyWavelets/pywt.png?branch=master 16 | :alt: Build Status 17 | :target: https://secure.travis-ci.org/PyWavelets/pywt 18 | 19 | If you are submitting a patch or pull request please make sure it 20 | does not break the build. 21 | 22 | 23 | Running tests locally 24 | --------------------- 25 | 26 | Tests are implemented with `pytest`_, so use one of: 27 | 28 | $ pytest --pyargs pywt -v 29 | 30 | There are also older doctests that can be run by performing the following from 31 | the root of the project source. 32 | 33 | $ python pywt/tests/test_doc.py 34 | $ cd doc 35 | $ make doctest 36 | 37 | Additionally the examples in the demo subfolder can be checked by running: 38 | 39 | $ python util/refguide_check.py 40 | 41 | Note: doctests require `Matplotlib`_ in addition to the usual dependencies. 42 | 43 | 44 | Running tests with Tox 45 | ---------------------- 46 | 47 | There's also a config file for running tests with `Tox`_ (``pip install tox``). 48 | To for example run tests for Python 3.5 and 3.6 use:: 49 | 50 | tox -e py35,py36 51 | 52 | For more information see the `Tox`_ documentation. 53 | 54 | 55 | .. _pytest: https://pytest.org 56 | .. _Tox: https://tox.readthedocs.io/en/latest/ 57 | .. _Matplotlib: https://matplotlib.org 58 | -------------------------------------------------------------------------------- /pywt-master/doc/source/pyplots/plot_mallat_2d.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pywt 3 | from matplotlib import pyplot as plt 4 | from pywt._doc_utils import wavedec2_keys, draw_2d_wp_basis 5 | 6 | x = pywt.data.camera().astype(np.float32) 7 | shape = x.shape 8 | 9 | max_lev = 3 # how many levels of decomposition to draw 10 | label_levels = 3 # how many levels to explicitly label on the plots 11 | 12 | fig, axes = plt.subplots(2, 4, figsize=[14, 8]) 13 | for level in range(0, max_lev + 1): 14 | if level == 0: 15 | # show the original image before decomposition 16 | axes[0, 0].set_axis_off() 17 | axes[1, 0].imshow(x, cmap=plt.cm.gray) 18 | axes[1, 0].set_title('Image') 19 | axes[1, 0].set_axis_off() 20 | continue 21 | 22 | # plot subband boundaries of a standard DWT basis 23 | draw_2d_wp_basis(shape, wavedec2_keys(level), ax=axes[0, level], 24 | label_levels=label_levels) 25 | axes[0, level].set_title('{} level\ndecomposition'.format(level)) 26 | 27 | # compute the 2D DWT 28 | c = pywt.wavedec2(x, 'db2', mode='periodization', level=level) 29 | # normalize each coefficient array independently for better visibility 30 | c[0] /= np.abs(c[0]).max() 31 | for detail_level in range(level): 32 | c[detail_level + 1] = [d/np.abs(d).max() for d in c[detail_level + 1]] 33 | # show the normalized coefficients 34 | arr, slices = pywt.coeffs_to_array(c) 35 | axes[1, level].imshow(arr, cmap=plt.cm.gray) 36 | axes[1, level].set_title('Coefficients\n({} level)'.format(level)) 37 | axes[1, level].set_axis_off() 38 | 39 | plt.tight_layout() 40 | plt.show() 41 | -------------------------------------------------------------------------------- /PyEMD-master/doc/intro.rst: -------------------------------------------------------------------------------- 1 | Intro 2 | ===== 3 | 4 | General 5 | ------- 6 | 7 | **PyEMD** is a Python implementation of `Empirical Mode Decomposition (EMD) `_ and its variations. 8 | One of the most popular expansion is `Ensemble Empirical Mode Decomposition (EEMD) `_, which utilises an ensemble of noise-assisted executions. 9 | 10 | As a result of *EMD* one will obtain a set of components that possess oscillatory features. In case of plain *EMD* algorithm, these are called Intrinsic Mode Functions (IMFs) as they are expected to have a single `mode `_. In contrary, *EEMD* will unlikely produce pure oscillations as the effects of injected noise can propagate throughout the decomposition. 11 | 12 | Installation 13 | ------------ 14 | 15 | Recommended 16 | ``````````` 17 | 18 | In order to get the newest version it is recommended to download source code from git repository. **Don't worry, installation is simple.** 19 | Simply download this directory either directly from GitHub, or using command line: :: 20 | 21 | $ git clone https://github.com/laszukdawid/PyEMD 22 | 23 | Then go into the downloaded project and run from command line: :: 24 | 25 | $ python setup.py install 26 | 27 | 28 | PyPi (simplest) 29 | ``````````````` 30 | 31 | Packaged obtained from PyPi is/will be slightly behind this project, so some features might not be the same. However, it seems to be the easiest/nicest way of installing any Python packages, so why not this one? :: 32 | 33 | $ pip install EMD-signal 34 | 35 | 36 | -------------------------------------------------------------------------------- /pywt-master/demo/wp_scalogram.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import numpy as np 5 | import matplotlib.pyplot as plt 6 | 7 | import pywt 8 | 9 | 10 | x = np.linspace(0, 1, num=512) 11 | data = np.sin(250 * np.pi * x**2) 12 | 13 | wavelet = 'db2' 14 | level = 4 15 | order = "freq" # other option is "normal" 16 | interpolation = 'nearest' 17 | cmap = plt.cm.cool 18 | 19 | # Construct wavelet packet 20 | wp = pywt.WaveletPacket(data, wavelet, 'symmetric', maxlevel=level) 21 | nodes = wp.get_level(level, order=order) 22 | labels = [n.path for n in nodes] 23 | values = np.array([n.data for n in nodes], 'd') 24 | values = abs(values) 25 | 26 | # Show signal and wavelet packet coefficients 27 | fig = plt.figure() 28 | fig.subplots_adjust(hspace=0.2, bottom=.03, left=.07, right=.97, top=.92) 29 | ax = fig.add_subplot(2, 1, 1) 30 | ax.set_title("linchirp signal") 31 | ax.plot(x, data, 'b') 32 | ax.set_xlim(0, x[-1]) 33 | 34 | ax = fig.add_subplot(2, 1, 2) 35 | ax.set_title("Wavelet packet coefficients at level %d" % level) 36 | ax.imshow(values, interpolation=interpolation, cmap=cmap, aspect="auto", 37 | origin="lower", extent=[0, 1, 0, len(values)]) 38 | ax.set_yticks(np.arange(0.5, len(labels) + 0.5), labels) 39 | 40 | # Show spectrogram and wavelet packet coefficients 41 | fig2 = plt.figure() 42 | ax2 = fig2.add_subplot(211) 43 | ax2.specgram(data, NFFT=64, noverlap=32, Fs=2, cmap=cmap, 44 | interpolation='bilinear') 45 | ax2.set_title("Spectrogram of signal") 46 | ax3 = fig2.add_subplot(212) 47 | ax3.imshow(values, origin='upper', extent=[-1, 1, -1, 1], 48 | interpolation='nearest') 49 | ax3.set_title("Wavelet packet coefficients") 50 | 51 | 52 | plt.show() 53 | -------------------------------------------------------------------------------- /pywt-master/doc/source/_templates/editdocument.html: -------------------------------------------------------------------------------- 1 | {% set repo="PyWavelets/pywt" %} 2 | {% set branch="master" %} 3 | 4 |
5 |

Edit this document

6 |

7 | 8 | 9 | The source code of this file is hosted on GitHub. Everyone can 10 | update and fix errors in this document with few clicks - 11 | no downloads needed. 12 | 13 |

14 | 42 |
43 | -------------------------------------------------------------------------------- /pywt-master/doc/source/pyplots/plot_2d_bases.py: -------------------------------------------------------------------------------- 1 | from itertools import product 2 | import numpy as np 3 | from matplotlib import pyplot as plt 4 | from pywt._doc_utils import (wavedec_keys, wavedec2_keys, draw_2d_wp_basis, 5 | draw_2d_fswavedecn_basis) 6 | 7 | shape = (512, 512) 8 | 9 | max_lev = 4 # how many levels of decomposition to draw 10 | label_levels = 2 # how many levels to explicitly label on the plots 11 | 12 | if False: 13 | fig, axes = plt.subplots(1, 4, figsize=[16, 4]) 14 | axes = axes.ravel() 15 | else: 16 | fig, axes = plt.subplots(2, 2, figsize=[8, 8]) 17 | axes = axes.ravel() 18 | 19 | # plot a 5-level standard DWT basis 20 | draw_2d_wp_basis(shape, wavedec2_keys(max_lev), ax=axes[0], 21 | label_levels=label_levels) 22 | axes[0].set_title('wavedec2 ({} level)'.format(max_lev)) 23 | 24 | # plot for the fully separable case 25 | draw_2d_fswavedecn_basis(shape, max_lev, ax=axes[1], label_levels=label_levels) 26 | axes[1].set_title('fswavedecn ({} level)'.format(max_lev)) 27 | 28 | # get all keys corresponding to a full wavelet packet decomposition 29 | wp_keys = list(product(['a', 'd', 'h', 'v'], repeat=max_lev)) 30 | draw_2d_wp_basis(shape, wp_keys, ax=axes[2]) 31 | axes[2].set_title('wavelet packet\n(full: {} level)'.format(max_lev)) 32 | 33 | # plot an example of a custom wavelet packet basis 34 | keys = ['aaaa', 'aaad', 'aaah', 'aaav', 'aad', 'aah', 'aava', 'aavd', 35 | 'aavh', 'aavv', 'ad', 'ah', 'ava', 'avd', 'avh', 'avv', 'd', 'h', 36 | 'vaa', 'vad', 'vah', 'vav', 'vd', 'vh', 'vv'] 37 | draw_2d_wp_basis(shape, keys, ax=axes[3], label_levels=label_levels) 38 | axes[3].set_title('wavelet packet\n(custom)'.format(max_lev)) 39 | 40 | plt.tight_layout() 41 | plt.show() 42 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/c/cwt.template.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016 Holger Nahrstaedt */ 2 | /* See COPYING for license details. */ 3 | 4 | 5 | #include "templating.h" 6 | 7 | #ifndef TYPE 8 | #error TYPE must be defined here. 9 | #else 10 | 11 | #include "cwt.h" 12 | 13 | #if defined _MSC_VER 14 | #define restrict __restrict 15 | #elif defined __GNUC__ 16 | #define restrict __restrict__ 17 | #endif 18 | 19 | 20 | void CAT(TYPE, _gaus)(const TYPE * const restrict input, 21 | TYPE * const restrict output, const size_t N, 22 | const size_t number); 23 | 24 | 25 | void CAT(TYPE, _mexh)(const TYPE * const restrict input, TYPE * const restrict output, const size_t N); 26 | 27 | void CAT(TYPE, _morl)(const TYPE * const restrict input, TYPE * const restrict output, const size_t N); 28 | 29 | void CAT(TYPE, _cgau)(const TYPE * const restrict input, 30 | TYPE * const restrict output_r, TYPE * const restrict output_i, const size_t N, 31 | const size_t number); 32 | 33 | 34 | void CAT(TYPE, _shan)(const TYPE * const restrict input, TYPE * const restrict output_r, TYPE * const restrict output_i, const size_t N, 35 | const TYPE FB, const TYPE FC); 36 | 37 | void CAT(TYPE, _fbsp)(const TYPE * const restrict input, TYPE * const restrict output_r, TYPE * const restrict output_i, const size_t N, 38 | const unsigned int M, const TYPE FB, const TYPE FC); 39 | 40 | void CAT(TYPE, _cmor)(const TYPE * const restrict input, TYPE * const restrict output_r, TYPE * const restrict output_i, const size_t N, 41 | const TYPE FB, const TYPE FC); 42 | #endif /* TYPE */ 43 | #undef restrict 44 | -------------------------------------------------------------------------------- /PyEMD-master/doc/usage.rst: -------------------------------------------------------------------------------- 1 | Usage 2 | ============= 3 | 4 | Typical Usage 5 | ------------- 6 | 7 | Majority, if not all, methods follow the same usage pattern: 8 | 9 | * Import method 10 | * Initiate method 11 | * Apply method on data 12 | 13 | On vanilla EMD this is as 14 | 15 | .. code-block:: python 16 | 17 | from PyEMD import EMD 18 | emd = EMD() 19 | imfs = emd(s) 20 | 21 | Parameters 22 | ---------- 23 | 24 | The decomposition can be changed by adjusting parameters related to either sifting or stopping conditions. 25 | 26 | Sifting 27 | ``````` 28 | The sifting depends on the used method so these parameters ought to be looked within the methods. 29 | However, the typical parameters relate to spline method or the number of mirroring points. 30 | 31 | 32 | Stopping conditions 33 | ``````````````````` 34 | All methods have the same two conditions, `FIXE` and `FIXE_H`, for stopping which relate to the number of sifting iterations. 35 | Setting parameter `FIXE` to any positive value will fix the number of iterations for each IMF to be exactly `FIXE`. 36 | 37 | Example: 38 | 39 | .. code-block:: python 40 | 41 | emd = EMD() 42 | emd.FIXE = 10 43 | imfs = emd(s) 44 | 45 | Parameter `FIXE_H` relates to the number of iterations when the proto-IMF signal fulfils IMF conditions, i.e. number of extrema and zero-crossings differ at most by one and the mean is close to zero. This means that there will be at least `FIXE_H` iteration per IMF. 46 | 47 | Example: 48 | 49 | .. code-block:: python 50 | 51 | emd = EMD() 52 | emd.FIXE_H = 5 53 | imfs = emd(s) 54 | 55 | When both `FIXE` and `FIXE_H` are 0 then other conditions are checked. These can be checking for convergence between consecutive iterations or whether the amplitude of output is below acceptable range. 56 | -------------------------------------------------------------------------------- /pywt-master/doc/source/_templates/page.html: -------------------------------------------------------------------------------- 1 | {# Drop version number from the HTML documentation title #} 2 | {%- set docstitle = "PyWavelets Documentation" %} 3 | 4 | {% extends "!page.html" %} 5 | 6 | {% block extrahead %} 7 | {{ super() }} 8 | 9 | 10 | 11 | 12 | 13 | 14 | 24 | 37 | {% endblock %} 38 | 39 | {# Remove version number from the top and bottom path bars #} 40 | {%- block rootrellink %} 41 |
  • Home{{ reldelim1 }}
  • 42 | {%- endblock %} 43 | -------------------------------------------------------------------------------- /pywt-master/doc/source/regression/multilevel.rst: -------------------------------------------------------------------------------- 1 | .. _reg-multilevel: 2 | 3 | .. currentmodule:: pywt 4 | 5 | Multilevel DWT, IDWT and SWT 6 | ============================ 7 | 8 | Multilevel DWT decomposition 9 | ---------------------------- 10 | 11 | >>> import pywt 12 | >>> x = [3, 7, 1, 1, -2, 5, 4, 6] 13 | >>> db1 = pywt.Wavelet('db1') 14 | >>> cA3, cD3, cD2, cD1 = pywt.wavedec(x, db1) 15 | >>> print(cA3) 16 | [ 8.83883476] 17 | >>> print(cD3) 18 | [-0.35355339] 19 | >>> print(cD2) 20 | [ 4. -3.5] 21 | >>> print(cD1) 22 | [-2.82842712 0. -4.94974747 -1.41421356] 23 | 24 | >>> pywt.dwt_max_level(len(x), db1) 25 | 3 26 | 27 | >>> cA2, cD2, cD1 = pywt.wavedec(x, db1, mode='constant', level=2) 28 | 29 | 30 | Multilevel IDWT reconstruction 31 | ------------------------------ 32 | 33 | >>> coeffs = pywt.wavedec(x, db1) 34 | >>> print(pywt.waverec(coeffs, db1)) 35 | [ 3. 7. 1. 1. -2. 5. 4. 6.] 36 | 37 | 38 | Multilevel SWT decomposition 39 | ---------------------------- 40 | 41 | >>> x = [3, 7, 1, 3, -2, 6, 4, 6] 42 | >>> (cA2, cD2), (cA1, cD1) = pywt.swt(x, db1, level=2) 43 | >>> print(cA1) 44 | [ 7.07106781 5.65685425 2.82842712 0.70710678 2.82842712 7.07106781 45 | 7.07106781 6.36396103] 46 | >>> print(cD1) 47 | [-2.82842712 4.24264069 -1.41421356 3.53553391 -5.65685425 1.41421356 48 | -1.41421356 2.12132034] 49 | >>> print(cA2) 50 | [ 7. 4.5 4. 5.5 7. 9.5 10. 8.5] 51 | >>> print(cD2) 52 | [ 3. 3.5 0. -4.5 -3. 0.5 0. 0.5] 53 | 54 | >>> [(cA2, cD2)] = pywt.swt(cA1, db1, level=1, start_level=1) 55 | >>> print(cA2) 56 | [ 7. 4.5 4. 5.5 7. 9.5 10. 8.5] 57 | >>> print(cD2) 58 | [ 3. 3.5 0. -4.5 -3. 0.5 0. 0.5] 59 | 60 | >>> coeffs = pywt.swt(x, db1) 61 | >>> len(coeffs) 62 | 3 63 | >>> pywt.swt_max_level(len(x)) 64 | 3 65 | -------------------------------------------------------------------------------- /pywt-master/benchmarks/benchmarks/cwt_benchmarks.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pywt 3 | 4 | 5 | class CwtTimeSuiteBase(object): 6 | """ 7 | Set-up for CWT timing. 8 | """ 9 | params = ([32, 128, 512, 2048], 10 | ['cmor', 'cgau4', 'fbsp', 'gaus4', 'mexh', 'morl', 'shan'], 11 | [16, 64, 256], 12 | [np.float32, np.float64], 13 | ['conv', 'fft'], 14 | ) 15 | param_names = ('n', 'wavelet', 'max_scale', 'dtype', 'method') 16 | 17 | def setup(self, n, wavelet, max_scale, dtype, method): 18 | try: 19 | from pywt import cwt 20 | except ImportError: 21 | raise NotImplementedError("cwt not available") 22 | self.data = np.ones(n, dtype=dtype) 23 | self.batch_data = np.ones((5, n), dtype=dtype) 24 | self.scales = np.arange(1, max_scale + 1) 25 | 26 | 27 | class CwtTimeSuite(CwtTimeSuiteBase): 28 | def time_cwt(self, n, wavelet, max_scale, dtype, method): 29 | try: 30 | pywt.cwt(self.data, self.scales, wavelet, method=method) 31 | except TypeError: 32 | # older PyWavelets does not support use of the method argument 33 | if method == 'fft': 34 | raise NotImplementedError( 35 | "fft-based convolution not available.") 36 | pywt.cwt(self.data, self.scales, wavelet) 37 | 38 | def time_cwt_batch(self, n, wavelet, max_scale, dtype, method): 39 | try: 40 | pywt.cwt(self.batch_data, self.scales, wavelet, method=method, 41 | axis=-1) 42 | except TypeError: 43 | # older PyWavelets does not support the axis argument 44 | raise NotImplementedError( 45 | "axis argument not available.") 46 | -------------------------------------------------------------------------------- /pywt-master/demo/plot_wavelets_pyqtgraph.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | import pywt 4 | from pyqtgraph.Qt import QtGui 5 | import pyqtgraph as pg 6 | 7 | 8 | families = ['db', 'sym', 'coif', 'bior', 'rbio'] 9 | 10 | 11 | def main(): 12 | app = QtGui.QApplication(sys.argv) 13 | tabs = QtGui.QTabWidget() 14 | 15 | for family in families: 16 | scroller = QtGui.QScrollArea() 17 | vb = pg.GraphicsWindow() 18 | vb.setMinimumHeight(3000) 19 | vb.setMinimumWidth(1900) 20 | scroller.setWidget(vb) 21 | for i, name in enumerate(pywt.wavelist(family)): 22 | pen = pg.intColor(i) 23 | wavelet = pywt.Wavelet(name) 24 | if wavelet.orthogonal: 25 | phi, psi, x = wavelet.wavefun(level=5) 26 | ax = vb.addPlot(title=wavelet.name + " phi") 27 | ax.plot(phi, pen=pen) 28 | bx = vb.addPlot(title=wavelet.name + " psi") 29 | bx.plot(psi, pen=pen) 30 | else: 31 | phi, psi, phi_r, psi_r, x = wavelet.wavefun(level=5) 32 | ax = vb.addPlot(title=wavelet.name + " phi") 33 | ax.plot(phi, pen=pen) 34 | bx = vb.addPlot(title=wavelet.name + " psi") 35 | bx.plot(psi, pen=pen) 36 | ax = vb.addPlot(title=wavelet.name + " phi_r") 37 | ax.plot(phi_r, pen=pen) 38 | bx = vb.addPlot(title=wavelet.name + " psi_r") 39 | bx.plot(psi_r, pen=pen) 40 | if i % 2 == 0: 41 | vb.nextRow() 42 | tabs.addTab(scroller, family) 43 | 44 | tabs.setWindowTitle('Wavelets') 45 | tabs.resize(1920, 1080) 46 | tabs.show() 47 | sys.exit(app.exec_()) 48 | 49 | 50 | if __name__ == '__main__': 51 | main() 52 | -------------------------------------------------------------------------------- /pywt-master/doc/source/dev/installing_build_dependencies.rst: -------------------------------------------------------------------------------- 1 | .. _dev-installing-build-dependencies: 2 | 3 | Installing build dependencies 4 | ============================= 5 | 6 | Setting up Python virtual environment 7 | ------------------------------------- 8 | 9 | A good practice is to create a separate Python virtual environment for each 10 | project. If you don't have `virtualenv`_ yet, install and activate it using:: 11 | 12 | curl -O https://raw.github.com/pypa/virtualenv/master/virtualenv.py 13 | python virtualenv.py 14 | . /bin/activate 15 | 16 | 17 | Installing Cython 18 | ----------------- 19 | 20 | Use ``pip`` (http://pypi.python.org/pypi/pip) to install Cython_:: 21 | 22 | 23 | pip install Cython>=0.16 24 | 25 | 26 | Installing numpy 27 | ---------------- 28 | 29 | Use ``pip`` to install numpy_:: 30 | 31 | pip install numpy 32 | 33 | Numpy can also be obtained via scientific python distributions such as: 34 | 35 | - Anaconda_ 36 | - `Enthought Canopy`_ 37 | - `Python(x,y) `_ 38 | 39 | .. note:: 40 | 41 | You can find binaries for 64-bit Windows on http://www.lfd.uci.edu/~gohlke/pythonlibs/. 42 | 43 | 44 | Installing Sphinx 45 | ----------------- 46 | 47 | Sphinx_ is a documentation tool that converts reStructuredText files into 48 | nicely looking html documentation. Install it with:: 49 | 50 | pip install Sphinx 51 | 52 | numpydoc_ is used to format the API docmentation appropriately. Install it 53 | via:: 54 | 55 | pip install numpydoc 56 | 57 | 58 | .. _virtualenv: http://pypi.python.org/pypi/virtualenv 59 | .. _numpy: http://numpy.org/ 60 | .. _Cython: http://cython.org/ 61 | .. _Sphinx: http://sphinx.pocoo.org 62 | .. _numpydoc: https://github.com/numpy/numpydoc 63 | .. _Anaconda: https://www.continuum.io/downloads 64 | .. _Enthought Canopy: https://www.enthought.com/products/canopy/ 65 | -------------------------------------------------------------------------------- /pywt-master/doc/source/install.rst: -------------------------------------------------------------------------------- 1 | Installing 2 | ========== 3 | 4 | The latest release, including binary packages for Windows, macOS and Linux, 5 | is available for download from `PyPI`_. You can also find source releases at 6 | the `Releases Page`_. 7 | 8 | You can install PyWavelets with:: 9 | 10 | pip install PyWavelets 11 | 12 | Users of the Anaconda_ Python distribution may wish to obtain pre-built 13 | Windows, Intel Linux or macOS / OSX binaries from the main or conda-forge 14 | channel:: 15 | 16 | conda install pywavelets 17 | 18 | Several Linux distributions have their own packages for PyWavelets, but these 19 | tend to be moderately out of date. Query your Linux package manager tool for 20 | ``python-pywavelets``, ``python-wavelets``, ``python-pywt`` or a similar 21 | package name. 22 | 23 | 24 | Building from source 25 | -------------------- 26 | 27 | The most recent *development* version can be found on GitHub at 28 | https://github.com/PyWavelets/pywt. 29 | 30 | The latest release, is available for download from `PyPI`_ or on the 31 | `Releases Page`_. 32 | 33 | If you want or need to install from source, you will need a working C compiler 34 | (any common one will work) and a recent version of `Cython`_. Navigate to the 35 | PyWavelets source code directory (containing ``setup.py``) and type:: 36 | 37 | pip install . 38 | 39 | The requirements needed to build from source are: 40 | 41 | - Python_ 2.7 or >=3.4 42 | - NumPy_ >= 1.13.3 43 | - Cython_ >= 0.23.5 (if installing from git, not from a PyPI source release) 44 | 45 | To run all the tests for PyWavelets, you will also need to install the 46 | Matplotlib_ package. If SciPy_ is available, FFT-based continuous wavelet 47 | transforms will use the FFT implementation from SciPy instead of NumPy. 48 | 49 | .. seealso:: :ref:`Development guide ` section contains more 50 | information on building and installing from source code. 51 | 52 | .. include:: common_refs.rst 53 | -------------------------------------------------------------------------------- /PyEMD-master/example/hht_example.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pylab as plt 3 | from scipy.signal import hilbert 4 | 5 | from PyEMD import EMD 6 | 7 | 8 | def instant_phase(imfs): 9 | """Extract analytical signal through Hilbert Transform.""" 10 | analytic_signal = hilbert(imfs) # Apply Hilbert transform to each row 11 | phase = np.unwrap(np.angle(analytic_signal)) # Compute angle between img and real 12 | return phase 13 | 14 | # Define signal 15 | t = np.linspace(0, 1, 200) 16 | dt = t[1]-t[0] 17 | 18 | sin = lambda x, p: np.sin(2*np.pi*x*t+p) 19 | S = 3*sin(18, 0.2)*(t-0.2)**2 20 | S += 5*sin(11, 2.7) 21 | S += 3*sin(14, 1.6) 22 | S += 1*np.sin(4*2*np.pi*(t-0.8)**2) 23 | S += t**2.1 -t 24 | 25 | # Compute IMFs with EMD 26 | emd = EMD() 27 | imfs = emd(S, t) 28 | 29 | # Extract instantaneous phases and frequencies using Hilbert transform 30 | instant_phases = instant_phase(imfs) 31 | instant_freqs = np.diff(instant_phases)/(2*np.pi*dt) 32 | 33 | # Create a figure consisting of 3 panels which from the top are the input signal, IMFs and instantaneous frequencies 34 | fig, axes = plt.subplots(3, figsize=(12,12)) 35 | 36 | # The top panel shows the input signal 37 | ax = axes[0] 38 | ax.plot(t, S) 39 | ax.set_ylabel("Amplitude [arb. u.]") 40 | ax.set_title("Input signal") 41 | 42 | # The middle panel shows all IMFs 43 | ax = axes[1] 44 | for num, imf in enumerate(imfs): 45 | ax.plot(t, imf, label='IMF %s' %(num+1)) 46 | 47 | # Label the figure 48 | ax.legend() 49 | ax.set_ylabel("Amplitude [arb. u.]") 50 | ax.set_title("IMFs") 51 | 52 | # The bottom panel shows all instantaneous frequencies 53 | ax = axes[2] 54 | for num, instant_freq in enumerate(instant_freqs): 55 | ax.plot(t[:-1], instant_freq, label='IMF %s'%(num+1)) 56 | 57 | # Label the figure 58 | ax.legend() 59 | ax.set_xlabel("Time [s]") 60 | ax.set_ylabel("Inst. Freq. [Hz]") 61 | ax.set_title("Huang-Hilbert Transform") 62 | 63 | plt.tight_layout() 64 | plt.savefig('hht_example', dpi=120) 65 | plt.show() 66 | -------------------------------------------------------------------------------- /pywt-master/demo/dwt2_dwtn_image.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import numpy as np 5 | import matplotlib.pyplot as plt 6 | 7 | import pywt 8 | import pywt.data 9 | 10 | 11 | # Load image 12 | original = pywt.data.camera() 13 | 14 | # Wavelet transform of image, and plot approximation and details 15 | titles = ['Approximation', ' Horizontal detail', 16 | 'Vertical detail', 'Diagonal detail'] 17 | coeffs2 = pywt.dwt2(original, 'bior1.3') 18 | LL, (LH, HL, HH) = coeffs2 19 | fig = plt.figure() 20 | for i, a in enumerate([LL, LH, HL, HH]): 21 | ax = fig.add_subplot(2, 2, i + 1) 22 | ax.imshow(a, interpolation="nearest", cmap=plt.cm.gray) 23 | ax.set_title(titles[i], fontsize=12) 24 | ax.set_xticks([]) 25 | ax.set_yticks([]) 26 | 27 | fig.suptitle("dwt2 coefficients", fontsize=14) 28 | 29 | # Now reconstruct and plot the original image 30 | reconstructed = pywt.idwt2(coeffs2, 'bior1.3') 31 | fig = plt.figure() 32 | plt.imshow(reconstructed, interpolation="nearest", cmap=plt.cm.gray) 33 | 34 | # Check that reconstructed image is close to the original 35 | np.testing.assert_allclose(original, reconstructed, atol=1e-13, rtol=1e-13) 36 | 37 | 38 | # Now do the same with dwtn/idwtn, to show the difference in their signatures 39 | 40 | coeffsn = pywt.dwtn(original, 'bior1.3') 41 | fig = plt.figure() 42 | for i, key in enumerate(['aa', 'ad', 'da', 'dd']): 43 | ax = fig.add_subplot(2, 2, i + 1) 44 | ax.imshow(coeffsn[key], interpolation="nearest", cmap=plt.cm.gray) 45 | ax.set_title(titles[i], fontsize=12) 46 | ax.set_xticks([]) 47 | ax.set_yticks([]) 48 | 49 | fig.suptitle("dwtn coefficients", fontsize=14) 50 | 51 | # Now reconstruct and plot the original image 52 | reconstructed = pywt.idwtn(coeffsn, 'bior1.3') 53 | fig = plt.figure() 54 | plt.imshow(reconstructed, interpolation="nearest", cmap=plt.cm.gray) 55 | 56 | # Check that reconstructed image is close to the original 57 | np.testing.assert_allclose(original, reconstructed, atol=1e-13, rtol=1e-13) 58 | 59 | 60 | plt.show() 61 | -------------------------------------------------------------------------------- /pywt-master/pywt/tests/test_perfect_reconstruction.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | """ 4 | Verify DWT perfect reconstruction. 5 | """ 6 | 7 | from __future__ import division, print_function, absolute_import 8 | 9 | import numpy as np 10 | from numpy.testing import assert_ 11 | 12 | import pywt 13 | 14 | 15 | def test_perfect_reconstruction(): 16 | families = ('db', 'sym', 'coif', 'bior', 'rbio') 17 | wavelets = sum([pywt.wavelist(name) for name in families], []) 18 | # list of mode names in pywt and matlab 19 | modes = [('zero', 'zpd'), 20 | ('constant', 'sp0'), 21 | ('symmetric', 'sym'), 22 | ('periodic', 'ppd'), 23 | ('smooth', 'sp1'), 24 | ('periodization', 'per')] 25 | 26 | dtypes = (np.float32, np.float64) 27 | 28 | for wavelet in wavelets: 29 | for pmode, mmode in modes: 30 | for dt in dtypes: 31 | check_reconstruction(pmode, mmode, wavelet, dt) 32 | 33 | 34 | def check_reconstruction(pmode, mmode, wavelet, dtype): 35 | data_size = list(range(2, 40)) + [100, 200, 500, 1000, 2000, 10000, 36 | 50000, 100000] 37 | np.random.seed(12345) 38 | # TODO: smoke testing - more failures for different seeds 39 | 40 | if dtype == np.float32: 41 | # was 3e-7 has to be lowered as db21, db29, db33, db35, coif14, coif16 were failing 42 | epsilon = 6e-7 43 | else: 44 | epsilon = 5e-11 45 | 46 | for N in data_size: 47 | data = np.asarray(np.random.random(N), dtype) 48 | 49 | # compute dwt coefficients 50 | pa, pd = pywt.dwt(data, wavelet, pmode) 51 | 52 | # compute reconstruction 53 | rec = pywt.idwt(pa, pd, wavelet, pmode) 54 | 55 | if len(data) % 2: 56 | rec = rec[:len(data)] 57 | 58 | rms_rec = np.sqrt(np.mean((data-rec)**2)) 59 | msg = ('[RMS_REC > EPSILON] for Mode: %s, Wavelet: %s, ' 60 | 'Length: %d, rms=%.3g' % (pmode, wavelet, len(data), rms_rec)) 61 | assert_(rms_rec < epsilon, msg=msg) 62 | -------------------------------------------------------------------------------- /pywt-master/demo/swt_variance.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import numpy as np 4 | import matplotlib.pyplot as plt 5 | 6 | import pywt 7 | import pywt.data 8 | 9 | ecg = pywt.data.ecg() 10 | 11 | # set trim_approx to avoid keeping approximation coefficients for all levels 12 | 13 | # set norm=True to rescale the wavelets so that the transform partitions the 14 | # variance of the input signal among the various coefficient arrays. 15 | 16 | coeffs = pywt.swt(ecg, wavelet='sym4', trim_approx=True, norm=True) 17 | ca = coeffs[0] 18 | details = coeffs[1:] 19 | 20 | print("Variance of the ecg signal = {}".format(np.var(ecg, ddof=1))) 21 | 22 | variances = [np.var(c, ddof=1) for c in coeffs] 23 | detail_variances = variances[1:] 24 | print("Sum of variance across all SWT coefficients = {}".format( 25 | np.sum(variances))) 26 | 27 | # Create a plot using the same y axis limits for all coefficient arrays to 28 | # illustrate the preservation of amplitude scale across levels when norm=True. 29 | ylim = [ecg.min(), ecg.max()] 30 | 31 | fig, axes = plt.subplots(len(coeffs) + 1) 32 | axes[0].set_title("normalized SWT decomposition") 33 | axes[0].plot(ecg) 34 | axes[0].set_ylabel('ECG Signal') 35 | axes[0].set_xlim(0, len(ecg) - 1) 36 | axes[0].set_ylim(ylim[0], ylim[1]) 37 | 38 | for i, x in enumerate(coeffs): 39 | ax = axes[-i - 1] 40 | ax.plot(coeffs[i], 'g') 41 | if i == 0: 42 | ax.set_ylabel("A%d" % (len(coeffs) - 1)) 43 | else: 44 | ax.set_ylabel("D%d" % (len(coeffs) - i)) 45 | # Scale axes 46 | ax.set_xlim(0, len(ecg) - 1) 47 | ax.set_ylim(ylim[0], ylim[1]) 48 | 49 | 50 | # reorder from first to last level of coefficients 51 | level = np.arange(1, len(detail_variances) + 1) 52 | 53 | # create a plot of the variance as a function of level 54 | plt.figure(figsize=(8, 6)) 55 | fontdict = dict(fontsize=16, fontweight='bold') 56 | plt.plot(level, detail_variances[::-1], 'k.') 57 | plt.xlabel("Decomposition level", fontdict=fontdict) 58 | plt.ylabel("Variance", fontdict=fontdict) 59 | plt.title("Variances of detail coefficients", fontdict=fontdict) 60 | plt.show() 61 | -------------------------------------------------------------------------------- /pywt-master/demo/dwt_signal_decomposition.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import numpy as np 5 | import matplotlib.pyplot as plt 6 | 7 | import pywt 8 | import pywt.data 9 | 10 | 11 | ecg = pywt.data.ecg() 12 | 13 | data1 = np.concatenate((np.arange(1, 400), 14 | np.arange(398, 600), 15 | np.arange(601, 1024))) 16 | x = np.linspace(0.082, 2.128, num=1024)[::-1] 17 | data2 = np.sin(40 * np.log(x)) * np.sign((np.log(x))) 18 | 19 | mode = pywt.Modes.smooth 20 | 21 | 22 | def plot_signal_decomp(data, w, title): 23 | """Decompose and plot a signal S. 24 | 25 | S = An + Dn + Dn-1 + ... + D1 26 | """ 27 | w = pywt.Wavelet(w) 28 | a = data 29 | ca = [] 30 | cd = [] 31 | for i in range(5): 32 | (a, d) = pywt.dwt(a, w, mode) 33 | ca.append(a) 34 | cd.append(d) 35 | 36 | rec_a = [] 37 | rec_d = [] 38 | 39 | for i, coeff in enumerate(ca): 40 | coeff_list = [coeff, None] + [None] * i 41 | rec_a.append(pywt.waverec(coeff_list, w)) 42 | 43 | for i, coeff in enumerate(cd): 44 | coeff_list = [None, coeff] + [None] * i 45 | rec_d.append(pywt.waverec(coeff_list, w)) 46 | 47 | fig = plt.figure() 48 | ax_main = fig.add_subplot(len(rec_a) + 1, 1, 1) 49 | ax_main.set_title(title) 50 | ax_main.plot(data) 51 | ax_main.set_xlim(0, len(data) - 1) 52 | 53 | for i, y in enumerate(rec_a): 54 | ax = fig.add_subplot(len(rec_a) + 1, 2, 3 + i * 2) 55 | ax.plot(y, 'r') 56 | ax.set_xlim(0, len(y) - 1) 57 | ax.set_ylabel("A%d" % (i + 1)) 58 | 59 | for i, y in enumerate(rec_d): 60 | ax = fig.add_subplot(len(rec_d) + 1, 2, 4 + i * 2) 61 | ax.plot(y, 'g') 62 | ax.set_xlim(0, len(y) - 1) 63 | ax.set_ylabel("D%d" % (i + 1)) 64 | 65 | 66 | plot_signal_decomp(data1, 'coif5', "DWT: Signal irregularity") 67 | plot_signal_decomp(data2, 'sym5', 68 | "DWT: Frequency and phase change - Symmlets5") 69 | plot_signal_decomp(ecg, 'sym5', "DWT: Ecg sample - Symmlets5") 70 | 71 | 72 | plt.show() 73 | -------------------------------------------------------------------------------- /pywt-master/doc/source/ref/dwt-discrete-wavelet-transform.rst: -------------------------------------------------------------------------------- 1 | .. _ref-dwt: 2 | 3 | .. currentmodule:: pywt 4 | 5 | ================================ 6 | Discrete Wavelet Transform (DWT) 7 | ================================ 8 | 9 | Wavelet transform has recently become a very popular when it comes to analysis, 10 | de-noising and compression of signals and images. This section describes 11 | functions used to perform single- and multilevel Discrete Wavelet Transforms. 12 | 13 | 14 | Single level ``dwt`` 15 | -------------------- 16 | 17 | .. autofunction:: dwt 18 | 19 | See the :ref:`signal extension modes ` section for the list of 20 | available options and the :func:`dwt_coeff_len` function for information on 21 | getting the expected result length. 22 | 23 | The transform can be performed over one axis of multi-dimensional 24 | data. By default this is the last axis. For multi-dimensional transforms 25 | see the :ref:`2D transforms ` section. 26 | 27 | 28 | Multilevel decomposition using ``wavedec`` 29 | ------------------------------------------ 30 | 31 | .. autofunction:: wavedec 32 | 33 | 34 | Partial Discrete Wavelet Transform data decomposition ``downcoef`` 35 | ------------------------------------------------------------------ 36 | 37 | .. autofunction:: downcoef 38 | 39 | 40 | Maximum decomposition level - ``dwt_max_level``, ``dwtn_max_level`` 41 | ------------------------------------------------------------------- 42 | 43 | .. autofunction:: dwt_max_level 44 | .. autofunction:: dwtn_max_level 45 | 46 | 47 | .. _`dwt_coeff_len`: 48 | 49 | Result coefficients length - ``dwt_coeff_len`` 50 | ---------------------------------------------- 51 | 52 | .. autofunction:: dwt_coeff_len 53 | 54 | Based on the given input data length (``data_len``), wavelet decomposition 55 | filter length (``filter_len``) and :ref:`signal extension mode `, the 56 | :func:`dwt_coeff_len` function calculates the length of the resulting 57 | coefficients arrays that would be created while performing :func:`dwt` 58 | transform. 59 | 60 | ``filter_len`` can be either an ``int`` or :class:`Wavelet` object for 61 | convenience. 62 | -------------------------------------------------------------------------------- /pywt-master/doc/source/ref/other-functions.rst: -------------------------------------------------------------------------------- 1 | .. _ref-other: 2 | 3 | .. currentmodule:: pywt 4 | 5 | =============== 6 | Other functions 7 | =============== 8 | 9 | 10 | Integrating wavelet functions 11 | ----------------------------- 12 | 13 | .. autofunction:: integrate_wavelet 14 | 15 | The result of the call depends on the ``wavelet`` argument: 16 | 17 | * for orthogonal and continuous wavelets - an integral of the 18 | wavelet function specified on an x-grid:: 19 | 20 | [int_psi, x_grid] = integrate_wavelet(wavelet, precision) 21 | 22 | * for other wavelets - integrals of decomposition and 23 | reconstruction wavelet functions and a corresponding x-grid:: 24 | 25 | [int_psi_d, int_psi_r, x_grid] = integrate_wavelet(wavelet, precision) 26 | 27 | 28 | Central frequency of ``psi`` wavelet function 29 | --------------------------------------------- 30 | 31 | .. autofunction:: central_frequency 32 | 33 | .. autofunction:: scale2frequency 34 | 35 | 36 | Quadrature Mirror Filter 37 | ------------------------ 38 | 39 | .. autofunction:: qmf 40 | 41 | Orthogonal Filter Banks 42 | ----------------------- 43 | 44 | .. autofunction:: orthogonal_filter_bank 45 | 46 | 47 | Example Datasets 48 | ---------------- 49 | 50 | The following example datasets are available in the module ``pywt.data``: 51 | 52 | ============ ======================================= 53 | **name** **description** 54 | ============ ======================================= 55 | ecg ECG waveform (1024 samples) 56 | aero grayscale image (512x512) 57 | ascent grayscale image (512x512) 58 | camera grayscale image (512x512) 59 | nino sea surface temperature (264 samples) 60 | demo_signal various synthetic 1d test signals 61 | ============ ======================================= 62 | 63 | Each can be loaded via a function of the same name. 64 | 65 | .. currentmodule:: pywt.data 66 | .. autofunction:: demo_signal 67 | 68 | **Example:** 69 | 70 | .. sourcecode:: python 71 | 72 | >>> import pywt 73 | >>> camera = pywt.data.camera() 74 | >>> doppler = pywt.data.demo_signal('doppler', 1024) 75 | >>> available_signals = pywt.data.demo_signal('list') 76 | -------------------------------------------------------------------------------- /pywt-master/demo/benchmark.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import gc 5 | import sys 6 | import time 7 | 8 | import numpy as np 9 | import matplotlib.pyplot as plt 10 | 11 | import pywt 12 | 13 | 14 | if sys.platform == 'win32': 15 | clock = time.clock 16 | else: 17 | clock = time.time 18 | 19 | sizes = [20, 50, 100, 120, 150, 200, 250, 300, 400, 500, 600, 750, 20 | 1000, 2000, 3000, 4000, 5000, 6000, 7500, 21 | 10000, 15000, 20000, 25000, 30000, 40000, 50000, 75000, 22 | 100000, 150000, 200000, 250000, 300000, 400000, 500000, 23 | 600000, 750000, 1000000, 2000000, 5000000][:-4] 24 | 25 | wavelet_names = ['db1', 'db2', 'db3', 'db4', 'db5', 'db6', 'db7', 26 | 'db8', 'db9', 'db10', 'sym10', 'coif1', 'coif2', 27 | 'coif3', 'coif4', 'coif5'] 28 | 29 | 30 | wavelets = [pywt.Wavelet(n) for n in wavelet_names] 31 | mode = pywt.Modes.zero 32 | 33 | times_dwt = [[] for i in range(len(wavelets))] 34 | times_idwt = [[] for i in range(len(wavelets))] 35 | 36 | for j, size in enumerate(sizes): 37 | data = np.ones((size,), dtype=np.float64) 38 | print((("%d/%d" % (j + 1, len(sizes))).rjust(6), str(size).rjust(9))) 39 | for i, w in enumerate(wavelets): 40 | min_t1, min_t2 = 9999., 9999. 41 | for _ in range(5): 42 | # Repeat timing 5 times to reduce run-to-run variation 43 | t1 = clock() 44 | (a, d) = pywt.dwt(data, w, mode) 45 | t1 = clock() - t1 46 | min_t1 = min(t1, min_t1) 47 | 48 | t2 = clock() 49 | a0 = pywt.idwt(a, d, w, mode) 50 | t2 = clock() - t2 51 | min_t2 = min(t2, min_t2) 52 | 53 | times_dwt[i].append(min_t1) 54 | times_idwt[i].append(min_t2) 55 | 56 | gc.collect() 57 | 58 | 59 | for j, (times, name) in enumerate([(times_dwt, 'dwt'), (times_idwt, 'idwt')]): 60 | fig = plt.figure(j) 61 | ax = fig.add_subplot(111) 62 | ax.set_title(name) 63 | 64 | for i, n in enumerate(wavelet_names): 65 | ax.loglog(sizes, times[i], label=n) 66 | 67 | ax.legend(loc='best') 68 | ax.set_xlabel('len(x)') 69 | ax.set_ylabel('time [s]') 70 | 71 | 72 | plt.show() 73 | -------------------------------------------------------------------------------- /pywt-master/demo/waveinfo.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import sys 5 | 6 | import matplotlib.pyplot as plt 7 | import numpy as np 8 | import pywt 9 | 10 | 11 | usage = """ 12 | Usage: 13 | python waveinfo.py waveletname 14 | 15 | Example: python waveinfo.py 'sym5' 16 | """ 17 | 18 | try: 19 | wavelet = pywt.Wavelet(sys.argv[1]) 20 | try: 21 | level = int(sys.argv[2]) 22 | except IndexError as e: 23 | level = 10 24 | except ValueError as e: 25 | print("Unknown wavelet") 26 | raise SystemExit 27 | except IndexError as e: 28 | print(usage) 29 | raise SystemExit 30 | 31 | 32 | data = wavelet.wavefun(level) 33 | if len(data) == 2: 34 | x = data[1] 35 | psi = data[0] 36 | fig = plt.figure() 37 | if wavelet.complex_cwt: 38 | plt.subplot(211) 39 | plt.title(wavelet.name+' real part') 40 | mi, ma = np.real(psi).min(), np.real(psi).max() 41 | margin = (ma - mi) * 0.05 42 | plt.plot(x,np.real(psi)) 43 | plt.ylim(mi - margin, ma + margin) 44 | plt.xlim(x[0], x[-1]) 45 | plt.subplot(212) 46 | plt.title(wavelet.name+' imag part') 47 | mi, ma = np.imag(psi).min(), np.imag(psi).max() 48 | margin = (ma - mi) * 0.05 49 | plt.plot(x,np.imag(psi)) 50 | plt.ylim(mi - margin, ma + margin) 51 | plt.xlim(x[0], x[-1]) 52 | else: 53 | mi, ma = psi.min(), psi.max() 54 | margin = (ma - mi) * 0.05 55 | plt.plot(x,psi) 56 | plt.title(wavelet.name) 57 | plt.ylim(mi - margin, ma + margin) 58 | plt.xlim(x[0], x[-1]) 59 | else: 60 | funcs, x = data[:-1], data[-1] 61 | labels = ["scaling function (phi)", "wavelet function (psi)", 62 | "r. scaling function (phi)", "r. wavelet function (psi)"] 63 | colors = ("r", "g", "r", "g") 64 | fig = plt.figure() 65 | for i, (d, label, color) in enumerate(zip(funcs, labels, colors)): 66 | mi, ma = d.min(), d.max() 67 | margin = (ma - mi) * 0.05 68 | ax = fig.add_subplot((len(data) - 1) // 2, 2, 1 + i) 69 | 70 | ax.plot(x, d, color) 71 | ax.set_title(label) 72 | ax.set_ylim(mi - margin, ma + margin) 73 | ax.set_xlim(x[0], x[-1]) 74 | 75 | plt.show() 76 | -------------------------------------------------------------------------------- /pywt-master/doc/source/regression/modes.rst: -------------------------------------------------------------------------------- 1 | .. _reg-modes: 2 | 3 | .. currentmodule:: pywt 4 | 5 | 6 | Signal Extension Modes 7 | ====================== 8 | 9 | Import :mod:`pywt` first 10 | 11 | >>> import pywt 12 | 13 | >>> def format_array(a): 14 | ... """Consistent array representation across different systems""" 15 | ... import numpy 16 | ... a = numpy.where(numpy.abs(a) < 1e-5, 0, a) 17 | ... return numpy.array2string(a, precision=5, separator=' ', suppress_small=True) 18 | 19 | List of available signal extension :ref:`modes `: 20 | 21 | >>> print(pywt.Modes.modes) 22 | ['zero', 'constant', 'symmetric', 'periodic', 'smooth', 'periodization', 'reflect', 'antisymmetric', 'antireflect'] 23 | 24 | 25 | Invalid mode name should rise a :exc:`ValueError`: 26 | 27 | >>> pywt.dwt([1,2,3,4], 'db2', 'invalid') 28 | Traceback (most recent call last): 29 | ... 30 | ValueError: Unknown mode name 'invalid'. 31 | 32 | 33 | You can also refer to modes via :ref:`Modes ` class attributes: 34 | 35 | >>> x = [1, 2, 1, 5, -1, 8, 4, 6] 36 | >>> for mode_name in ['zero', 'constant', 'symmetric', 'reflect', 'periodic', 'smooth', 'periodization']: 37 | ... mode = getattr(pywt.Modes, mode_name) 38 | ... cA, cD = pywt.dwt(x, 'db2', mode) 39 | ... print("Mode: %d (%s)" % (mode, mode_name)) 40 | Mode: 0 (zero) 41 | Mode: 2 (constant) 42 | Mode: 1 (symmetric) 43 | Mode: 6 (reflect) 44 | Mode: 4 (periodic) 45 | Mode: 3 (smooth) 46 | Mode: 5 (periodization) 47 | 48 | 49 | The default mode is :ref:`symmetric `: 50 | 51 | >>> cA, cD = pywt.dwt(x, 'db2') 52 | >>> print(cA) 53 | [ 1.76776695 1.73309178 3.40612438 6.32928585 7.77817459] 54 | >>> print(cD) 55 | [-0.61237244 -2.15599552 -5.95034847 -1.21545369 1.22474487] 56 | >>> print(pywt.idwt(cA, cD, 'db2')) 57 | [ 1. 2. 1. 5. -1. 8. 4. 6.] 58 | 59 | 60 | And using a keyword argument: 61 | 62 | >>> cA, cD = pywt.dwt(x, 'db2', mode='symmetric') 63 | >>> print(cA) 64 | [ 1.76776695 1.73309178 3.40612438 6.32928585 7.77817459] 65 | >>> print(cD) 66 | [-0.61237244 -2.15599552 -5.95034847 -1.21545369 1.22474487] 67 | >>> print(pywt.idwt(cA, cD, 'db2')) 68 | [ 1. 2. 1. 5. -1. 8. 4. 6.] 69 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/wavelet.pxd: -------------------------------------------------------------------------------- 1 | from .common cimport pywt_index_t 2 | 3 | cdef extern from "c/wavelets.h": 4 | ctypedef enum SYMMETRY: 5 | ASYMMETRIC 6 | NEAR_SYMMETRIC 7 | SYMMETRIC 8 | ANTI_SYMMETRIC 9 | 10 | 11 | ctypedef enum WAVELET_NAME: 12 | HAAR 13 | RBIO 14 | DB 15 | SYM 16 | COIF 17 | BIOR 18 | DMEY 19 | GAUS 20 | MEXH 21 | MORL 22 | CGAU 23 | SHAN 24 | FBSP 25 | CMOR 26 | 27 | ctypedef struct BaseWavelet: 28 | pywt_index_t support_width 29 | 30 | unsigned int orthogonal 31 | unsigned int biorthogonal 32 | unsigned int compact_support 33 | 34 | SYMMETRY symmetry 35 | 36 | 37 | int _builtin 38 | char* family_name 39 | char* short_name 40 | 41 | ctypedef struct DiscreteWavelet: 42 | double* dec_hi_double # highpass decomposition 43 | double* dec_lo_double # lowpass decomposition 44 | double* rec_hi_double # highpass reconstruction 45 | double* rec_lo_double # lowpass reconstruction 46 | 47 | float* dec_hi_float 48 | float* dec_lo_float 49 | float* rec_hi_float 50 | float* rec_lo_float 51 | size_t dec_len # length of decomposition filter 52 | size_t rec_len # length of reconstruction filter 53 | 54 | int vanishing_moments_psi 55 | int vanishing_moments_phi 56 | BaseWavelet base 57 | 58 | 59 | ctypedef struct ContinuousWavelet: 60 | 61 | BaseWavelet base 62 | float lower_bound 63 | float upper_bound 64 | float center_frequency 65 | float bandwidth_frequency 66 | unsigned int fbsp_order 67 | int complex_cwt 68 | 69 | 70 | cdef int is_discrete_wavelet(WAVELET_NAME name) 71 | cdef DiscreteWavelet* discrete_wavelet(WAVELET_NAME name, int type) 72 | cdef DiscreteWavelet* blank_discrete_wavelet(size_t filter_length) 73 | cdef void free_discrete_wavelet(DiscreteWavelet* wavelet) 74 | 75 | cdef ContinuousWavelet* continuous_wavelet(WAVELET_NAME name, int type) 76 | cdef ContinuousWavelet* blank_continuous_wavelet() 77 | cdef void free_continuous_wavelet(ContinuousWavelet* wavelet) 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /pywt-master/doc/source/pyplots/cwt_scaling_demo.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pywt 3 | import matplotlib.pyplot as plt 4 | 5 | wav = pywt.ContinuousWavelet('cmor1.5-1.0') 6 | 7 | # print the range over which the wavelet will be evaluated 8 | print("Continuous wavelet will be evaluated over the range [{}, {}]".format( 9 | wav.lower_bound, wav.upper_bound)) 10 | 11 | width = wav.upper_bound - wav.lower_bound 12 | 13 | scales = [1, 2, 3, 4, 10, 15] 14 | 15 | max_len = int(np.max(scales)*width + 1) 16 | t = np.arange(max_len) 17 | fig, axes = plt.subplots(len(scales), 2, figsize=(12, 6)) 18 | for n, scale in enumerate(scales): 19 | 20 | # The following code is adapted from the internals of cwt 21 | int_psi, x = pywt.integrate_wavelet(wav, precision=10) 22 | step = x[1] - x[0] 23 | j = np.floor( 24 | np.arange(scale * width + 1) / (scale * step)) 25 | if np.max(j) >= np.size(int_psi): 26 | j = np.delete(j, np.where((j >= np.size(int_psi)))[0]) 27 | j = j.astype(np.int) 28 | 29 | # normalize int_psi for easier plotting 30 | int_psi /= np.abs(int_psi).max() 31 | 32 | # discrete samples of the integrated wavelet 33 | filt = int_psi[j][::-1] 34 | 35 | # The CWT consists of convolution of filt with the signal at this scale 36 | # Here we plot this discrete convolution kernel at each scale. 37 | 38 | nt = len(filt) 39 | t = np.linspace(-nt//2, nt//2, nt) 40 | axes[n, 0].plot(t, filt.real, t, filt.imag) 41 | axes[n, 0].set_xlim([-max_len//2, max_len//2]) 42 | axes[n, 0].set_ylim([-1, 1]) 43 | axes[n, 0].text(50, 0.35, 'scale = {}'.format(scale)) 44 | 45 | f = np.linspace(-np.pi, np.pi, max_len) 46 | filt_fft = np.fft.fftshift(np.fft.fft(filt, n=max_len)) 47 | filt_fft /= np.abs(filt_fft).max() 48 | axes[n, 1].plot(f, np.abs(filt_fft)**2) 49 | axes[n, 1].set_xlim([-np.pi, np.pi]) 50 | axes[n, 1].set_ylim([0, 1]) 51 | axes[n, 1].set_xticks([-np.pi, 0, np.pi]) 52 | axes[n, 1].set_xticklabels([r'$-\pi$', '0', r'$\pi$']) 53 | axes[n, 1].grid(True, axis='x') 54 | axes[n, 1].text(np.pi/2, 0.5, 'scale = {}'.format(scale)) 55 | 56 | axes[n, 0].set_xlabel('time (samples)') 57 | axes[n, 1].set_xlabel('frequency (radians)') 58 | axes[0, 0].legend(['real', 'imaginary'], loc='upper left') 59 | axes[0, 1].legend(['Power'], loc='upper left') 60 | axes[0, 0].set_title('filter') 61 | axes[0, 1].set_title(r'|FFT(filter)|$^2$') 62 | -------------------------------------------------------------------------------- /pywt-master/doc/source/ref/2d-dwt-and-idwt.rst: -------------------------------------------------------------------------------- 1 | .. _ref-dwt2: 2 | 3 | .. currentmodule:: pywt 4 | 5 | ================================================= 6 | 2D Forward and Inverse Discrete Wavelet Transform 7 | ================================================= 8 | 9 | 10 | Single level ``dwt2`` 11 | ~~~~~~~~~~~~~~~~~~~~~ 12 | 13 | .. autofunction:: dwt2 14 | 15 | The relation to the other common data layout where all the approximation and 16 | details coefficients are stored in one big 2D array is as follows: 17 | 18 | :: 19 | 20 | ------------------- 21 | | | | 22 | | cA(LL) | cH(LH) | 23 | | | | 24 | (cA, (cH, cV, cD)) <---> ------------------- 25 | | | | 26 | | cV(HL) | cD(HH) | 27 | | | | 28 | ------------------- 29 | 30 | PyWavelets does not follow this pattern because of pure practical reasons of simple 31 | access to particular type of the output coefficients. 32 | 33 | 34 | Single level ``idwt2`` 35 | ~~~~~~~~~~~~~~~~~~~~~~ 36 | 37 | .. autofunction:: idwt2 38 | 39 | 2D multilevel decomposition using ``wavedec2`` 40 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 41 | 42 | .. autofunction:: wavedec2 43 | 44 | 2D multilevel reconstruction using ``waverec2`` 45 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 46 | 47 | .. autofunction:: waverec2 48 | 49 | 50 | 2D coordinate conventions 51 | ~~~~~~~~~~~~~~~~~~~~~~~~~ 52 | 53 | The labels for "horizontal" and "vertical" used by ``dwt2`` and ``idwt2`` 54 | follow the common mathematical convention that coordinate axis 0 55 | is horizontal while axis 1 is vertical:: 56 | 57 | dwt2, idwt2 convention 58 | ---------------------- 59 | 60 | axis 1 ^ 61 | | 62 | | 63 | | 64 | |---------> 65 | axis 0 66 | 67 | Note that this is different from another common convention used in computer 68 | graphics and image processing (e.g. by matplotlib's ``imshow`` and functions in 69 | ``scikit-image``). In those packages axis 0 is a vertical axis and axis 1 is 70 | horizontal as follows:: 71 | 72 | imshow convention 73 | ------------------- 74 | axis 1 75 | |---------> 76 | | 77 | | 78 | | 79 | axis 0 v 80 | 81 | -------------------------------------------------------------------------------- /pywt-master/pywt/tests/test_data.py: -------------------------------------------------------------------------------- 1 | import os 2 | import numpy as np 3 | from numpy.testing import assert_allclose, assert_raises, assert_ 4 | 5 | import pywt.data 6 | 7 | data_dir = os.path.join(os.path.dirname(__file__), 'data') 8 | wavelab_data_file = os.path.join(data_dir, 'wavelab_test_signals.npz') 9 | wavelab_result_dict = np.load(wavelab_data_file) 10 | 11 | 12 | def test_data_aero(): 13 | aero = pywt.data.aero() 14 | 15 | ref = np.array([[178, 178, 179], 16 | [170, 173, 171], 17 | [185, 174, 171]]) 18 | 19 | assert_allclose(aero[:3, :3], ref) 20 | 21 | 22 | def test_data_ascent(): 23 | ascent = pywt.data.ascent() 24 | 25 | ref = np.array([[83, 83, 83], 26 | [82, 82, 83], 27 | [80, 81, 83]]) 28 | 29 | assert_allclose(ascent[:3, :3], ref) 30 | 31 | 32 | def test_data_camera(): 33 | ascent = pywt.data.camera() 34 | 35 | ref = np.array([[156, 157, 160], 36 | [156, 157, 159], 37 | [158, 157, 156]]) 38 | 39 | assert_allclose(ascent[:3, :3], ref) 40 | 41 | 42 | def test_data_ecg(): 43 | ecg = pywt.data.ecg() 44 | 45 | ref = np.array([-86, -87, -87]) 46 | 47 | assert_allclose(ecg[:3], ref) 48 | 49 | 50 | def test_wavelab_signals(): 51 | """Comparison with results generated using WaveLab""" 52 | rtol = atol = 1e-12 53 | 54 | # get a list of the available signals 55 | available_signals = pywt.data.demo_signal('list') 56 | assert_('Doppler' in available_signals) 57 | 58 | for signal in available_signals: 59 | # reference dictionary has lowercase names for the keys 60 | key = signal.replace('-', '_').lower() 61 | val = wavelab_result_dict[key] 62 | if key in ['gabor', 'sineoneoverx']: 63 | # these functions do not allow a size to be provided 64 | assert_allclose(val, pywt.data.demo_signal(signal), 65 | rtol=rtol, atol=atol) 66 | assert_raises(ValueError, pywt.data.demo_signal, key, val.size) 67 | else: 68 | assert_allclose(val, pywt.data.demo_signal(signal, val.size), 69 | rtol=rtol, atol=atol) 70 | # these functions require a size to be provided 71 | assert_raises(ValueError, pywt.data.demo_signal, key) 72 | 73 | # ValueError on unrecognized signal type 74 | assert_raises(ValueError, pywt.data.demo_signal, 'unknown_signal', 512) 75 | 76 | # ValueError on invalid length 77 | assert_raises(ValueError, pywt.data.demo_signal, 'Doppler', 0) 78 | -------------------------------------------------------------------------------- /pywt-master/pywt/tests/test_deprecations.py: -------------------------------------------------------------------------------- 1 | import warnings 2 | 3 | import numpy as np 4 | from numpy.testing import assert_warns, assert_array_equal 5 | 6 | import pywt 7 | 8 | 9 | def test_intwave_deprecation(): 10 | wavelet = pywt.Wavelet('db3') 11 | assert_warns(DeprecationWarning, pywt.intwave, wavelet) 12 | 13 | 14 | def test_centrfrq_deprecation(): 15 | wavelet = pywt.Wavelet('db3') 16 | assert_warns(DeprecationWarning, pywt.centrfrq, wavelet) 17 | 18 | 19 | def test_scal2frq_deprecation(): 20 | wavelet = pywt.Wavelet('db3') 21 | assert_warns(DeprecationWarning, pywt.scal2frq, wavelet, 1) 22 | 23 | 24 | def test_orthfilt_deprecation(): 25 | assert_warns(DeprecationWarning, pywt.orthfilt, range(6)) 26 | 27 | 28 | def test_integrate_wave_tuple(): 29 | sig = [0, 1, 2, 3] 30 | xgrid = [0, 1, 2, 3] 31 | assert_warns(DeprecationWarning, pywt.integrate_wavelet, (sig, xgrid)) 32 | 33 | 34 | old_modes = ['zpd', 35 | 'cpd', 36 | 'sym', 37 | 'ppd', 38 | 'sp1', 39 | 'per', 40 | ] 41 | 42 | 43 | def test_MODES_from_object_deprecation(): 44 | for mode in old_modes: 45 | assert_warns(DeprecationWarning, pywt.Modes.from_object, mode) 46 | 47 | 48 | def test_MODES_attributes_deprecation(): 49 | def get_mode(Modes, name): 50 | return getattr(Modes, name) 51 | 52 | for mode in old_modes: 53 | assert_warns(DeprecationWarning, get_mode, pywt.Modes, mode) 54 | 55 | 56 | def test_MODES_deprecation_new(): 57 | def use_MODES_new(): 58 | return pywt.MODES.symmetric 59 | 60 | assert_warns(DeprecationWarning, use_MODES_new) 61 | 62 | 63 | def test_MODES_deprecation_old(): 64 | def use_MODES_old(): 65 | return pywt.MODES.sym 66 | 67 | assert_warns(DeprecationWarning, use_MODES_old) 68 | 69 | 70 | def test_MODES_deprecation_getattr(): 71 | def use_MODES_new(): 72 | return getattr(pywt.MODES, 'symmetric') 73 | 74 | assert_warns(DeprecationWarning, use_MODES_new) 75 | 76 | 77 | def test_mode_equivalence(): 78 | old_new = [('zpd', 'zero'), 79 | ('cpd', 'constant'), 80 | ('sym', 'symmetric'), 81 | ('ppd', 'periodic'), 82 | ('sp1', 'smooth'), 83 | ('per', 'periodization')] 84 | x = np.arange(8.) 85 | with warnings.catch_warnings(): 86 | warnings.simplefilter('ignore', DeprecationWarning) 87 | for old, new in old_new: 88 | assert_array_equal(pywt.dwt(x, 'db2', mode=old), 89 | pywt.dwt(x, 'db2', mode=new)) 90 | -------------------------------------------------------------------------------- /pywt-master/benchmarks/README.rst: -------------------------------------------------------------------------------- 1 | .. -*- rst -*- 2 | 3 | ===================== 4 | PyWavelets benchmarks 5 | ===================== 6 | 7 | Benchmarking PyWavelets with Airspeed Velocity. 8 | 9 | 10 | Usage 11 | ----- 12 | 13 | Airspeed Velocity manages building and Python virtualenvs (or conda 14 | environments) by itself, unless told otherwise. To run the benchmarks, you do 15 | not need to install a development version of PyWavelets to your current Python environment. 16 | 17 | First navigate to the benchmarks subfolder of the repository. 18 | 19 | cd benchmarks 20 | 21 | To run all benchmarks against the current build of PyWavelets:: 22 | 23 | asv run --python=same --quick 24 | 25 | The following notation (tag followed by ^!) can be used to run only on a 26 | specific tag or commit. (In this case, a python version for the virtualenv 27 | must be provided) 28 | 29 | asv run --python=3.5 --quick v0.4.0^! 30 | 31 | To record the results use: 32 | 33 | asv publish 34 | 35 | And to see the results via a web browser, run: 36 | 37 | asv preview 38 | 39 | More on how to use ``asv`` can be found in `ASV documentation`_ 40 | Command-line help is available as usual via ``asv --help`` and 41 | ``asv run --help``. 42 | 43 | .. _ASV documentation: https://asv.readthedocs.io/ 44 | 45 | 46 | Writing benchmarks 47 | ------------------ 48 | 49 | See `ASV documentation`_ for basics on how to write benchmarks. 50 | 51 | Some things to consider: 52 | 53 | - The benchmark files need to be importable when benchmarking old versions 54 | of PyWavelets. So if anything from PyWavelets is imported at the top level, 55 | it should be done as: 56 | 57 | try: 58 | from pywt import cwt 59 | except ImportError: 60 | pass 61 | 62 | The benchmarks themselves don't need any guarding against missing features 63 | --- only the top-level imports. 64 | 65 | To allow tests of newer functions to be marked as "n/a" (not available) 66 | rather than "failed" for older versions, the setup method itself can raise a NotImplemented error. See the following example for the CWT: 67 | 68 | try: 69 | from pywt import cwt 70 | except ImportError: 71 | raise NotImplementedError("cwt not available") 72 | 73 | - Try to keep the runtime of the benchmark reasonable. 74 | 75 | - Use ASV's ``time_`` methods for benchmarking times rather than cooking up 76 | time measurements via ``time.clock``, even if it requires some juggling when 77 | writing the benchmark. 78 | 79 | - Preparing arrays etc. should generally be put in the ``setup`` method rather 80 | than the ``time_`` methods, to avoid counting preparation time together with 81 | the time of the benchmarked operation. 82 | 83 | -------------------------------------------------------------------------------- /pywt-master/pywt/_pytest.py: -------------------------------------------------------------------------------- 1 | """common test-related code.""" 2 | import os 3 | import sys 4 | import multiprocessing 5 | import numpy as np 6 | import pytest 7 | 8 | 9 | __all__ = ['uses_matlab', # skip if pymatbridge and Matlab unavailable 10 | 'uses_futures', # skip if futures unavailable 11 | 'uses_pymatbridge', # skip if no PYWT_XSLOW environment variable 12 | 'uses_precomputed', # skip if PYWT_XSLOW environment variable found 13 | 'matlab_result_dict_cwt', # dict with precomputed Matlab dwt data 14 | 'matlab_result_dict_dwt', # dict with precomputed Matlab cwt data 15 | 'futures', # the futures module or None 16 | 'max_workers', # the number of workers available to futures 17 | 'size_set', # the set of Matlab tests to run 18 | ] 19 | 20 | try: 21 | if sys.version_info[0] == 2: 22 | import futures 23 | else: 24 | from concurrent import futures 25 | max_workers = multiprocessing.cpu_count() 26 | futures_available = True 27 | except ImportError: 28 | futures_available = False 29 | futures = None 30 | 31 | # check if pymatbridge + MATLAB tests should be run 32 | matlab_result_dict_dwt = None 33 | matlab_result_dict_cwt = None 34 | matlab_missing = True 35 | use_precomputed = True 36 | size_set = 'reduced' 37 | if 'PYWT_XSLOW' in os.environ: 38 | try: 39 | from pymatbridge import Matlab 40 | mlab = Matlab() 41 | matlab_missing = False 42 | use_precomputed = False 43 | size_set = 'full' 44 | except ImportError: 45 | print("To run Matlab compatibility tests you need to have MathWorks " 46 | "MATLAB, MathWorks Wavelet Toolbox and the pymatbridge Python " 47 | "package installed.") 48 | if use_precomputed: 49 | # load dictionaries of precomputed results 50 | data_dir = os.path.join(os.path.dirname(__file__), 'tests', 'data') 51 | matlab_data_file_cwt = os.path.join( 52 | data_dir, 'cwt_matlabR2015b_result.npz') 53 | matlab_result_dict_cwt = np.load(matlab_data_file_cwt) 54 | 55 | matlab_data_file_dwt = os.path.join( 56 | data_dir, 'dwt_matlabR2012a_result.npz') 57 | matlab_result_dict_dwt = np.load(matlab_data_file_dwt) 58 | 59 | uses_futures = pytest.mark.skipif( 60 | not futures_available, reason='futures not available') 61 | uses_matlab = pytest.mark.skipif( 62 | matlab_missing, reason='pymatbridge and/or Matlab not available') 63 | uses_pymatbridge = pytest.mark.skipif( 64 | use_precomputed, 65 | reason='PYWT_XSLOW set: skipping tests against precomputed Matlab results') 66 | uses_precomputed = pytest.mark.skipif( 67 | not use_precomputed, 68 | reason='PYWT_XSLOW not set: test against precomputed matlab tests') 69 | -------------------------------------------------------------------------------- /pywt-master/demo/dwt_swt_show_coeffs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import numpy as np 5 | import matplotlib.pyplot as plt 6 | 7 | import pywt 8 | import pywt.data 9 | 10 | 11 | ecg = pywt.data.ecg() 12 | 13 | data1 = np.concatenate((np.arange(1, 400), 14 | np.arange(398, 600), 15 | np.arange(601, 1024))) 16 | x = np.linspace(0.082, 2.128, num=1024)[::-1] 17 | data2 = np.sin(40 * np.log(x)) * np.sign((np.log(x))) 18 | 19 | mode = pywt.Modes.sp1DWT = 1 20 | 21 | 22 | def plot_coeffs(data, w, title, use_dwt=True): 23 | """Show dwt or swt coefficients for given data and wavelet.""" 24 | w = pywt.Wavelet(w) 25 | a = data 26 | ca = [] 27 | cd = [] 28 | 29 | if use_dwt: 30 | for i in range(5): 31 | (a, d) = pywt.dwt(a, w, mode) 32 | ca.append(a) 33 | cd.append(d) 34 | else: 35 | coeffs = pywt.swt(data, w, 5) # [(cA5, cD5), ..., (cA1, cD1)] 36 | for a, d in reversed(coeffs): 37 | ca.append(a) 38 | cd.append(d) 39 | 40 | fig = plt.figure() 41 | ax_main = fig.add_subplot(len(ca) + 1, 1, 1) 42 | ax_main.set_title(title) 43 | ax_main.plot(data) 44 | ax_main.set_xlim(0, len(data) - 1) 45 | 46 | for i, x in enumerate(ca): 47 | ax = fig.add_subplot(len(ca) + 1, 2, 3 + i * 2) 48 | ax.plot(x, 'r') 49 | ax.set_ylabel("A%d" % (i + 1)) 50 | if use_dwt: 51 | ax.set_xlim(0, len(x) - 1) 52 | else: 53 | ax.set_xlim(w.dec_len * i, len(x) - 1 - w.dec_len * i) 54 | 55 | for i, x in enumerate(cd): 56 | ax = fig.add_subplot(len(cd) + 1, 2, 4 + i * 2) 57 | ax.plot(x, 'g') 58 | ax.set_ylabel("D%d" % (i + 1)) 59 | # Scale axes 60 | ax.set_xlim(0, len(x) - 1) 61 | if use_dwt: 62 | ax.set_ylim(min(0, 1.4 * min(x)), max(0, 1.4 * max(x))) 63 | else: 64 | vals = x[w.dec_len * (1 + i):len(x) - w.dec_len * (1 + i)] 65 | ax.set_ylim(min(0, 2 * min(vals)), max(0, 2 * max(vals))) 66 | 67 | 68 | # Show DWT coefficients 69 | use_dwt = True 70 | plot_coeffs(data1, 'db1', 71 | "DWT: Signal irregularity shown in D1 - Haar wavelet", 72 | use_dwt) 73 | plot_coeffs(data2, 'sym5', "DWT: Frequency and phase change - Symmlets5", 74 | use_dwt) 75 | plot_coeffs(ecg, 'sym5', "DWT: Ecg sample - Symmlets5", use_dwt) 76 | 77 | # Show DWT coefficients 78 | use_dwt = False 79 | plot_coeffs(data1, 'db1', "SWT: Signal irregularity detection - Haar wavelet", 80 | use_dwt) 81 | plot_coeffs(data2, 'sym5', "SWT: Frequency and phase change - Symmlets5", 82 | use_dwt) 83 | plot_coeffs(ecg, 'sym5', "SWT: Ecg sample - simple QRS detection - Symmlets5", 84 | use_dwt) 85 | 86 | 87 | plt.show() 88 | -------------------------------------------------------------------------------- /pywt-master/doc/source/index.rst: -------------------------------------------------------------------------------- 1 | PyWavelets - Wavelet Transforms in Python 2 | ========================================= 3 | 4 | PyWavelets is open source wavelet transform software for Python_. It combines 5 | a simple high level interface with low level C and Cython performance. 6 | 7 | PyWavelets is very easy to use and get started with. Just install the package, 8 | open the Python interactive shell and type: 9 | 10 | .. sourcecode:: python 11 | 12 | >>> import pywt 13 | >>> cA, cD = pywt.dwt([1, 2, 3, 4], 'db1') 14 | 15 | Voilà! Computing wavelet transforms has never been so simple :) 16 | 17 | Here is a slightly more involved example of applying a digital wavelet 18 | transform to an image: 19 | 20 | .. plot:: pyplots/camera_approx_detail.py 21 | 22 | Main features 23 | ------------- 24 | 25 | The main features of PyWavelets are: 26 | 27 | * 1D, 2D and nD Forward and Inverse Discrete Wavelet Transform (DWT and IDWT) 28 | * 1D, 2D and nD Multilevel DWT and IDWT 29 | * 1D, 2D and nD Stationary Wavelet Transform (Undecimated Wavelet Transform) 30 | * 1D and 2D Wavelet Packet decomposition and reconstruction 31 | * 1D Continuous Wavelet Transform 32 | * Computing Approximations of wavelet and scaling functions 33 | * Over 100 `built-in wavelet filters`_ and support for custom wavelets 34 | * Single and double precision calculations 35 | * Real and complex calculations 36 | * Results compatible with Matlab Wavelet Toolbox (TM) 37 | 38 | 39 | Getting help 40 | ------------ 41 | 42 | Use `GitHub Issues`_, `StackOverflow`_, or the `PyWavelets discussions group`_ 43 | to post your comments or questions. 44 | 45 | License 46 | ------- 47 | 48 | PyWavelets is a free Open Source software released under the MIT license. 49 | 50 | Citing 51 | ------ 52 | 53 | If you use PyWavelets in a scientific publication, we would appreciate 54 | citations of the project via the following 55 | JOSS publication: 56 | 57 | Gregory R. Lee, Ralf Gommers, Filip Wasilewski, Kai Wohlfahrt, Aaron 58 | O'Leary (2019). PyWavelets: A Python package for wavelet analysis. Journal 59 | of Open Source Software, 4(36), 1237, https://doi.org/10.21105/joss.01237. 60 | 61 | .. image:: http://joss.theoj.org/papers/10.21105/joss.01237/status.svg 62 | :target: https://doi.org/10.21105/joss.01237 63 | 64 | Specific releases can also be cited via Zenodo. The DOI below will correspond 65 | to the most recent release. DOIs for past versions can be found by following 66 | the link in the badge below to Zenodo: 67 | 68 | .. image:: https://zenodo.org/badge/DOI/10.5281/zenodo.1407171.svg 69 | :target: https://doi.org/10.5281/zenodo.1407171 70 | 71 | Contents 72 | -------- 73 | 74 | .. toctree:: 75 | :maxdepth: 1 76 | 77 | install 78 | ref/index 79 | regression/index 80 | contributing 81 | dev/index 82 | releasenotes 83 | 84 | .. include:: common_refs.rst 85 | -------------------------------------------------------------------------------- /pywt-master/demo/plot_wavelets.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | # Plot scaling and wavelet functions for db, sym, coif, bior and rbio families 5 | 6 | import itertools 7 | 8 | import matplotlib.pyplot as plt 9 | 10 | import pywt 11 | 12 | 13 | plot_data = [('db', (4, 3)), 14 | ('sym', (4, 3)), 15 | ('coif', (3, 2))] 16 | 17 | 18 | for family, (rows, cols) in plot_data: 19 | fig = plt.figure() 20 | fig.subplots_adjust(hspace=0.2, wspace=0.2, bottom=.02, left=.06, 21 | right=.97, top=.94) 22 | colors = itertools.cycle('bgrcmyk') 23 | 24 | wnames = pywt.wavelist(family) 25 | i = iter(wnames) 26 | for col in range(cols): 27 | for row in range(rows): 28 | try: 29 | wavelet = pywt.Wavelet(next(i)) 30 | except StopIteration: 31 | break 32 | phi, psi, x = wavelet.wavefun(level=5) 33 | 34 | color = next(colors) 35 | ax = fig.add_subplot(rows, 2 * cols, 1 + 2 * (col + row * cols)) 36 | ax.set_title(wavelet.name + " phi") 37 | ax.plot(x, phi, color) 38 | ax.set_xlim(min(x), max(x)) 39 | 40 | ax = fig.add_subplot(rows, 2*cols, 1 + 2*(col + row*cols) + 1) 41 | ax.set_title(wavelet.name + " psi") 42 | ax.plot(x, psi, color) 43 | ax.set_xlim(min(x), max(x)) 44 | 45 | for family, (rows, cols) in [('bior', (4, 3)), ('rbio', (4, 3))]: 46 | fig = plt.figure() 47 | fig.subplots_adjust(hspace=0.5, wspace=0.2, bottom=.02, left=.06, 48 | right=.97, top=.94) 49 | 50 | colors = itertools.cycle('bgrcmyk') 51 | wnames = pywt.wavelist(family) 52 | i = iter(wnames) 53 | for col in range(cols): 54 | for row in range(rows): 55 | try: 56 | wavelet = pywt.Wavelet(next(i)) 57 | except StopIteration: 58 | break 59 | phi, psi, phi_r, psi_r, x = wavelet.wavefun(level=5) 60 | row *= 2 61 | 62 | color = next(colors) 63 | ax = fig.add_subplot(2*rows, 2*cols, 1 + 2*(col + row*cols)) 64 | ax.set_title(wavelet.name + " phi") 65 | ax.plot(x, phi, color) 66 | ax.set_xlim(min(x), max(x)) 67 | 68 | ax = fig.add_subplot(2*rows, 2*cols, 2*(1 + col + row*cols)) 69 | ax.set_title(wavelet.name + " psi") 70 | ax.plot(x, psi, color) 71 | ax.set_xlim(min(x), max(x)) 72 | 73 | row += 1 74 | ax = fig.add_subplot(2*rows, 2*cols, 1 + 2*(col + row*cols)) 75 | ax.set_title(wavelet.name + " phi_r") 76 | ax.plot(x, phi_r, color) 77 | ax.set_xlim(min(x), max(x)) 78 | 79 | ax = fig.add_subplot(2*rows, 2*cols, 1 + 2*(col + row*cols) + 1) 80 | ax.set_title(wavelet.name + " psi_r") 81 | ax.plot(x, psi_r, color) 82 | ax.set_xlim(min(x), max(x)) 83 | 84 | plt.show() 85 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/c/common.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2006-2012 Filip Wasilewski 2 | * Copyright (c) 2012-2016 The PyWavelets Developers 3 | * 4 | * See COPYING for license details. 5 | */ 6 | 7 | #include "common.h" 8 | #include // for U*_MAX 9 | 10 | // MSVC <= 2008 does not have stdint.h, but defines SIZE_MAX in limits.h 11 | #if (!defined(_MSC_VER)) || (_MSC_VER > 1500) 12 | #include // for SIZE_MAX 13 | #endif /* _MSC_VER */ 14 | 15 | /* Returns the floor of the base-2 log of it's input 16 | * 17 | * Undefined for x = 0 18 | */ 19 | unsigned char size_log2(size_t x){ 20 | #if defined(_MSC_VER) 21 | unsigned long i; 22 | #if SIZE_MAX == 0xFFFFFFFF 23 | _BitScanReverse(&i, x); 24 | #elif SIZE_MAX == 0xFFFFFFFFFFFFFFFF 25 | _BitScanReverse64(&i, x); 26 | #else 27 | #error "Unrecognized SIZE_MAX" 28 | #endif /* SIZE_MAX */ 29 | return i; 30 | #else 31 | // GCC and clang 32 | // Safe cast: 0 <= clzl < arch_bits (64) where result is defined 33 | #if SIZE_MAX == UINT_MAX 34 | unsigned char leading_zeros = (unsigned char) __builtin_clz(x); 35 | #elif SIZE_MAX == ULONG_MAX 36 | unsigned char leading_zeros = (unsigned char) __builtin_clzl(x); 37 | #elif SIZE_MAX == ULLONG_MAX 38 | unsigned char leading_zeros = (unsigned char) __builtin_clzll(x); 39 | #else 40 | #error "Unrecognized SIZE_MAX" 41 | #endif /* SIZE_MAX */ 42 | return sizeof(size_t) * 8 - leading_zeros - 1; 43 | #endif /* _MSC_VER */ 44 | } 45 | 46 | /* buffers and max levels params */ 47 | 48 | size_t dwt_buffer_length(size_t input_len, size_t filter_len, MODE mode){ 49 | if(input_len < 1 || filter_len < 1) 50 | return 0; 51 | 52 | switch(mode){ 53 | case MODE_PERIODIZATION: 54 | return input_len / 2 + ((input_len%2) ? 1 : 0); 55 | default: 56 | return (input_len + filter_len - 1) / 2; 57 | } 58 | } 59 | 60 | size_t reconstruction_buffer_length(size_t coeffs_len, size_t filter_len){ 61 | if(coeffs_len < 1 || filter_len < 1) 62 | return 0; 63 | 64 | return 2*coeffs_len+filter_len-2; 65 | } 66 | 67 | size_t idwt_buffer_length(size_t coeffs_len, size_t filter_len, MODE mode){ 68 | switch(mode){ 69 | case MODE_PERIODIZATION: 70 | return 2*coeffs_len; 71 | default: 72 | return 2*coeffs_len-filter_len+2; 73 | } 74 | } 75 | 76 | size_t swt_buffer_length(size_t input_len){ 77 | return input_len; 78 | } 79 | 80 | unsigned char dwt_max_level(size_t input_len, size_t filter_len){ 81 | if(filter_len <= 1 || input_len < (filter_len-1)) 82 | return 0; 83 | 84 | return size_log2(input_len/(filter_len-1)); 85 | } 86 | 87 | unsigned char swt_max_level(size_t input_len){ 88 | /* check how many times input_len is divisible by 2 */ 89 | unsigned char j = 0; 90 | while (input_len > 0){ 91 | if (input_len % 2) 92 | return j; 93 | input_len /= 2; 94 | j++; 95 | } 96 | return j; 97 | } 98 | -------------------------------------------------------------------------------- /pywt-master/benchmarks/asv.conf.json: -------------------------------------------------------------------------------- 1 | { 2 | // The version of the config file format. Do not change, unless 3 | // you know what you are doing. 4 | "version": 1, 5 | 6 | // The name of the project being benchmarked 7 | "project": "pywt", 8 | 9 | // The project's homepage 10 | "project_url": "https://github.com/PyWavelets/pywt/", 11 | 12 | // The URL or local path of the source code repository for the 13 | // project being benchmarked 14 | //"repo": "https://github.com/PyWavelets/pywt.git", 15 | "repo": "..", 16 | 17 | // List of branches to benchmark. If not provided, defaults to "master" 18 | // (for git) or "tip" (for mercurial). 19 | "branches": ["master"], // for git 20 | // "branches": ["tip"], // for mercurial 21 | 22 | // The DVCS being used. If not set, it will be automatically 23 | // determined from "repo" by looking at the protocol in the URL 24 | // (if remote), or by looking for special directories, such as 25 | // ".git" (if local). 26 | "dvcs": "git", 27 | 28 | // The tool to use to create environments. May be "conda", 29 | // "virtualenv" or other value depending on the plugins in use. 30 | // If missing or the empty string, the tool will be automatically 31 | // determined by looking for tools on the PATH environment 32 | // variable. 33 | // "environment_type": "virtualenv", 34 | 35 | // the base URL to show a commit for the project. 36 | "show_commit_url": "http://github.com/PyWavelets/pywt/commit/", 37 | 38 | // The Pythons you'd like to test against. If not provided, defaults 39 | // to the current version of Python used to run `asv`. 40 | // "pythons": ["2.7", "3.4"], 41 | 42 | // The matrix of dependencies to test. Each key is the name of a 43 | // package (in PyPI) and the values are version numbers. An empty 44 | // list indicates to just test against the default (latest) 45 | // version. 46 | "matrix": { 47 | "numpy": [], 48 | "Cython": [], 49 | }, 50 | 51 | // The directory (relative to the current directory) that benchmarks are 52 | // stored in. If not provided, defaults to "benchmarks" 53 | // "benchmark_dir": "benchmarks", 54 | 55 | // The directory (relative to the current directory) to cache the Python 56 | // environments in. If not provided, defaults to "env" 57 | // "env_dir": "env", 58 | 59 | 60 | // The directory (relative to the current directory) that raw benchmark 61 | // results are stored in. If not provided, defaults to "results". 62 | // "results_dir": "results", 63 | 64 | // The directory (relative to the current directory) that the html tree 65 | // should be written to. If not provided, defaults to "html". 66 | // "html_dir": "html", 67 | 68 | // The number of characters to retain in the commit hashes. 69 | // "hash_length": 8, 70 | 71 | // `asv` will cache wheels of the recent builds in each 72 | // environment, making them faster to install next time. This is 73 | // number of builds to keep, per environment. 74 | // "wheel_cache_size": 0 75 | } 76 | -------------------------------------------------------------------------------- /pywt-master/CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | ================================== 2 | PyWavelets pull request guidelines 3 | ================================== 4 | 5 | Pull requests are always welcome, and the PyWavelets community appreciates 6 | any help you give. 7 | 8 | When submitting a pull request, we ask you check the following: 9 | 10 | 1. **Unit tests**, **documentation**, and **code style** are in order. 11 | See below for details. 12 | 13 | It's also OK to submit work in progress if you're unsure of what 14 | this exactly means, in which case you'll likely be asked to make 15 | some further changes. 16 | 17 | 2. The contributed code will be **licensed under PyWavelets's license**, 18 | (the MIT license, https://github.com/PyWavelets/pywt/blob/master/LICENSE). 19 | If you did not write the code yourself, you ensure the existing 20 | license is compatible and include the license information in the 21 | contributed files, or obtain a permission from the original 22 | author to relicense the contributed code. 23 | 24 | 25 | Coding guidelines 26 | ================= 27 | 28 | 1. Unit tests 29 | In principle you should aim to create unit tests that exercise all the code 30 | that you are adding. This gives some degree of confidence that your code 31 | runs correctly, also on Python versions and hardware or OSes that you don't 32 | have available yourself. An extensive description of how to write unit 33 | tests is given in the NumPy `testing guidelines`_. 34 | 35 | 2. Documentation 36 | Clear and complete documentation is essential in order for users to be able 37 | to find and understand the code. Documentation for individual functions 38 | and classes -- which includes at least a basic description, type and 39 | meaning of all parameters and returns values, and usage examples in 40 | `doctest`_ format -- is put in docstrings. Those docstrings can be read 41 | within the interpreter, and are compiled into a reference guide in html and 42 | pdf format. Higher-level documentation for key (areas of) functionality is 43 | provided in tutorial format and/or in module docstrings. A guide on how to 44 | write documentation is given in the `numpydoc docstring guide`_. 45 | 46 | 3. Code style 47 | Uniformity of style in which code is written is important to others trying 48 | to understand the code. PyWavelets follows the standard Python guidelines 49 | for code style, `PEP8`_. In order to check that your code conforms to 50 | PEP8, you can use the `pep8 package`_ style checker. Most IDEs and text 51 | editors have settings that can help you follow PEP8, for example by 52 | translating tabs by four spaces. Using `pyflakes`_ to check your code is 53 | also a good idea. 54 | 55 | 56 | .. _PEP8: http://www.python.org/dev/peps/pep-0008/ 57 | 58 | .. _pep8 package: http://pypi.python.org/pypi/pep8 59 | 60 | .. _numpydoc docstring guide: https://numpydoc.readthedocs.io/en/latest/ 61 | 62 | .. _doctest: http://www.doughellmann.com/PyMOTW/doctest/ 63 | 64 | .. _pyflakes: http://pypi.python.org/pypi/pyflakes 65 | 66 | .. _testing guidelines: https://github.com/numpy/numpy/blob/master/doc/TESTS.rst.txt 67 | -------------------------------------------------------------------------------- /PyEMD-master/doc/examples.rst: -------------------------------------------------------------------------------- 1 | Example 2 | ******* 3 | 4 | Some examples can be found in PyEMD/example directory. 5 | 6 | EMD 7 | === 8 | 9 | Quick start 10 | ----------- 11 | In most cases default settings are enough. Simply 12 | import :py:class:`EMD` and pass your signal to `emd` method. 13 | 14 | .. code:: python 15 | 16 | from PyEMD import EMD 17 | 18 | s = np.random.random(100) 19 | emd = EMD() 20 | IMFs = emd.emd(s) 21 | 22 | Something more 23 | `````````````` 24 | Here is a complete script on how to create and plot results. 25 | 26 | .. code:: python 27 | 28 | from PyEMD import EMD 29 | import numpy as np 30 | import pylab as plt 31 | 32 | # Define signal 33 | t = np.linspace(0, 1, 200) 34 | s = np.cos(11*2*np.pi*t*t) + 6*t*t 35 | 36 | # Execute EMD on signal 37 | IMF = EMD().emd(s,t) 38 | N = IMF.shape[0]+1 39 | 40 | # Plot results 41 | plt.subplot(N,1,1) 42 | plt.plot(t, s, 'r') 43 | plt.title("Input signal: $S(t)=cos(22\pi t^2) + 6t^2$") 44 | plt.xlabel("Time [s]") 45 | 46 | for n, imf in enumerate(IMF): 47 | plt.subplot(N,1,n+2) 48 | plt.plot(t, imf, 'g') 49 | plt.title("IMF "+str(n+1)) 50 | plt.xlabel("Time [s]") 51 | 52 | plt.tight_layout() 53 | plt.savefig('simple_example') 54 | plt.show() 55 | 56 | 57 | The Figure below was produced with input: 58 | 59 | :math:`S(t) = cos(22 \pi t^2) + 6t^2` 60 | 61 | |simpleExample| 62 | 63 | EEMD 64 | ==== 65 | 66 | Simplest case of using Esnembld EMD (EEMD) is by importing `EEMD` and passing your signal to `eemd` method. 67 | 68 | .. code:: python 69 | 70 | from PyEMD import EEMD 71 | import numpy as np 72 | import pylab as plt 73 | 74 | # Define signal 75 | t = np.linspace(0, 1, 200) 76 | 77 | sin = lambda x,p: np.sin(2*np.pi*x*t+p) 78 | S = 3*sin(18,0.2)*(t-0.2)**2 79 | S += 5*sin(11,2.7) 80 | S += 3*sin(14,1.6) 81 | S += 1*np.sin(4*2*np.pi*(t-0.8)**2) 82 | S += t**2.1 -t 83 | 84 | # Assign EEMD to `eemd` variable 85 | eemd = EEMD() 86 | 87 | # Say we want detect extrema using parabolic method 88 | emd = eemd.EMD 89 | emd.extrema_detection="parabol" 90 | 91 | # Execute EEMD on S 92 | eIMFs = eemd.eemd(S, t) 93 | nIMFs = eIMFs.shape[0] 94 | 95 | # Plot results 96 | plt.figure(figsize=(12,9)) 97 | plt.subplot(nIMFs+1, 1, 1) 98 | plt.plot(t, S, 'r') 99 | 100 | for n in range(nIMFs): 101 | plt.subplot(nIMFs+1, 1, n+2) 102 | plt.plot(t, eIMFs[n], 'g') 103 | plt.ylabel("eIMF %i" %(n+1)) 104 | plt.locator_params(axis='y', nbins=5) 105 | 106 | plt.xlabel("Time [s]") 107 | plt.tight_layout() 108 | plt.savefig('eemd_example', dpi=120) 109 | plt.show() 110 | 111 | |eemdExample| 112 | 113 | 114 | .. |simpleExample| image:: https://github.com/laszukdawid/PyEMD/raw/master/example/simple_example.png?raw=true 115 | :width: 640px 116 | :height: 480px 117 | .. |eemdExample| image:: https://github.com/laszukdawid/PyEMD/raw/master/example/eemd_example.png?raw=true 118 | :width: 720px 119 | :height: 540px 120 | -------------------------------------------------------------------------------- /pywt-master/demo/fswavedecn_mondrian.py: -------------------------------------------------------------------------------- 1 | """Using the FSWT to process anistropic images. 2 | 3 | In this demo, an anisotropic piecewise-constant image is transformed by the 4 | standard DWT and the fully-separable DWT. The 'Haar' wavelet gives a sparse 5 | representation for such piecewise constant signals (detail coefficients are 6 | only non-zero near edges). 7 | 8 | For such anistropic signals, the number of non-zero coefficients will be lower 9 | for the fully separable DWT than for the isotropic one. 10 | 11 | This example is inspired by the following publication where it is proven that 12 | the FSWT gives a sparser representation than the DWT for this class of 13 | anistropic images: 14 | 15 | .. V Velisavljevic, B Beferull-Lozano, M Vetterli and PL Dragotti. 16 | Directionlets: Anisotropic Multidirectional Representation With 17 | Separable Filtering. IEEE Transactions on Image Processing, Vol. 15, 18 | No. 7, July 2006. 19 | 20 | """ 21 | 22 | import numpy as np 23 | import pywt 24 | 25 | from matplotlib import pyplot as plt 26 | 27 | 28 | def mondrian(shape=(256, 256), nx=5, ny=8, seed=4): 29 | """ Piecewise-constant image (reminiscent of Dutch painter Piet Mondrian's 30 | geometrical period). 31 | """ 32 | rstate = np.random.RandomState(seed) 33 | min_dx = 0 34 | while(min_dx < 3): 35 | xp = np.sort(np.round(rstate.rand(nx-1)*shape[0]).astype(np.int)) 36 | xp = np.concatenate(((0, ), xp, (shape[0], ))) 37 | min_dx = np.min(np.diff(xp)) 38 | min_dy = 0 39 | while(min_dy < 3): 40 | yp = np.sort(np.round(rstate.rand(ny-1)*shape[1]).astype(np.int)) 41 | yp = np.concatenate(((0, ), yp, (shape[1], ))) 42 | min_dy = np.min(np.diff(yp)) 43 | img = np.zeros(shape) 44 | for ix, x in enumerate(xp[:-1]): 45 | for iy, y in enumerate(yp[:-1]): 46 | slices = [slice(x, xp[ix+1]), slice(y, yp[iy+1])] 47 | val = rstate.rand(1)[0] 48 | img[slices] = val 49 | return img 50 | 51 | 52 | # create an anisotropic piecewise constant image 53 | img = mondrian((128, 128)) 54 | 55 | # perform DWT 56 | coeffs_dwt = pywt.wavedecn(img, wavelet='db1', level=None) 57 | 58 | # convert coefficient dictionary to a single array 59 | coeff_array_dwt, _ = pywt.coeffs_to_array(coeffs_dwt) 60 | 61 | # perform fully seperable DWT 62 | fswavedecn_result = pywt.fswavedecn(img, wavelet='db1') 63 | 64 | nnz_dwt = np.sum(coeff_array_dwt != 0) 65 | nnz_fswavedecn = np.sum(fswavedecn_result.coeffs != 0) 66 | 67 | print("Number of nonzero wavedecn coefficients = {}".format(np.sum(nnz_dwt))) 68 | print("Number of nonzero fswavedecn coefficients = {}".format(np.sum(nnz_fswavedecn))) 69 | 70 | img = mondrian() 71 | fig, axes = plt.subplots(1, 3) 72 | imshow_kwargs = dict(cmap=plt.cm.gray, interpolation='nearest') 73 | axes[0].imshow(img, **imshow_kwargs) 74 | axes[0].set_title('Anisotropic Image') 75 | axes[1].imshow(coeff_array_dwt != 0, **imshow_kwargs) 76 | axes[1].set_title('Nonzero DWT\ncoefficients\n(N={})'.format(nnz_dwt)) 77 | axes[2].imshow(fswavedecn_result.coeffs != 0, **imshow_kwargs) 78 | axes[2].set_title('Nonzero FSWT\ncoefficients\n(N={})'.format(nnz_fswavedecn)) 79 | for ax in axes: 80 | ax.set_axis_off() 81 | 82 | plt.show() 83 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/c/wavelets.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2006-2012 Filip Wasilewski 2 | * Copyright (c) 2012-2016 The PyWavelets Developers 3 | * 4 | * See COPYING for license details. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "common.h" 10 | 11 | /* Wavelet symmetry properties */ 12 | typedef enum { 13 | UNKNOWN = -1, 14 | ASYMMETRIC = 0, 15 | NEAR_SYMMETRIC = 1, 16 | SYMMETRIC = 2, 17 | ANTI_SYMMETRIC = 3 18 | } SYMMETRY; 19 | 20 | /* Wavelet name */ 21 | typedef enum { 22 | HAAR, 23 | RBIO, 24 | DB, 25 | SYM, 26 | COIF, 27 | BIOR, 28 | DMEY, 29 | GAUS, 30 | MEXH, 31 | MORL, 32 | CGAU, 33 | SHAN, 34 | FBSP, 35 | CMOR 36 | } WAVELET_NAME; 37 | 38 | 39 | /* Wavelet structure holding pointers to filter arrays and property attributes */ 40 | typedef struct { 41 | /* Wavelet properties */ 42 | 43 | pywt_index_t support_width; 44 | 45 | SYMMETRY symmetry; 46 | 47 | unsigned int orthogonal:1; 48 | unsigned int biorthogonal:1; 49 | unsigned int compact_support:1; 50 | 51 | int _builtin; 52 | char* family_name; 53 | char* short_name; 54 | 55 | 56 | } BaseWavelet; 57 | 58 | typedef struct { 59 | BaseWavelet base; 60 | double* dec_hi_double; /* highpass decomposition */ 61 | double* dec_lo_double; /* lowpass decomposition */ 62 | double* rec_hi_double; /* highpass reconstruction */ 63 | double* rec_lo_double; /* lowpass reconstruction */ 64 | float* dec_hi_float; 65 | float* dec_lo_float; 66 | float* rec_hi_float; 67 | float* rec_lo_float; 68 | size_t dec_len; /* length of decomposition filter */ 69 | size_t rec_len; /* length of reconstruction filter */ 70 | 71 | int vanishing_moments_psi; 72 | int vanishing_moments_phi; 73 | 74 | } DiscreteWavelet; 75 | 76 | typedef struct { 77 | 78 | BaseWavelet base; 79 | float lower_bound; 80 | float upper_bound; 81 | /* Parameters for shan, fbsp, cmor*/ 82 | int complex_cwt; 83 | float center_frequency; 84 | float bandwidth_frequency; 85 | unsigned int fbsp_order; 86 | 87 | } ContinuousWavelet; 88 | 89 | 90 | int is_discrete_wavelet(WAVELET_NAME name); 91 | 92 | /* 93 | * Allocate Wavelet struct and set its attributes 94 | * name - (currently) a character codename of a wavelet family 95 | * order - order of the wavelet (ie. coif3 has order 3) 96 | */ 97 | DiscreteWavelet* discrete_wavelet(WAVELET_NAME name, unsigned int order); 98 | ContinuousWavelet* continuous_wavelet(WAVELET_NAME name, unsigned int order); 99 | /* 100 | * Allocate blank Discrete Wavelet with zero-filled filters of given length 101 | */ 102 | DiscreteWavelet* blank_discrete_wavelet(size_t filters_length); 103 | 104 | ContinuousWavelet* blank_continuous_wavelet(void); 105 | 106 | /* Deep copy Discrete Wavelet */ 107 | DiscreteWavelet* copy_discrete_wavelet(DiscreteWavelet* base); 108 | 109 | /* 110 | * Free wavelet struct. Use this to free Wavelet allocated with 111 | * wavelet(...) or blank_wavelet(...) functions. 112 | */ 113 | void free_discrete_wavelet(DiscreteWavelet *wavelet); 114 | 115 | void free_continuous_wavelet(ContinuousWavelet *wavelet); 116 | -------------------------------------------------------------------------------- /pywt-master/.travis.yml: -------------------------------------------------------------------------------- 1 | # After changing this file, check it on: 2 | # http://lint.travis-ci.org/ 3 | language: python 4 | sudo: false 5 | 6 | env: 7 | global: 8 | # Use non-interactive backend 9 | - MPLBACKEND: Agg 10 | - CYTHON_TRACE: 1 11 | 12 | matrix: 13 | include: 14 | - os: linux 15 | python: 3.6 16 | env: 17 | - NUMPYSPEC=numpy 18 | - MATPLOTLIBSPEC=matplotlib 19 | - CYTHONSPEC=cython 20 | - USE_WHEEL=1 21 | - os: linux 22 | python: 3.7 23 | dist: xenial # travis-ci/travis-ci/issues/9815 24 | sudo: true 25 | env: 26 | - NUMPYSPEC=numpy 27 | - MATPLOTLIBSPEC=matplotlib 28 | - CYTHONSPEC=cython 29 | - USE_SDIST=1 30 | - USE_SCIPY=1 31 | - os: linux 32 | python: 3.5 33 | env: 34 | - NUMPYSPEC="numpy==1.13.3" 35 | - MATPLOTLIBSPEC=matplotlib 36 | - CYTHONSPEC="cython==0.23.5" 37 | - REFGUIDE_CHECK=1 # run doctests only 38 | - os: osx 39 | osx_image: xcode7.3 40 | language: objective-c 41 | env: 42 | - NUMPYSPEC=numpy 43 | - MATPLOTLIBSPEC=matplotlib 44 | - CYTHONSPEC=cython 45 | - TRAVIS_PYTHON_VERSION=3.5 46 | 47 | cache: pip 48 | 49 | before_install: 50 | - uname -a 51 | - df -h 52 | - ulimit -a 53 | - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then source util/travis_osx_install.sh; fi 54 | - ccache -s 55 | - which python; python --version 56 | - pip install --upgrade pip 57 | - pip install --upgrade wheel 58 | # Set numpy version first, other packages link against it 59 | - pip install $NUMPYSPEC 60 | - pip install $MATPLOTLIBSPEC 61 | - pip install $CYTHONSPEC 62 | - pip install pytest pytest-cov coverage codecov futures 63 | - set -o pipefail 64 | - if [ "${USE_WHEEL}" == "1" ]; then pip install wheel; fi 65 | - if [ "${USE_SCIPY}" == "1" ]; then pip install scipy; fi 66 | - | 67 | if [ "${REFGUIDE_CHECK}" == "1" ]; then 68 | pip install sphinx numpydoc 69 | fi 70 | 71 | script: 72 | # Define a fixed build dir so next step works 73 | - | 74 | if [ "${USE_WHEEL}" == "1" ]; then 75 | # Need verbose output or TravisCI will terminate after 10 minutes 76 | pip wheel . -v 77 | pip install PyWavelets*.whl -v 78 | pushd demo 79 | pytest --pyargs pywt 80 | python ../pywt/tests/test_doc.py 81 | popd 82 | elif [ "${USE_SDIST}" == "1" ]; then 83 | python setup.py sdist 84 | # Move out of source directory to avoid finding local pywt 85 | pushd dist 86 | pip install PyWavelets* -v 87 | pytest --pyargs pywt 88 | python ../pywt/tests/test_doc.py 89 | popd 90 | elif [ "${REFGUIDE_CHECK}" == "1" ]; then 91 | pip install -e . -v 92 | python util/refguide_check.py --doctests 93 | else 94 | CFLAGS="--coverage" python setup.py build --build-lib build/lib/ --build-temp build/tmp/ 95 | CFLAGS="--coverage" pip install -e . -v 96 | pushd demo 97 | pytest --pyargs pywt --cov=pywt 98 | popd 99 | fi 100 | 101 | after_success: 102 | - codecov 103 | # Travis CI has old gcov, needs object dir explicitly specified 104 | - gcov --object-directory build/tmp/pywt/_extensions/c/ build/tmp/pywt/_extensions/c/*.o 105 | - bash <(curl -s https://codecov.io/bash) 106 | -------------------------------------------------------------------------------- /pywt-master/benchmarks/benchmarks/swt_benchmarks.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import pywt 3 | 4 | 5 | class SwtTimeSuiteBase(object): 6 | """ 7 | Set-up for (I)SWT timing. 8 | """ 9 | params = ([16, 64, 256, 1024, 4096], 10 | ['haar', 'db4', 'sym8'],) 11 | param_names = ('n', 'wavelet') 12 | 13 | def setup(self, n, wavelet): 14 | self.data = np.ones(n, dtype='float') 15 | 16 | 17 | class SwtTimeSuite(SwtTimeSuiteBase): 18 | def time_swt(self, n, wavelet): 19 | pywt.swt(self.data, wavelet) 20 | 21 | 22 | class IswtTimeSuite(SwtTimeSuiteBase): 23 | def setup(self, n, wavelet): 24 | try: 25 | from pywt import iswt 26 | except ImportError: 27 | raise NotImplementedError("iswt not available") 28 | super(IswtTimeSuite, self).setup(n, wavelet) 29 | self.coeffs = pywt.swt(self.data, wavelet) 30 | 31 | def time_iswt(self, n, wavelet): 32 | pywt.iswt(self.coeffs, wavelet) 33 | 34 | 35 | class Swt2TimeSuiteBase(object): 36 | """ 37 | Set-up for (I)SWT2 timing. 38 | """ 39 | params = ([16, 64, 256], 40 | ['haar', 'db4'],) 41 | param_names = ('n', 'wavelet') 42 | 43 | def setup(self, n, wavelet): 44 | try: 45 | from pywt import swt2 46 | except ImportError: 47 | raise NotImplementedError("swt2 not available") 48 | self.data = np.ones((n, n), dtype='float') 49 | self.level = pywt.swt_max_level(n) 50 | 51 | 52 | class Swt2TimeSuite(Swt2TimeSuiteBase): 53 | def time_swt2(self, n, wavelet): 54 | pywt.swt2(self.data, wavelet, self.level) 55 | 56 | 57 | class Iswt2TimeSuite(Swt2TimeSuiteBase): 58 | def setup(self, n, wavelet): 59 | try: 60 | from pywt import iswt2 61 | except ImportError: 62 | raise NotImplementedError("iswt2 not available") 63 | super(Iswt2TimeSuite, self).setup(n, wavelet) 64 | self.data = pywt.swt2(self.data, wavelet, self.level) 65 | 66 | def time_iswt2(self, n, wavelet): 67 | pywt.iswt2(self.data, wavelet) 68 | 69 | 70 | class SwtnTimeSuiteBase(object): 71 | """ 72 | Set-up for (I)SWTN timing. 73 | """ 74 | params = ([1, 2, 3], 75 | [16, 64], 76 | ['haar', 'db4'], 77 | [np.float32, np.float64, np.complex64]) 78 | param_names = ('D', 'n', 'wavelet', 'dtype') 79 | 80 | def setup(self, D, n, wavelet, dtype): 81 | try: 82 | from pywt import swtn 83 | except ImportError: 84 | raise NotImplementedError("swtn not available") 85 | self.data = np.ones((n,) * D, dtype=dtype) 86 | self.level = 4 # run 4 levels in all cases 87 | 88 | 89 | class SwtnTimeSuite(SwtnTimeSuiteBase): 90 | def time_swtn(self, D, n, wavelet, dtype): 91 | pywt.swtn(self.data, wavelet, self.level) 92 | 93 | 94 | class IswtnTimeSuite(SwtnTimeSuiteBase): 95 | def setup(self, D, n, wavelet, dtype): 96 | try: 97 | from pywt import iswtn 98 | except ImportError: 99 | raise NotImplementedError("iswtn not available") 100 | super(IswtnTimeSuite, self).setup(D, n, wavelet, dtype) 101 | self.data = pywt.swtn(self.data, wavelet, self.level) 102 | 103 | def time_iswtn(self, D, n, wavelet, dtype): 104 | pywt.iswtn(self.data, wavelet) 105 | -------------------------------------------------------------------------------- /pywt-master/doc/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 14 | 15 | .PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest 16 | 17 | help: 18 | @echo "Please use \`make ' where is one of" 19 | @echo " html to make standalone HTML files" 20 | @echo " dirhtml to make HTML files named index.html in directories" 21 | @echo " pickle to make pickle files" 22 | @echo " json to make JSON files" 23 | @echo " htmlhelp to make HTML files and a HTML help project" 24 | @echo " qthelp to make HTML files and a qthelp project" 25 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 26 | @echo " changes to make an overview of all changed/added/deprecated items" 27 | @echo " linkcheck to check all external links for integrity" 28 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 29 | 30 | clean: 31 | -rm -rf $(BUILDDIR)/* 32 | 33 | html: 34 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 35 | @echo 36 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 37 | 38 | dirhtml: 39 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 40 | @echo 41 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 42 | 43 | pickle: 44 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 45 | @echo 46 | @echo "Build finished; now you can process the pickle files." 47 | 48 | json: 49 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 50 | @echo 51 | @echo "Build finished; now you can process the JSON files." 52 | 53 | htmlhelp: 54 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 55 | @echo 56 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 57 | ".hhp project file in $(BUILDDIR)/htmlhelp." 58 | 59 | qthelp: 60 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 61 | @echo 62 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 63 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 64 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/PyWavelets.qhcp" 65 | @echo "To view the help file:" 66 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/PyWavelets.qhc" 67 | 68 | latex: 69 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 70 | @echo 71 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 72 | @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ 73 | "run these through (pdf)latex." 74 | 75 | changes: 76 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 77 | @echo 78 | @echo "The overview file is in $(BUILDDIR)/changes." 79 | 80 | linkcheck: 81 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 82 | @echo 83 | @echo "Link check complete; look for any errors in the above output " \ 84 | "or in $(BUILDDIR)/linkcheck/output.txt." 85 | 86 | doctest: 87 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 88 | @echo "Testing of doctests in the sources finished, look at the " \ 89 | "results in $(BUILDDIR)/doctest/output.txt." 90 | -------------------------------------------------------------------------------- /pywt-master/pywt/tests/data/generate_matlab_data_cwt.py: -------------------------------------------------------------------------------- 1 | """ This script was used to generate dwt_matlabR2012a_result.npz by storing 2 | the outputs from Matlab R2012a. """ 3 | 4 | from __future__ import division, print_function, absolute_import 5 | 6 | import numpy as np 7 | import pywt 8 | 9 | try: 10 | from pymatbridge import Matlab 11 | mlab = Matlab() 12 | _matlab_missing = False 13 | except ImportError: 14 | print("To run Matlab compatibility tests you need to have MathWorks " 15 | "MATLAB, MathWorks Wavelet Toolbox and the pymatbridge Python " 16 | "package installed.") 17 | _matlab_missing = True 18 | 19 | if _matlab_missing: 20 | raise EnvironmentError("Can't generate matlab data files without MATLAB") 21 | 22 | size_set = 'reduced' 23 | 24 | # list of mode names in pywt and matlab 25 | modes = [('zero', 'zpd'), 26 | ('constant', 'sp0'), 27 | ('symmetric', 'sym'), 28 | ('periodic', 'ppd'), 29 | ('smooth', 'sp1'), 30 | ('periodization', 'per')] 31 | 32 | families = ('gaus', 'mexh', 'morl', 'cgau', 'shan', 'fbsp', 'cmor') 33 | wavelets = sum([pywt.wavelist(name) for name in families], []) 34 | 35 | rstate = np.random.RandomState(1234) 36 | mlab.start() 37 | try: 38 | all_matlab_results = {} 39 | for wavelet in wavelets: 40 | w = pywt.Wavelet(wavelet) 41 | if np.any((wavelet == np.array(['shan', 'cmor'])),axis=0): 42 | mlab.set_variable('wavelet', wavelet+str(w.bandwidth_frequency)+'-'+str(w.center_frequency)) 43 | elif wavelet == 'fbsp': 44 | mlab.set_variable('wavelet', wavelet+str(w.fbsp_order)+'-'+str(w.bandwidth_frequency)+'-'+str(w.center_frequency)) 45 | else: 46 | mlab.set_variable('wavelet', wavelet) 47 | if size_set == 'full': 48 | data_sizes = list(range(100, 101)) + \ 49 | [100, 200, 500, 1000, 50000] 50 | Scales = (1,np.arange(1,3),np.arange(1,4),np.arange(1,5)) 51 | else: 52 | data_sizes = (1000, 1000 + 1) 53 | Scales = (1,np.arange(1,3)) 54 | mlab_code = ("psi = wavefun(wavelet,10)") 55 | res = mlab.run_code(mlab_code) 56 | if not res['success']: 57 | raise RuntimeError( 58 | "Matlab failed to execute the provided code. " 59 | "Check that the wavelet toolbox is installed.") 60 | psi = np.asarray(mlab.get_variable('psi')) 61 | psi_key = '_'.join([wavelet, 'psi']) 62 | all_matlab_results[psi_key] = psi 63 | for N in data_sizes: 64 | data = rstate.randn(N) 65 | mlab.set_variable('data', data) 66 | 67 | # Matlab result 68 | scale_count = 0 69 | for scales in Scales: 70 | scale_count += 1 71 | mlab.set_variable('scales', scales) 72 | mlab_code = ("coefs = cwt(data, scales, wavelet)") 73 | res = mlab.run_code(mlab_code) 74 | if not res['success']: 75 | raise RuntimeError( 76 | "Matlab failed to execute the provided code. " 77 | "Check that the wavelet toolbox is installed.") 78 | # need np.asarray because sometimes the output is type float 79 | coefs = np.asarray(mlab.get_variable('coefs')) 80 | coefs_key = '_'.join([str(scale_count), wavelet, str(N), 'coefs']) 81 | all_matlab_results[coefs_key] = coefs 82 | 83 | finally: 84 | mlab.stop() 85 | 86 | np.savez('cwt_matlabR2015b_result.npz', **all_matlab_results) 87 | -------------------------------------------------------------------------------- /pywt-master/doc/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | set SPHINXBUILD=sphinx-build 6 | set BUILDDIR=build 7 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source 8 | if NOT "%PAPER%" == "" ( 9 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 10 | ) 11 | 12 | if "%1" == "" goto help 13 | 14 | if "%1" == "help" ( 15 | :help 16 | echo.Please use `make ^` where ^ is one of 17 | echo. html to make standalone HTML files 18 | echo. dirhtml to make HTML files named index.html in directories 19 | echo. pickle to make pickle files 20 | echo. json to make JSON files 21 | echo. htmlhelp to make HTML files and a HTML help project 22 | echo. qthelp to make HTML files and a qthelp project 23 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 24 | echo. changes to make an overview over all changed/added/deprecated items 25 | echo. linkcheck to check all external links for integrity 26 | echo. doctest to run all doctests embedded in the documentation if enabled 27 | goto end 28 | ) 29 | 30 | if "%1" == "clean" ( 31 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 32 | del /q /s %BUILDDIR%\* 33 | goto end 34 | ) 35 | 36 | if "%1" == "html" ( 37 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 38 | echo. 39 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 40 | goto end 41 | ) 42 | 43 | if "%1" == "dirhtml" ( 44 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 45 | echo. 46 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 47 | goto end 48 | ) 49 | 50 | if "%1" == "pickle" ( 51 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 52 | echo. 53 | echo.Build finished; now you can process the pickle files. 54 | goto end 55 | ) 56 | 57 | if "%1" == "json" ( 58 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 59 | echo. 60 | echo.Build finished; now you can process the JSON files. 61 | goto end 62 | ) 63 | 64 | if "%1" == "htmlhelp" ( 65 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 66 | echo. 67 | echo.Build finished; now you can run HTML Help Workshop with the ^ 68 | .hhp project file in %BUILDDIR%/htmlhelp. 69 | goto end 70 | ) 71 | 72 | if "%1" == "qthelp" ( 73 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 74 | echo. 75 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 76 | .qhcp project file in %BUILDDIR%/qthelp, like this: 77 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\PyWavelets.qhcp 78 | echo.To view the help file: 79 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\PyWavelets.ghc 80 | goto end 81 | ) 82 | 83 | if "%1" == "latex" ( 84 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 85 | echo. 86 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 87 | goto end 88 | ) 89 | 90 | if "%1" == "changes" ( 91 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 92 | echo. 93 | echo.The overview file is in %BUILDDIR%/changes. 94 | goto end 95 | ) 96 | 97 | if "%1" == "linkcheck" ( 98 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 99 | echo. 100 | echo.Link check complete; look for any errors in the above output ^ 101 | or in %BUILDDIR%/linkcheck/output.txt. 102 | goto end 103 | ) 104 | 105 | if "%1" == "doctest" ( 106 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 107 | echo. 108 | echo.Testing of doctests in the sources finished, look at the ^ 109 | results in %BUILDDIR%/doctest/output.txt. 110 | goto end 111 | ) 112 | 113 | :end 114 | -------------------------------------------------------------------------------- /PyEMD-master/PyEMD/tests/test_splines.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Coding: UTF-8 3 | 4 | from __future__ import division, print_function 5 | 6 | import numpy as np 7 | from PyEMD import EMD 8 | from PyEMD.splines import * 9 | import unittest 10 | 11 | class IMFTest(unittest.TestCase): 12 | """ 13 | Since these tests depend heavily on NumPy & SciPy, 14 | make sure you have NumPy >= 1.12 and SciPy >= 0.19. 15 | """ 16 | 17 | def test_unsupporter_spline(self): 18 | emd = EMD() 19 | emd.spline_kind = "waterfall" 20 | 21 | S = np.random.random(20) 22 | 23 | with self.assertRaises(ValueError): 24 | emd.emd(S) 25 | 26 | def test_akima(self): 27 | dtype = np.float32 28 | 29 | emd = EMD() 30 | emd.spline_kind = 'akima' 31 | emd.DTYPE = dtype 32 | 33 | # Test error: len(X)!=len(Y) 34 | with self.assertRaises(ValueError): 35 | akima(np.array([0]), np.array([1,2]), np.array([0,1,2])) 36 | 37 | # Test error: any(dt) <= 0 38 | with self.assertRaises(ValueError): 39 | akima(np.array([1,0,2]), np.array([1,2]), np.array([0,1,2])) 40 | with self.assertRaises(ValueError): 41 | akima(np.array([0,0,2]), np.array([1,2]), np.array([0,1,1])) 42 | 43 | # Test for correct responses 44 | T = np.array([0, 1, 2, 3, 4], dtype) 45 | S = np.array([0, 1, -1, -1, 5], dtype) 46 | t = np.array([i/2. for i in range(9)], dtype) 47 | 48 | _t, s = emd.spline_points(t, np.array((T,S))) 49 | s_true = np.array([S[0], 0.9125, S[1], 0.066666, 50 | S[2],-1.35416667, S[3], 1.0625, S[4]], dtype) 51 | 52 | self.assertTrue(np.allclose(s_true, s), "Comparing akima with true") 53 | 54 | s_np = akima(np.array(T), np.array(S), np.array(t)) 55 | self.assertTrue(np.allclose(s, s_np), "Shouldn't matter if with numpy") 56 | 57 | def test_cubic(self): 58 | dtype = np.float64 59 | 60 | emd = EMD() 61 | emd.spline_kind = 'cubic' 62 | emd.DTYPE = dtype 63 | 64 | T = np.array([0, 1, 2, 3, 4], dtype=dtype) 65 | S = np.array([0, 1, -1, -1, 5], dtype=dtype) 66 | t = np.arange(9, dtype=dtype)/2. 67 | 68 | # TODO: Something weird with float32. 69 | # Seems to be SciPy problem. 70 | _t, s = emd.spline_points(t, np.array((T,S))) 71 | 72 | s_true = np.array([S[0], 1.203125, S[1], 0.046875, \ 73 | S[2], -1.515625, S[3], 1.015625, S[4]], dtype=dtype) 74 | self.assertTrue(np.allclose(s, s_true, atol=0.01), "Comparing cubic") 75 | 76 | T = T[:-2].copy() 77 | S = S[:-2].copy() 78 | t = np.arange(5, dtype=dtype)/2. 79 | 80 | _t, s3 = emd.spline_points(t, np.array((T,S))) 81 | 82 | s3_true = np.array([S[0], 0.78125, S[1], 0.28125, S[2]], dtype=dtype) 83 | self.assertTrue(np.allclose(s3, s3_true), "Compare cubic 3pts") 84 | 85 | def test_slinear(self): 86 | dtype = np.float64 87 | 88 | emd = EMD() 89 | emd.spline_kind = 'slinear' 90 | emd.DTYPE = dtype 91 | 92 | T = np.array([0, 1, 2, 3, 4], dtype=dtype) 93 | S = np.array([0, 1, -1, -1, 5], dtype=dtype) 94 | t = np.arange(9, dtype=dtype)/2. 95 | 96 | _t, s = emd.spline_points(t, np.array((T,S))) 97 | 98 | s_true = np.array([S[0], 0.5, S[1], 0, \ 99 | S[2], -1, S[3], 2, S[4]], dtype=dtype) 100 | self.assertTrue(np.allclose(s, s_true), "Comparing SLinear") 101 | if __name__ == "__main__": 102 | unittest.main() 103 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/c/convolution.template.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2006-2012 Filip Wasilewski 2 | * Copyright (c) 2012-2016 The PyWavelets Developers 3 | * 4 | * See COPYING for license details. 5 | */ 6 | 7 | #include "templating.h" 8 | 9 | 10 | #ifndef REAL_TYPE 11 | #error REAL_TYPE must be defined here. 12 | #else 13 | 14 | #ifndef TYPE 15 | #error TYPE must be defined here. 16 | #else 17 | 18 | #include "common.h" 19 | 20 | #if defined _MSC_VER 21 | #define restrict __restrict 22 | #elif defined __GNUC__ 23 | #define restrict __restrict__ 24 | #endif 25 | 26 | /* Performs convolution of input with filter and downsamples by taking every 27 | * step-th element from the result. 28 | * 29 | * input - input data 30 | * N - input data length 31 | * filter - filter data 32 | * F - filter data length 33 | * output - output data 34 | * step - decimation step 35 | * mode - signal extension mode 36 | */ 37 | 38 | /* memory efficient version */ 39 | 40 | int CAT(TYPE, _downsampling_convolution)(const TYPE * const restrict input, const size_t N, 41 | const REAL_TYPE * const restrict filter, const size_t F, 42 | TYPE * const restrict output, const size_t step, 43 | MODE mode); 44 | 45 | 46 | /* downsampling convolution routine specific to periodization mode. 47 | * 48 | * input - input data 49 | * N - input data length 50 | * filter - filter data 51 | * F - filter data length 52 | * output - output data 53 | * step - decimation step 54 | * fstep - step size between non-zero entries in filter 55 | * (used to improve performance for the multilevel swt) 56 | */ 57 | int CAT(TYPE, _downsampling_convolution_periodization)( 58 | const TYPE * const restrict input, const size_t N, 59 | const REAL_TYPE * const restrict filter, const size_t F, 60 | TYPE * const restrict output, const size_t step, 61 | const size_t fstep); 62 | 63 | /* 64 | * Performs normal (full) convolution of "upsampled" input coeffs array with 65 | * filter Requires zero-filled output buffer (adds values instead of 66 | * overwriting - can be called many times with the same output). 67 | * 68 | * input - input data 69 | * N - input data length 70 | * filter - filter data 71 | * F - filter data length 72 | * output - output data 73 | * O - output lenght (currently not used) 74 | * mode - signal extension mode 75 | */ 76 | 77 | int CAT(TYPE, _upsampling_convolution_full)(const TYPE * const restrict input, const size_t N, 78 | const REAL_TYPE * const restrict filter, const size_t F, 79 | TYPE * const restrict output, const size_t O); 80 | 81 | /* Performs valid convolution (signals must overlap) 82 | * Extends (virtually) input for MODE_PERIODIZATION. 83 | */ 84 | 85 | int CAT(TYPE, _upsampling_convolution_valid_sf)(const TYPE * const restrict input, const size_t N, 86 | const REAL_TYPE * const restrict filter, const size_t F, 87 | TYPE * const restrict output, const size_t O, 88 | MODE mode); 89 | 90 | /* TODO 91 | * for SWT 92 | * int upsampled_filter_convolution(const TYPE * const restrict input, const int N, 93 | * const REAL_TYPE * const restrict filter, const int F, 94 | * TYPE * const restrict output, int step, int mode); 95 | */ 96 | 97 | 98 | 99 | #undef restrict 100 | #endif /* REAL_TYPE */ 101 | #endif /* TYPE */ 102 | -------------------------------------------------------------------------------- /pywt-master/pywt/_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2017 The PyWavelets Developers 2 | # 3 | # See COPYING for license details. 4 | import inspect 5 | import sys 6 | from collections.abc import Iterable 7 | 8 | from ._extensions._pywt import (Wavelet, ContinuousWavelet, 9 | DiscreteContinuousWavelet, Modes) 10 | 11 | 12 | # define string_types as in six for Python 2/3 compatibility 13 | if sys.version_info[0] == 3: 14 | string_types = str, 15 | else: 16 | string_types = basestring, 17 | 18 | 19 | def _as_wavelet(wavelet): 20 | """Convert wavelet name to a Wavelet object""" 21 | if not isinstance(wavelet, (ContinuousWavelet, Wavelet)): 22 | wavelet = DiscreteContinuousWavelet(wavelet) 23 | if isinstance(wavelet, ContinuousWavelet): 24 | raise ValueError( 25 | "A ContinuousWavelet object was provided, but only discrete " 26 | "Wavelet objects are supported by this function. A list of all " 27 | "supported discrete wavelets can be obtained by running:\n" 28 | "print(pywt.wavelist(kind='discrete'))") 29 | return wavelet 30 | 31 | 32 | def _wavelets_per_axis(wavelet, axes): 33 | """Initialize Wavelets for each axis to be transformed. 34 | 35 | Parameters 36 | ---------- 37 | wavelet : Wavelet or tuple of Wavelets 38 | If a single Wavelet is provided, it will used for all axes. Otherwise 39 | one Wavelet per axis must be provided. 40 | axes : list 41 | The tuple of axes to be transformed. 42 | 43 | Returns 44 | ------- 45 | wavelets : list of Wavelet objects 46 | A tuple of Wavelets equal in length to ``axes``. 47 | 48 | """ 49 | axes = tuple(axes) 50 | if isinstance(wavelet, string_types + (Wavelet, )): 51 | # same wavelet on all axes 52 | wavelets = [_as_wavelet(wavelet), ] * len(axes) 53 | elif isinstance(wavelet, Iterable): 54 | # (potentially) unique wavelet per axis (e.g. for dual-tree DWT) 55 | if len(wavelet) == 1: 56 | wavelets = [_as_wavelet(wavelet[0]), ] * len(axes) 57 | else: 58 | if len(wavelet) != len(axes): 59 | raise ValueError(( 60 | "The number of wavelets must match the number of axes " 61 | "to be transformed.")) 62 | wavelets = [_as_wavelet(w) for w in wavelet] 63 | else: 64 | raise ValueError("wavelet must be a str, Wavelet or iterable") 65 | return wavelets 66 | 67 | 68 | def _modes_per_axis(modes, axes): 69 | """Initialize mode for each axis to be transformed. 70 | 71 | Parameters 72 | ---------- 73 | modes : str or tuple of strings 74 | If a single mode is provided, it will used for all axes. Otherwise 75 | one mode per axis must be provided. 76 | axes : tuple 77 | The tuple of axes to be transformed. 78 | 79 | Returns 80 | ------- 81 | modes : tuple of int 82 | A tuple of Modes equal in length to ``axes``. 83 | 84 | """ 85 | axes = tuple(axes) 86 | if isinstance(modes, string_types + (int, )): 87 | # same wavelet on all axes 88 | modes = [Modes.from_object(modes), ] * len(axes) 89 | elif isinstance(modes, Iterable): 90 | if len(modes) == 1: 91 | modes = [Modes.from_object(modes[0]), ] * len(axes) 92 | else: 93 | # (potentially) unique wavelet per axis (e.g. for dual-tree DWT) 94 | if len(modes) != len(axes): 95 | raise ValueError(("The number of modes must match the number " 96 | "of axes to be transformed.")) 97 | modes = [Modes.from_object(mode) for mode in modes] 98 | else: 99 | raise ValueError("modes must be a str, Mode enum or iterable") 100 | return modes 101 | -------------------------------------------------------------------------------- /pywt-master/demo/batch_processing.py: -------------------------------------------------------------------------------- 1 | """ 2 | Demo: Parallel processing accross images 3 | 4 | Multithreading can be used to run transforms on a set of images in parallel. 5 | This will give a net performance benefit if the images to be transformed are 6 | sufficiently large. 7 | 8 | This demo runs a multilevel wavelet decomposition on a list of 32 images, 9 | each of size (512, 512). Computations are repeated sequentially and in 10 | parallel and the runtimes compared. 11 | 12 | In general, multithreading will be more beneficial for larger images and for 13 | wavelets with a larger filter size. 14 | 15 | One can also change ``ndim`` to 3 in the code below to use a set of 3D volumes 16 | instead. 17 | """ 18 | 19 | import time 20 | from functools import partial 21 | from multiprocessing import cpu_count 22 | 23 | try: 24 | from concurrent import futures 25 | except ImportError: 26 | raise ImportError( 27 | "This demo requires concurrent.futures. It can be installed for " 28 | "for python 2.x via: pip install futures") 29 | 30 | import numpy as np 31 | from numpy.testing import assert_array_equal 32 | 33 | import pywt 34 | 35 | # the test image 36 | cam = pywt.data.camera().astype(float) 37 | 38 | ndim = 2 # dimension of images to transform (2 or 3) 39 | num_images = 32 # number of images to transform 40 | max_workers = cpu_count() # max number of available threads 41 | nrepeat = 5 # averages used in the benchmark 42 | 43 | # create a list of num_images images 44 | if ndim == 2: 45 | imgs = [cam, ] * num_images 46 | wavelet = 'db8' 47 | elif ndim == 3: 48 | # stack image along 3rd dimension to create a [512 x 512 x 16] 3D volume 49 | im3 = np.concatenate([cam[:, :, np.newaxis], ]*16, axis=-1) 50 | # create multiple copies of the volume 51 | imgs = [im3, ] * num_images 52 | wavelet = 'db1' 53 | else: 54 | ValueError("Only 2D and 3D test cases implemented") 55 | 56 | # define a function to apply to each image 57 | wavedecn_func = partial(pywt.wavedecn, wavelet=wavelet, mode='periodization', 58 | level=3) 59 | 60 | 61 | def concurrent_transforms(func, imgs, max_workers=None): 62 | """Call func on each img in imgs using a ThreadPoolExecutor.""" 63 | executor = futures.ThreadPoolExecutor 64 | if max_workers is None: 65 | # default to as many workers as available cpus 66 | max_workers = cpu_count() 67 | results = [] 68 | with executor(max_workers=max_workers) as execute: 69 | for result in execute.map(func, imgs): 70 | results.append(result) 71 | return results 72 | 73 | 74 | print("Processing {} images of shape {}".format(len(imgs), imgs[0].shape)) 75 | 76 | # Sequential computation via a list comprehension 77 | tstart = time.time() 78 | for n in range(nrepeat): 79 | results = [wavedecn_func(img) for img in imgs] 80 | t = (time.time()-tstart)/nrepeat 81 | print("\nSequential Case") 82 | print("\tElapsed time: {:0.2f} ms".format(1000*t)) 83 | 84 | 85 | # Concurrent computation via concurrent.futures 86 | tstart = time.time() 87 | for n in range(nrepeat): 88 | results_concurrent = concurrent_transforms(wavedecn_func, imgs, 89 | max_workers=max_workers) 90 | t2 = (time.time()-tstart)/nrepeat 91 | print("\nMultithreaded Case") 92 | print("\tNumber of concurrent workers: {}".format(max_workers)) 93 | print("\tElapsed time: {:0.2f} ms".format(1000*t2)) 94 | print("\nRelative speedup with concurrent = {}".format(t/t2)) 95 | 96 | # check a couple of the coefficient arrays to verify matching results for 97 | # sequential and multithreaded computation 98 | assert_array_equal(results[-1][0], 99 | results_concurrent[-1][0]) 100 | assert_array_equal(results[-1][1]['d' + 'a'*(ndim-1)], 101 | results_concurrent[-1][1]['d' + 'a'*(ndim-1)]) 102 | -------------------------------------------------------------------------------- /PyEMD-master/PyEMD/tests/test_bemd.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | # Coding: UTF-8 3 | import unittest 4 | import numpy as np 5 | 6 | from PyEMD.BEMD import BEMD 7 | 8 | @unittest.skip 9 | class BEMDTest(unittest.TestCase): 10 | 11 | bemd = BEMD() 12 | 13 | @staticmethod 14 | def _generate_image(r=64, c=64): 15 | return np.random.random((r,c)) 16 | 17 | @staticmethod 18 | def _generate_linear_image(r=16, c=16): 19 | rows = np.arange(r) 20 | return np.repeat(rows, c).reshape(r,c) 21 | 22 | @staticmethod 23 | def _generate_Gauss(x, y, pos, std, amp=1): 24 | x_s = x-pos[0] 25 | y_s = y-pos[1] 26 | x2 = x_s*x_s 27 | y2 = y_s*y_s 28 | exp = np.exp(-(x2+y2)/(2*std*std)) 29 | #exp[exp<1e-6] = 0 30 | scale = amp/np.linalg.norm(exp) 31 | return scale*exp 32 | 33 | @classmethod 34 | def _sin(cls, x_n=128, y_n=128, x_f=[1], y_f=[0], dx=0, dy=0): 35 | x = np.linspace(0, 1, x_n)-dx 36 | y = np.linspace(0, 1, y_n)-dy 37 | xv, yv = np.meshgrid(x, y) 38 | img = np.zeros(xv.shape) 39 | for f in x_f: 40 | img += np.sin(f*2*np.pi*xv) 41 | for f in y_f: 42 | img += np.cos(f*2*np.pi*yv) 43 | return 255*(img-img.min())/(img.max()-img.min()) 44 | 45 | def test_extract_maxima(self): 46 | image = self._sin(x_n=32, y_n=32, y_f=[1], dy=1) 47 | max_peak_x, max_peak_y = BEMD.extract_maxima_positions(image) 48 | self.assertEqual(max_peak_x.size, 6) # Clustering 49 | self.assertEqual(max_peak_y.size, 6) # Clustering 50 | 51 | def test_extract_minima(self): 52 | image = self._sin(x_n=64, y_n=64, y_f=[2]) 53 | min_peak_x, min_peak_y = BEMD.extract_minima_positions(image) 54 | self.assertEqual(min_peak_x.size, 16) # Clustering 55 | self.assertEqual(min_peak_y.size, 16) # Clustering 56 | 57 | def test_find_extrema(self): 58 | image = self._sin() 59 | min_peaks, max_peaks = BEMD.find_extrema_positions(image) 60 | self.assertTrue(isinstance(min_peaks, tuple)) 61 | self.assertTrue(isinstance(min_peaks[0], np.ndarray)) 62 | self.assertTrue(isinstance(max_peaks[1], np.ndarray)) 63 | 64 | def test_default_call_BEMD(self): 65 | x = np.arange(50) 66 | y = np.arange(50) 67 | xv, yv = np.meshgrid(x,y) 68 | img = self._generate_Gauss(xv, yv, (10,20), 5) 69 | img += self._sin(x_n=x.size, y_n=y.size) 70 | 71 | max_imf = 2 72 | self.bemd(img, max_imf) 73 | 74 | def test_endCondition_perfectReconstruction(self): 75 | c1 = self._generate_image() 76 | c2 = self._generate_image() 77 | IMFs = np.stack((c1,c2)) 78 | org_img = np.sum(IMFs, axis=0) 79 | self.assertTrue(self.bemd.end_condition(org_img, IMFs)) 80 | 81 | def test_bemd_simpleIMF(self): 82 | image = self._sin(x_f=[3,5], y_f=[2]) 83 | IMFs = self.bemd(image) 84 | 85 | # One of the reasons this algorithm isn't the preferred one 86 | self.assertTrue(IMFs.shape[0] == 7, 87 | "Depending on spline, there should be an IMF and possibly trend") 88 | 89 | def test_bemd_limitImfNo(self): 90 | 91 | # Create image 92 | rows, cols = 64, 64 93 | linear_background = 0.2*self._generate_linear_image(rows, cols) 94 | 95 | # Sinusoidal IMF 96 | X = np.arange(cols)[None,:].T 97 | Y = np.arange(rows) 98 | x_comp_1d = np.sin(X*0.3) + np.cos(X*2.9)**2 99 | y_comp_1d = np.sin(Y*0.2) 100 | comp_2d = 10*x_comp_1d*y_comp_1d 101 | comp_2d = comp_2d 102 | 103 | image = linear_background + comp_2d 104 | 105 | # Limit number of IMFs 106 | max_imf = 2 107 | 108 | # decompose image 109 | IMFs = self.bemd(image, max_imf=max_imf) 110 | 111 | # It should have no more than 2 (max_imf) + residue 112 | self.assertEqual(IMFs.shape[0], 1+max_imf) 113 | 114 | if __name__ == "__main__": 115 | unittest.main() 116 | -------------------------------------------------------------------------------- /pywt-master/doc/paper/paper.bib: -------------------------------------------------------------------------------- 1 | 2 | 3 | @Book{mallat2008wavelet, 4 | title = {A wavelet tour of signal processing: the sparse way}, 5 | author = {Mallat, Stéphane}, 6 | year = {2008}, 7 | publisher = {Academic press} 8 | } 9 | 10 | @book{Daubechies1992, 11 | author = {Daubechies, Ingrid}, 12 | title = {Ten Lectures on Wavelets}, 13 | year = {1992}, 14 | isbn = {0-89871-274-2}, 15 | publisher = {Society for Industrial and Applied Mathematics}, 16 | address = {Philadelphia, PA, USA}, 17 | doi = {10.1137/1.9781611970104}, 18 | url = {https://doi.org/10.1137/1.9781611970104} 19 | } 20 | 21 | @Article{cython, 22 | author = {S. Behnel and R. Bradshaw and C. Citro and L. Dalcin and D. S. Seljebotn and K. Smith}, 23 | journal = {Computing in Science Engineering}, 24 | title = {Cython: The Best of Both Worlds}, 25 | year = {2011}, 26 | volume = {13}, 27 | number = {2}, 28 | pages = {31-39}, 29 | keywords = {C language;numerical analysis;Python language extension;Fortran code;numerical loops;Cython language;programming language;Sparse matrices;Runtime;Syntactics;Computer programs;Programming;Python;Cython;numerics;scientific computing}, 30 | doi = {10.1109/MCSE.2010.118}, 31 | ISSN = {1521-9615}, 32 | month = {March},} 33 | 34 | @Article{scikit-image, 35 | title = {scikit-image: image processing in {P}ython}, 36 | author = {van der Walt, {S}t\'efan and {S}ch\"onberger, {J}ohannes {L}. and 37 | {Nunez-Iglesias}, {J}uan and {B}oulogne, {F}ran\c{c}ois and {W}arner, 38 | {J}oshua {D}. and {Y}ager, {N}eil and {G}ouillart, {E}mmanuelle and 39 | {Y}u, {T}ony and the scikit-image contributors}, 40 | year = {2014}, 41 | month = {6}, 42 | keywords = {Image processing, Reproducible research, Education, 43 | Visualization, Open source, Python, Scientific programming}, 44 | volume = {2}, 45 | pages = {e453}, 46 | journal = {PeerJ}, 47 | issn = {2167-8359}, 48 | url = {http://dx.doi.org/10.7717/peerj.453}, 49 | doi = {10.7717/peerj.453} 50 | } 51 | 52 | @article{kymatio, 53 | author = {Mathieu Andreux and 54 | Tom{\'{a}}s Angles and 55 | Georgios Exarchakis and 56 | Roberto Leonarduzzi and 57 | Gaspar Rochette and 58 | Louis Thiry and 59 | John Zarka and 60 | St{\'{e}}phane Mallat and 61 | Joakim And{\'{e}}n and 62 | Eugene Belilovsky and 63 | Joan Bruna and 64 | Vincent Lostanlen and 65 | Matthew J. Hirn and 66 | Edouard Oyallon and 67 | Sixhin Zhang and 68 | Carmine{-}Emanuele Cella and 69 | Michael Eickenberg}, 70 | title = {Kymatio: Scattering Transforms in Python}, 71 | journal = {CoRR}, 72 | volume = {abs/1812.11214}, 73 | year = {2018}, 74 | url = {http://arxiv.org/abs/1812.11214}, 75 | archivePrefix = {arXiv}, 76 | eprint = {1812.11214}, 77 | timestamp = {Wed, 02 Jan 2019 14:40:18 +0100}, 78 | biburl = {https://dblp.org/rec/bib/journals/corr/abs-1812-11214}, 79 | bibsource = {dblp computer science bibliography, https://dblp.org} 80 | } 81 | 82 | @Misc{odl, 83 | author = {Jonas Adler and 84 | Holger Kohr and 85 | Axel Ringh and 86 | Julian Moosmann and 87 | Sebastian Banert and 88 | Matthias J. Ehrhardt and 89 | Gregory R. Lee and 90 | niinimaki and 91 | bgris and 92 | Olivier Verdier and 93 | Johan Karlsson and 94 | zickert and 95 | Willem Jan Palenstijn and 96 | \"Oktem Ozan and 97 | Chong Chen and 98 | Hector Andrade Loarca and 99 | Michael Lohmann}, 100 | title = {odlgroup/odl: ODL 0.7.0}, 101 | month = sep, 102 | year = 2018, 103 | doi = {10.5281/zenodo.1442734}, 104 | url = {https://doi.org/10.5281/zenodo.1442734} 105 | } 106 | TODO: determine real name for bgris, zickert, niinimaki 107 | -------------------------------------------------------------------------------- /pywt-master/pywt/_extensions/c/wt.template.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2006-2012 Filip Wasilewski 2 | * Copyright (c) 2012-2016 The PyWavelets Developers 3 | * 4 | * See COPYING for license details. 5 | */ 6 | 7 | /* Wavelet transforms using convolution functions defined in convolution.h */ 8 | 9 | #include "templating.h" 10 | 11 | #ifndef TYPE 12 | #error TYPE must be defined here. 13 | #else 14 | 15 | #include "wt.h" 16 | 17 | #if defined _MSC_VER 18 | #define restrict __restrict 19 | #elif defined __GNUC__ 20 | #define restrict __restrict__ 21 | #endif 22 | 23 | /* _a suffix - wavelet transform approximations */ 24 | /* _d suffix - wavelet transform details */ 25 | 26 | int CAT(TYPE, _downcoef_axis)(const TYPE * const restrict input, const ArrayInfo input_info, 27 | TYPE * const restrict output, const ArrayInfo output_info, 28 | const DiscreteWavelet * const restrict wavelet, const size_t axis, 29 | const Coefficient detail, const MODE dwt_mode, 30 | const size_t swt_level, 31 | const DiscreteTransformType transform); 32 | 33 | // a_info and d_info are pointers, as they may be NULL 34 | int CAT(TYPE, _idwt_axis)(const TYPE * const restrict coefs_a, const ArrayInfo * a_info, 35 | const TYPE * const restrict coefs_d, const ArrayInfo * d_info, 36 | TYPE * const restrict output, const ArrayInfo output_info, 37 | const DiscreteWavelet * const restrict wavelet, 38 | const size_t axis, const MODE mode); 39 | 40 | /* Single level decomposition */ 41 | int CAT(TYPE, _dec_a)(const TYPE * const restrict input, const size_t input_len, 42 | const DiscreteWavelet * const restrict wavelet, 43 | TYPE * const restrict output, const size_t output_len, 44 | const MODE mode); 45 | 46 | int CAT(TYPE, _dec_d)(const TYPE * const restrict input, const size_t input_len, 47 | const DiscreteWavelet * const restrict wavelet, 48 | TYPE * const restrict output, const size_t output_len, 49 | const MODE mode); 50 | 51 | /* Single level reconstruction */ 52 | int CAT(TYPE, _rec_a)(const TYPE * const restrict coeffs_a, const size_t coeffs_len, 53 | const DiscreteWavelet * const restrict wavelet, 54 | TYPE * const restrict output, const size_t output_len); 55 | 56 | int CAT(TYPE, _rec_d)(const TYPE * const restrict coeffs_d, const size_t coeffs_len, 57 | const DiscreteWavelet * const restrict wavelet, 58 | TYPE * const restrict output, const size_t output_len); 59 | 60 | /* Single level IDWT reconstruction */ 61 | int CAT(TYPE, _idwt)(const TYPE * const restrict coeffs_a, const size_t coeffs_a_len, 62 | const TYPE * const restrict coeffs_d, const size_t coeffs_d_len, 63 | TYPE * const restrict output, const size_t output_len, 64 | const DiscreteWavelet * const restrict wavelet, const MODE mode); 65 | 66 | /* SWT decomposition at given level */ 67 | int CAT(TYPE, _swt_a)(const TYPE * const restrict input, pywt_index_t input_len, 68 | const DiscreteWavelet * const restrict wavelet, 69 | TYPE * const restrict output, pywt_index_t output_len, 70 | unsigned int level); 71 | 72 | int CAT(TYPE, _swt_d)(const TYPE * const restrict input, pywt_index_t input_len, 73 | const DiscreteWavelet * const restrict wavelet, 74 | TYPE * const restrict output, pywt_index_t output_len, 75 | unsigned int level); 76 | 77 | int CAT(TYPE, _swt_axis)(const TYPE * const restrict input, const ArrayInfo input_info, 78 | TYPE * const restrict output, const ArrayInfo output_info, 79 | const DiscreteWavelet * const restrict wavelet, const size_t axis, 80 | const Coefficient detail, unsigned int level); 81 | 82 | #endif /* TYPE */ 83 | #undef restrict 84 | -------------------------------------------------------------------------------- /pywt-master/doc/source/dev/how_to_release.rst: -------------------------------------------------------------------------------- 1 | Guidelines for Releasing PyWavelets 2 | =================================== 3 | 4 | The following are guidelines for preparing a release of PyWavelets. The 5 | notation ``vX.X.X`` in the commands below would be replaced by the actual release 6 | number. 7 | 8 | 9 | Updating the release notes 10 | -------------------------- 11 | 12 | Prior to the release, make sure the release notes are up to date. The author 13 | lists can be generated via:: 14 | 15 | python ./util/authors.py vP.P.P.. 16 | 17 | where ``vP.P.P`` is the previous release number. 18 | 19 | The lists of issues closed and PRs merged can be generated via 20 | (script requires Python 2.X to run):: 21 | 22 | python ./util/gh_lists.py vX.X.X 23 | 24 | 25 | Tag the release 26 | --------------- 27 | 28 | Change ``ISRELEASED`` to ``True`` in ``setup.py`` and commit. 29 | 30 | Tag the release via:: 31 | 32 | git tag -s vX.X.X 33 | 34 | Then push the ``vX.X.X`` tag to the PyWavelets GitHub repo. 35 | 36 | Note that while Appveyor will build wheels for Windows, it is preferred to 37 | get those wheels from the step below. Instructions for grabbing Appveyor 38 | wheels manually here for reference only: if the commit with 39 | ``ISRELEASED=True`` is submitted as a PR, the wheels can be downloaded from 40 | Appveyor once it has run on the PR. They can be found under the "Artifacts" 41 | tab in the Appveyor interface. 42 | 43 | 44 | Build Windows, OS X and Linux wheels and upload to PyPI 45 | ------------------------------------------------------- 46 | 47 | Push a commit with the new tag and updates of dependency versions where needed 48 | to https://github.com/MacPython/pywavelets-wheels. The wheels will be 49 | produced automatically and uploaded to http://wheels.scipy.org/. 50 | From there they can be uploaded to 51 | `PyPI `_ automatically with 52 | ``wheel-uploader``. 53 | 54 | See the README on https://github.com/MacPython/pywavelets-wheels for more 55 | details. 56 | 57 | Create the source distribution 58 | ------------------------------ 59 | 60 | Remove untracked files and directories with ``git clean``. 61 | *Warning: this will delete files & directories that are not under version 62 | control so you may want to do a dry run first by adding -n, so you can see what 63 | will be removed*:: 64 | 65 | git clean -xfdn 66 | 67 | Then run without ``-n``:: 68 | 69 | git clean -xfd 70 | 71 | Create the source distribution files via:: 72 | 73 | python setup.py sdist --formats=gztar,zip 74 | 75 | 76 | Upload the release to PyPI 77 | -------------------------- 78 | 79 | The binary Windows wheels downloaded from Appveyor (see above) should 80 | also be placed into the ``/dist`` subfolder along with the sdist archives. 81 | 82 | The wheels and source distributions created above can all be securely uploaded 83 | to pypi.python.org using twine:: 84 | 85 | twine upload -s dist/* 86 | 87 | Note that the documentation on ReadTheDocs (http://pywavelets.readthedocs.org) 88 | will have been automatically generated, so no actions need to be taken for 89 | documentation. 90 | 91 | 92 | Update conda-forge 93 | ------------------ 94 | 95 | Send a PR with the new version number and ``sha256`` hash of the source release 96 | to https://github.com/conda-forge/pywavelets-feedstock. 97 | 98 | 99 | Create the release on GitHub 100 | ---------------------------- 101 | 102 | On the project's GitHub page, click the releases tab and then press the 103 | "*Draft a new release*" button to create a release from the appropriate tag. 104 | 105 | 106 | Announcing the release 107 | ---------------------- 108 | 109 | Send release announcements to: 110 | 111 | - pywavelets@googlegroups.com 112 | - python-announce-list@python.org 113 | - scipy-user@python.org 114 | 115 | 116 | Prepare for continued development 117 | --------------------------------- 118 | 119 | Increment the version number in setup.py and change ISRELEASED to False. 120 | 121 | Prepare new release note files for the upcoming release:: 122 | 123 | git add doc/release/X.X.X-notes.rst 124 | git add doc/source/release.X.X.X.rst 125 | 126 | And add ``release.X.X.X`` to the list in ``doc/source/releasenotes.rst`` 127 | --------------------------------------------------------------------------------