コード例 #1
0
ファイル: myreceiver.py プロジェクト: huazhixixi/filter_code
def receiver_nonlinear_noise(name):
    import joblib
    from library.electrical import Resampler
    import resampy
    from library import matched_filter

    signal = __reconstruct_signal(name)
    fibers = [LinearFiber(0.2, 16.7, 80, 0, 1550) for _ in range(12)]

    signal = cd_compensation(fibers, signal, signal.fs_in_fiber)
    signal.samples = resampy.resample(signal[:],
                                      signal.sps_in_fiber,
                                      2,
                                      axis=-1,
                                      filter='kaiser_fast')

    signal = matched_filter(signal, 0.02)
    signal.samples = signal[:, ::2]

    phase = np.angle(
        np.mean(signal.samples / signal.symbol, axis=-1, keepdims=True))
    signal.samples = signal.samples * np.exp(-1j * phase)

    signal.inplace_normalise()
    noise = signal.samples - signal.symbol

    noise_power = np.sum(np.mean(np.abs(noise)**2, axis=-1))

    nonlinear_snr = 10 * np.log10((2 - noise_power) / noise_power)

    return nonlinear_snr, signal, noise
コード例 #2
0
def receiver_nonlinear_noise(name, config_ith):
    import joblib
    from library.electrical import Resampler
    import resampy
    from library import matched_filter
   

    config = joblib.load('../simulate_data/config_setting')[config_ith]
    signal = __reconstruct_signal(name,config)
    fibers = fiber_for_reconstruct(config)
    
    signal = cd_compensation(fibers,signal, signal.fs_in_fiber)
    signal.samples = resampy.resample(
        signal[:], signal.sps_in_fiber, 2, axis=-1, filter='kaiser_fast')
    
    
    signal = matched_filter(signal, 0.02)
    signal.samples = signal[:, ::2]

    phase = np.angle(np.mean(signal.samples / signal.symbol, axis=-1, keepdims=True))
    signal.samples = signal.samples * np.exp(-1j*phase)
    
    signal.inplace_normalise()
    noise = signal.samples - signal.symbol

    noise_power = np.sum(np.mean(np.abs(noise) ** 2, axis=-1))
    
    nonlinear_snr = 10 * np.log10((2 - noise_power) / noise_power)



    return nonlinear_snr,signal
コード例 #3
0
def extract_spectrum(name, config_ith):
    import joblib
    from library.electrical import Resampler
    import resampy
    from library import matched_filter
    from scipy.signal import welch

    config = joblib.load('../simulate_data/config_setting')[config_ith]
    signal = QamSignal.load(name,True)
    fibers = fiber_for_reconstruct(config)
    
    signal = cd_compensation(fibers,signal, signal.fs_in_fiber)
    signal.samples = resampy.resample(
        signal[:], signal.sps_in_fiber, 2, axis=-1, filter='kaiser_fast')
    signal = matched_filter(signal, 0.02)
    [f,pxx] = welch(signal.samples[0],detrend=None,return_onesided = False,nfft = 1024,fs=signal.fs)
    signal.inplace_normalise()
    from library.receiver_dsp import LMS_PLL
    from library.receiver_dsp import syncsignal_tx2rx

    lms = LMS_PLL(0.1, 321, 3, 3, 0.0001)
    signal = lms.equalize(signal)
    tx_symbol = syncsignal_tx2rx(signal.samples, signal.symbol)[:,:signal.samples.shape[1]]

    noise = signal.samples - tx_symbol

    noise_power = np.sum(np.mean(np.abs(noise) ** 2, axis=-1))




    # pxx,lms,signal.samples,tx_symbol

    return f,pxx, lms, signal, tx_symbol
コード例 #4
0
    def prop(self, signal, span, roll_off):
        from library import cd_compensation, matched_filter, LMS
        from library.receiver_dsp import syncsignal_tx2rx
        import resampy
        signal = cd_compensation(span, signal, signal.fs_in_fiber)
        signal.samples = resampy.resample(signal.samples, signal.sps_in_fiber,
                                          signal.sps)
        signal = matched_filter(signal, roll_off)

        angle = np.angle(
            np.mean(signal[:, ::2] / signal.symbol, axis=-1, keepdims=True))
        signal.samples = signal.samples * np.exp(-1j * angle)
        signal.inplace_normalise()
        lms = LMS(321, 3, 3, 0.001)
        signal = lms.equalize(signal)
        signal.symbol = syncsignal_tx2rx(signal.samples,
                                         signal.symbol)[:, :signal.shape[1]]

        noise = signal.samples - signal.symbol
        power = np.mean(np.abs(noise)**2, axis=-1)
        power = np.sum(power)
        snr = (2 - power) / power
        snr = 10 * np.log10(snr)

        print(snr)
        self.equalizer = lms
        return signal