# Time signal FFT different for whole signal than half signal on high frequencies

I have a time signal of u from 0 to 1000 time units. If I chop the signal in two halves and compare the frequency spectrum of both it looks similar, as it should (the signal should be statistically steady from where I start recording it). However if I compare it to the frequency spectrum of the full signal I get a different slope in the high-frequency region.

I do not understand this. If I use the whole signal there should be a change on the low-frequency region rather than the high-frequency one right?

This is the code I use compute the frequency spectrum. I think it's okay, but maybe I'm doing something wrong.

def time_spectra(t, u):
import numpy as np
from scipy.interpolate import interp1d
# Re-sample u on a evenly spaced time series (constant dt)
u_function = interp1d(t, u, kind='cubic')
t_min, t_max = np.min(t), np.max(t)
dt = (t_max-t_min)/len(t)
t_regular = np.arange(t_min, t_max, dt)[:-1] # Skip last one because can be problematic if > than actual t_max
u_regular = u_function(t_regular)

# Compute fft and associated frequencies
uk = np.abs(np.fft.fft(u_regular)) / len(u_regular)
freqs = np.fft.fftfreq(u_regular.size, d=dt)

# Take only positive frequencies
freqs = freqs[freqs > 0]
uk = uk[:len(freqs)]

return freqs, uk

• I think there are two effects at play: one you will have a smaller resolution bandwidth (so the power in each bin will go down by 3dB) and in addition to this spectral leakage? I do not see that you are using a window in your code. Can you repeat with a window on your signal prior to FFT (Blackman or any other high dynamic range window of your choice) - we will still see a difference if the window has a frequency roll-off but possible we reach your signals noise floor first in which case it would be just a 3 dB difference. If this happens I can provide the further details why as an answer. Sep 14, 2018 at 11:15
• Thanks for the comment. I will do the windowing, but what is it useful for in this case? Also, why is the bandwidth resolution smaller for the half signals?
– b-fg
Sep 14, 2018 at 11:18
• The bandwidth is wider for half signals. Without a window the bandwidth in Hz is 1/T where T is the time length of your signal (I have another recent answer to another question that goes into the details of this- can add the link later when not on my phone). The rectangular window (which is what you have if you did no other window) has sidelobes (spectral leakage) that roll-off in magnitude slower than any other window, so depending on the actual signal level of adjacent lower power frequencies you may be just seeing the leakage and not the signals. Sep 14, 2018 at 11:24
• I suspect the floor has a 3 dB difference due to the change in time length T and the rest due to the change in leakage but repeating with a better window will test that Sep 14, 2018 at 11:27
• @Dan, the blackman window did the trick indeed! Thank you very much. Please elaborate an answer so I can accept it :)
– b-fg
Sep 17, 2018 at 3:59

You will also see a 3 dB difference between two windows if the signal energy is distributed wider than the resolution bandwidth in each case, since the resolution bandwidth for the rectangular window is $1/T$ where T is the length of your waveform. (So when you double the length from 500 to 1000, the resolution bandwidth is half resulting in half the power in each bin (unless a spectral tone occupies one bin in which case you would not see a change).