# Effect of Nyquist frequency on Fourier transformed data Upper plot is the original data's plot, and the bottom plot is Fourier transformed data. For the bottom plot, x-axis is the frequency and y-axis is the amplitude. I don't understand the weird behavior towards the right side of the Fourier transformed data - frequency is very sparsely distributed and they seem to soar up.

My peers said that this has to do with some minimum frequency, and Nyquist frequency, and that amplitudes not shown up beyond the right limit of the Fourier transformed data are squashed up into the last data point.

He said that our data is sampled every 1 minute, making Nyquest frequency -> 1/60/2 ~ 0.00833, making data points beyond 0.008 meaningless.

Can anyone explain this behavior?

++ the data is sampled every 1 minute, or 2 minutes. Sampling rate switches between 1 min or 2 min quite often

++ codes:

My original time data is in timestamps, and the sampling rate switches between 1 min and 2 min quite often.

t_delta = [(t[i + 1] - t[i]).total_seconds() for i in range(len(t) - 1)]
t_sec = np.cumsum(t_delta)
f = 1 / t_sec
>>> t_sec
[60, 180, 300, 360, 420, 540 ...]

# fourier transform
n = len(t)
inj_fft = np.fft.fft(inj) * (2 / n) # multiply by 2 to get single side spectrum
# divide by N to normalize
# backtransform
inj_orig = np.fft.fft(inj_fft) / 2
inj_orig = np.flip(inj_orig)

# plotting
fig, ax = plt.subplots(figsize=(8, 2))
ax.plot(f[1: np.int(n / 2)], abs(inj_fft[1: np.int(n / 2)])) # remove imaginary with abs()

fig,ax = plt.subplots(figsize=(8, 2))
ax.plot(t, inj)
ax.set_title('original data')

fig,ax = plt.subplots(figsize=(8, 2))
ax.plot(t, inj_orig, 'r')
ax.set_title('backtransformed')


I believe that my codes are correct, because when I backtransform the Fourier transformed data to reconstruct the original signal, they look exactly the same • This does NOT look like a Fourier transform pair. In all likelihood your code and/or plotting is wrong. How did you test/verify that your code is correct ? – Hilmar Jun 7 at 14:52
• @Hilmar could you please check the update? – Eric Kim Jun 7 at 15:13

without seeing your code, one can only guess.

your Fourier Transform doesn’t look like it is uniformly sampled in frequency. There are fewer points covering the frequencies as frequency increases, but the labels imply uniform coverage.

I’m guessing that the frequency analysis is of the constant Q type but is being plotted as a linear frequency plot. a loglog plot would probably look much better. the frequency labels are still a problem.

your colleague is correct about frequencies above nyquist being invalid but a FFT doesn’t calculate those frequencies. One can have aliasing but that depends on your acquisition system properly filtering the data prior to digitization.

the main problem appears to be your Fourier transform calculation. you may also have aliasing problems but those are more subtle.

edit update:

one needs to sample uniformly in time to use the FFT. you can use lomb-scargle for nonuniform sampled time data.

https://en.wikipedia.org/wiki/Least-squares_spectral_analysis

the fact that an inverse fft returns your data is not an indication of correctness. you need uniformly sampled time data without missing values to use the FFT.

• How could you tell that the data was not uniformly samples? You are correct about that, just curious how you came to that conclusion. Also, what does it mean by "labels imply uniform coverage"? – Eric Kim Jun 7 at 14:49
• @EricKim I was referring to the frequency points not being calculated (sample points) at uniform intervals. I've done a lot of frequency analysis. If your time series isn't uniformly sampled, that is another problem. If you are using Matlab to analyze your data, using the timeseries class simplifies that issue. Your frequency labels show a linear progression. A constant Q analysis has a logarithmic progression. Historically, constant Q analysis was and often still is the more common way to do spectral analysis. Many communities retain the constant Q, also known as proportional bandwidth. – Stanley Pawlukiewicz Jun 7 at 15:25
• The FFT is a linear frequency analysis technique. One can convert to proportional bandwidth. – Stanley Pawlukiewicz Jun 7 at 15:26