예제 #1
0
def build_and_impair_signal(set, sigdir):
    nmodes = set['nmodes']
    N = set['N']
    t_conv = N - 50000
    t_stop = N - 1000
    sig = signals.SignalQAMGrayCoded(4, N, fb=25e9, nmodes=nmodes)
    sig_Martin = sig.copy()
    trainingSyms = sig.copy()
    ovsmpl = set['ovsmpl']
    if ovsmpl > 1:
        sig = sig.resample(ovsmpl * sig.fb, beta=0.1, renormalise=True)

    if set['impulse_impaired']:
        sig = apply_impulse_response_impairment(sig)

    matrix = build_mixing_matrix(nmodes, set['mixing'], set['loss'])
    sig = apply_mltichnl_delayed_matrix_impairment(sig, set['delay'], matrix)
    if set['pmd'] > 0:
        for i_dmode in range(int(nmodes / 2)):
            sig[i_dmode * 2:i_dmode * 2 + 2] = impairments.apply_PMD(
                sig[i_dmode * 2:i_dmode * 2 + 2], np.pi / 5.6, set['pmd'])
    sig = impairments.change_snr(sig, set['snr'])
    sig = impairments.apply_phase_noise(sig, set['phase_noise'])
    plot_constellation(sig[:, t_conv:t_stop], "Recieved", True, sigdir)
    return sig, sig_Martin, trainingSyms
예제 #2
0
def try_mimo_setting(df, sig, set, mset, trainingSyms, mimodir):
    N = set['N']
    nmodes = set['nmodes']
    n_training_syms = mset['n_training_syms']
    lb = mset['lb']
    mu = mset['mu']
    nloops = mset['nloops']
    ovsmpl = set['ovsmpl']
    t_conv = N - 50000
    t_stop = N - 1000

    if mset['errorcalc'] == 'lms':
        print('LMS Enabled')
        unit = np.sqrt(2) * 0.5
        constellation = [
            unit + 1j * unit, unit - 1j * unit, -unit + 1j * unit,
            -unit - 1j * unit
        ]
        errorcalc = TrainedLMS(trainingSyms[:, :n_training_syms],
                               constellation, lb)
        sig_with_loops = errorcalc.AddTrainingLoops(sig, ovsmpl, nloops)
        sig_Martin = sig_with_loops.copy()[:, :N + n_training_syms * nloops]
        mimo = FrequencyDomainBlockwizeMimo(nmodes, lb, ovsmpl, mu, errorcalc)
        sig_Martin[:, :], taps_Martin = mimo.equalize_signal(sig_with_loops)

    else:
        errorcalc = CMAErrorCalculator()
        sig_Martin = sig_with_loops.copy()[:, :N]
        mimo = FrequencyDomainBlockwizeMimo(nmodes, lb, ovsmpl, mu, errorcalc)
        sig_Martin[:, :], taps_Martin = mimo.equalize_signal(sig)
    print(sig_Martin.shape)
    #sig_Martin ,ph = phaserec.viterbiviterbi(sig_Martin, 11)
    err_Martin = []
    for i_mode in range(nmodes):
        err_Martin_ = calculate_radius_directed_error(
            sig_Martin[i_mode, 0:t_stop], 1)
        err_Martin.append(mlab.movavg(abs(err_Martin_), movavg_taps))
    try:
        ber_martin = calculate_BER(sig_Martin, range(t_conv, t_stop))
    except:
        ber_martin = np.ones(nmodes)

    title = "Martin_mu {mu}_lb{lb}"
    plot_constellation(sig_Martin[:, t_conv:t_stop], title, True, mimodir)
    plot_error(err_Martin, title, True, mimodir)
    plot_taps(taps_Martin, True, mimodir)
    final_error_Martin = calculate_final_error(err_Martin, t_conv, t_stop)
    t_conv_martin = calculate_convergence(err_Martin, final_error_Martin)
    df_martin = UpdateDataFrame(set, mset, ber_martin, t_conv_martin,
                                final_error_Martin, "Martin")
    return df.append(df_martin)
예제 #3
0
        else:
            errorcalc = CMAErrorCalculator()
        mimo = FrequencyDomainBlockwizeMimo(set['nmodes'], mset['lb'], ovsmpl,
                                            mset['mu'], errorcalc)

        sig_Martin[:, :], taps_Martin = mimo.equalize_signal(sig)
        sig_Martin, ph = phaserec.viterbiviterbi(sig_Martin, 11)
        err_Martin = []
        for i_mode in range(set['nmodes']):
            err_Martin_ = calculate_radius_directed_error(
                sig_Martin[i_mode, 0:t_stop], 1)
            err_Martin.append(mlab.movavg(abs(err_Martin_), movavg_taps))
        try:
            ber_martin = calculate_BER(sig_Martin, range(t_conv, t_stop))
        except:
            ber_martin = np.ones(nmodes)

        title = "Martin_mu" + str(mset['mu']) + "_lb" + str(mset['lb'])
        plot_constellation(sig_Martin[:, t_conv:t_stop], title, True, mimodir)
        plot_error(err_Martin, title, True, mimodir)
        plot_taps(taps_Martin[:, :, 0, :], True, mimodir)
        final_error_Martin = calculate_final_error(err_Martin, t_conv, t_stop)
        t_conv_martin = calculate_convergence(err_Martin, final_error_Martin)
        df_martin = UpdateDataFrame(set, mset, ber_martin, t_conv_martin,
                                    final_error_Martin, "Martin")
        df = df.append(df_martin)

#df = df.sort_values(['mode','pmd','snr','ber'],ascending=[0,0,1,1])
print(df)
df.to_csv(testDir + "\Results.csv", sep=',')
예제 #4
0
            if apply_impulse:
                sig = apply_impulse_response_impairment(sig)
            if apply_matrix:
                if delay_after_matrix:
                    sig[:, :] = apply_2chnl_delayed_matrix_impairment(
                        sig, 1e-9, 25e9)
                else:
                    sig[:, :] = apply_2chnl_delayed_after_mix_matrix_impairment(
                        sig, 1e-9, 25e9)

            sig = impairments.apply_PMD(sig, np.pi / 5.6, pmd)
            sig = impairments.change_snr(sig, snr)
            sig = impairments.apply_phase_noise(sig, phase_noise)

            plot_constellation(sig[:, t_conv:t_stop], "Recieved", True, sigdir)

            filename = sigdir + "/_rep" + str(r) + ".txt"
            file = open(filename, 'wb')
            pickle.dump(sig, file)
            for mu_q in list_mu_q:
                for ntaps in list_ntaps:
                    mimodir = create_dir_for_mimo_result(
                        sigdir, mu_q, ntaps, "Qampy")
                    taps_qampy, err = equalisation.equalise_signal(
                        sig, mu_q, Ntaps=ntaps, method="cma")
                    sig_qampy = equalisation.apply_filter(sig, taps_qampy)
                    sig_qampy, ph = phaserec.viterbiviterbi(sig_qampy, 11)

                    err_qampy = []
                    for i_mode in range(2):