I'm following a Tensorflow tutorial and I've run into the Fast Fourier Transform:
fft = tf.signal.rfft(df['T (degC)'])
f_per_dataset = np.arange(0, len(fft))
n_samples_h = len(df['T (degC)'])
hours_per_year = 24*365.2524
years_per_dataset = n_samples_h/(hours_per_year)
f_per_year = f_per_dataset/years_per_dataset
plt.step(f_per_year, np.abs(fft))
plt.xscale('log')
plt.ylim(0, 400000)
plt.xlim([0.1, max(plt.xlim())])
plt.xticks([1, 365.2524], labels=['1/Year', '1/day'])
_ = plt.xlabel('Frequency (log scale)')
The dataset contains hourly temperature measures. The code performs an FFT on this, to see which components have a big impact, basically finding periodicity in the data. This yields the following plot:
I don't quite understand the X axis though. I do see it's a logged scale, however, I see that '1' corresponds to a year, and '365.2524' represents the daily periodicity. Does this mean that the scale is 'n-th of a year', so 1th of 1 year is a year, and a 365.2524th of a year is a day, and with the same logic 4 would be a quarter, 2 would be a half year etc.? If so, what does the leftmost value (0) mean? There is also some periodicity in the 0th of a year - what does this mean intuitively?
Another one here. There are some key differences. This time the dataset is the daily volume of Amazon shares traded (so the dataset is not hourly anymore, but rather daily). Also, the dataset only contains WEEKDAY data, that's why the number of days in a year is marked as 252 (the average number of days in a year for this dataset).
fft = tf.signal.rfft(df['Volume'])
f_per_dataset = np.arange(0, len(fft))
n_samples_d = len(df['Volume'])
days_per_year = 252
years_per_dataset = n_samples_d/(days_per_year)
f_per_year = f_per_dataset/years_per_dataset
plt.step(f_per_year, np.abs(fft))
plt.xscale('log')
plt.xticks([1, 4, 252], labels=['1/Year', '1/quarter(???)', '1/day'])
_ = plt.xlabel('Frequency (log scale)')
Here the periodicity is not as pronounced, however, I did find a peak at "4". Given that I changed the code and the data periodicity is now daily, and not hourly, does this still hold up? Does the peak at 4 mean there's a quarterly periodicity?
And lastly, again, what does it mean that there's a big 'spike' around zero? The dataset has 12 years of data, does this main the main periodicity is "every 12 years"?
Thank you!

