Index: fact/tools/pyscripts/pyfact/drs_spikes.py
===================================================================
--- fact/tools/pyscripts/pyfact/drs_spikes.py	(revision 13011)
+++ fact/tools/pyscripts/pyfact/drs_spikes.py	(revision 13012)
@@ -17,7 +17,7 @@
     """
     
-    def __init__(self, threshold, 
-                 single_pattern=np.array( [0.5, 1.0, 0.5]) ,
-                 double_pattern=np.array([1., 1., 1., 1.]), 
+    def __init__(self, threshold=10., 
+                 single_pattern=np.array( [-0.5, 1.0, -0.5]) ,
+                 double_pattern=np.array([-1., 1., 1., -1.]), 
                  debug = False):
         """ initialize spike filter 
@@ -28,9 +28,10 @@
 
         self.threshold = threshold
-        self.single_pattern = list(single_pattern * threshold)
-        self.double_pattern = list(double_pattern * threshold)
+        self.single_pattern = single_pattern * threshold
+        self.double_pattern = double_pattern * threshold
         
         self.remove_signal = fir.RemoveSignal()
-        
+        self.debug = debug
+
     def __call__(self, data):
 
@@ -40,19 +41,27 @@
         singles = []
         doubles = []
-       
+
+        cc = candidates = np.where(a > self.threshold)
+        print 'candidates: ', candidates[0]-1
         #: find single spikes
-        p = self.single_pattern
-        for i, x in enumerate(zip(-a[:-2], a[1:-1], -a[2:])):
-            if ( (x[0]>p[0]) & (x[1] > p[1]) & (x[2] > p[2]) ):
-                singles.append(i)
+        p = self.single_pattern * np.sign( self.single_pattern )
+        for i, can in enumerate( zip(a[cc[0]-1], a[cc[0]], a[cc[0]+1]) ):
+            print 'can : p', can, p
+            can = can * np.sign(self.single_pattern)
+            if all(can > p):
+                singles.append(candidates[0][i] - 1)
 
-        #: find double spike
-        p = self.double_pattern
-        for i, x in enumerate(zip(-a[:-3], a[1:-2], a[2:-1], -a[3:])):
-            if (x[0] > p[0]) & (x[1] > p[1]) & (x[2] > p[2]) & (x[3] > p[3]):
-                doubles.append(i)
+        #: find double spikes
+        p = self.double_pattern * np.sign( self.double_pattern )
+        for i, can in enumerate( zip(a[cc[0]-1], a[cc[0]], 
+                                     a[cc[0]+1], a[cc[0]+2]) ):
+            print 'can : p', can, p
+            can = can * np.sign(self.double_pattern)
+            if all(can > p):
+                doubles.append(candidates[0][i] - 1)
 
-        print 'singles: ', singles
-        print 'doubles: ', doubles
+        if self.debug:
+            print 'singles: ', singles
+            print 'doubles: ', doubles
 
         data = self.remove_single_spikes(singles, data)
@@ -85,5 +94,5 @@
     print a 
 
-    SpikeRemover = DRSSpikes(3.)
+    SpikeRemover = DRSSpikes(3., debug=True)
     print 'single spike pattern ', SpikeRemover.single_pattern
     print 'double spike pattern ', SpikeRemover.double_pattern
