1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379
|
<!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="Content-Type" content="text/html; charset=utf-8" />
<title>The Wavelet object — PyWavelets Documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.2.0',
COLLAPSE_MODINDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
};
</script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="top" title="PyWavelets Documentation" href="../index.html" />
<link rel="up" title="Usage examples" href="index.html" />
<link rel="next" title="Signal Extension Modes" href="modes.html" />
<link rel="prev" title="Usage examples" href="index.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, Filip Wasilewski" />
<meta name="author" content="Filip Wasilewski" />
<meta name="Distribution" content="Global" />
<meta name="Robots" content="INDEX,FOLLOW" />
</head>
<body>
<div class="related">
<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="../modindex.html" title="Global Module Index"
accesskey="M">modules</a> |</li>
<li class="right" >
<a href="modes.html" title="Signal Extension Modes"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="index.html" title="Usage examples"
accesskey="P">previous</a> |</li>
<li><a href="../index.html">PyWavelets Documentation</a> »</li>
<li><a href="index.html" accesskey="U">Usage examples</a> »</li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body">
<div class="section" id="the-wavelet-object">
<span id="reg-wavelet"></span><h1>The Wavelet object<a class="headerlink" href="#the-wavelet-object" title="Permalink to this headline">¶</a></h1>
<div class="section" id="wavelet-families-and-builtin-wavelets-names">
<h2>Wavelet families and builtin Wavelets names<a class="headerlink" href="#wavelet-families-and-builtin-wavelets-names" title="Permalink to this headline">¶</a></h2>
<p><a title="pywt.Wavelet" class="reference external" href="../ref/wavelets.html#pywt.Wavelet"><tt class="xref docutils literal"><span class="pre">Wavelet</span></tt></a> objects are really a handy carriers of a bunch of DWT-specific
data like <em>quadrature mirror filters</em> and some general properties associated
with them.</p>
<p>At first let’s go through the methods of creating a <a title="pywt.Wavelet" class="reference external" href="../ref/wavelets.html#pywt.Wavelet"><tt class="xref docutils literal"><span class="pre">Wavelet</span></tt></a> object.
The easiest and the most convenient way is to use builtin named Wavelets.</p>
<p>These wavelets are organized into groups called wavelet families. The most
commonly used families are:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">pywt</span>
<span class="gp">>>> </span><span class="n">pywt</span><span class="o">.</span><span class="n">families</span><span class="p">()</span>
<span class="go">['haar', 'db', 'sym', 'coif', 'bior', 'rbio', 'dmey']</span>
</pre></div>
</div>
<p>The <a title="pywt.wavelist" class="reference external" href="../ref/wavelets.html#pywt.wavelist"><tt class="xref docutils literal"><span class="pre">wavelist()</span></tt></a> function with family name passed as an argument is used to
obtain the list of wavelet names in each family.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="k">for</span> <span class="n">family</span> <span class="ow">in</span> <span class="n">pywt</span><span class="o">.</span><span class="n">families</span><span class="p">():</span>
<span class="gp">... </span> <span class="k">print</span> <span class="s">"</span><span class="si">%s</span><span class="s"> family:"</span> <span class="o">%</span> <span class="n">family</span><span class="p">,</span> <span class="s">', '</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">pywt</span><span class="o">.</span><span class="n">wavelist</span><span class="p">(</span><span class="n">family</span><span class="p">))</span>
<span class="go">haar family: haar</span>
<span class="go">db family: db1, db2, db3, db4, db5, db6, db7, db8, db9, db10, db11, db12, db13, db14, db15, db16, db17, db18, db19, db20</span>
<span class="go">sym family: sym2, sym3, sym4, sym5, sym6, sym7, sym8, sym9, sym10, sym11, sym12, sym13, sym14, sym15, sym16, sym17, sym18, sym19, sym20</span>
<span class="go">coif family: coif1, coif2, coif3, coif4, coif5</span>
<span class="go">bior family: bior1.1, bior1.3, bior1.5, bior2.2, bior2.4, bior2.6, bior2.8, bior3.1, bior3.3, bior3.5, bior3.7, bior3.9, bior4.4, bior5.5, bior6.8</span>
<span class="go">rbio family: rbio1.1, rbio1.3, rbio1.5, rbio2.2, rbio2.4, rbio2.6, rbio2.8, rbio3.1, rbio3.3, rbio3.5, rbio3.7, rbio3.9, rbio4.4, rbio5.5, rbio6.8</span>
<span class="go">dmey family: dmey</span>
</pre></div>
</div>
<p>To get the full list of builtin wavelets’ names just use the <a title="pywt.wavelist" class="reference external" href="../ref/wavelets.html#pywt.wavelist"><tt class="xref docutils literal"><span class="pre">wavelist()</span></tt></a>
with no argument. As you can see currently there are 76 builtin wavelets.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="nb">len</span><span class="p">(</span><span class="n">pywt</span><span class="o">.</span><span class="n">wavelist</span><span class="p">())</span>
<span class="go">76</span>
</pre></div>
</div>
</div>
<div class="section" id="creating-wavelet-objects">
<h2>Creating Wavelet objects<a class="headerlink" href="#creating-wavelet-objects" title="Permalink to this headline">¶</a></h2>
<p>Now when we know all the names let’s finnally create a <a title="pywt.Wavelet" class="reference external" href="../ref/wavelets.html#pywt.Wavelet"><tt class="xref docutils literal"><span class="pre">Wavelet</span></tt></a> object:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">w</span> <span class="o">=</span> <span class="n">pywt</span><span class="o">.</span><span class="n">Wavelet</span><span class="p">(</span><span class="s">'db3'</span><span class="p">)</span>
</pre></div>
</div>
<p>So.. that’s it.</p>
</div>
<div class="section" id="wavelet-properties">
<h2>Wavelet properties<a class="headerlink" href="#wavelet-properties" title="Permalink to this headline">¶</a></h2>
<p>But what can we do with <a title="pywt.Wavelet" class="reference external" href="../ref/wavelets.html#pywt.Wavelet"><tt class="xref docutils literal"><span class="pre">Wavelet</span></tt></a> objects? Well, they carry some
interresting information.</p>
<p>First, let’s try printing a <a title="pywt.Wavelet" class="reference external" href="../ref/wavelets.html#pywt.Wavelet"><tt class="xref docutils literal"><span class="pre">Wavelet</span></tt></a> object. This shows a brief
information about it’s name, it’s family name and some properties like
orthogonality and symmetry.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="k">print</span> <span class="n">w</span>
<span class="go">Wavelet db3</span>
<span class="go"> Family name: Daubechies</span>
<span class="go"> Short name: db</span>
<span class="go"> Filters length: 6</span>
<span class="go"> Orthogonal: True</span>
<span class="go"> Biorthogonal: True</span>
<span class="go"> Symmetry: asymmetric</span>
</pre></div>
</div>
<p>But the most important information are the wavelet filters coefficients, which
are used in <a class="reference external" href="../ref/dwt-discrete-wavelet-transform.html#ref-dwt"><em>Discrete Wavelet Transform</em></a>. These coefficients can
be obtained via the <a title="pywt.Wavelet.dec_lo" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.dec_lo"><tt class="xref docutils literal"><span class="pre">dec_lo</span></tt></a>, <a title="pywt.Wavelet.dec_hi" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.dec_hi"><tt class="xref docutils literal"><span class="pre">Wavelet.dec_hi</span></tt></a>,
<a title="pywt.Wavelet.rec_lo" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.rec_lo"><tt class="xref docutils literal"><span class="pre">rec_lo</span></tt></a> and <a title="pywt.Wavelet.rec_hi" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.rec_hi"><tt class="xref docutils literal"><span class="pre">rec_hi</span></tt></a> attributes, which
corresponds to lowpass and highpass decomposition filters and lowpass and
highpass reconstruction filters respectively:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">w</span><span class="o">.</span><span class="n">dec_lo</span>
<span class="go">[0.035226291882100656, -0.085441273882241486, -0.13501102001039084, 0.45987750211933132, 0.80689150931333875, 0.33267055295095688]</span>
<span class="gp">>>> </span><span class="n">w</span><span class="o">.</span><span class="n">dec_hi</span>
<span class="go">[-0.33267055295095688, 0.80689150931333875, -0.45987750211933132, -0.13501102001039084, 0.085441273882241486, 0.035226291882100656]</span>
<span class="gp">>>> </span><span class="n">w</span><span class="o">.</span><span class="n">rec_lo</span>
<span class="go">[0.33267055295095688, 0.80689150931333875, 0.45987750211933132, -0.13501102001039084, -0.085441273882241486, 0.035226291882100656]</span>
<span class="gp">>>> </span><span class="n">w</span><span class="o">.</span><span class="n">rec_hi</span>
<span class="go">[0.035226291882100656, 0.085441273882241486, -0.13501102001039084, -0.45987750211933132, 0.80689150931333875, -0.33267055295095688]</span>
</pre></div>
</div>
<p>Another way to get the filters data is to use the <a title="pywt.Wavelet.filter_bank" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.filter_bank"><tt class="xref docutils literal"><span class="pre">filter_bank</span></tt></a>
attribute, which returns all four filters in a tuple:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">w</span><span class="o">.</span><span class="n">filter_bank</span> <span class="o">==</span> <span class="p">(</span><span class="n">w</span><span class="o">.</span><span class="n">dec_lo</span><span class="p">,</span> <span class="n">w</span><span class="o">.</span><span class="n">dec_hi</span><span class="p">,</span> <span class="n">w</span><span class="o">.</span><span class="n">rec_lo</span><span class="p">,</span> <span class="n">w</span><span class="o">.</span><span class="n">rec_hi</span><span class="p">)</span>
<span class="go">True</span>
</pre></div>
</div>
<p>Other Wavelet’s properties are:</p>
<blockquote>
<p>Wavelet <a title="pywt.Wavelet.name" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.name"><tt class="xref docutils literal"><span class="pre">name</span></tt></a>, <a title="pywt.Wavelet.short_family_name" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.short_family_name"><tt class="xref docutils literal"><span class="pre">short_family_name</span></tt></a> and <a title="pywt.Wavelet.family_name" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.family_name"><tt class="xref docutils literal"><span class="pre">family_name</span></tt></a>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="k">print</span> <span class="n">w</span><span class="o">.</span><span class="n">name</span>
<span class="go">db3</span>
<span class="gp">>>> </span><span class="k">print</span> <span class="n">w</span><span class="o">.</span><span class="n">short_family_name</span>
<span class="go">db</span>
<span class="gp">>>> </span><span class="k">print</span> <span class="n">w</span><span class="o">.</span><span class="n">family_name</span>
<span class="go">Daubechies</span>
</pre></div>
</div>
<ul>
<li><p class="first">Decomposition (<a title="pywt.Wavelet.dec_len" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.dec_len"><tt class="xref docutils literal"><span class="pre">dec_len</span></tt></a>) and reconstruction
(<a title="pywt.Wavelet.rec_len" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.rec_len"><tt class="xref docutils literal"><span class="pre">rec_len</span></tt></a>) filter lengths:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">w</span><span class="o">.</span><span class="n">dec_len</span>
<span class="go">6</span>
<span class="gp">>>> </span><span class="n">w</span><span class="o">.</span><span class="n">rec_len</span>
<span class="go">6</span>
</pre></div>
</div>
</li>
<li><p class="first">Orthogonality (<a title="pywt.Wavelet.orthogonal" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.orthogonal"><tt class="xref docutils literal"><span class="pre">orthogonal</span></tt></a>) and biorthogonality (<a title="pywt.Wavelet.biorthogonal" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.biorthogonal"><tt class="xref docutils literal"><span class="pre">biorthogonal</span></tt></a>):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">w</span><span class="o">.</span><span class="n">orthogonal</span>
<span class="go">True</span>
<span class="gp">>>> </span><span class="n">w</span><span class="o">.</span><span class="n">biorthogonal</span>
<span class="go">True</span>
</pre></div>
</div>
</li>
<li><p class="first">Symmetry (<a title="pywt.Wavelet.symmetry" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.symmetry"><tt class="xref docutils literal"><span class="pre">symmetry</span></tt></a>):</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="k">print</span> <span class="n">w</span><span class="o">.</span><span class="n">symmetry</span>
<span class="go">asymmetric</span>
</pre></div>
</div>
</li>
<li><p class="first">Number of vanishing moments for the scaling function <em>phi</em>
(<a title="pywt.Wavelet.vanishing_moments_phi" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.vanishing_moments_phi"><tt class="xref docutils literal"><span class="pre">vanishing_moments_phi</span></tt></a>) and the wavelet function <em>psi</em>
(<a title="pywt.Wavelet.vanishing_moments_psi" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.vanishing_moments_psi"><tt class="xref docutils literal"><span class="pre">vanishing_moments_psi</span></tt></a>) associated with the filters:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">w</span><span class="o">.</span><span class="n">vanishing_moments_phi</span>
<span class="go">0</span>
<span class="gp">>>> </span><span class="n">w</span><span class="o">.</span><span class="n">vanishing_moments_psi</span>
<span class="go">3</span>
</pre></div>
</div>
</li>
</ul>
</blockquote>
<p>Now when we know a bit about the builtin Wavelets, les’t see how to create
<a class="reference external" href="../ref/wavelets.html#custom-wavelets"><em>custom Wavelets</em></a> objects. These can be done in two ways:</p>
<blockquote>
<ol class="arabic">
<li><p class="first">Passing the filter bank object that implements the <cite>filter_bank</cite>
attribute. The attribute must return four filters coefficients.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="k">class</span> <span class="nc">MyHaarFilterBank</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
<span class="gp">... </span> <span class="nd">@property</span>
<span class="gp">... </span> <span class="k">def</span> <span class="nf">filter_bank</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
<span class="gp">... </span> <span class="kn">from</span> <span class="nn">math</span> <span class="kn">import</span> <span class="n">sqrt</span>
<span class="gp">... </span> <span class="k">return</span> <span class="p">([</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="o">-</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">],</span>
<span class="gp">... </span> <span class="p">[</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="o">-</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">])</span>
</pre></div>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">my_wavelet</span> <span class="o">=</span> <span class="n">pywt</span><span class="o">.</span><span class="n">Wavelet</span><span class="p">(</span><span class="s">'My Haar Wavelet'</span><span class="p">,</span> <span class="n">filter_bank</span><span class="o">=</span><span class="n">MyHaarFilterBank</span><span class="p">())</span>
</pre></div>
</div>
</li>
<li><p class="first">Passing the filters coefficients directly as the <em>filter_bank</em> parameter.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">math</span> <span class="kn">import</span> <span class="n">sqrt</span>
<span class="gp">>>> </span><span class="n">my_filter_bank</span> <span class="o">=</span> <span class="p">([</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="o">-</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">],</span>
<span class="gp">... </span> <span class="p">[</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">],</span> <span class="p">[</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">,</span> <span class="o">-</span><span class="n">sqrt</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">my_wavelet</span> <span class="o">=</span> <span class="n">pywt</span><span class="o">.</span><span class="n">Wavelet</span><span class="p">(</span><span class="s">'My Haar Wavelet'</span><span class="p">,</span> <span class="n">filter_bank</span><span class="o">=</span><span class="n">my_filter_bank</span><span class="p">)</span>
</pre></div>
</div>
</li>
</ol>
</blockquote>
<p>Note that such custom wavelets <strong>will not</strong> have all the properties set
to correct values:</p>
<blockquote>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="k">print</span> <span class="n">my_wavelet</span>
<span class="go">Wavelet My Haar Wavelet</span>
<span class="go"> Family name:</span>
<span class="go"> Short name:</span>
<span class="go"> Filters length: 2</span>
<span class="go"> Orthogonal: False</span>
<span class="go"> Biorthogonal: False</span>
<span class="go"> Symmetry: unknown</span>
</pre></div>
</div>
<p>You can hovewer set a few of them on your own:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">my_wavelet</span><span class="o">.</span><span class="n">orthogonal</span> <span class="o">=</span> <span class="bp">True</span>
<span class="gp">>>> </span><span class="n">my_wavelet</span><span class="o">.</span><span class="n">biorthogonal</span> <span class="o">=</span> <span class="bp">True</span>
</pre></div>
</div>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="k">print</span> <span class="n">my_wavelet</span>
<span class="go">Wavelet My Haar Wavelet</span>
<span class="go"> Family name:</span>
<span class="go"> Short name:</span>
<span class="go"> Filters length: 2</span>
<span class="go"> Orthogonal: True</span>
<span class="go"> Biorthogonal: True</span>
<span class="go"> Symmetry: unknown</span>
</pre></div>
</div>
</blockquote>
</div>
<div class="section" id="and-now-the-wavefun">
<h2>And now... the <cite>wavefun</cite>!<a class="headerlink" href="#and-now-the-wavefun" title="Permalink to this headline">¶</a></h2>
<p>We all know that the fun with wavelets is in wavelet functions.
Now what would be this package without a tool to compute wavelet
and scaling functions approximations?</p>
<p>This is the purpose of the <a title="pywt.Wavelet.wavefun" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.wavefun"><tt class="xref docutils literal"><span class="pre">wavefun()</span></tt></a> method, which is used to
approximate scaling function (<em>phi</em>) and wavelet function (<em>psi</em>) at the given
level of refinement, based on the filters coefficients.</p>
<p>The number of returned values varies depending on the wavelet’s
orthogonality property. For orthogonal wavelets the result is tuple
with scaling function, wavelet function and xgrid coordinates.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">w</span> <span class="o">=</span> <span class="n">pywt</span><span class="o">.</span><span class="n">Wavelet</span><span class="p">(</span><span class="s">'sym3'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">w</span><span class="o">.</span><span class="n">orthogonal</span>
<span class="go">True</span>
<span class="gp">>>> </span><span class="p">(</span><span class="n">phi</span><span class="p">,</span> <span class="n">psi</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span> <span class="o">=</span> <span class="n">w</span><span class="o">.</span><span class="n">wavefun</span><span class="p">(</span><span class="n">level</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
</pre></div>
</div>
<p>For biorthogonal (non-orthogonal) wavelets different scaling and wavelet
functions are used for decomposition and reconstruction, and thus five
elements are returned: decomposition scaling and wavelet functions
approximations, reconstruction scaling and wavelet functions approximations,
and the xgrid.</p>
<div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">w</span> <span class="o">=</span> <span class="n">pywt</span><span class="o">.</span><span class="n">Wavelet</span><span class="p">(</span><span class="s">'bior1.3'</span><span class="p">)</span>
<span class="gp">>>> </span><span class="n">w</span><span class="o">.</span><span class="n">orthogonal</span>
<span class="go">False</span>
<span class="gp">>>> </span><span class="p">(</span><span class="n">phi_d</span><span class="p">,</span> <span class="n">psi_d</span><span class="p">,</span> <span class="n">phi_r</span><span class="p">,</span> <span class="n">psi_r</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span> <span class="o">=</span> <span class="n">w</span><span class="o">.</span><span class="n">wavefun</span><span class="p">(</span><span class="n">level</span><span class="o">=</span><span class="mi">5</span><span class="p">)</span>
</pre></div>
</div>
<div class="admonition-see-also admonition seealso">
<p class="first admonition-title">See also</p>
<p class="last">You can find live examples of <a title="pywt.Wavelet.wavefun" class="reference external" href="../ref/wavelets.html#pywt.Wavelet.wavefun"><tt class="xref docutils literal"><span class="pre">wavefun()</span></tt></a> usage and
images of all the built-in wavelets on the
<a class="reference external" href="http://wavelets.pybytes.com">Wavelet Properties Browser</a> page.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar">
<div class="sphinxsidebarwrapper">
<h3><a href="../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference external" href="#">The Wavelet object</a><ul>
<li><a class="reference external" href="#wavelet-families-and-builtin-wavelets-names">Wavelet families and builtin Wavelets names</a></li>
<li><a class="reference external" href="#creating-wavelet-objects">Creating Wavelet objects</a></li>
<li><a class="reference external" href="#wavelet-properties">Wavelet properties</a></li>
<li><a class="reference external" href="#and-now-the-wavefun">And now... the <cite>wavefun</cite>!</a></li>
</ul>
</li>
</ul>
<h4>Previous topic</h4>
<p class="topless"><a href="index.html"
title="previous chapter">Usage examples</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="modes.html"
title="next chapter">Signal Extension Modes</a></p>
<h3>This Page</h3>
<ul class="this-page-menu">
<li><a href="../_sources/regression/wavelet.txt"
rel="nofollow">Show Source</a></li>
</ul>
<div id="searchbox" style="display: none">
<h3>Quick search</h3>
<form class="search" action="../search.html" method="get">
<input type="text" name="q" size="18" />
<input type="submit" value="Go" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
<p class="searchtip" style="font-size: 90%">
Enter search terms or a module, class or function name.
</p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
<div>
<h3>Quick links</h3>
<ul>
<li><a href="http://groups.google.com/group/pywavelets"><img src="../_static/comments.png" height="16" width="16" alt="" /> Visit Discussion Group</a></li>
<li><a href="http://wavelets.scipy.org/moin/"><img src="../_static/page_edit.png" height="16" width="16" alt="" /> View Wiki Page</a></li>
<li><a href="http://projects.scipy.org/wavelets/browser/pywt/trunk/"><img src="../_static/cog.png" height="16" width="16" alt="" /> Browse Source Code</a></li>
<li><a href="http://wavelets.pybytes.com/"><img src="../_static/wave.png" height="16" width="16" alt="" /> Explore Wavelets</a></li>
<li><a href="http://delicious.com/save" onclick="window.open('http://delicious.com/save?v=5&noui&jump=close&url='+encodeURIComponent('http://www.pybytes.com/pywavelets/')+'&title='+encodeURIComponent('PyWavelets - Discrete Wavelet Transform in Python'), 'delicious','toolbar=no,width=550,height=550'); return false;"><img src="../_static/delicious.png" height="12" width="12" alt="Delicious" style="margin: 0 2px 0 2px;" /> Bookmark with Delicious</a></li>
<li><a href="http://twitter.com/filipwasilewski"><img src="../_static/twitter.png" height="16" width="16" alt="" /> Follow on Twitter</a></li>
</ul>
</div>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="related">
<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="../modindex.html" title="Global Module Index"
>modules</a> |</li>
<li class="right" >
<a href="modes.html" title="Signal Extension Modes"
>next</a> |</li>
<li class="right" >
<a href="index.html" title="Usage examples"
>previous</a> |</li>
<li><a href="../index.html">PyWavelets Documentation</a> »</li>
<li><a href="index.html" >Usage examples</a> »</li>
</ul>
</div>
<div class="footer">
© Copyright 2006-2010, <a href="http://filipwasilewski.pl/">Filip Wasilewski</a>.
Last updated on Mar 16, 2010.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 0.6.5.
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3396395-3");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</body>
</html>
|