add LUT for encodings; make varnames more explicit; update plot labels and title
This commit is contained in:
+34
-39
@@ -1,61 +1,56 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
import glob, os, re
|
import glob, os, re, sys
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
x= []
|
log_info = []
|
||||||
y= []
|
|
||||||
tmp = []
|
|
||||||
table = {}
|
table = {}
|
||||||
|
|
||||||
path = "result/"
|
enc_table = ["BPSK 1/2", "BPSK 3/4", "QPSK 1/2",
|
||||||
|
"QPSK 3/4", "16QAM 1/2", "16QAM 3/4",
|
||||||
|
"64QAM 2/3", "64QAM 3/4"]
|
||||||
|
|
||||||
|
path = sys.argv[1]
|
||||||
|
|
||||||
for filename in glob.glob(os.path.join(path, "*.log")):
|
for filename in glob.glob(os.path.join(path, "*.log")):
|
||||||
pat = re.search(r"s([-+]?\d+.\d+)", filename)
|
snr_arg = re.search(r"s([-+]?\d+.\d+)", filename) # SNR
|
||||||
pat2 = re.search(r"n(\d+)", filename)
|
nfiles_arg = re.search(r"n(\d+)", filename) # Nfiles
|
||||||
pat3 = re.search(r"e(\d+)", filename)
|
enc_arg = re.search(r"e(\d+)", filename) # Encoding
|
||||||
|
|
||||||
if pat and pat2 and pat3:
|
if snr_arg and nfiles_arg and enc_arg:
|
||||||
|
total = nfiles_arg.group(1)
|
||||||
receive = sum(1 for line in open(filename))
|
pdrate = sum(1 for line in open(filename))/float(total)
|
||||||
total = pat2.group(1)
|
encode = int(enc_arg.group(1))
|
||||||
encode = pat3.group(1)
|
|
||||||
|
|
||||||
tmp.append((float(pat.group(1)), receive/float(total), encode))
|
log_info.append((float(snr_arg.group(1)), pdrate, encode))
|
||||||
|
|
||||||
|
else:
|
||||||
|
print "Missing a log file--exiting!"
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
for a,b,c in tmp:
|
print log_info
|
||||||
if c not in table:
|
|
||||||
table[c] = []
|
for snr,pdr,enc in log_info:
|
||||||
table[c].append((a,b))
|
if enc not in table:
|
||||||
|
table[enc] = []
|
||||||
|
table[enc].append((snr,pdr))
|
||||||
|
|
||||||
print table
|
print table
|
||||||
|
|
||||||
for c in table:
|
for enc in sorted(table.keys()):
|
||||||
tmp = []
|
tmp = table[enc]
|
||||||
for a,b in table[c]:
|
|
||||||
tmp.append((a,b))
|
|
||||||
|
|
||||||
tmp = sorted(tmp, key=lambda tmp: tmp[0])
|
table[enc] = sorted(tmp, key=lambda tmp: tmp[0])
|
||||||
# print tmp
|
# print tmp
|
||||||
x = []
|
x = [snr for snr,pdr in table[enc]]
|
||||||
y = []
|
y = [pdr for snr,pdr in table[enc]]
|
||||||
for a,b in tmp:
|
|
||||||
x.append(a)
|
print enc, x, y
|
||||||
y.append(b)
|
plt.plot(x, y, marker='o', label="%s" % enc_table[enc])
|
||||||
print x
|
|
||||||
print y
|
|
||||||
plt.plot(x,y, label = "encode " + str(c))
|
|
||||||
# plt.text(x[-1], y[-1], "encode " + str(c))
|
|
||||||
#for a,b in tmp:
|
|
||||||
# x.append(a)
|
|
||||||
# y.append(b)
|
|
||||||
#print x
|
|
||||||
#print y
|
|
||||||
plt.ylabel("PDR")
|
plt.ylabel("PDR")
|
||||||
plt.xlabel("SNR")
|
plt.xlabel("SNR")
|
||||||
#plt.plot(x, y)
|
plt.title("Delivery rate vs. SNR for different encoding schemes")
|
||||||
#plt.plot(x)
|
|
||||||
plt.legend()
|
plt.legend()
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user