Пример #1
0
def _rrcos_pulseshaping_freq(sig, fs, T, beta):
    """
    Root-raised cosine filter in the spectral domain by multiplying the fft of the signal with the
    frequency response of the rrcos filter.

    Parameters
    ----------
    sig    : array_like
        input time distribution of the signal
    fs    : float
        sampling frequency of the signal
    T     : float
        width of the filter (typically this is the symbol period)
    beta  : float
        filter roll-off factor needs to be in range [0, 1]

    Returns
    -------
    sign_out : array_like
        filtered signal in time domain
    """
    f = scifft.fftfreq(sig.shape[0]) * fs
    nyq_fil = rrcos_freq(f, beta, T)
    nyq_fil /= nyq_fil.max()
    sig_f = scifft.fft(sig)
    sig_out = scifft.ifft(sig_f * nyq_fil)
    return sig_out
def comp_dac_resp(dpe_fb,
                  sim_len,
                  rrc_beta,
                  PAPR=9,
                  prms_dac=(16e9, 2, 'sos', 6),
                  os=2):
    """
    Compensate frequency response of a simulated digital-to-analog converter(DAC).

    Parameters
    ----------

    dpe_fb : int
        symbol rate to compensate for
    sim_len : int
        length of the oversampled signal array
    rrc_beta : float
        root-raised cosine roll-off factor of the simulated signal
    PAPR: int (optional)
        peak to average power ratio of the signal
    prms_dac: tuple(float, int, str, int)
        DAC filer parameters for calculating the filter response using scipy.signal
    os: int (optional)
        oversampling factor of the signal
    """
    dpe_fs = dpe_fb * os
    # Derive RRC filter frequency response np.sqrt(n_f)
    T_rrc = 1 / dpe_fb
    fre_rrc = np.fft.fftfreq(sim_len) * dpe_fs
    rrc_f = rrcos_freq(fre_rrc, rrc_beta, T_rrc)
    rrc_f /= rrc_f.max()
    n_f = rrc_f**2

    # Derive bessel filter (DAC) frequency response d_f
    cutoff, order, frmt, enob = prms_dac
    system_dig = signal.bessel(order,
                               cutoff,
                               'low',
                               analog=False,
                               output=frmt,
                               norm='mag',
                               fs=dpe_fs)
    # w_bes=np.linspace(0,fs-fs/worN,worN)
    w_bes, d_f = signal.sosfreqz(system_dig,
                                 worN=sim_len,
                                 whole=True,
                                 fs=dpe_fs)

    # Calculate dpe filter p_f
    df = dpe_fs / sim_len
    alpha = 10**(PAPR / 10) / (6 * dpe_fb * 2**(2 * enob)) * np.sum(
        abs(d_f)**2 * n_f * df)
    p_f = n_f * np.conj(d_f) / (n_f * abs(d_f)**2 + alpha)
    return p_f
Пример #3
0
def comp_dac_resp(dpe_fb,
                  sim_len,
                  rrc_beta,
                  PAPR=9,
                  prms_dac=(16e9, 2, 'sos', 6)):
    """
    Compensate frequency response of simulated digital-to-analog converter(DAC).
    """
    dpe_fs = dpe_fb * 2
    # Derive RRC filter frequency response np.sqrt(n_f)
    T_rrc = 1 / dpe_fb
    fre_rrc = np.fft.fftfreq(sim_len) * dpe_fs
    rrc_f = rrcos_freq(fre_rrc, rrc_beta, T_rrc)
    rrc_f /= rrc_f.max()
    n_f = rrc_f**2

    # Derive bessel filter (DAC) frequency response d_f
    cutoff, order, frmt, enob = prms_dac
    system_dig = signal.bessel(order,
                               cutoff,
                               'low',
                               analog=False,
                               output=frmt,
                               norm='mag',
                               fs=dpe_fs)
    # w_bes=np.linspace(0,fs-fs/worN,worN)
    w_bes, d_f = signal.sosfreqz(system_dig,
                                 worN=sim_len,
                                 whole=True,
                                 fs=dpe_fs)

    # Calculate dpe filter p_f
    df = dpe_fs / sim_len
    alpha = 10**(PAPR / 10) / (6 * dpe_fb * 2**(2 * enob)) * np.sum(
        abs(d_f)**2 * n_f * df)
    p_f = n_f * np.conj(d_f) / (n_f * abs(d_f)**2 + alpha)
    return p_f