<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Other functions — PyWavelets Documentation</title> <link rel="stylesheet" href="../_static/nature.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/language_data.js"></script> <script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within PyWavelets Documentation" href="../_static/opensearch.xml"/> <link rel="shortcut icon" href="../_static/favicon.ico"/> <link rel="index" title="Index" href="../genindex.html" /> <link rel="search" title="Search" href="../search.html" /> <link rel="next" title="Usage examples" href="../regression/index.html" /> <link rel="prev" title="Thresholding functions" href="thresholding-functions.html" /> <meta name="description" content="PyWavelets is a scientific Python module for Wavelet Transform calculations."/> <meta name="keywords" content="PyWavelets, wavelets, Python, wavelet transform, discrete wavelet transform, dwt, idwt, swt, wavelet packets, stationary wavelet transform, pywt"/> <meta name="author" content="Filip Wasilewski"/> <meta name="Distribution" content="Global"/> <meta name="Robots" content="INDEX,FOLLOW"/> <script type="text/javascript"> (function ($) { $(document).ready(function () { $("#toggle-edit-info").click(function (e) { e.preventDefault(); $("#edit-info").toggle(); }); }); })(jQuery); </script> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-3396395-3']); _gaq.push(['_trackPageview']); (function () { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </head><body> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../regression/index.html" title="Usage examples" accesskey="N">next</a> |</li> <li class="right" > <a href="thresholding-functions.html" title="Thresholding functions" accesskey="P">previous</a> |</li> <li><a href="../index.html">Home »</a></li> <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">API Reference</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body" role="main"> <div class="section" id="other-functions"> <span id="ref-other"></span><h1>Other functions<a class="headerlink" href="#other-functions" title="Permalink to this headline">¶</a></h1> <div class="section" id="integrating-wavelet-functions"> <h2>Integrating wavelet functions<a class="headerlink" href="#integrating-wavelet-functions" title="Permalink to this headline">¶</a></h2> <dl class="function"> <dt id="pywt.integrate_wavelet"> <code class="descclassname">pywt.</code><code class="descname">integrate_wavelet</code><span class="sig-paren">(</span><em>wavelet</em>, <em>precision=8</em><span class="sig-paren">)</span><a class="headerlink" href="#pywt.integrate_wavelet" title="Permalink to this definition">¶</a></dt> <dd><p>Integrate <cite>psi</cite> wavelet function from -Inf to x using the rectangle integration method.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><dl class="first docutils"> <dt><strong>wavelet</strong> <span class="classifier-delimiter">:</span> <span class="classifier">Wavelet instance or str</span></dt> <dd><p class="first last">Wavelet to integrate. If a string, should be the name of a wavelet.</p> </dd> <dt><strong>precision</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int, optional</span></dt> <dd><p class="first last">Precision that will be used for wavelet function approximation computed with the wavefun(level=precision) Wavelet’s method (default: 8).</p> </dd> </dl> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><dl class="first last docutils"> <dt><strong>[int_psi, x] :</strong></dt> <dd><p class="first last">for orthogonal wavelets</p> </dd> <dt><strong>[int_psi_d, int_psi_r, x] :</strong></dt> <dd><p class="first last">for other wavelets</p> </dd> </dl> </td> </tr> </tbody> </table> <p class="rubric">Examples</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">pywt</span> <span class="k">import</span> <span class="n">Wavelet</span><span class="p">,</span> <span class="n">integrate_wavelet</span> <span class="gp">>>> </span><span class="n">wavelet1</span> <span class="o">=</span> <span class="n">Wavelet</span><span class="p">(</span><span class="s1">'db2'</span><span class="p">)</span> <span class="gp">>>> </span><span class="p">[</span><span class="n">int_psi</span><span class="p">,</span> <span class="n">x</span><span class="p">]</span> <span class="o">=</span> <span class="n">integrate_wavelet</span><span class="p">(</span><span class="n">wavelet1</span><span class="p">,</span> <span class="n">precision</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">wavelet2</span> <span class="o">=</span> <span class="n">Wavelet</span><span class="p">(</span><span class="s1">'bior1.3'</span><span class="p">)</span> <span class="gp">>>> </span><span class="p">[</span><span class="n">int_psi_d</span><span class="p">,</span> <span class="n">int_psi_r</span><span class="p">,</span> <span class="n">x</span><span class="p">]</span> <span class="o">=</span> <span class="n">integrate_wavelet</span><span class="p">(</span><span class="n">wavelet2</span><span class="p">,</span> <span class="n">precision</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span> </pre></div> </div> </dd></dl> <p>The result of the call depends on the <code class="docutils literal notranslate"><span class="pre">wavelet</span></code> argument:</p> <ul> <li><p class="first">for orthogonal and continuous wavelets - an integral of the wavelet function specified on an x-grid:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">int_psi</span><span class="p">,</span> <span class="n">x_grid</span><span class="p">]</span> <span class="o">=</span> <span class="n">integrate_wavelet</span><span class="p">(</span><span class="n">wavelet</span><span class="p">,</span> <span class="n">precision</span><span class="p">)</span> </pre></div> </div> </li> <li><p class="first">for other wavelets - integrals of decomposition and reconstruction wavelet functions and a corresponding x-grid:</p> <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="p">[</span><span class="n">int_psi_d</span><span class="p">,</span> <span class="n">int_psi_r</span><span class="p">,</span> <span class="n">x_grid</span><span class="p">]</span> <span class="o">=</span> <span class="n">integrate_wavelet</span><span class="p">(</span><span class="n">wavelet</span><span class="p">,</span> <span class="n">precision</span><span class="p">)</span> </pre></div> </div> </li> </ul> </div> <div class="section" id="central-frequency-of-psi-wavelet-function"> <h2>Central frequency of <code class="docutils literal notranslate"><span class="pre">psi</span></code> wavelet function<a class="headerlink" href="#central-frequency-of-psi-wavelet-function" title="Permalink to this headline">¶</a></h2> <dl class="function"> <dt id="pywt.central_frequency"> <code class="descclassname">pywt.</code><code class="descname">central_frequency</code><span class="sig-paren">(</span><em>wavelet</em>, <em>precision=8</em><span class="sig-paren">)</span><a class="headerlink" href="#pywt.central_frequency" title="Permalink to this definition">¶</a></dt> <dd><p>Computes the central frequency of the <cite>psi</cite> wavelet function.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><dl class="first docutils"> <dt><strong>wavelet</strong> <span class="classifier-delimiter">:</span> <span class="classifier">Wavelet instance, str or tuple</span></dt> <dd><p class="first last">Wavelet to integrate. If a string, should be the name of a wavelet.</p> </dd> <dt><strong>precision</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int, optional</span></dt> <dd><p class="first last">Precision that will be used for wavelet function approximation computed with the wavefun(level=precision) Wavelet’s method (default: 8).</p> </dd> </dl> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><dl class="first last docutils"> <dt><strong>scalar</strong></dt> <dd></dd> </dl> </td> </tr> </tbody> </table> </dd></dl> <dl class="function"> <dt id="pywt.scale2frequency"> <code class="descclassname">pywt.</code><code class="descname">scale2frequency</code><span class="sig-paren">(</span><em>wavelet</em>, <em>scale</em>, <em>precision=8</em><span class="sig-paren">)</span><a class="headerlink" href="#pywt.scale2frequency" title="Permalink to this definition">¶</a></dt> <dd><table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><dl class="first docutils"> <dt><strong>wavelet</strong> <span class="classifier-delimiter">:</span> <span class="classifier">Wavelet instance or str</span></dt> <dd><p class="first last">Wavelet to integrate. If a string, should be the name of a wavelet.</p> </dd> <dt><strong>scale</strong> <span class="classifier-delimiter">:</span> <span class="classifier">scalar</span></dt> <dd></dd> <dt><strong>precision</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int, optional</span></dt> <dd><p class="first last">Precision that will be used for wavelet function approximation computed with <code class="docutils literal notranslate"><span class="pre">wavelet.wavefun(level=precision)</span></code>. Default is 8.</p> </dd> </dl> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><dl class="first last docutils"> <dt><strong>freq</strong> <span class="classifier-delimiter">:</span> <span class="classifier">scalar</span></dt> <dd></dd> </dl> </td> </tr> </tbody> </table> </dd></dl> </div> <div class="section" id="quadrature-mirror-filter"> <h2>Quadrature Mirror Filter<a class="headerlink" href="#quadrature-mirror-filter" title="Permalink to this headline">¶</a></h2> <dl class="function"> <dt id="pywt.qmf"> <code class="descclassname">pywt.</code><code class="descname">qmf</code><span class="sig-paren">(</span><em>filt</em><span class="sig-paren">)</span><a class="headerlink" href="#pywt.qmf" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the Quadrature Mirror Filter(QMF).</p> <p>The magnitude response of QMF is mirror image about <cite>pi/2</cite> of that of the input filter.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><dl class="first docutils"> <dt><strong>filt</strong> <span class="classifier-delimiter">:</span> <span class="classifier">array_like</span></dt> <dd><p class="first last">Input filter for which QMF needs to be computed.</p> </dd> </dl> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><dl class="first last docutils"> <dt><strong>qm_filter</strong> <span class="classifier-delimiter">:</span> <span class="classifier">ndarray</span></dt> <dd><p class="first last">Quadrature mirror of the input filter.</p> </dd> </dl> </td> </tr> </tbody> </table> </dd></dl> </div> <div class="section" id="orthogonal-filter-banks"> <h2>Orthogonal Filter Banks<a class="headerlink" href="#orthogonal-filter-banks" title="Permalink to this headline">¶</a></h2> <dl class="function"> <dt id="pywt.orthogonal_filter_bank"> <code class="descclassname">pywt.</code><code class="descname">orthogonal_filter_bank</code><span class="sig-paren">(</span><em>scaling_filter</em><span class="sig-paren">)</span><a class="headerlink" href="#pywt.orthogonal_filter_bank" title="Permalink to this definition">¶</a></dt> <dd><p>Returns the orthogonal filter bank.</p> <p>The orthogonal filter bank consists of the HPFs and LPFs at decomposition and reconstruction stage for the input scaling filter.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><dl class="first docutils"> <dt><strong>scaling_filter</strong> <span class="classifier-delimiter">:</span> <span class="classifier">array_like</span></dt> <dd><p class="first last">Input scaling filter (father wavelet).</p> </dd> </dl> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><dl class="first last docutils"> <dt><strong>orth_filt_bank</strong> <span class="classifier-delimiter">:</span> <span class="classifier">tuple of 4 ndarrays</span></dt> <dd><p class="first last">The orthogonal filter bank of the input scaling filter in the order : 1] Decomposition LPF 2] Decomposition HPF 3] Reconstruction LPF 4] Reconstruction HPF</p> </dd> </dl> </td> </tr> </tbody> </table> </dd></dl> </div> <div class="section" id="example-datasets"> <h2>Example Datasets<a class="headerlink" href="#example-datasets" title="Permalink to this headline">¶</a></h2> <p>The following example datasets are available in the module <code class="docutils literal notranslate"><span class="pre">pywt.data</span></code>:</p> <blockquote> <div><table border="1" class="docutils"> <colgroup> <col width="24%" /> <col width="76%" /> </colgroup> <thead valign="bottom"> <tr class="row-odd"><th class="head"><strong>name</strong></th> <th class="head"><strong>description</strong></th> </tr> </thead> <tbody valign="top"> <tr class="row-even"><td>ecg</td> <td>ECG waveform (1024 samples)</td> </tr> <tr class="row-odd"><td>aero</td> <td>grayscale image (512x512)</td> </tr> <tr class="row-even"><td>ascent</td> <td>grayscale image (512x512)</td> </tr> <tr class="row-odd"><td>camera</td> <td>grayscale image (512x512)</td> </tr> <tr class="row-even"><td>nino</td> <td>sea surface temperature (264 samples)</td> </tr> <tr class="row-odd"><td>demo_signal</td> <td>various synthetic 1d test signals</td> </tr> </tbody> </table> </div></blockquote> <p>Each can be loaded via a function of the same name.</p> <dl class="function"> <dt id="pywt.data.demo_signal"> <code class="descclassname">pywt.data.</code><code class="descname">demo_signal</code><span class="sig-paren">(</span><em>name='Bumps'</em>, <em>n=None</em><span class="sig-paren">)</span><a class="headerlink" href="#pywt.data.demo_signal" title="Permalink to this definition">¶</a></dt> <dd><p>Simple 1D wavelet test functions.</p> <p>This function can generate a number of common 1D test signals used in papers by David Donoho and colleagues (e.g. <a class="reference internal" href="#re2ac4194fcbd-1" id="id1">[1]</a>) as well as the wavelet book by Stéphane Mallat <a class="reference internal" href="#re2ac4194fcbd-2" id="id2">[2]</a>.</p> <table class="docutils field-list" frame="void" rules="none"> <col class="field-name" /> <col class="field-body" /> <tbody valign="top"> <tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><dl class="first docutils"> <dt><strong>name</strong> <span class="classifier-delimiter">:</span> <span class="classifier">{‘Blocks’, ‘Bumps’, ‘HeaviSine’, ‘Doppler’, …}</span></dt> <dd><p class="first last">The type of test signal to generate (<cite>name</cite> is case-insensitive). If <cite>name</cite> is set to <cite>‘list’</cite>, a list of the avialable test functions is returned.</p> </dd> <dt><strong>n</strong> <span class="classifier-delimiter">:</span> <span class="classifier">int or None</span></dt> <dd><p class="first last">The length of the test signal. This should be provided for all test signals except <cite>‘Gabor’</cite> and <cite>‘sineoneoverx’</cite> which have a fixed length.</p> </dd> </dl> </td> </tr> <tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><dl class="first last docutils"> <dt><strong>f</strong> <span class="classifier-delimiter">:</span> <span class="classifier">np.ndarray</span></dt> <dd><p class="first last">Array of length <code class="docutils literal notranslate"><span class="pre">n</span></code> corresponding to the specified test signal type.</p> </dd> </dl> </td> </tr> </tbody> </table> <p class="rubric">Notes</p> <p>This function is a partial reimplementation of the <cite>MakeSignal</cite> function from the [Wavelab](<a class="reference external" href="https://statweb.stanford.edu/~wavelab/">https://statweb.stanford.edu/~wavelab/</a>) toolbox. These test signals are provided with permission of Dr. Donoho to encourage reproducible research.</p> <p class="rubric">References</p> <table class="docutils citation" frame="void" id="re2ac4194fcbd-1" rules="none"> <colgroup><col class="label" /><col /></colgroup> <tbody valign="top"> <tr><td class="label">[1]</td><td><em>(<a class="fn-backref" href="#id1">1</a>, <a class="fn-backref" href="#id3">2</a>)</em> D.L. Donoho and I.M. Johnstone. Ideal spatial adaptation by wavelet shrinkage. Biometrika, vol. 81, pp. 425–455, 1994.</td></tr> </tbody> </table> <table class="docutils citation" frame="void" id="re2ac4194fcbd-2" rules="none"> <colgroup><col class="label" /><col /></colgroup> <tbody valign="top"> <tr><td class="label">[2]</td><td><em>(<a class="fn-backref" href="#id2">1</a>, <a class="fn-backref" href="#id4">2</a>)</em> S. Mallat. A Wavelet Tour of Signal Processing: The Sparse Way. Academic Press. 2009.</td></tr> </tbody> </table> </dd></dl> <p><strong>Example:</strong></p> <div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">pywt</span> <span class="gp">>>> </span><span class="n">camera</span> <span class="o">=</span> <span class="n">pywt</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">camera</span><span class="p">()</span> <span class="gp">>>> </span><span class="n">doppler</span> <span class="o">=</span> <span class="n">pywt</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">demo_signal</span><span class="p">(</span><span class="s1">'doppler'</span><span class="p">)</span> <span class="gp">>>> </span><span class="n">available_signals</span> <span class="o">=</span> <span class="n">pywt</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">demo_signal</span><span class="p">(</span><span class="s1">'list'</span><span class="p">)</span> </pre></div> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar" role="navigation" aria-label="main navigation"> <div class="sphinxsidebarwrapper"> <h3><a href="../index.html">Table of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Other functions</a><ul> <li><a class="reference internal" href="#integrating-wavelet-functions">Integrating wavelet functions</a></li> <li><a class="reference internal" href="#central-frequency-of-psi-wavelet-function">Central frequency of <code class="docutils literal notranslate"><span class="pre">psi</span></code> wavelet function</a></li> <li><a class="reference internal" href="#quadrature-mirror-filter">Quadrature Mirror Filter</a></li> <li><a class="reference internal" href="#orthogonal-filter-banks">Orthogonal Filter Banks</a></li> <li><a class="reference internal" href="#example-datasets">Example Datasets</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="thresholding-functions.html" title="previous chapter">Thresholding functions</a></p> <h4>Next topic</h4> <p class="topless"><a href="../regression/index.html" title="next chapter">Usage examples</a></p><div> <h3>Quick links</h3> <ul> <li><a href="https://github.com/PyWavelets/pywt"><img src="../_static/github.png" height="16" width="16" alt="" /> Fork on Github</a></li> <li><a href="http://groups.google.com/group/pywavelets"><img src="../_static/comments.png" height="16" width="16" alt="" /> Discussion Group</a></li> <li><a href="http://wavelets.pybytes.com/"><img src="../_static/wave.png" height="16" width="16" alt="" /> Explore Wavelets</a></li> </ul> </div> <div id="searchbox" style="display: none" role="search"> <h3>Quick search</h3> <div class="searchformwrapper"> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> </div> </div> <script type="text/javascript">$('#searchbox').show(0);</script> <div id="edit-instructions"> <h3>Edit this document</h3> <p> <a href="#" id="toggle-edit-info"> <img src="../_static/page_edit.png" height="16" width="16" alt="" /> The source code of this file is hosted on GitHub. Everyone can update and fix errors in this document with few clicks - no downloads needed. </a> </p> <ol id="edit-info" style="display: none;"> <li> Go to <i><a href="https://github.com/PyWavelets/pywt/blob/master/doc/source/ref/other-functions.rst" target="_blank"> Other functions </a></i> on GitHub. </li> <li> Press <b>Edit this file</b> button. </li> <li> Edit file contents using GitHub's text editor in your web browser </li> <li> Fill in the <b>Commit message</b> text box at the end of the page telling <i>why</i> you did the changes. Press <b>Propose file change</b> button next to it when done. </li> <li> On <i>Send a pull request</i> page you don't need to fill in text anymore. Just press <b>Send pull request</b> button. </li> <li> Your changes are now queued for review under project's <a href="https://github.com/PyWavelets/pywt/pulls" target="_blank">Pull requests</a> tab on Github. </li> </ol> </div> </div> </div> <div class="clearer"></div> </div> <div class="related" role="navigation" aria-label="related navigation"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../regression/index.html" title="Usage examples" >next</a> |</li> <li class="right" > <a href="thresholding-functions.html" title="Thresholding functions" >previous</a> |</li> <li><a href="../index.html">Home »</a></li> <li class="nav-item nav-item-1"><a href="index.html" >API Reference</a> »</li> </ul> </div> <div class="footer" role="contentinfo"> © Copyright 2006-2019, The PyWavelets Developers. Last updated on Jan 12, 2019. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.3. </div> </body> </html>