-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathanalyse.py
More file actions
173 lines (137 loc) · 7.08 KB
/
analyse.py
File metadata and controls
173 lines (137 loc) · 7.08 KB
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
import pandas
import matplotlib.pyplot as plt
import statsmodels.api as sm
import sys
import re
import numpy as np
import math
argv = sys.argv
data = pandas.read_csv(argv[1], nrows = int(argv[2]), header=None, names=['timestamp','chan','signal','datarate','phy','crc','length'])
data['dataratefloat'] = data[['datarate']].applymap(lambda x: float(str(x).split(',')[0]))
print(data)
#print(data.groupby('dataratefloat').count())
#CRC vs signal strength
#
# bysignal = data.groupby('signal')['crc'].mean().rolling(1).mean()
# samples = data.groupby('signal')['crc'].count()
# fig =bysignal[samples>10].plot(title='percentage of correctly received packets vs signal strength', color='b', style='.-')
#
# fig2=samples[samples>10].plot(ax=fig, secondary_y=True, color='y', style='.-')
# fig2.set_ylabel("samples", color='y')
# fig.set_xlabel("SSI signal strength [dBm]")
# fig.set_ylabel("Percentage of packets correctly received", color='b')
# plt.show()
def bydatarate(data):
bydatarate = data.groupby(['signal','datarate'])['crc'].mean()
print(bydatarate)
samples = data.groupby(['signal','datarate'])['crc'].count()
plt.figure()
fig =bydatarate.unstack().plot(subplots=True,title='percentage of correctly received packets vs signal strength by datarate')
#samples.unstack().plot(ax=fig, secondary_y=True)
plt.show()
def graphall(data):
# CRC vs signal strength
bysignal = data.groupby('signal')['crc'].mean().rolling(1).mean()
samples = data.groupby('signal')['crc'].count()
fig =bysignal[samples>10].plot(title='percentage of correctly received packets vs signal strength', color='b', style='.-')
fig2=samples[samples>10].plot(ax=fig, secondary_y=True, color='y', style='.-')
fig2.set_ylabel("samples", color='y')
fig.set_xlabel("SSI signal strength [dBm]")
fig.set_ylabel("Percentage of packets correctly received", color='b')
plt.show()
def graph58ghz(data):
filter = data['chan'].apply(int) > 15
bysignal = data[filter].groupby('signal')['crc'].mean().rolling(1).mean()
samples = data[filter].groupby('signal')['crc'].count()
fig = bysignal[samples > 10].plot(title='5.8 GHz', color='b', style='.-')
fig2 = samples[samples > 10].plot(ax=fig, secondary_y=True, color='y', style='.-')
fig2.set_ylabel("samples", color='y')
fig.set_xlabel("SSI signal strength [dBm]")
fig.set_ylabel("Percentage of packets correctly received", color='b')
plt.show()
def graph58ghz144mbps(data):
filter = data['chan'].apply(int) > 15
bysignal = data[filter][data['dataratefloat'] >= 80].groupby('signal')['crc'].mean().rolling(1).mean()
samples = data[filter][data['dataratefloat'] >= 80].groupby('signal')['crc'].count()
fig = bysignal[samples > 10].plot(title='5.8 GHz', color='b', style='.-')
fig2 = samples[samples > 10].plot(ax=fig, secondary_y=True, color='y', style='.-')
fig2.set_ylabel("samples", color='y')
fig.set_xlabel("SSI signal strength [dBm]")
fig.set_ylabel("Percentage of packets correctly received", color='b')
plt.show()
def graph24ghz72mbps(data):
filter = data['chan'].apply(int) < 15
bysignal = data[filter][data['dataratefloat'] == 24.0 ].groupby('signal')['crc'].mean().rolling(1).mean()
samples = data[filter][data['dataratefloat'] == 24.0 ].groupby('signal')['crc'].count()
fig = bysignal[samples > 10].plot(title='correctly received packets at 2.8 GHz, 72.2Mbps', color='b', style='.-')
fig2 = samples[samples > 10].plot(ax=fig, secondary_y=True, color='y', style='.-')
fig2.set_ylabel("samples", color='y')
fig.set_xlabel("SSI signal strength [dBm]")
fig.set_ylabel("Percentage of packets correctly received", color='b')
plt.show()
def graph24ghz(data):
filter = data['chan'].apply(int) < 15
bysignal = data[filter].groupby('signal')['crc'].mean().rolling(1).mean()
samples = data[filter].groupby('signal')['crc'].count()
fig = bysignal[samples > 10].plot(title='correctly received packets at 2.8 GHz, 72.2Mbps', color='b', style='.-')
fig2 = samples[samples > 10].plot(ax=fig, secondary_y=True, color='y', style='.-')
fig2.set_ylabel("samples", color='y')
fig.set_xlabel("SSI signal strength [dBm]")
fig.set_ylabel("Percentage of packets correctly received", color='b')
plt.show()
def graphlength(data):
samples = data.groupby('length')['crc'].count()
bylength = data.groupby('length')['crc'].mean()[samples>4]
plt.figure()
fig =bylength[samples>4].plot(title='correctly received packets vs packet length', color='gray')
bylength[samples>4].rolling(20).mean().plot(color='black')
fig.set_ylabel("ratio of correct packets")
fig.set_xlabel("packet length [Bytes]")
#samples[samples > 10].plot(ax=fig, secondary_y=True)
#fig.right_ax.set_yscale('log')
#l = np.arange(150,1700,1)
#plt.plot(l, (1 - (0.001**l)))
plt.show()
# nf = bylength.to_frame().reset_index().dropna();
# newindex = pandas.RangeIndex(1,1618,1)
# resampled = nf.reindex('length',newindex)
# #resampled.interpolate('index',inplace=True)
# print(resampled)
# print(sm.OLS(nf['crc'],nf['length']).fit().summary())
def graphairtime(data):
data['airtime'] = (data['length'] * 8) / data['dataratefloat']
samples = data.groupby('airtime')['crc'].count()
bylength = data.groupby('airtime')['crc'].mean()[samples>4].rolling(5).mean()
plt.figure()
fig =bylength[samples>4].plot(title='percentage of correctly received packets vs packet airtime',color='gray')
bylength[samples>4].rolling(50).mean().plot(color='black')
fig.set_xlabel("airtime [uS]")
fig.set_ylabel("non-crc error")
#samples[samples > 10].plot(ax=fig, secondary_y=True)
#fig.right_ax.set_yscale('log')
#l = np.arange(150,1700,1)
#plt.plot(l, (1 - (0.001**l)))
plt.show()
def dataratevsstrength(data):
data['dataratefloat'] = data[['datarate']].applymap(lambda x: float(x.split(',')[0]))
print(data[data.crc == 1][['crc','signal','dataratefloat']].groupby('signal')['dataratefloat'].max().to_frame())
fig = data[data.crc == 1][['crc','signal','dataratefloat']].groupby('signal')['dataratefloat'].mean().plot(color='y', style='.-')
fig2 = data[['crc','signal','dataratefloat']].groupby('signal')['dataratefloat'].mean().plot(color='b', style='.-')
data[['crc','signal','dataratefloat']].groupby('signal')['dataratefloat'].max().plot(color='b', style='.-')
data[data.crc == 1][['crc','signal','dataratefloat']].groupby('signal')['dataratefloat'].max().plot(color='y', style='.-')
data[['crc','signal','dataratefloat']].groupby('signal')['dataratefloat'].min().plot(color='b', style='.-')
data[data.crc == 1][['crc','signal','dataratefloat']].groupby('signal')['dataratefloat'].min().plot(color='y', style='.-')
fig.set_ylabel("datarate [Mbps]")
fig.set_xlabel("SSI signal strength [dBm]")
fig.legend([fig,fig2],["all packets", "successful packets"])
plt.show()
graphall(data)
bydatarate(data)
graph58ghz(data)
graph24ghz(data)
graph24ghz72mbps(data)
graphlength(data)
graphairtime(data)
dataratevsstrength(data)
#print(data.groupby('chan')['crc'].mean())
#print(data.groupby('chan')['crc'].count())