I built a moving average from approximately 300,000 data points, and I need to find the maximum y value for the peak in the signal and its corresponding x value, which will be its frequency. I would like him to give me the coordinates on the plot, but if I get it, at least print it out, I will be satisfied. Sorry my programming skills as they are not the strongest. Here's a section of code I'm working on, and a link to the plot that it creates. I do not have enough points to publish the image.
def movingaverage(interval, window_size):
window= np.ones(int(window_size))/float(window_size)
return np.convolve(interval, window, 'same')
x = freq[0:300000]
y = fft
pylab.plot(x,y,"k.")
y_av = movingaverage(y, 30)
pylab.plot(x, y_av,"r")
pylab.xlim(0,10)
pylab.ylim(0,1500)
pylab.xlabel("Frequency")
pylab.ylabel("Moving Average Magnitude")
pylab.grid(True)
pylab.show()
Moving Average Chart
source
share