forked from caiusseverus/adsbcompare
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdaily.sh
385 lines (273 loc) · 12.2 KB
/
daily.sh
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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
#!/bin/bash
sudo rm /tmp/daily.png
for i in $(ls -1 /var/lib/graphs1090/scatter/ | tail -n 1); do
cat /var/lib/graphs1090/scatter/$i >> /tmp/day
done
for i in $(ls -1 /var/lib/graphs1090/scatter/ | tail -n 7); do
cat /var/lib/graphs1090/scatter/$i >> /tmp/week
done
for i in $(ls -1 /var/lib/graphs1090/scatter/ | tail -n 30); do
cat /var/lib/graphs1090/scatter/$i >> /tmp/month
done
for i in $(ls -1 /var/lib/graphs1090/scatter/ | tail -n 365); do
cat /var/lib/graphs1090/scatter/$i >> /tmp/year
done
for i in $(ls -1 /var/lib/graphs1090/scatter/ | tail -n 372 | head -n 365); do
cat /var/lib/graphs1090/scatter/$i >> /tmp/old
done
for i in /var/lib/graphs1090/scatter/*; do
cat $i >> /tmp/all
done
for i in $(ls -1 /var/lib/graphs1090/scatter/ | tail -n 8 | head -n 7); do
cat /var/lib/graphs1090/scatter/$i >> /tmp/histweek
done
for i in $(ls -1 /var/lib/graphs1090/scatter/ | tail -n 38 | head -n 30); do
cat /var/lib/graphs1090/scatter/$i >> /tmp/histmonth
done
for i in $(ls -1 /var/lib/graphs1090/scatter/ | tail -n 403 | head -n 365); do
cat /var/lib/graphs1090/scatter/$i >> /tmp/histyear
done
for i in $(ls -1 /var/lib/graphs1090/scatter/ | head -n -404); do
cat /var/lib/graphs1090/scatter/$i >> /tmp/histold
done
gnuplot -c /dev/stdin <<"EOF"
set terminal pngcairo enhanced size 1900,900 background rgb 'gray15'
set output '/tmp/daily.png'
set datafile missing "NaN"
date = system ('date -I')
set multiplot layout 3,2 title 'Created '.date
set size 0.5,0.33
set origin 0.5,0.66
set xtics ("Year" 1, "Month" 2, "Week" 3, "Day" 4)
set title "Range"
set style fill solid 0.5 border -1
set style boxplot nooutliers
set pointsize 0.5
stats '/tmp/year' u ($1/1852) name "Y" noout
stats '/tmp/month' u ($1/1852) name "M" noout
stats '/tmp/week' u ($1/1852) name "W" noout
stats '/tmp/day' u ($1/1852) name "D" noout
stats '/tmp/all' u ($1/1852) name "all"
ub = ceil((Y_median + (Y_up_quartile - Y_lo_quartile) * 2) / 10) * 10 + 10
lb = floor((Y_median - (Y_up_quartile - Y_lo_quartile) * 2) / 10) * 10 - 10
print ub
print lb
set yrange [lb:ub]
Ymax = Y_up_quartile + ((Y_up_quartile - Y_lo_quartile) * 1.5)
Ymin = Y_lo_quartile - ((Y_up_quartile - Y_lo_quartile) * 1.5)
Mmax = M_up_quartile + ((M_up_quartile - M_lo_quartile) * 1.5)
Mmin = M_lo_quartile - ((M_up_quartile - M_lo_quartile) * 1.5)
Wmax = W_up_quartile + ((W_up_quartile - W_lo_quartile) * 1.5)
Wmin = W_lo_quartile - ((W_up_quartile - W_lo_quartile) * 1.5)
Dmax = D_up_quartile + ((D_up_quartile - D_lo_quartile) * 1.5)
if (D_min > (D_lo_quartile - ((D_up_quartile - D_lo_quartile) * 1.5))) {Dmin = D_min} ; else {Dmin = (D_lo_quartile - ((D_up_quartile - D_lo_quartile) * 1.5))}
set label 1 sprintf("%3.2f",Ymax) right at 0.725,Ymax font ",8"
set label 2 sprintf("%3.2f",Y_up_quartile) right at 0.725,Y_up_quartile font ",8"
set label 3 sprintf("%3.2f",Y_median) right at 0.725,Y_median font ",8"
set label 4 sprintf("%3.2f",Y_lo_quartile) right at 0.725,Y_lo_quartile font ",8"
set label 5 sprintf("%3.2f",Ymin) right at 0.725,Ymin font ",8"
set label 6 sprintf("%3.2f",Mmax) right at 1.725,Mmax font ",8"
set label 7 sprintf("%3.2f",M_up_quartile) right at 1.725,M_up_quartile font ",8"
set label 8 sprintf("%3.2f",M_median) right at 1.725,M_median font ",8"
set label 9 sprintf("%3.2f",M_lo_quartile) right at 1.725,M_lo_quartile font ",8"
set label 10 sprintf("%3.2f",Mmin) right at 1.725,Mmin font ",8"
set label 11 sprintf("%3.2f",Wmax) right at 2.725,Wmax font ",8"
set label 12 sprintf("%3.2f",W_up_quartile) right at 2.725,W_up_quartile font ",8"
set label 13 sprintf("%3.2f",W_median) right at 2.725,W_median font ",8"
set label 14 sprintf("%3.2f",W_lo_quartile) right at 2.725,W_lo_quartile font ",8"
set label 15 sprintf("%3.2f",Wmin) right at 2.725,Wmin font ",8"
set label 16 sprintf("%3.2f",Dmax) right at 3.725,Dmax font ",8"
set label 17 sprintf("%3.2f",D_up_quartile) right at 3.725,D_up_quartile font ",8"
set label 18 sprintf("%3.2f",D_median) right at 3.725,D_median font ",8"
set label 19 sprintf("%3.2f",D_lo_quartile) right at 3.725,D_lo_quartile font ",8"
set label 20 sprintf("%3.2f",Dmin) right at 3.725,Dmin font ",8"
plot '/tmp/year' u (1):($1/1852) w boxplot lc "blue" notitle, \
'/tmp/month' u (2):($1/1852) w boxplot lc "blue" notitle, \
'/tmp/week' u (3):($1/1852) w boxplot lc "blue" notitle, \
'/tmp/day' u (4):($1/1852) w boxplot lc "blue" notitle
unset for [i=1:20] label i
unset yrange
set size 0.5,0.33
set origin 0.5,0.33
set xtics ("Year" 1, "Month" 2, "Week" 3, "Day" 4)
set title "Messages"
set style fill solid 0.5 border -1
set style boxplot nooutliers
set pointsize 0.5
stats '/tmp/year' u ($2+$3) name "Y" noout
stats '/tmp/month' u ($2+$3) name "M" noout
stats '/tmp/week' u ($2+$3) name "W" noout
stats '/tmp/day' u ($2+$3) name "D" noout
stats '/tmp/all' u ($2+$3) name "all" noout
ub = ceil((Y_max / 100) * 100 + 100)
lb = floor((Y_min / 100) * 100 - 100)
set yrange [lb:ub]
Ymax = Y_max
Ymin = Y_min
Mmax = M_max
Mmin = M_min
Wmax = W_max
Wmin = W_min
Dmax = D_max
Dmin = D_min
set label 1 sprintf("%3.0f",Ymax) right at 0.725,Ymax font ",8"
set label 2 sprintf("%3.0f",Y_up_quartile) right at 0.725,Y_up_quartile font ",8"
set label 3 sprintf("%3.0f",Y_median) right at 0.725,Y_median font ",8"
set label 4 sprintf("%3.0f",Y_lo_quartile) right at 0.725,Y_lo_quartile font ",8"
set label 5 sprintf("%3.0f",Ymin) right at 0.725,Ymin font ",8"
set label 6 sprintf("%3.0f",Mmax) right at 1.725,Mmax font ",8"
set label 7 sprintf("%3.0f",M_up_quartile) right at 1.725,M_up_quartile font ",8"
set label 8 sprintf("%3.0f",M_median) right at 1.725,M_median font ",8"
set label 9 sprintf("%3.0f",M_lo_quartile) right at 1.725,M_lo_quartile font ",8"
set label 10 sprintf("%3.0f",Mmin) right at 1.725,Mmin font ",8"
set label 11 sprintf("%3.0f",Wmax) right at 2.725,Wmax font ",8"
set label 12 sprintf("%3.0f",W_up_quartile) right at 2.725,W_up_quartile font ",8"
set label 13 sprintf("%3.0f",W_median) right at 2.725,W_median font ",8"
set label 14 sprintf("%3.0f",W_lo_quartile) right at 2.725,W_lo_quartile font ",8"
set label 15 sprintf("%3.0f",Wmin) right at 2.725,Wmin font ",8"
set label 16 sprintf("%3.0f",Dmax) right at 3.725,Dmax font ",8"
set label 17 sprintf("%3.0f",D_up_quartile) right at 3.725,D_up_quartile font ",8"
set label 18 sprintf("%3.0f",D_median) right at 3.725,D_median font ",8"
set label 19 sprintf("%3.0f",D_lo_quartile) right at 3.725,D_lo_quartile font ",8"
set label 20 sprintf("%3.0f",Dmin) right at 3.725,Dmin font ",8"
plot '/tmp/year' u (1):($2+$3) w boxplot lc "green" notitle, \
'/tmp/month' u (2):($2+$3) w boxplot lc "green" notitle, \
'/tmp/week' u (3):($2+$3) w boxplot lc "green" notitle, \
'/tmp/day' u (4):($2+$3) w boxplot lc "green" notitle
unset for [i=1:20] label i
unset yrange
set size 0.5,0.33
set origin 0.5,0
set xtics ("Year" 1, "Month" 2, "Week" 3, "Day" 4)
set title "Aircraft"
set style fill solid 0.5 border -1
set style boxplot nooutliers
set pointsize 0.5
stats '/tmp/year' u ($4) name "Y" noout
stats '/tmp/month' u ($4) name "M" noout
stats '/tmp/week' u ($4) name "W" noout
stats '/tmp/day' u ($4) name "D" noout
stats '/tmp/all' u ($4) name "all" noout
ub = ceil((Y_max / 10) * 10 + 10)
lb = floor((Y_min / 10) * 10 - 10)
set yrange [lb:ub]
Ymax = Y_max
Ymin = Y_min
Mmax = M_max
Mmin = M_min
Wmax = W_max
Wmin = W_min
Dmax = D_max
Dmin = D_min
set label 1 sprintf("%3.0f",Ymax) right at 0.725,Ymax font ",8"
set label 2 sprintf("%3.0f",Y_up_quartile) right at 0.725,Y_up_quartile font ",8"
set label 3 sprintf("%3.0f",Y_median) right at 0.725,Y_median font ",8"
set label 4 sprintf("%3.0f",Y_lo_quartile) right at 0.725,Y_lo_quartile font ",8"
set label 5 sprintf("%3.0f",Ymin) right at 0.725,Ymin font ",8"
set label 6 sprintf("%3.0f",Mmax) right at 1.725,Mmax font ",8"
set label 7 sprintf("%3.0f",M_up_quartile) right at 1.725,M_up_quartile font ",8"
set label 8 sprintf("%3.0f",M_median) right at 1.725,M_median font ",8"
set label 9 sprintf("%3.0f",M_lo_quartile) right at 1.725,M_lo_quartile font ",8"
set label 10 sprintf("%3.0f",Mmin) right at 1.725,Mmin font ",8"
set label 11 sprintf("%3.0f",Wmax) right at 2.725,Wmax font ",8"
set label 12 sprintf("%3.0f",W_up_quartile) right at 2.725,W_up_quartile font ",8"
set label 13 sprintf("%3.0f",W_median) right at 2.725,W_median font ",8"
set label 14 sprintf("%3.0f",W_lo_quartile) right at 2.725,W_lo_quartile font ",8"
set label 15 sprintf("%3.0f",Wmin) right at 2.725,Wmin font ",8"
set label 16 sprintf("%3.0f",Dmax) right at 3.725,Dmax font ",8"
set label 17 sprintf("%3.0f",D_up_quartile) right at 3.725,D_up_quartile font ",8"
set label 18 sprintf("%3.0f",D_median) right at 3.725,D_median font ",8"
set label 19 sprintf("%3.0f",D_lo_quartile) right at 3.725,D_lo_quartile font ",8"
set label 20 sprintf("%3.0f",Dmin) right at 3.725,Dmin font ",8"
plot '/tmp/year' u (1):($4) w boxplot lc "red" notitle, \
'/tmp/month' u (2):($4) w boxplot lc "red" notitle, \
'/tmp/week' u (3):($4) w boxplot lc "red" notitle, \
'/tmp/day' u (4):($4) w boxplot lc "red" notitle
unset for [i=1:20] label i
unset yrange
unset xtics
set size 0.5,1
set origin 0,0
set xlabel "Aircraft"
set ylabel "Message rate"
set grid xtics ytics
set xtics 50
set ytics 100
set title "Last week compared with preceding year"
set fit prescale
set fit logfile '/tmp/fit'
FIT_LIMIT = 1.e-10
FIT_MAXITER = 10000
f(x) = a - b * exp(-c*x)
a=3000
b=3000
c=0.01
fit f(x) '/tmp/week' using ($4):($2+$3) via a,b,c
stats '/tmp/week' using ($1/1852) name "Range" noout
lb = (Range_mean - Range_stddev*2)
ub = (Range_mean + Range_stddev*2)
set palette rgbformula 21,22,23
set cblabel 'Range nm'
set cbrange [lb:ub]
set colorbox horizontal user origin graph 0.4, graph 0.1 size graph 0.5, graph 0.05
set key off
plot '/tmp/old' u ($4):($2+$3) with points lt rgb '#001CD2' pt 2 notitle, \
'/tmp/week' u ($4):($2+$3):($1/1852) with points lt palette pt 7 notitle, \
[0:W_max] f(x) lt rgb "black" title "Week" at end
reset
unset multiplot
set terminal pngcairo enhanced size 1900,900 background rgb 'gray15'
set output '/tmp/history.png'
set multiplot layout 2,2 title 'Created '.date
set size 0.5,1
set origin 0,0
set pointsize 0.5
set title 'Message Rate/Aircraft'
set xlabel "Aircraft"
set ylabel "Message rate"
set grid xtics ytics
set xtics 50
set ytics 100
plot '/tmp/histold' u ($4):($2+$3) with points lt rgb '#666666' pt 7 title "Old", \
'/tmp/histyear' u ($4):($2+$3) with points lt rgb '#001CD2' pt 7 title "Year", \
'/tmp/histmonth' u ($4):($2+$3) with points lt rgb '#90ee90' pt 7 title "Month", \
'/tmp/histweek' u ($4):($2+$3) with points lt rgb '#ffff00' pt 7 title "Week", \
'/tmp/day' u ($4):($2+$3) with points lt rgb '#ff0000' pt 7 title "Day"
set size 0.5,0.5
set origin 0.5,0.5
set title 'Range/Aircraft'
set xlabel 'Aircraft'
set ylabel 'Range (nm)'
set xtics 50
set ytics 25
plot '/tmp/histold' u ($4):($1/1852) with points lt rgb '#666666' pt 7 title "Old", \
'/tmp/histyear' u ($4):($1/1852) with points lt rgb '#001CD2' pt 7 title "Year", \
'/tmp/histmonth' u ($4):($1/1852) with points lt rgb '#90ee90' pt 7 title "Month", \
'/tmp/histweek' u ($4):($1/1852) with points lt rgb '#ffff00' pt 7 title "Week", \
'/tmp/day' u ($4):($1/1852) with points lt rgb '#ff0000' pt 7 title "Day"
set origin 0.5,0
set title 'Messages/Aircraft'
set xlabel 'Aircraft'
set ylabel 'Messages/Aircraft'
set xtics 50
set ytics 5
set yrange [0:35]
plot '/tmp/histold' u ($4):(($2+$3)/$4) with points lt rgb '#666666' pt 7 title "Old", \
'/tmp/histyear' u ($4):(($2+$3)/$4) with points lt rgb '#001CD2' pt 7 title "Year", \
'/tmp/histmonth' u ($4):(($2+$3)/$4) with points lt rgb '#90ee90' pt 7 title "Month", \
'/tmp/histweek' u ($4):(($2+$3)/$4) with points lt rgb '#ffff00' pt 7 title "Week", \
'/tmp/day' u ($4):(($2+$3)/$4) with points lt rgb '#ff0000' pt 7 title "Day"
EOF
sudo rm /tmp/day
sudo rm /tmp/week
sudo rm /tmp/month
sudo rm /tmp/year
sudo rm /tmp/old
sudo rm /tmp/fit
sudo rm /tmp/all
sudo rm /tmp/histold
sudo rm /tmp/histyear
sudo rm /tmp/histmonth
sudo rm /tmp/histweek
sudo cp /tmp/daily.png /run/dump1090-fa/daily.png
sudo cp /tmp/history.png /run/dump1090-fa/history.png