0
$\begingroup$

I want to analyze an arbitrary impulse response. Basically, a list of tap coefficient. In general, "tap1" will give me a BW limitation. I want to add more taps and see what it does to the FFT. I have two cases

  1. The "cursor" is the first item in the list. I think the amplitude graph is correct, but something doesn't look right in the simple case: Why does the phase go back to zero?
  2. I add 100 zeros before the cursor: I get the same amplitude response, but the phase response is oscillating.

I know I am missing something basic here

Python code:

import numpy as np
import pandas as pd
import plotly.express as px


def fft_on_signal(signal):
    fft = pd.DataFrame()
    n = len(signal)
    fft['fft'] = np.fft.rfft(signal)
    fft['radians'] = np.angle(fft.fft)
    fft["amp"] = fft.fft.abs()
    fft['freq'] = np.fft.rfftfreq(n=n, d=1 / n)
    return fft



data=[1,0.2]+[0]*99 ##adding tap1 for BW limitation
fig=px.line(data, height=200, width=350).update_traces(line_shape='hvh')
fig.show()

fig=px.line(fft_on_signal(data), x='freq', y='amp', height=400, width=600)
fig.show()

fig=px.line(fft_on_signal(data), x='freq', y='radians', height=400, width=600)
fig.show()

data=100*[0]+[1,0.2]+[0]*99 ##adding 100 zeros before the cursor
fig=px.line(data, height=200, width=350).update_traces(line_shape='hvh')
fig.show()

fig=px.line(fft_on_signal(data), x='freq', y='amp', height=400, width=600)
fig.show()

fig=px.line(fft_on_signal(data), x='freq', y='radians', height=400, width=600)
fig.show()
$\endgroup$
1
$\begingroup$

The "cursor" is the first item in the list. I think the amplitude graph is correct, but something doesn't look right in the simple case: Why does the phase go back to zero?

You are not showing the picture so we can't really tell. My guess is, it's phase wrapping. The phase is periodic from with $2\pi$. If you want a continuous phase graph you need to "unwrap" it. So for example: https://ccrma.stanford.edu/~jos/fp/Phase_Unwrapping.html#:~:text=Phase%20unwrapping%20ensures%20that%20all,converted%20to%20true%20time%20delay.

I add 100 zeros before the cursor: I get the same amplitude response, but the phase response is oscillating.

Of course you do. Adding 100 zeros in front of the signal is the same as delaying it by 100 samples. The Fourier Transform of a delay of $n$ samples is

$$H(\omega) = e^{-j\omega nT}$$

where T is the sample period. So you add a steep linear phase to the signal and due to the phase wrapping it turns into a sawtooth like shape.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.