Merge of sandbox gui into analysis. Started csv_acp_pnl.

--HG--
branch : sandbox
This commit is contained in:
Andreas
2009-07-23 21:39:12 +00:00
parent 3cd2666eaf
commit 147af5b163

View File

@@ -114,11 +114,16 @@ def num2sod(x):
frac, integ = math.modf(x)
return frac * 86400
class Lohi:
"""Time series online low and high detector."""
def __init__(self, bias):
class TimedLohi:
"""Time series online low and high detector.
Confirms low/high candidates after timeout.
Time dependent.
"""
def __init__(self, bias, timeout = ONE_MINUTE):
assert(bias > 0)
self.bias = bias
self.timeout = timeout
self.low0 = None
self.high0 = None
self.prev_lohi = NONE
@@ -162,7 +167,7 @@ class Lohi:
self.lows.append(self.low0)
self.lohis.append(self.low0)
self.prev_lohi = LOW
if self.high0[1] < cdt - ONE_MINUTE and \
if self.high0[1] < cdt - self.timeout and \
((self.prev_lohi == LOW and \
self.high0[2] > self.lows[-1][2] + self.bias) or
(self.prev_lohi == HIGH and \
@@ -172,7 +177,7 @@ class Lohi:
self.highs.append(self.high0)
self.lohis.append(self.high0)
self.prev_lohi = HIGH
if self.low0[1] < cdt - ONE_MINUTE and \
if self.low0[1] < cdt - self.timeout and \
((self.prev_lohi == LOW and \
self.low0[2] < self.lows[-1][2]) or
(self.prev_lohi == HIGH and \
@@ -403,7 +408,7 @@ class Main:
self.ss = [ 0 ] * len(self.xs)
self.gs = [ 0 ] * len(self.xs)
self.mmh = Lohi(5)
self.mmh = TimedLohi(5)
self.osw = SlidingWindow(5)
self.w0 = 0