Prove sulla refinement equation.

Leonardo Robol [2010-03-10 09:37]
Prove sulla refinement equation.
Filename
RefinementEquation/Iteration.py
diff --git a/RefinementEquation/Iteration.py b/RefinementEquation/Iteration.py
index cc1c69d..c49c756 100755
--- a/RefinementEquation/Iteration.py
+++ b/RefinementEquation/Iteration.py
@@ -8,13 +8,14 @@

 print " => Carico le librerie necessarie...",
 from pylab import *
-import time, numpy
+import time, numpy, Filtering
 print "ok"

 # Si comincia ad iterare
 h = numpy.array([0.125 , 0.25, 0.25, 0.25, 0.125])
-
-t = numpy.linspace(-10,10,100)
+h = Filtering.DaubechiesFilterBank.lowPassFilter.GetResponse()
+h = Filtering.StrangFilterBank.lowPassFilter.GetResponse()
+t = numpy.linspace(-0.05,len(h) + 0.05,1000)

 def box(x):
     """box function"""
@@ -34,7 +35,7 @@ def refinement(x):
     for value in h:
         newphi += value * phi_func(2*x - counter)
         counter += 1
-    return 2 * newphi
+    return max(min(2 * newphi, 10), -10)

 def phi_func(x):

@@ -44,15 +45,27 @@ def phi_func(x):
     return phi[t.tolist().index(item)]

 ion ()
-for i in xrange(0,5):
-    plot(t,phi)
-    draw ()
-
-    time.sleep (1)
-    phi = map(refinement, t)
+hold(False)
+diff = 1
+try:
+    while True:
+        # plot(t,phi)
+        # draw ()
+        print "diff = %f" % diff
+        # time.sleep (0.25)
+        newphi = map(refinement, t)
+        diff = numpy.linalg.norm(numpy.array(newphi) - numpy.array(phi))
+        phi = newphi
+except KeyboardInterrupt:

+    plot(t,phi)
+    draw()
+    raw_input()

-raw_input ()
+    f = open("phi.txt", "w")
+    for value in phi:
+        f.write("%s\n" % value)
+    f.close ()


ViewGit