# Fast Fourier Transform showing the same results but with different files?

so I'm pretty sure that I'm plotting the wrong frequency domain against my FFT values because I keep getting basically the same graph shape every single time. I think that I just don't comprehend the context of some of the values, as I'm quite new to signal processing. Attached below is the frequency domain I'm attempting to use, which is what I'm seeing on most websites. Is T the actual period of your data? It doesn't really matter whether or not I have user input or hardcode a value in, the same graph shape remains. Same goes with completely different data sets, always the same shape remains.

import matplotlib.pyplot as plt
from scipy.fft import fft, ifft

transform = fft(data)
per = input("What's your period: ")
T = int(per)
f = np.linspace(0, 1 / T, N)
plt.plot(f, np.abs(transform)*(1/N))


I'm not familiar with this type of code, but I can take a guess at what you want to do. Your variable names are inappropriate. I suggest you change your code to something like the following (comments are inside brackets):

spectrum = fft(data) [Assumes you've transformed a data sequence whose length is 'N' samples.]

fs = input("What's the 'data' sampling rate (in Hz): ")

delta_freq = fs/N ['delta_freq' is the frequency spacing (measured in Hz) between the spectral samples contained in the 'spectrum' sequence]

freq_axis = np.linspace(0, delta_freq, (N-1)*delta_freq)

plt.plot(freq_axis[:N//2], np.abs(spectrum)[:N//2]*(1/N)) [Plots the normalized (i.e., the 1/N scaling) spectral magnitude over the positive-frequency range]

To complete the answer given above, depending on the nature of the data you're trying to analyse, maybe you could try to plot the spectral magitude using a logarithmic scale to adjust the dynamic ?

• Nathan, that is a good suggestion. May 14 '20 at 7:25