コード例 #1
0
ファイル: PAPR.py プロジェクト: oneway1988/myRepo
def papr_Calc(datain):
    power = datain.real**2 + datain.imag**2
    ##papr = 10 * math.log((np.max(power) / np.mean(power)),10)
    power = np.sort(power)
    papr = 10 * math.log(
        (power[int(len(power) * 0.9999)] / np.mean(power)), 10)  ##0.00001 PAPR
    return papr


bbIQ0, sr0 = bb.baseband_Gen("64QAM", 20, 1)
bbIQ1, sr1 = bb.baseband_Gen("64QAM", 20, 1)

bbIQ_20M_0, sr0 = fb.firbranch_DL(bbIQ0, sr0)
bbIQ_20M_1, sr1 = fb.firbranch_DL(bbIQ1, sr1)

bbIQ_2x20M_20, sr3 = duc.duc([bbIQ_20M_0, bbIQ_20M_1], [-20000000, 20000000],
                             sr0)

plt.figure(0)
bb.PSD_Disp(bbIQ_2x20M_20, sr3)

papr_40 = papr_Calc(bbIQ_2x20M_20)
papr_20_0 = papr_Calc(bbIQ_20M_0)
papr_20_1 = papr_Calc(bbIQ_20M_1)

power = bbIQ_2x20M_20.real**2 + bbIQ_2x20M_20.imag**2
thrsh = np.mean(power) * math.pow(10, 0.75)
plt.figure(1)
plt.plot(power)
plt.axhline(thrsh, color='r')
コード例 #2
0
#    plt.show()
#        
    
bbIQ0,sr0 = bb.baseband_Gen("64QAM",10,1)
bbIQ1,sr1 = bb.baseband_Gen("64QAM",20,1)

bbIQ_122_10M,sr0 = fb.firbranch_DL(bbIQ0,sr0)
bbIQ_122_20M,sr1 = fb.firbranch_DL(bbIQ1,sr1)
bbIQ_245_20M,sr2 = fb.upsampling_2x(bbIQ_122_20M,sr1)

bbIQ_122_2x10M_5,sr3 = duc.duc([bbIQ_122_10M,bbIQ_122_10M],[-5000000,5000000],sr0)
bbIQ_122_2x10M_25,sr4 = duc.duc([bbIQ_122_10M,bbIQ_122_10M],[-25000000,25000000],sr0)
bbIQ_122_2x20M_20,sr5 = duc.duc([bbIQ_122_20M,bbIQ_122_20M],[-20000000,20000000],sr0)

plt.figure(0)
bb.PSD_Disp(bbIQ_122_10M,sr0)
bb.PSD_Disp(bbIQ_122_20M,sr1)
bb.PSD_Disp(bbIQ_122_2x10M_5,sr3)
bb.PSD_Disp(bbIQ_122_2x10M_25,sr4)
bb.PSD_Disp(bbIQ_122_2x20M_20,sr5)

skewR_122_10M = calc_SkewR(bbIQ_122_10M)
skewR_122_20M = calc_SkewR(bbIQ_122_20M)
skewR_245_20M = calc_SkewR(bbIQ_245_20M)
skewR_122_2x10M_5 = calc_SkewR(bbIQ_122_2x10M_5)
skewR_122_2x10M_25 = calc_SkewR(bbIQ_122_2x10M_25)
skewR_122_2x20M_20 = calc_SkewR(bbIQ_122_2x20M_20)

disp_SkewRCDF([skewR_122_10M,skewR_122_20M,skewR_122_2x10M_5,skewR_122_2x10M_25,skewR_122_2x20M_20])

コード例 #3
0
    data_interp = np.zeros([len(datain) * 2], dtype=complex)
    data_interp[0::2] = datain
    dataout = signal.convolve(hbcoef, data_interp)
    dataout = dataout[len(hbcoef) - 1:]
    return dataout, sr * 2


#%%
'''
Downlink filter branch
Input: data IQ
Output: 122.88Msps data IQ    
'''


def firbranch_DL(datain, sr):
    bbIQ = channelfir(datain)
    while int(122880000 / sr) != 1:
        bbIQ, sr = upsampling_2x(bbIQ, sr)
    return bbIQ, int(sr)


#%%
if __name__ == '__main__':
    (bbIQ, sr) = baseband.baseband_Gen("16QAM", 10, 1)
    #    bbIQf = channelfir(bbIQ)
    #    bbIQ2x,sr = upsampling_2x(bbIQf,sr)
    #    bbIQ122,sr = upsampling_2x(bbIQ2x,sr)
    bbIQ122, sr = firbranch_DL(bbIQ, sr)
    baseband.PSD_Disp(bbIQ122, sr)
コード例 #4
0
Output: (duc IQ out, sample rate)
Note: NCO unit is Hz
'''


def duc(bbIQ_list, NCO_list, fs):
    dataout = np.zeros([len(bbIQ_list[0])], dtype=complex)
    #    idx = 0
    for idx in range(len(bbIQ_list)):
        #        frq_shift = np.zeros([len(bbIQ)],dtype=complex)
        frq_shift = np.exp(1j * 2 * cmath.pi * (NCO_list[idx] / fs) *
                           np.arange(len(bbIQ_list[idx])))
        #        for k in range(0,len(bbIQ)):
        #            frq_shift[k] = cmath.exp(1j*2*cmath.pi*(NCO_list[idx]/fs)*k)
        dataout = dataout + bbIQ_list[idx] * frq_shift
#        idx = idx + 1
    return dataout, fs


#%%

if __name__ == '__main__':
    bbIQ, sr = bb.baseband_Gen("64QAM", 20, 1)
    bbIQf = fb.channelfir(bbIQ)
    bbIQ2x, sr = fb.upsampling_2x(bbIQf, sr)
    bbIQ4x, sr = fb.upsampling_2x(bbIQ2x, sr)

    bbduc, sr = duc([bbIQ4x, bbIQ4x, bbIQ4x], [-20000000, 0, 20000000], sr)

    bb.PSD_Disp(bbduc, sr)
コード例 #5
0
ファイル: test.py プロジェクト: oneway1988/myRepo
# -*- coding: utf-8 -*-
"""
Created on Fri Aug 31 16:49:41 2018

@author: exabefa
"""
import math
import duc
import baseband as bb
import filterbranch as fb
import numpy as np
import matplotlib.pyplot as plt

bbIQ0,sr0 = bb.baseband_Gen("64QAM",20,1)
plt.figure(0)
bb.PSD_Disp(bbIQ0,sr0)
power = bbIQ0.real **2 + bbIQ0.imag **2
power = np.sort(power)
b = len(power)
a = int(len(power)*0.9999)
r = power[a]
papr = 10 * math.log((r / np.mean(power)),10)
papr1 = 10 * math.log((power[int(len(power)*0.9999)] / np.mean(power)),10)