I have around 1000 different time series, and for each one of them I want to automatically determine if there is any seasonality in the time series.
Given the assumption that there is seasonality present, it is easy to determine periodicity from FFT or PSD.
But how do you automatically decide that there is no seasonality or periodicity in the signal based on FFT or PSD?
def psd_time_series(y): yAC = np.correlate(Y-np.mean(Y), Y-np.mean(Y), mode='full') yAC = yAC/np.max(yAC) # not necessary, but scales large values fft_yAC= np.fft.fft(yAC) freqs = np.arange(0,len(fft_yAC))/len(fft_yAC) psd = 10*np.log10(np.abs(fft_yAC)/max(np.abs(fft_yAC)) return psd,freqs def determine_if_seasonal(psd): ### part I need help with def detect_seasonality(y): psd,freqs = psd_time_series(y) seasonality = ... #### do some check of PSD to determine if seasonal if seasonality: periodicity = round(1/freqs[psd.argsort()[::-1]]) else: periodicity = None return periodicity
What would be a way of automatically determining that a single spike or Gaussian noise does not have seasonality based on the FFT or PSD of the time series? Is there any rule of thumb for the threshold of the magnitude of PSD? The prominence of peaks? Height of peaks?
For example, a PSD plot of a single spike might look like
FFT of a single spike
Or PSD of Gaussian noise might look like
FFT of Gaussian noise
Or PSD of an actual signal with periodicity might look like
FFT of the same signal
Appreciate any input or insights.