I have a Python snippet of code I found. I used it to create useful Python code to extract the dominate frequency. I know the code works because I have used it with the default N and Nev values on some runs and received the same Strouhal number (St) as the sinusoidal method.
I am evaluating the frequency of a vortex street, so I don't have DC frequency, but I am getting "0.0". I tested the values of N and Nev when the code was working. I noticed the final result of the dominate frequency is very dependent on N.
I have looked at suggested posts, but they fall short. Here is the code. How do I adjust sample for linspace as my lift data increases?
#1/usr/bin/env python
import sys
import numpy as np
import scipy.fftpack as fftpack
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], N)
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)