Python Pandas: How to determine a 'cycle' as well as its peaks

380 views Asked by At

Using the following snippet from my data below:

Data = [95,95,95,95,95,95,95,95,94,94,94,94,94,94,94,94,229,444,457,387,280,188,236,181,183,183,185,186,189,190,190,190,179,165,151,151,161,214,213,213,214,213,212,195,179,160,158,155,114,98,164,346,229,39,134,149,194,1,153,171,187,185,104,102,100,90,90,92,92,92,93,93,93,93,93,93,94,94,94,94,94,11,1,11,11,70,182,104,58,60,134,115,99,97,99,98,98,97,97,97,97,97,97,97,97,97,96,96,96,96,96,96,96,96,96,96,96,96,95,95,95,95,95,95,95,95,95,95,95,95,95,95,95,95,95,95,95,95,94,94,94,94,94,94,94,94,94,94,94,94,94,94,94,93,93,152,206,221,286,326,341,360,377,391,392,393,393,393,394,406,418,420,422,422,408,389,345,329,276,224,166,113,-6,91,91,91,442,324,387,389,387,443,393,393,393,393,391,381,379,377,303,174,131,0,115,112,112,111,111,109,107,106,104,104,103,102,101,101,101,101,100,100,1,1,12,13,65,138,87]
df2 = pd.DataFrame(Data)

It forms the following graph:

Pressure Peaks

This data sample consists of 2 cycles from a machine I am receiving it from. You can see the machine starts, than rises to its peak pressure of 457 than to its second peak of 346. This is considered 1 'cycle'. It than is idle until its next 'cycle' where you can see it rises to 422 and 443. Each 'cycle' has 2 peak values in it. My actual data has hundreds of these cycles.

I have been trying to find a way to write a code that will be able to locate these cycles as well as the two maximum peak values associated with it.

So for example I would like the output to be something like: Cycle 1: 457,346 Cycle 2: 422, 443

However when I have tried this I am getting problems identifying the peak values as well as the cycle start/stops. The biggest problem is the duration of the cycle varies and the peak values also greatly vary. I have played around with gaussian mix models but have been unsuccesfull.

I am also relativley new to python so any simplified help would be greatly appreciated :.

0

There are 0 answers