[英]How to find dominant frequency from FFT?
The peak suggestion, in the comments, does not find the peak that occurs most often.峰值建议,在评论中,没有找到最常出现的峰值。 I need to find the frequency that occurs most often.
我需要找到最常出现的频率。
I need to find the dominant frequency in my Coefficient of Lift data.我需要在我的提升系数数据中找到主导频率。 The frequency I am getting with the following code is quite large and not the dominant frequency.
我使用以下代码获得的频率非常大,而不是主要频率。 I know because the 2-D analysis is easy to analyze with a graph.
我知道是因为二维分析很容易用图表分析。 It is sinusoidal.
它是正弦的。 By dominant frequency, I mean the frequency of the signal with the most repeats.
主频是指重复次数最多的信号频率。
#1/usr/bin/env python
import sys
import numpy
from numpy import sin
from math import pi
print("Hello World!")
data = numpy.loadtxt('CoefficientLiftData.dat', usecols= (0,3))
n = data.size
timestep = 0.000005
The peak data suggestion, in the comments, does not provide a count method to find how often a frequency occurs.
print(data)
fourier = numpy.fft.fft(data)
frequencies = numpy.fft.fftfreq(n, d=timestep)
positive_frequencies = frequencies[numpy.where(frequencies >= 0)]
magnitudes = abs(fourier[numpy.where(frequencies >= 0)])
peak_frequency = numpy.argmax(magnitudes)
print(peak_frequency)
Here is how to extract the dominate frequency from Coefficient of Lift data from, as an example, OpenFOAM.以下是如何从例如 OpenFOAM 的提升系数数据中提取主导频率。
#1/usr/bin/env python
import sys
import numpy as np
import scipy.fftpack as fftpack
from numpy import sin
from math import pi
import matplotlib.pyplot as plt
print("Hello World!")
N = 2500
Nev = 1000
data = np.loadtxt('CoefficientLiftData.dat', usecols= (0,3))
times = data[:,0]
length = int(len(times)/2)
forcez= data[:,1]
t = np.linspace(times[length], times[-1], 2500)
forcezint = np.interp(t, times, forcez)
fourier = fftpack.fft(forcezint[Nev-1:N-1])
frequencies = fftpack.fftfreq(forcezint[Nev-1:N-1].size, d=t[1]-t[0])
#print(frequencies)
freq = frequencies[np.argmax(np.abs(fourier))]
print(freq)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.