[Python] How to shift the frequency spectrum of a signal without FFT?

Discussão em 'Python' iniciado por Stack, Maio 19, 2025.

  1. Stack

    Stack Membro Participativo

    That's my function to shift a signal (1024 IQ samples) by some freq. f0. But that doesn't work as intended...

    def shift_by(x, shift):
    f0 = shift
    t = np.arange(0, 1024, 1)
    exp = np.exp(2j*np.pi*-f0*t) # this is essentially a complex sine wave
    return x * exp


    For example, x = shift_by(x, 2000000.0) gives me (weird): this

    And for x = shift_by(x, 2000000.1): this

    What am I doing wrong?

    upd: So, as Paul suggested, the problem was in scaling.

    def shift_by(x, shift):
    Ts = 1/sample_rate
    f0 = shift
    t = np.arange(0.0, Ts*len(x), Ts)
    exp = np.exp(2j*np.pi*-f0*t) # this is essentially a complex sine wave
    return x * exp


    It gives nice picture: [​IMG]

    Continue reading...

Compartilhe esta Página