Example #1
0
plt.close('all')
''' 采样参数 '''
sampling_period = 1
sampling_time = 3
''' 量化参数 '''
block_size = 25
coef = 0.8
qtype = 'gray'
order = 1
mtype = ['RSSI', 'Phase', 'cross', 'and', 'or']
''' 多组取平均 '''
gro_num = 100
mtype_num = len(mtype)
times = []
''' 采样 '''
rssi_A, rssi_B, rssi_E = sampling('RSSI', sampling_period, sampling_time, 0.9,
                                  0.4)
phase_A, phase_B, phase_E = mod(
    sampling('Phase', sampling_period, sampling_time, 0.9, 0.4), 2 * pi)
''' RSSI Only '''
begin = datetime.datetime.now()
for i in range(gro_num):
    print 'Running... Current group: RSSI Only, ', i
    bits_A_rssi, drop_list_A = quantization_thre(rssi_A, block_size, coef)
    bits_B_rssi, drop_list_B = quantization_thre(rssi_B, block_size, coef)
    bits_A_rssi = remain(bits_A_rssi, drop_list_A, drop_list_B)
    bits_B_rssi = remain(bits_B_rssi, drop_list_A, drop_list_B)
end = datetime.datetime.now()
times.append(end - begin)
''' Phase Only '''
begin = datetime.datetime.now()
for i in range(gro_num):
Example #2
0
qtype = ['natural','gray']

''' 多组取平均 '''
group_num = 100
condi_num = size(order)
qtype_num = size(qtype)
bmr = zeros((group_num,condi_num,qtype_num))
bgr = zeros((group_num,condi_num,qtype_num))

for i in range(group_num):
    for j in range(condi_num):
        for k in range(qtype_num):
            print 'Running... Current group: ',i,j,k
        	
            ''' 采样 '''
            phase_A,phase_B,phase_E = mod(sampling('Phase',sampling_period,sampling_time,0.9,0.4), 2*pi)

            ''' Phase量化 '''
            bits_A = quantization_even('Phase',phase_A,size(phase_A),qtype[k],order[j])
            bits_B = quantization_even('Phase',phase_B,size(phase_B),qtype[k],order[j])    
            
            ''' 评价性能 '''
            bmr[i,j,k] = BMR(bits_A,bits_B)
            bgr[i,j,k] = BGR(bits_A,sampling_time,sampling_period)

bmr = mean(bmr,0)
bgr = mean(bgr,0)

''' 画图 '''
plt.figure(figsize=(8,5))
plt.plot(order,bmr[:,0],'ko-',label=qtype[0])
Example #3
0
''' 采样参数 '''
sampling_period = 1
sampling_time = 20

''' 量化参数 '''
block_size = 25
coef = 0.8
qtype = 'gray'
order = 1
mtype = ['RSSI', 'Phase', 'cross', 'and', 'or']

mtype_num = len(mtype)
ust = zeros(mtype_num)

''' 采样 ''' 
rssi_A,rssi_B,rssi_E = sampling('RSSI',sampling_period,sampling_time,0.8,0.4)  
phase_A,phase_B,phase_E = mod(sampling('Phase',sampling_period,sampling_time,0.8,0.4),2*pi)
    
''' RSSI量化 '''
bits_A_rssi,drop_list_A = quantization_thre(rssi_A,block_size,coef)
bits_B_rssi,drop_list_B = quantization_thre(rssi_B,block_size,coef)
bits_A_rssi = remain(bits_A_rssi,drop_list_A,drop_list_B)

''' Phase量化 '''
bits_A_phase = quantization_even('Phase',phase_A,size(phase_A),qtype,order)

''' 合并 '''
bits_A_cross = merge(bits_A_rssi,bits_A_phase,'cross')
bits_A_and = merge(bits_A_rssi,bits_A_phase,'and')
bits_A_or = merge(bits_A_rssi,bits_A_phase,'or')
sampling_period = 1
sampling_time = 3
''' 量化参数 '''
block_size = range(5, 41, 5)
coef = 0.8
''' 多组取平均 '''
group_num = 100
block_num = size(block_size)
bmr = zeros((group_num, block_num))
bgr = zeros((group_num, block_num))

for i in range(group_num):
    for j in range(block_num):
        print 'Running... Current group: ', i, j
        ''' 采样 '''
        rssi_A, rssi_B, rssi_E = sampling('RSSI', sampling_period,
                                          sampling_time, 0.9, 0.4)
        ''' RSSI量化 '''
        bits_A, drop_list_A = quantization_thre(rssi_A, block_size[j], coef)
        bits_B, drop_list_B = quantization_thre(rssi_B, block_size[j], coef)
        bits_A = remain(bits_A, drop_list_A, drop_list_B)
        bits_B = remain(bits_B, drop_list_A, drop_list_B)
        ''' 评价性能 '''
        bmr[i, j] = BMR(bits_A, bits_B)
        bgr[i, j] = BGR(bits_A, sampling_time, sampling_period)

bmr = mean(bmr, 0)
bgr = mean(bgr, 0)
''' 画图 '''
plt.figure(figsize=(8, 5))
plt.plot(block_size, bmr, 'ko-')
plt.xlabel('Block size')