Python Forum
fft calculation from csv file
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
fft calculation from csv file
#1
hello i want to calculate fft of a sinusoid that i get from a csv file, i tried the fft function, but the specter that i found is not the one that i expect, the sinusoid that i used was recuperated from other program, the idea is to find frequencies and harmonics to test my program and use it to analyse other unknown signals; here is the code
import numpy
import matplotlib.pyplot as plt
from matplotlib.pyplot import *
from scipy.fftpack import fft
x=numpy.genfromtxt(r'C:\Users\souag\Desktop\pywav\sinus.csv', delimiter=',')
time=x[:,][:,0]
sine=x[:,][:,1:5]
print (sine[0:30])
time=time-time[0]
plt.subplot(2,1,1)
plt.plot(time,sine,'r')
axis([0,2,-2,4])
grid()
T=200.0
fe=10.0
Te=1/fe
N=int(T*fe)
tfd=numpy.fft.fft(sine)
f=numpy.arange(0,N)
figure(figsize=(10,4))
vlines(f,[0],numpy.absolute(tfd),'b')
xlabel('f')
ylabel('C')
axis([0,20,0,10])
grid()
Reply
#2
Remember to "Please make sure you use python tags when inserting code into the forum. ie.
PUT CODE HERE
".

It might be easier to generate your own sinusoid rather than using an auxiliary csv file?
Reply
#3
Can you also show the data please?
Reply
#4
hello, thanks for your reply, which data you want to see?
Reply
#5
The contents of the CSV file.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020