-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
94 lines (67 loc) · 2.05 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import time
from os import listdir
from os.path import isfile, join
import matplotlib.pyplot as plt
import streamlit as st
import numpy as np
import pandas as pd
from CsiExplorer import Explorer
from CsiPlotter import Plotter
st.title('CSI Explorer')
pcapDir = 'files/'
bandwidth = st.sidebar.selectbox(
'Select Bandwidth',
[20, 40, 80],
index=2
)
pcapfilename = st.sidebar.selectbox(
'Select file to explore',
[f for f in listdir(pcapDir) if isfile(join(pcapDir, f))]
)
remove_null = st.sidebar.checkbox(
'Remove Null subcarriers',
value=True
)
remove_pilot = st.sidebar.checkbox(
'Remove Pilot subcarriers',
value=True
)
show_animation = st.sidebar.checkbox(
'Play animation',
value=True
)
explorer = Explorer(pcapDir + pcapfilename)
if show_animation:
fig, ax = plt.subplots()
nfft = int(bandwidth * 3.2)
x = np.arange(-1 * nfft/2, nfft/2)
ax.set_ylim(0, 4000)
plt.xlabel("Sub carrier index")
plt.ylabel("Amplitude")
line, = ax.plot(x, explorer.get_sample(0).get_csi(remove_null, remove_pilot))
el_plot = st.pyplot(plt)
el_status = st.markdown('### Showing sample 0')
el_summary = st.text('Summary')
def init(): # give a clean slate to start
line.set_ydata([np.nan] * len(x))
def animate(i): # update the y values (every 1000ms)
sample = explorer.get_sample(i)
line.set_ydata(sample.get_csi(remove_null, remove_pilot))
el_plot.pyplot(plt)
el_status.markdown('### Showing sample %d' % (i))
el_summary.text(sample)
init()
for i in range(explorer.get_max_index() + 1):
animate(i)
time.sleep(0.05)
else:
samplenumber = st.sidebar.slider(
label='Select CSI sample to explore',
min_value=0,
max_value=explorer.get_max_index(),
value=0
)
sample = explorer.get_sample(int(samplenumber))
st.line_chart(sample.get_csi(remove_null, remove_pilot))
el_status = st.markdown('### Showing sample %d' % (samplenumber))
el_summary = st.text(sample)