[Python] Power Spectral Density of Sinusoid in Python using Scipy

Discussão em 'Python' iniciado por Stack, Junho 12, 2025.

  1. Stack

    Stack Membro Participativo

    I have the following code to generate a sinusoidal signal with some noise floor:

    Kmax = 1000000
    fref = 125e6
    fin = fref/5
    t = 10*np.linspace(0,Kmax,Kmax)/fref

    tdelay = (1+np.sin(2*np.pi*fin*t)) + np.random.uniform(0,0.2,Kmax)
    plt.plot(t,tdelay)
    plt.grid()
    plt.show()
    f, psd_td = signal.welch((tdelay - np.mean(tdelay)), fref, nperseg = len(tdelay) / 8)
    plt.semilogx(f,10*np.log10(psd_td), label = 'PSD Signal')
    plt.grid()
    plt.show()


    The time domain waveform looks as below: [​IMG]

    But the Power spectral density does not show me the signal tone: [​IMG]

    Could someone explain what am I doing wrong? And why I do not observe the signal tone.

    Continue reading...

Compartilhe esta Página