You are a guest. Restricted access. Read more.

# Wavelets

Snippet from Wikipedia: Wavelet

A wavelet is a wave-like oscillation with an amplitude that begins at zero, increases, and then decreases back to zero. It can typically be visualized as a "brief oscillation" like one might see recorded by a seismograph or heart monitor. Generally, wavelets are purposefully crafted to have specific properties that make them useful for signal processing.

A good introduction to wavelets is given here. Below we show how to use wavelets using the “jsci” package which is incorporated into the the core of the SCaVis package.

In this example, we will create a 1D vector of Gaussian numbers and transform using Fast Wavelet Transform (daubechies 2). We convert the input array into a histogram for visualization. Then we extract coefficients and convert the signal back. Then we compare the original data with the converted ones.

Code example

``` 1: from jhplot  import *
2: from java.util import Random
3: from java.awt  import Color
4:
5: c1 = HPlot("Canvas",600,400)
6: c1.setNameX("X")
7: c1.setNameY("Y")
8: c1.visible(1)
9: c1.setAutoRange()
10:
11: p1 = P0D("Input data")
12: rand = Random();
13: for i in range(100):
14:           x=10*rand.nextGaussian()
16: print p1.toString()
17:
18: h1=p1.getH1D(50,-10,10)
19: c1.draw(h1)
20:
21: #########  do wavelets
22: from jsci.maths import *
23: from jsci.maths.wavelet import *
24: from jsci.maths.wavelet.daubechies2 import *
25:
26: ondelette = Daubechies2()
27: signal =Signal(p1.getArray())
28:
29: signal.setFilter(ondelette) # transform
30: level = 1 # for some level int
31: sCoef = signal.fwt(level) # get coefficients from Fast Wavelet Transform
32: p2=P0D("Coefs0",sCoef.getCoefs()[0])
33: p3=P0D("Coefs1",sCoef.getCoefs()[1])
34: signalBack=P0D("Signal back", sCoef.rebuildSignal(ondelette).evaluate(0))
35:
36: h3=signalBack.getH1D(50,-10,10) #  get the signal back
37: h3.setColor(Color.red)
38: c1.draw(h3)
```

You will see 2 identical histograms. Please refer the package jsci.maths.wavelet.

One can comment and discuss this section after becoming a full member.