# Maximum value of multiple peaks for each step of stepwise signal

Go to solution Solved by John Cox,

## Recommended Posts

Posted (edited)

Hello again ðŸ™‚

I am trying to estimate how much of a batch results in finished product.

To accomplish this my plan was to:

1. Find theÂ maximum value of two signals for each step of the stepwise signal.

2. For each step, take the biggest value and subtract from it the stepwise signal value.

3. Display the differences (lost product) along with the start and end time of the batches (stepwise signal).

Â

I started off by finding where the stepwise signal changed by using this formula:Â \$b.valueSearch(5min, isNotBetween(-1000,1000))

Then I took the inverse of these points to get capsules for each step (not shown in image).

Then I tried to get the maximum values of one of the signals for each step-capsule:

\$p1.aggregate(maxValue(), \$s.removeLongerThan(5d), maxKey()).toStep()

Unfortunately, this did not work as intended because some peaks cross from one step to another, which creates a fake max value for that step. However, this might not cause any problems as long as the real peak from the other signal which belongs to that step is greater than the fake peak.

Another issue was that the new stepwise signal created did not match the old stepwise signal.

Â

Hopefully there is a better method for doing this.

Edited by Learning_in_progress
##### Share on other sites

• Seeq Team
• Solution

Hello Learning_in_progress,

I have a few suggestions for you to try. After trying these suggestions, if you need additional help, please sign up for an upcoming Seeq Office Hours (link) where a Seeq analytics engineer can help with your remaining questions. Here are my suggestions:

1. Create a new signal which is the maximum of the blue and green signals, using this formula:

\$signal1.max(\$signal2)

2. An easier way to create capsules for each change in the step signal is to use this formula, or the "Condition with Properties" tool located under Identify in Workbench:

\$StepSignal.toCondition()

3. To get the maximum value of the 2 signals over each step capsule, use the result from suggestion #1 above as "MaxOfTwoSignals" in the formula shown below. Also, if you use durationKey() instead of maxKey() as shown below, you should get a result which matches with the original step signal.Â

\$MaxOfTwoSignals.aggregate(maxValue(), \$StepCapsules.removeLongerThan(5d), durationKey()).toStep()

##### Share on other sites

Thank you John, this helped tremendously ðŸ˜„