Index: /fact/tools/pyscripts/pyfact/fir_filter.py
===================================================================
--- /fact/tools/pyscripts/pyfact/fir_filter.py	(revision 14485)
+++ /fact/tools/pyscripts/pyfact/fir_filter.py	(revision 14486)
@@ -7,4 +7,7 @@
 from scipy import signal
 
+# For FastSlidingAverage
+from scipy import weave
+from scipy.weave import converters
 
 class FirFilter(object):
@@ -87,5 +90,67 @@
             a[0] = len(b)
         FirFilter.__init__(self, b, a, 'sliding average')
-            
+
+
+
+
+class FastSlidingAverage( object ):
+        def __init__(self, shape, length=8):
+            """ initialize the object
+                length:  lenght of the averaging window
+            """
+            self.length = length
+            # allocate memory for the filtered data once
+            self.filtered = np.zeros( shape, np.float64 )
+            self.shape = shape
+
+        def __call__(self, data):
+            if self.shape != data.shape:
+                raise TypeException('data has wrong shape')
+
+            length = self.length
+            numpix = data.shape[0]
+            numslices = data.shape[1]
+
+            filtered = self.filtered
+            cppcode = """
+                double sum = 0;
+                for (int pix=0; pix<numpix; pix++)
+                {
+                    for ( int sl=0; sl<numslices-length; ++sl)
+                    {
+                        for ( int i=0; i<length; ++i)
+                        {
+                            sum += data(pix,sl+i);
+                        }
+                        filtered(pix,sl) = sum/length;
+                    }
+                }
+            """
+
+            ## this seems to run a little bit faster.
+
+            cppcode2 = """
+                double sum = 0;
+                for (int pix=0; pix<numpix; pix++)
+                {
+                    sum = 0;
+                    for ( int i=0; i<length-1; ++i)
+                    {
+                        sum += data(pix,i);
+                    }
+                    for ( int sl=length-1; sl<numslices-length; ++sl)
+                    {
+                        sum += data(pix,sl);
+                        filtered(pix,sl) = sum/length;
+                        sum -= data(pix,sl-(length-1) );
+                    }
+                }
+            """ 
+
+            weave.inline( cppcode2,
+                    [ 'length' , 'numpix', 'numslices', 'data', 'filtered'],
+                    type_converters=converters.blitz)
+
+            return filtered
 
 class CFD(FirFilter):
