-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCDF_Plot.py
873 lines (774 loc) · 33.2 KB
/
CDF_Plot.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
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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
import struct
import os
import re
import matplotlib.pyplot as plt
import numpy as np
import sys
import math
from scipy import stats
##TOF Values - Manually taken at each point - START
lobbyDiagonal = [1880325.87,1880326.5,sys.maxint,1880328.62]
lobbyBackward = [1880325.87,1880326.75,1880327.75,1880328.75]
lobbyBackwardExtra = [1756229.62,1756231.24,1756231.87,1756232.5,1756233.75,1756234.5,1756235.25,1756236,1756236.75]
lobbyLateral = [1880325.87,1880325.87,1880326.25,1880326.62,1880327.12,1880327.62]
lobbyRotation_10 = [576247.37,576247.37,576247.37,576247.5,576247.5,sys.maxint,sys.maxint,576247.37,576247.75,576247.5,576247.5,576252.5,sys.maxint]
lobbyRotation_12 = [576248.25,576248.25,576248.25,sys.maxint,576248.25,576248.25,576248.25,576248.25,576248.25,sys.maxint,576249.75,576249.75,576249.75]
conferenceRoom = [1129091.37,1129091.25,1129091.5,sys.maxint,1129091.89,1129091.76,1129091.64,1129091.64]
conferenceRoomRotation_Pos1_1_1 = [639285.75,639285.75,639285.75,639285.75,639285.75,639285.75,639285.75,639285.75,639285.75,639285.75,639285.75,639285.75,639285.75]
conferenceRoomRotation_Pos5 = [639289.37,639289.37,639289.37,639289.37,sys.maxint,sys.maxint,sys.maxint,639289.37,639289.37,639289.37,639289.25,639289.25,639289.25]
lab = [280073.12,280073.25,sys.maxint,280074.5,280075,280076,280076.62,280077.37,280078.12,280079.10]
labRotation_Pos3 =[801884.75,801884.75,801884.75,801884.75,801884.75,801884.75,801884.75,801884.62,801884.62,801884.62,801884.62,801884.62,801884.75]
labRotation_Pos6 =[801886.62,801886.62,801886.62,801886.62,801888.25,801888.25,801889.12,801886.62,801886.62,801886.62,801886.62,801886.62,801886.62]
labRotation_Pos9 =[801888.37,801888.37,sys.maxint,sys.maxint,sys.maxint,sys.maxint,sys.maxint,801888.37,sys.maxint,sys.maxint,sys.maxint,sys.maxint,sys.maxint]
corridor = [1835631.87,1835632.655,1835633.5,1835634.345,1835635.19,1835636.035,1835636.88,1835637.725,1835638.57,1835639.415,1835640.26,1835641.105,1835641.95,1835642.795,1835643.64,1835644.485,1835645.33]
corridorRotation_Pos5 = [1740825.87,1740825.87,1740826,1740825.87,1740825.87,sys.maxint,sys.maxint,1740825.87,1740825.87,1740825.87,1740825.87,sys.maxint,sys.maxint]
frontCorridor_part1 = [1368529.12,1368529.87,1368530.62,1368531.37,1368532.12,1368533.25,1368533.75,1368534.62,1368535.62,1368536.25,1368537.12]
frontCorridor_part2 = [383181.75,383182.62,383183.37,383184.25,383185,383185.75,383186.87,383187.37,383188.25,383189,383189.87]
##TOF Values - Manually taken at each point -- END
##Blockage_TOF_Values
conference_blockage_lat_1 = [329637.62,329637.75,329637.62,329637.62]
conference_blockage_lat_7 = [329641.5,329642,329641.5,329641.62]
corridor_blockage_lat_5 = [544585.12,544589.37,544585.12,544585.12]
corridor_blockage_lat_10 = [544589.25,544589.37,544589.37,544589.25]
corridor_blockage_lat_12_5 = [544592.12,544592.25,544592.25,544592.12]
front_corridor_1_lat_10 = [331383,331383.25,331383,331383.25]
front_corridor_2_lat_10 = [138589.5,138589.75,138589.62,138589.62]
lab_blockage_2 = [224003.37,224003.37]
lobby_blockage_1_1 = [289863.37,0,0,0]
lobby_blockage_1_10 = [289865.25,289865.62,0,289865.25]
lobby_blockage_2_3 = [1756229.62,0,1756229.62,1756229.87]
##
##Interference_TOF_Value
interference_front_corridor_1 = [1365626.66,1365626.66,1365626.66,1365626.66]
interference_front_corridor_2 = [777806.5,777806.5,777806.5,777806.5]
interference_back_corridor_5 = [601599,601599,601599,601599]
interference_back_corridor_10 = [226865.5,226865.5,226865.5,226865.5]
interference_back_corridor_12_5 = [1592995.37,1592995.37,1592995.37,1592995.37]
interference_lobby_1_1 = [8692995.5,8692995.5,8692995.5,8692995.5]
interference_lobby_1_10 = [1152820.87,1152820.87,1152820.87,1152820.87]
interference_lobby_2_3 = [1996526.5,1996526.5,1996526.5,1996526.5]
interference_conference_1 = [1395190.75,1395190.75,1395190.75,1395190.75]
interference_conference_7 = [274307.62,274307.62,274307.62,274307.62]
interference_lab = [343844.87,343844.87,343844.87,343844.87]
## SNR,PDP,CIR,FFT_PDP,FFT_CIR,All,TOF
plotparameter = "ALL"
## ALL,Lat,Rotation,Interference,SpecificLocation
locationParameter = "LabLat"
snrCondition = False
tofCondition = False
labelTxtForSNR = ""
labelTxtForTOF = ""
if snrCondition:
labelTxtForSNR = "_With_SNR_Condition"
if tofCondition:
labelTxtForTOF = "_With_TOF_Condition"
##fontsize in plots for x,y - labels
fontsize = '8'
##HANDle division by zero error in matplot
np.seterr(divide='ignore', invalid='ignore')
##ba/ra/ba=ra lists
list_ba = []
list_ra = []
list_baplusra = []
list_ba_ra = []
##ALL
pdp_list = []
cir_list = []
ftt_pdp_list = []
ftt_cir_list= []
##LocationList
locList = []
##Locations where pdp/cir files are not proper
##Same are also being written to a .txt file
corrupt_pdp_locations = []
corrupt_cir_locations = []
##pdp-threshold for selecting peaks
pdpthreshold = 0.001
cirthreshold = 0.01
def writeCorruptLocationsToFile(errorlist,corruptfilename):
fd = open("errorLocations.txt", "w")
str0 = plotparameter +"\n"
str1 = ''.join(errorlist)
str2 = str(len(errorlist))
fd.write("Files Corrupt : " + corruptfilename + "\n\n" + str1 + "\n\n" + "Number of files : " + str2)
fd.close()
def plotIncludingLocations(x_list,y_list):
labeltext = "PDP Similarity at : "+locationParameter
plt.plot(x_list,y_list,label = labeltext)
plt.grid(True)
plt.legend(loc="upper left")
plt.xticks(fontsize=3)
plt.xlabel("Locations", fontsize=8)
plt.savefig("PDP_Similarity"+"_"+locationParameter+".pdf")
plt.close()
def plotCDFForAllParameters():
parameter = 0
for n in [pdp_list,cir_list,ftt_pdp_list,ftt_cir_list]:
temp = np.sort(n)
yvals = np.arange(len(n))/float(len(n)-1)
if parameter == 0:
labeltext = "PDP Similarity"
parameter = 1
elif parameter == 1:
labeltext = "CIR Similarity"
parameter = 2
elif parameter == 2:
labeltext = "PDP Similarity - FFT"
parameter = 3
elif parameter == 3:
labeltext = "CIR Similarity - FFT"
else:
break;
plt.plot(temp,yvals,label=labeltext)
plt.grid(True)
plt.legend(loc="upper left")
plt.xticks(np.arange(0,1,0.1))
plt.xlabel(plotparameter, fontsize=14)
plt.savefig("AllParameters_CDF"+"_"+locationParameter+".pdf")
plt.close()
if len(corrupt_pdp_locations) > 0:
writeCorruptLocationsToFile(corrupt_pdp_locations,"PDP")
if len(corrupt_cir_locations) > 0:
writeCorruptLocationsToFile(corrupt_cir_locations,"CIR")
def plotCDFUsingList():
count = 1
for n in [list_ba,list_ra,list_baplusra,list_ba_ra]:
temp = np.sort(n)
yvals = np.arange(len(n))/float(len(n)-1)
if count == 1:
labeltext = "BA"+" ("+str(len(temp)) + ")"
plt.plot(temp,yvals,label=labeltext)
count = 2
else:
if count == 2:
labeltext = "RA"+" ("+str(len(temp)) + ")"
plt.plot(temp,yvals,label=labeltext)
count = 3
elif count == 3:
labeltext = "BA+RA"+" ("+str(len(temp)) + ")"
plt.plot(temp,yvals,label=labeltext)
count = 4
else:
labeltext = "BA = RA"+" ("+str(len(temp)) + ")"
plt.plot(temp,yvals,label=labeltext)
plt.grid(True)
if plotparameter == "TOF":
plt.xlim((-20,20))
plt.legend(loc="upper left")
plt.xlabel(plotparameter, fontsize=14)
plt.savefig("BAvsRA_" + plotparameter +"Location_"+ locationParameter + labelTxtForSNR + labelTxtForTOF + ".pdf")
plt.close()
print "\n"
if len(corrupt_pdp_locations) > 0:
writeCorruptLocationsToFile(corrupt_pdp_locations,"PDP")
if len(corrupt_cir_locations) > 0:
writeCorruptLocationsToFile(corrupt_cir_locations,"CIR")
def convert_beam_to_text(beam):
return '[' + str(beam[0]) + ']_[' + str(beam[1]) + ']_[0]'
def get_best_beam(path):
try:
initialflag = 1
linelist = []
fileHandler = open(path+"/workfile",'r')
for line in fileHandler:
linelist.append(line)
# print len(linelist)
data = np.full((25,25),-9999.0)
# print data
for line in linelist:
l = line.strip()
i = int(l.split(',')[0])
j = int(l.split(',')[1])
regex = r"\[(.*?)\]"
match = re.findall(regex, l)
list1=[]
list1 = match[0].split(",")
sum,avg = 0,0
for k in range(len(list1)):
sum += float(list1[k])
avg = sum/len(list1)
data[i][j] = avg
# print path
# print np.unravel_index(np.argmax(data), np.shape(data))
return np.unravel_index(np.argmax(data), np.shape(data))
except:
print len(linelist),path,"error reading workfile"
def get_pdp_AND_snr(pos, beam_text):
try:
listoflist = []
finalList = []
f = open(pos + '/' + beam_text + '_[ ].pdp', "rb")
num = 0
total = 0
while True:
flag = 0
list = []
total += 1
bits = f.read(4)
if not bits:
break
x = struct.unpack_from('>i',bits)
if x[0] == 0:
continue
for i in range(0,x[0]):
bits = f.read(8)
num += 1
x = struct.unpack_from('>d',bits)
if(math.isnan(x[0])):
list.append(0)
else:
list.append(x[0])
listoflist.append(list)
lengthOfList = len(listoflist)
for i in range(0,1024):
sum = 0
avg = 0
for k in range(0,lengthOfList):
sum = sum + listoflist[k][i]
avg = float(sum)/lengthOfList
finalList.append(avg)
##SNR Calculation from PDP
first100 = 0
for n in range (0,100):
first100 = first100 + finalList[n]
last100 = 0
for n in range (924,1024):
last100 = last100 + finalList[n]
noiseEstimate = (first100 + last100)/200.0
signalPowerEstimate = 0
for n in range(0,1024):
signalPowerEstimate = signalPowerEstimate + finalList[n]
signalPowerEstimate = signalPowerEstimate/1024.0
signalPowerEstimate = signalPowerEstimate - noiseEstimate
snrEstimate = signalPowerEstimate/noiseEstimate
return finalList,np.log10(snrEstimate) * 10
except Exception as e:
print "PDP : Exception - ",e
corrupt_pdp_locations.append(pos + " - " + beam_text + "\n")
return [],-10
def get_crc(pos,beam_text):
count_success = 0
count_failure = 0
f = open(pos + '/' + beam_text + '_[ ].crcpattern', "rb")
while True:
bits = f.read(4)
if not bits:
break
a = struct.unpack_from('>i',bits)
bits = f.read(4)
b = struct.unpack_from('>i',bits)
for i in range(a[0] * b[0]):
bits = f.read(1)
x = struct.unpack_from('>?',bits)
if not x[0]:
count_success = count_success + 1
else:
count_failure = count_failure + 1
return float(count_success)/(count_success+count_failure)
def get_phase(pos,beam_text):
listoflist = []
finalList = []
f = open(pos + '/' + beam_text + '_[ ].phase', "rb")
num = 0
total = 0
while True:
flag = 0
list = []
total += 1
bits = f.read(4)
if not bits:
break
a = struct.unpack_from('>i',bits)
bits = f.read(4)
b = struct.unpack_from('>i',bits)
for i in range(a[0] * b[0]):
bits = f.read(8)
num += 1
x = struct.unpack_from('>d',bits)
if(math.isnan(x[0])):
list.append(0)
else:
list.append(x[0])
listoflist.append(np.average(list[:22]))
return np.average(listoflist)
def get_cir(pos,beam_text):
try:
listoflist = []
finalList = []
f = open(pos + '/' + beam_text + '_[ ].impulseresponse', "rb")
num = 0
total = 0
while True:
flag = 0
list = []
total += 1
bits = f.read(4)
if not bits:
break
a = struct.unpack_from('>i',bits)
bits = f.read(4)
b = struct.unpack_from('>i',bits)
for i in range(a[0] * b[0]):
bits = f.read(8)
num += 1
x = struct.unpack_from('>d',bits)
if(math.isnan(x[0])):
list.append(0)
else:
list.append(x[0])
listoflist.append(list[:1024])
lengthOfList = len(listoflist)
for i in range(0,1024):
sum = 0
avg = 0
for k in range(0,lengthOfList):
sum = sum + listoflist[k][i]
avg = float(sum)/lengthOfList
finalList.append(avg)
return finalList
except Exception as e:
print "CIR : Exception - ",e
corrupt_cir_locations.append(pos + " - " + beam_text + "\n")
return []
def getPDPSimilarity(initialpdpvalues,currentpositionpdpvalues):
currentmin = 0
currentmax = 0
temporaryList = []
for n in [initialpdpvalues,currentpositionpdpvalues]:
for i in n:
if i > pdpthreshold:
temporaryList.append(n.index(i))
currentmin = min(temporaryList)
currentmax = max(temporaryList)
return initialpdpvalues[currentmin:currentmax+1],currentpositionpdpvalues[currentmin:currentmax+1]
def getCIRSimilarity(initialcirvalues,currentpositioncirvalues):
currentmin = 0
currentmax = 0
temporaryList = []
for n in [initialcirvalues,currentpositioncirvalues]:
for i in n:
if i > cirthreshold:
temporaryList.append(n.index(i))
currentmin = min(temporaryList)
currentmax = max(temporaryList)
return initialcirvalues[currentmin:currentmax+1],currentpositioncirvalues[currentmin:currentmax+1]
def getPeaksFromPDP(pdpValueList):
peaks = 0
for n in pdpValueList:
if n > pdpthreshold:
peaks = peaks + 1
return peaks
def get_list_for_cdf_plots(beam_tput_overall,best_beam_dict,max_tput,best_init_mcs,best_init_beam,path,test_pos):
# print test_pos
positions = sorted(beam_tput_overall.keys())
if 'Rotation' in path:
positions = ['0', '15', '30', '45', '60', '75', '90', 'neg15', 'neg30', 'neg45', 'neg60', 'neg75', 'neg90']
# Beam adaptation
tput_val = []
label = []
for pos in positions:
tput = beam_tput_overall[pos][convert_beam_to_text(best_beam_dict[pos]) + '_[' + best_init_mcs + ']']
tput_val.append(tput)
label.append(convert_beam_to_text(best_beam_dict[pos]) + '_[' + best_init_mcs + ']')
tput_val_ba = tput_val[:]
label_ba = label[:]
# Rate adaptation
tput_val = []
label = []
for pos in positions:
max_tput = -1
for beam_text, tput in beam_tput_overall[pos].items():
if best_init_beam_text in beam_text:
if tput > max_tput:
max_beam_text = beam_text
max_tput = tput
tput_val.append(max_tput)
label.append(max_beam_text)
tput_val_ra = tput_val[:]
label_ra = label[:]
# BA + RA
tput_val = []
label = []
for pos in positions:
max_tput = -1
for beam_text, tput in beam_tput_overall[pos].items():
if convert_beam_to_text(best_beam_dict[pos]) in beam_text:
if tput > max_tput:
max_beam_text = beam_text
max_tput = tput
tput_val.append(max_tput)
label.append(max_beam_text)
tput_val_ba_ra = tput_val[:]
label_ba_ra = label[:]
# (BA + RA) - BA
tput_val = []
label = []
tput_val = [i - j for i, j in zip(tput_val_ba_ra, tput_val_ba)]
label = [i + ' - ' + j for i, j in zip(label_ba_ra, label_ba)]
# No adaptation
tput_val = []
snr_val = []
snr_values = []
locationList = []
pdp_values = []
cir_values = []
phase_values = []
crc_values = []
for pos in positions:
tput_val.append(beam_tput_overall[pos][best_init_beam_mcs])
pdp, snr = get_pdp_AND_snr(path + pos, best_init_beam_mcs)
pdp_values.append(pdp)
snr_values.append(snr)
cir_values.append(get_cir(path + pos, best_init_beam_mcs))
phase_values.append(get_phase(path + pos, best_init_beam_mcs))
crc_values.append(get_crc(path + pos, best_init_beam_mcs))
if plotparameter != "ALL":
if path.find("ConferenceRoom_Lat") > 0 :
locationList = conferenceRoom
elif path.find("ConferenceRotation/Pos1") > 0:
locationList = conferenceRoomRotation_Pos1_1_1
elif path.find("ConferenceRotation/Pos5") > 0:
locationList = conferenceRoomRotation_Pos5
elif path.find("CoridoorRotation/pos5") > 0:
locationList = corridorRotation_Pos5
elif path.find("CoridoorRotation/pos15") > 0:
locationList = []
elif path.find("CoridoorRotation/pos25") > 0:
locationList = []
elif path.find("CorridorLat") > 0:
locationList = corridor
elif path.find("LabRotation/Pos3") > 0:
locationList = labRotation_Pos3
elif path.find("LabRotation/Pos6") > 0:
locationList = labRotation_Pos6
elif path.find("LabRotation/Pos9") > 0:
locationList = labRotation_Pos9
elif path.find("LabLat") > 0:
locationList = lab
elif path.find("Lobby_Lat_Backward") > 0:
locationList = lobbyBackward
elif path.find("Lobby_Lat_Diagonal") > 0:
locationList = lobbyDiagonal
elif path.find("Lobby_Lateral") > 0:
locationList = lobbyLateral
elif path.find("Lobby_Rotation/Pos10") > 0:
locationList = lobbyRotation_10
elif path.find("Lobby_Rotation/Pos12") > 0:
locationList = lobbyRotation_12
elif path.find("Lobby_Lat_2"):
locationList = lobbyBackwardExtra
elif path.find("Front_Corridor_back_Lat"):
locationList = frontCorridor_part2
elif path.find("Front_CorridorLat"):
locationList = frontCorridor_part1
elif path.find("Conference_Blockage_Lat/pos1"):
locationList = conference_blockage_lat_1
elif path.find("Conference_Blockage_Lat/pos7"):
locationList = conference_blockage_lat_7
elif path.find("Corridor_Blockage_Lat/pos5"):
locationList = corridor_blockage_lat_5
elif path.find("Corridor_Blockage_Lat/pos10"):
locationList = corridor_blockage_lat_10
elif path.find("Corridor_Blockage_Lat/pos12_5"):
locationList = corridor_blockage_lat_12_5
elif path.find("FrontCorridor_1_Blockage_Lat"):
locationList = front_corridor_1_lat_10
elif path.find("FrontCorridor_2_Blockage_Lat"):
locationList = front_corridor_2_lat_10
elif path.find("Lab_Blockage_Lat"):
locationList = lab_blockage_2
elif path.find("Lobby_2_Blockage_lat"):
locationList = lobby_blockage_2_3
elif path.find("Lobby_Blockage_Lat/pos1"):
locationList = lobby_blockage_1_1
elif path.find("Lobby_Blockage_Lat/pos10"):
locationList = lobby_blockage_1_10
elif path.find("X60_Interference/Back_Corridor/pos5"):
locationList = interference_back_corridor_5
elif path.find("X60_Interference/Back_Corridor/pos10"):
locationList = interference_back_corridor_10
elif path.find("X60_Interference/Back_Corridor/pos12_5"):
locationList = interference_back_corridor_12_5
elif path.find("X60_Interference/Conference/pos1"):
locationList = interference_conference_1
elif path.find("X60_Interference/Conference/pos7"):
locationList = interference_conference_7
elif path.find("X60_Interference/Front_Corridor_1/pos10"):
locationList = interference_front_corridor_1
elif path.find("X60_Interference/Front_Corridor_2/pos10"):
locationList = interference_front_corridor_2
elif path.find("X60_Interference/Lab/pos2"):
locationList = interference_lab
elif path.find("X60_Interference/Lobby_1/pos1"):
locationList = interference_lobby_1_1
elif path.find("X60_Interference/Lobby_1/pos10"):
locationList = interference_lobby_1_10
elif path.find("X60_Interference/Lobby_2/pos1"):
locationList = interference_lobby_2_3
else:
locationList = []
flag = 1
list_val = tput_val_ra
initialTOFValue = 0
initial_snr = 0
initial_tput = 0
initial_pdp = 0
initial_cir = 0
initial_phase = 0
tempPDPval = []
tempCIRval = []
for pdp_val,tput_ra, tput_ba,tput_baplusra, snr_val,cir_val,phase_val,crc_val,tof_val,currentPosition in zip(pdp_values,list_val, tput_val_ba,tput_val_ba_ra,snr_values,cir_values,phase_values,crc_values,locationList,positions):
# print "Inside"
if flag == 1:
initial_snr = snr_val
initial_pdp = pdp_val
initial_cir = cir_val
initialTOFValue = tof_val
initial_phase = phase_val
initial_crc = crc_val
flag = 0
continue
if pdp_val == [] and (plotparameter == "PDP" or plotparameter == "FFT_PDP"):
continue
##TOF Condition
if (initialTOFValue - tof_val > -0.5 or initialTOFValue - tof_val < -15) and tofCondition == True:
continue
##condition for low snr drops
if initial_snr - snr_val >= 12 and snrCondition == True:
continue
##difference between ba AND ra throughput
tput = tput_ba - tput_ra
##Phase similarity
if plotparameter == "PHASE":
plotvalue = initial_phase - phase_val
if plotparameter == "CRC":
plotvalue = initial_crc - crc_val
## similarity between two pdp vectors using pearson coeff.
if plotparameter == "PDP":
plotvalue = stats.pearsonr(initial_pdp, pdp_val)
plotvalue = plotvalue[0]
formatted_list = [ '%.6f' % elem for elem in tempPDPval ]
formatted_list = [ '%.6f' % elem for elem in pdp_val ]
## similarity between two pdp vectors using pearson coeff.
if plotparameter == "CIR":
plotvalue = stats.pearsonr(initial_cir, cir_val)
plotvalue = plotvalue[0]
if plotparameter == "PEAK":
peaksininitialpos = getPeaksFromPDP(initial_pdp)
peaksatcurrentpos = getPeaksFromPDP(pdp_val)
plotvalue = peaksininitialpos - peaksatcurrentpos
## snr drop
if plotparameter == "SNR":
plotvalue = initial_snr - snr_val
#TOF Drop
if plotparameter == "TOF":
plotvalue = initialTOFValue - tof_val
if plotparameter == "FFT_PDP":
fftinitialpos = abs(np.fft.fft(initial_pdp))
fftcurrentpos = abs(np.fft.fft(pdp_val))
plotvalue = stats.pearsonr(fftinitialpos,fftcurrentpos)
plotvalue = plotvalue[0]
if plotparameter == "FFT_CIR":
cirinitialpos = abs(np.fft.fft(initial_cir))
circurrentpos = abs(np.fft.fft(cir_val))
plotvalue = stats.pearsonr(cirinitialpos,circurrentpos)
plotvalue = plotvalue[0]
if tput >= 100:
list_ba.append(plotvalue)
elif tput <= -100:
list_ra.append(plotvalue)
elif tput_ba < 100 and tput_ra < 100 and tput_baplusra >= 100:
list_baplusra.append(plotvalue)
else:
list_ba_ra.append(plotvalue)
print "\nlen(list_ba)",len(list_ba)
print "len(list_ra)",len(list_ra)
print "len(list_ba+ra)",len(list_baplusra)
print "len(list_ba_ra)",len(list_ba_ra)
else:
flag = 1
initial_pdp = 0
initial_cir = 0
initial_snr = 0
print test_pos
for pdp_val,snr_val,cir_val,position in zip(pdp_values,snr_values,cir_values,positions):
if flag == 1:
initial_pdp = pdp_val
initial_cir = cir_val
initial_snr = snr_val
flag = 0
continue
##condition for low snr drops
if initial_snr - snr_val >= 12 and snrCondition == True:
continue
if pdp_val != []:
pdp_list.append(stats.pearsonr(initial_pdp,pdp_val)[0])
if test_pos.find("Rotation")>0:
tempStr = (test_pos.split("-")[1]+"_"+position).replace("Pos","")
locList.append(tempStr.replace("neg","-"))
else:
if position.find("9_1")>0:
locList.append(position.replace("9_1","10"))
else:
locList.append(position)
fftinitialpos = abs(np.fft.fft(initial_pdp))
fftcurrentpos = abs(np.fft.fft(pdp_val))
plotvalue = stats.pearsonr(fftinitialpos,fftcurrentpos)
ftt_pdp_list.append(plotvalue[0])
cir_list.append(stats.pearsonr(initial_cir,cir_val)[0])
cirinitialpos = abs(np.fft.fft(initial_cir))
circurrentpos = abs(np.fft.fft(cir_val))
plotvalue = stats.pearsonr(cirinitialpos,circurrentpos)
ftt_cir_list.append(plotvalue[0])
print "\nlen(pdp_list) : ",len(pdp_list)
print "len(cir_list) : ",len(cir_list)
home_path = sys.argv[1]
if locationParameter != "ALL":
directory = sorted([f for f in os.listdir(home_path) if locationParameter in f])
else:
directory = sorted([f for f in os.listdir(home_path) if "" in f])
print "Directories considered : ",directory
for dir in directory:
print "\n---------------------"
print "Dir : ",dir
print "---------------------"
if 'Rotation' in dir:
subdirectory = sorted([f for f in os.listdir(home_path + dir) if not f.startswith('.')])
for subdir in subdirectory:
beam_tput_overall = {}
best_init_beam = (-1,-1)
best_init_mcs = -1
max_tput = -1
best_beam_dict = {}
print "\n****************"
print "Subdir : ",subdir
print "****************"
subdirect = sorted([f for f in os.listdir(home_path + dir + "/" + subdir) if not f.startswith('.')])
for position in subdirect:
absolute_path = home_path + dir
best_beam = get_best_beam(home_path + dir + "/" + subdir + "/" + position)
best_beam_dict[position] = best_beam
if best_init_beam == (-1,-1):
best_init_beam_text = convert_beam_to_text(best_beam)
pos_throughput = sorted([f for f in os.listdir(home_path + dir + "/" + subdir + "/" + position) if re.search('.tput', f)])
beam_tput = {}
for tput in pos_throughput:
f = open(home_path + dir + "/" + subdir + "/" + position + "/" + tput, "rb")
sum, avg = 0, 0
list = []
while True:
bits = f.read(8)
if not bits:
break
x = struct.unpack_from('>d',bits)
if str(x[0]) != 'nan':
list.append(x)
for val in list:
sum += val[0]
avg = sum/len(list)
if best_init_beam_text in tput and best_init_beam == (-1,-1):
if avg > max_tput:
best_init_mcs = tput[-11:-10]
max_tput = avg
beam_tput[tput[:-9]] = avg
if best_init_beam == (-1,-1):
best_init_beam = best_beam
best_init_beam_text = '[' + str(best_init_beam[0]) + ']_[' + str(best_init_beam[1]) + ']_[0]'
best_init_beam_mcs = best_init_beam_text + '_[' + best_init_mcs + ']'
beam_tput_overall[position] = beam_tput
path = home_path + dir +"/" + subdir + "/"
get_list_for_cdf_plots(beam_tput_overall,best_beam_dict,max_tput,best_init_mcs,best_init_beam,path,dir+"-"+subdir)
elif dir.find("Blockage") > 0 or dir.find('Interference') >= 0:
subdirectory = sorted([f for f in os.listdir(home_path + dir) if not f.startswith('.')])
for subdir in subdirectory:
beam_tput_overall = {}
best_init_beam = (-1,-1)
best_init_mcs = -1
max_tput = -1
best_beam_dict = {}
print "\n****************"
print "Subdir : ",subdir
print "****************"
subdirect = sorted([f for f in os.listdir(home_path + dir + "/" + subdir) if not f.startswith('.')])
for position in subdirect:
absolute_path = home_path + dir
best_beam = get_best_beam(home_path + dir + "/" + subdir + "/" + position)
best_beam_dict[position] = best_beam
if best_init_beam == (-1,-1):
best_init_beam_text = convert_beam_to_text(best_beam)
pos_throughput = sorted([f for f in os.listdir(home_path + dir + "/" + subdir + "/" + position) if re.search('.tput', f)])
beam_tput = {}
for tput in pos_throughput:
f = open(home_path + dir + "/" + subdir + "/" + position + "/" + tput, "rb")
sum, avg = 0, 0
list = []
while True:
bits = f.read(8)
if not bits:
break
x = struct.unpack_from('>d',bits)
if str(x[0]) != 'nan':
list.append(x)
for val in list:
sum += val[0]
avg = sum/len(list)
if best_init_beam_text in tput and best_init_beam == (-1,-1):
if avg > max_tput:
best_init_mcs = tput[-11:-10]
max_tput = avg
beam_tput[tput[:-9]] = avg
if best_init_beam == (-1,-1):
best_init_beam = best_beam
best_init_beam_text = '[' + str(best_init_beam[0]) + ']_[' + str(best_init_beam[1]) + ']_[0]'
best_init_beam_mcs = best_init_beam_text + '_[' + best_init_mcs + ']'
beam_tput_overall[position] = beam_tput
path = home_path + dir +"/" + subdir + "/"
get_list_for_cdf_plots(beam_tput_overall,best_beam_dict,max_tput,best_init_mcs,best_init_beam,path,dir+"-"+subdir)
else:
beam_tput_overall = {}
best_init_beam = (-1,-1)
best_init_mcs = -1
max_tput = -1
best_beam_dict = {}
subdirectory = sorted([f for f in os.listdir(home_path + dir) if not f.startswith('.')])
for position in subdirectory:
best_beam = get_best_beam(home_path + dir + "/" + position)
# print best_beam
best_beam_dict[position] = best_beam
if best_init_beam == (-1,-1):
best_init_beam_text = convert_beam_to_text(best_beam)
pos_throughput = sorted([f for f in os.listdir(home_path + dir + "/" + position) if re.search('.tput', f)])
beam_tput = {}
for tput in pos_throughput:
f = open(home_path + dir + "/" + position +'/'+ tput, "rb")
sum, avg = 0, 0
list = []
while True:
bits = f.read(8)
if not bits:
break
x = struct.unpack_from('>d',bits)
if str(x[0]) != 'nan':
list.append(x)
for val in list:
sum += val[0]
avg = sum/len(list)
if best_init_beam_text in tput and best_init_beam == (-1,-1):
if avg > max_tput:
best_init_mcs = tput[-11:-10]
max_tput = avg
beam_tput[tput[:-9]] = avg
if best_init_beam == (-1,-1):
best_init_beam = best_beam
best_init_beam_text = '[' + str(best_init_beam[0]) + ']_[' + str(best_init_beam[1]) + ']_[0]'
best_init_beam_mcs = best_init_beam_text + '_[' + best_init_mcs + ']'
beam_tput_overall[position] = beam_tput
path = home_path + dir + "/"
get_list_for_cdf_plots(beam_tput_overall,best_beam_dict,max_tput,best_init_mcs,best_init_beam,path,dir)
if plotparameter != "ALL":
plotCDFUsingList()
elif plotparameter == "ALL":
plotCDFForAllParameters()
else:
##locatinoWise pdp - similarity
plotIncludingLocations(locList,pdp_list)