From 38bc146d95d769d812f9157329b75dd622c8b35c Mon Sep 17 00:00:00 2001 From: jaseg Date: Sun, 26 Jan 2020 22:04:20 +0100 Subject: Make detection algorithm prototype slightly easier to implement --- viz.ipynb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/viz.ipynb b/viz.ipynb index 7166bef..04a185d 100644 --- a/viz.ipynb +++ b/viz.ipynb @@ -1699,7 +1699,7 @@ }, { "cell_type": "code", - "execution_count": 101, + "execution_count": 103, "metadata": { "scrolled": false }, @@ -2503,7 +2503,7 @@ "for ax, capture in zip(axs.flatten(), [data_downstairs[0] + data_downstairs[1], data_upstairs]):\n", " cap = np.array(capture)\n", " cap -= np.mean(cap).astype(int)\n", - " lens = np.array([ len(g) for g in (list(g) for g_key, g in itertools.groupby(cap, lambda x: 1 if x >= 0 else -1)) for _x in g ])\n", + " lens = np.array([ x for g in (list(g) for g_key, g in itertools.groupby(cap, lambda x: 1 if x >= 0 else -1)) for x in range(len(g)) ])\n", " w = 32\n", " k = 8\n", " lens = np.array(list(sum(xs) for xs in zip(*(lens[i::k] for i in range(w))))) / w\n", @@ -2518,10 +2518,10 @@ " for idx, data in enumerate(zip(*(both_data[i*p:] for i in range(q)))):\n", " h_len, h_rms = zip(*data)\n", " if all(x > 1500 for x in h_rms):\n", - " if all(1.0 < x < 1.5 for x in h_len[::2]) and \\\n", - " all(1.3 < x < 1.8 for x in h_len[1::2]):\n", + " if all(0.1 < x < 0.25 for x in h_len[::2]) and \\\n", + " all(0.25 < x < 0.4 for x in h_len[1::2]):\n", " ax.axvspan(idx, idx + p*q, color='lightgreen')\n", - " elif all(1.4 < x < 1.8 for x in h_len):\n", + " elif all(0.25 < x < 0.4 for x in h_len):\n", " ax.axvspan(idx, idx + p*q, color='pink')" ] } -- cgit