1 Star 0 Fork 1

xiaodangshan/PAPR-net

forked from zhoub86/PAPR-net 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.py 1.43 KB
一键复制 编辑 原始数据 按行查看 历史
XieYe9909 提交于 2020-03-22 23:31 . PAPR net
import numpy as np
import matplotlib.pyplot as plt
from ofdm import OFDMTransmitter, OFDMReceiver
from signals import papr_calc, awgn, ber_subcarrier_calc
from initialize.params import channel, h, bit_allocation, coef
params = dict()
params['BitAllocation'] = bit_allocation
params['Coef'] = coef
params['OverSampleRate'] = 4
params['CPLength'] = 100
symbol_num = 1000
bits_per_symbol = np.sum(params['BitAllocation'])
bit_send = np.random.randint(0, 2, bits_per_symbol * symbol_num)
tx = OFDMTransmitter(**params)
sig = tx.transmit(bit_send, encoder='training/encoder_30.hdf5', papr_net=True)
papr = papr_calc(sig)
plt.figure(1)
plt.plot(sig[0: 10 * 2148])
plt.show()
sig_recv = np.convolve(sig, h)[0: len(sig)]
sig_recv = awgn(sig_recv, snr=20)
rx = OFDMReceiver(**params)
bit_recv = rx.receive(sig_recv, shift=rx.CPLength, channel=channel,
decoder='training/decoder_30.hdf5', papr_net=True)
ber = np.sum(np.logical_xor(bit_send, bit_recv)) / bit_send.size
print('PAPR = %.4f\nBER = %.6f' % (papr, ber))
ber_subcarrier = ber_subcarrier_calc(bit_send, bit_recv, bit_allocation)
plt.figure(2)
plt.plot(ber_subcarrier, marker='o')
plt.show()
# rx = OFDMReceiver(**params)
# ofdm_chunks = rx.get_recv_qam(sig_recv, shift=rx.CPLength, channel=channel,
# decoder='training/decoder_30.hdf5', papr_net=True)
#
# k = 0
# plt.figure(1)
# plt.scatter(ofdm_chunks[:, k].real, ofdm_chunks[:, k].imag)
# plt.show()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chenxuanlut/PAPR-net.git
git@gitee.com:chenxuanlut/PAPR-net.git
chenxuanlut
PAPR-net
PAPR-net
master

搜索帮助

0d507c66 1850385 C8b1a773 1850385