From 4e1fbc37b0a7c36fc15df7a2c81925f8928c8910 Mon Sep 17 00:00:00 2001
From: Peter Luenenschloss <peter.luenenschloss@ufz.de>
Date: Wed, 7 Oct 2020 16:30:05 +0200
Subject: [PATCH] problem solved

---
 saqc/funcs/spikes_detection.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/saqc/funcs/spikes_detection.py b/saqc/funcs/spikes_detection.py
index 601d4dfbf..894d9805f 100644
--- a/saqc/funcs/spikes_detection.py
+++ b/saqc/funcs/spikes_detection.py
@@ -942,8 +942,8 @@ def spikes_flagBasic(data, field, flagger, thresh, tolerance, window, numba_kick
     # define spike testing function to roll with:
     def spikeTester(chunk, thresh=thresh, tol=tolerance):
         # signum change!!!
-        # chunk_stair=(np.sign(chunk[-2] - chunk[-1])*(chunk - chunk[-1]) < thresh)[::-1].cumsum()
-        chunk_stair = (np.abs(chunk - chunk[-1]) < thresh)[::-1].cumsum()
+        chunk_stair = (np.sign(chunk[-2] - chunk[-1])*(chunk - chunk[-1]) < thresh)[::-1].cumsum()
+        #chunk_stair = (np.abs(chunk - chunk[-1]) < thresh)[::-1].cumsum()
         initial = np.searchsorted(chunk_stair, 2)
         if initial == len(chunk):
             return 0
@@ -958,7 +958,7 @@ def spikes_flagBasic(data, field, flagger, thresh, tolerance, window, numba_kick
     engine=None
     if roll_mask.sum() > numba_kickin:
         engine = 'numba'
-    result = customRolling(to_roll, window, spikeTester, roll_mask, closed='both', engine=engine)
+    result = customRolling(to_roll, window, spikeTester, roll_mask, closed='both', engine=engine, min_periods=2)
 
     # correct the result: only those values define plateaus, that do not have
     # values at their left starting point, that belong to other plateaus themself:
-- 
GitLab