I’m working on a signal processing task where I need to detect peak points in a Power Spectral Density (PSD) graph within specific frequency ranges (Freqs[0] to Freqs[2]). I’m using Python and calculating the derivative to find where the slope changes from positive to negative, which I expect to correspond to peaks. However, my code doesn’t seem to reliably catch the peaks, especially within the regions where I’ve plotted red, green, and blue lines on the graph. It is okay the peak is in range of +- 0.2Hz in Freqs[0] to Freqs[2]
Here’s the PSD graph I’m working with:
PSD Graph
Here’s a simplified version of my code:
def diff_f(f, a):
return (f[a+1] - f[a]) / 0.2 # a is the index corresponding to the frequency
find_peak = []
# Example of detecting a peak around Freqs[0]
if diff_f(f1, int(round((Freqs[0] / 0.2)) - 1)) > 0 and diff_f(f1, int(round((Freqs[0] / 0.2)))) < 0:
find_peak.append(Freqs[0]) # (Freqs[0] / 0.2) 0.2 is Frequency Resolution of FFT
# Similar checks for Freqs[1], Freqs[2], and other combinations
Is there an issue with my derivative calculation method for detecting peaks?
A simple threshold value peak-detection algorithm does not work, because the noise in the first section has the same amplitude as the peak later on.
Shelling ford is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.