-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmaorder.py
More file actions
58 lines (54 loc) · 2.82 KB
/
maorder.py
File metadata and controls
58 lines (54 loc) · 2.82 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
import numpy as np
from cumxst import cumx
from cumest import cumest
import impulse_response as ir
def pcs_cx(pcs, testing_order, winsize, r, slicing, snr, noise_type):
if snr > 100:
f = open("result/cx_testorder%s_hos%d_winsize%d_slice%d_snr%d.csv"%(testing_order, len(pcs), winsize, slicing, snr), 'w')
for i in range(r):
receive = np.load("temp/data_%d.npy"%(i))[:slicing]
temp = cumx(receive, pcs, len(pcs), testing_order, winsize)
f.write('%s\n' % temp)
print "snr=+inf, ", temp
elif noise_type=="white":
f = open("result/cx_testorder%s_hos%d_winsize%d_slice%d_white_snr%d.csv"%(testing_order, len(pcs), winsize, slicing, snr), 'w')
for i in range(r):
receive = np.load("temp/data_white_%d_%d.npy"%(snr, i))[:slicing]
temp = cumx(receive, pcs, len(pcs), testing_order, winsize)
f.write('%s\n' % temp)
print "white noise, snr=%d, "%(snr), temp
elif noise_type=="color":
f = open("result/cx_testorder%s_hos%d_winsize%d_slice%d_color_snr%d.csv"%(testing_order, len(pcs), winsize, slicing, snr), 'w')
for i in range(r):
receive = np.load("temp/data_color_%d_%d.npy"%(snr, i))[:slicing]
temp = cumx(receive, pcs, len(pcs), testing_order, winsize)
f.write('%s\n' % temp)
print "color noise, snr=%d, "%(snr), temp
else:
print "ERROR: the noise type is wrong!!"
f.close()
def hos_cm(hos_order, testing_order, winsize, r, slicing, snr, noise_type):
if snr > 100:
f = open("result/cm_testorder%s_hos%d_winsize%d_slice%d_snr%d.csv"%(testing_order, hos_order, winsize, slicing, snr), 'w')
for i in range(r):
receive = np.load("temp/data_%d.npy"%(i))[:slicing]
temp = cumest(receive, hos_order, testing_order, winsize)
f.write('%s\n' % temp)
print "snr=+inf, ", temp
elif noise_type=="white":
f = open("result/cm_testorder%s_hos%d_winsize%d_slice%d_white_snr%d.csv"%(testing_order, hos_order, winsize, slicing, snr), 'w')
for i in range(r):
receive = np.load("temp/data_white_%d_%d.npy"%(snr, i))[:slicing]
temp = cumest(receive, hos_order, testing_order, winsize)
f.write('%s\n' % temp)
print "white noise, snr=%d, "%(snr), temp
elif noise_type=="color":
f = open("result/cm_testorder%s_hos%d_winsize%d_slice%d_color_snr%d.csv"%(testing_order, hos_order, winsize, slicing, snr), 'w')
for i in range(r):
receive = np.load("temp/data_color_%d_%d.npy"%(snr, i))[:slicing]
temp = cumest(receive, hos_order, testing_order, winsize)
f.write('%s\n' % temp)
print "color noise, snr=%d, "%(snr), temp
else:
print "ERROR: the noise type is wrong!!"
f.close()