I'm using Python. Input is a .csv file with timestamp, current (AC). I'm able to plot the FFT of a signal and I see the harmonics. I'd like to find and output(or display on the plot the x and y coordinates) the magnitude of the harmonics (e.g. every magnitude out to the 50th harmonic). What would be the best method for doing so? Thank you.
Update
Here's the plot that I have: Harmonic plots
My signal is 60Hz, so I know my harmonics will be at 120, 180,...
What I'm trying to do, is to find or output the magnitude of all the harmonics (from 2nd up to the 50th). So I'd like to ask there's a good way to approach this.
Ultimately, what I'm trying to achieve is to be able to calculate the harmonic amplitude to the fundamental (percentage).
Update
I ended up using zip to map the frequency and amplitude, then printed it out. Here's my code:
import pandas as pd
import numpy as np
import plotly
import matplotlib.pyplot as plt
from scipy.fftpack import fft, ifft
from scipy import arange
import csv
import math
df=pd.read_csv (r'C:\Users\20amps.csv')
N=df.shape[0] #Number of samples
T=125000 #Frequency of Signal
k=arange(N)
Ts=N/T
freq=k/Ts
freq=freq[range(N//40)]
amp=df["AC1 A"]
rms= [i * math.sqrt(2) for i in amp]
yf=fft(rms)/N
yf=yf[range(N//40)]
zipped = zip (freq, abs(yf))
print (zipped)
w = list(zipped)
print(w)
#Writing to csv file
#with open('data.csv', 'w') as csvFile:
# writer =csv.writer(csvFile, delimiter=',')
# writer.writerow(w)
plt.plot(freq, abs(yf),'r') #plot results
plt.grid()
plt.xlabel('Frequency')
plt.ylabel(r'Amplitude')
plt.show()
Then I would just look up the frequencies and amplitude that I need.
Would be open to suggestion on better ways to do this.