Usiamo il TeX per scrivere le etichette dei grafici.

Leonardo Robol [2010-03-13 10:11]
Usiamo il TeX per scrivere le etichette dei grafici.
Filename
Filtering/Filtering.py
Filtering/dwt
diff --git a/Filtering/Filtering.py b/Filtering/Filtering.py
index 2247897..8a78335 100644
--- a/Filtering/Filtering.py
+++ b/Filtering/Filtering.py
@@ -245,14 +245,10 @@ class FilterBank():
     def Split(self, samples):
         """
         Split the samples using the filter provided
-        by the user. It returns an array of samples similar
-        to this:
-
-          [ high, high, high , ... , high, low ]
-
-        that contains the details and the last average.
+        by the user. It returns a WaveletStack that
+        contains the details and the last average.
         The original signal can be rebuilt collapsing
-        all these downsamples signals with the Rebuild
+        all these downsampled signals with the Rebuild
         method.
         """

@@ -300,15 +296,14 @@ class FilterBank():
             # Sfortunatamente questo ci rovinerà tutta l'ultima parte del
             # segnale, ma per ora non vedo una soluzione comoda.
             low = roll(low, -1 * self.length)
-
+
+        # Riparo gli eventuali end effect
         low[:-2*self.depth*len(self.lowPassFilter.GetResponse())] = samplesStack.PopEndEffectSamples ()

         # Riattacchiamo la coda
         return concatenate ((low, end))


-
-
 DaubechiesFilterBank = FilterBank ()
 DaubechiesFilterBank.SetFilterMatrix ( [
         0.125 * array([ 1 + sqrt(3), 3 + sqrt(3), 3 - sqrt(3), 1 - sqrt(3)]),
diff --git a/Filtering/dwt b/Filtering/dwt
index b6d0fd8..c515b08 100755
--- a/Filtering/dwt
+++ b/Filtering/dwt
@@ -60,10 +60,17 @@ LoadingLibrariesStarted()

 # Importing libraries
 import Filtering
-from pylab import show, plot
+from pylab import show, plot, title, xlabel, ylabel, rcParams
 from numpy import array, sqrt, memmap, roll
 from numpy.linalg import norm
 import time
+
+params = {
+    "text.usetex": True,
+    'font.family': 'serif',
+}
+
+rcParams.update(params)



@@ -74,19 +81,27 @@ class DWT():

     def __init__(self, filename, action = 'show', filewrite = 'rebuilt.wav',
                  filterbank = 'haar', depth = 4):
-
+
         StartProgram ()

         startingTime = time.time ()
         self.depth = depth
+
+        self.filterBankName = ""

         # Scelgo la filterbank da utilizzare
         if filterbank == 'haar':
             filterBank = Filtering.HaarFilterBank
+            self.filterBankName = "Haar"
         elif (filterbank == 'daubechies') or (filterbank.lower() == 'd4'):
             filterBank = Filtering.DaubechiesFilterBank
+            self.filterBankName = "Daubechies D4"
         elif filterbank == 'strang':
             filterBank = Filtering.StrangFilterBank
+            self.filterBankName = "Strang"
+        elif filterbank == 'leo':
+            filterBank = Filtering.LeoFilterBank
+            self.filterBankName = "Leo"
         else:
             filterBank = Filtering.HaarFilterBank
             Output ("FilterBank %s not known. Setting 'haar'" % filterbank)
@@ -166,7 +181,6 @@ class DWT():
         toPlot = int(frequency) * 60

         # Stampo i low
-        print scale
         scale = int(0.5 * scale)
         low = wavelets.PopLowSamples()
         data = low[:toPlot / scale]
@@ -187,6 +201,11 @@ class DWT():
             plot (axes, data + offset)
             offset += singleOffset
             scale = int(0.5*scale)
+
+
+        # Set some nice text
+        title (r"Decomposition using %s filter bank" % self.filterBankName)
+        xlabel (r"time (s)")

         show ()
ViewGit