# FFT on impulse response: phase doesn't look right, Python

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["amp"] = fft.fft.abs()
fft['freq'] = np.fft.rfftfreq(n=n, d=1 / n)
return fft

data=[1,0.2]+*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.show()

data=100*+[1,0.2]+*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.show()


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.
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}$$