'Identifying individual peaks from find_peaks

I have successfully identified peaks in a 2D time-series signal (time vs intensity) using scipy.signal.find_peaks and have the peak properties generated by the function in a dictionary, including left and right base time values for each peak.

Now I would now like to go back to my original signal and identify the individual peaks. I feel like there is probably a simple way to do it, but I cannot seem to find it.

The data looks like:

Time (s) Intensity

0        0  
1        1        
2        3     
3        1       
4        0
5        0 
6        1 
7        5 
8        3 
9        1 
10       0

The left and right base values of the peaks on the time (x) axis look like:

left bases
1
6

right bases
3
9

The result would look like:

Time (s) Intensity   Peak  

0        0           Nan       
1        1           Peak 1        
2        3           Peak 1        
3        1           Peak 1       
4        0           Nan
5        0           Nan
6        1           Peak 2
7        5           Peak 2
8        3           Peak 2
9        1           Peak 2
10       0           Nan        

Thank you for your help!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source