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?
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