Jump to content

Capsule from condition / Duration between features


Go to solution Solved by Chris Orr,

Recommended Posts

How do I make a capsule from a condition?

I am very new to Seeq, and it is very much possible that I am doing this in a more complicated way than necessary, so I will try to explain the goal and problem I have.

I have a signal which I have filtered to only show me the interesting regions. In these regions, the signal has a start value of about 38 and slowly decreases until around 34 around which there is a small bump and then the signal decreases again until it reaches a another bump between 25 and 23. There is some variations for the different regions.

1a.png.e2f4a08e0a9111dd057fbdbd8a544665.png

My goal is to find the time between the lowest point of the first bump and the first occurrence after where the signal has a value of 25.2. Depending on the second bump, there might be several such points after the first bump, or only one.

What I have done:

I took the derivative of the signal and smoothed it using the agileFilter to be able pick out the first bump (This also gave me the second bump, but I don't care about that).

1b.png.20b0038b05263f0ee315b11a1edf3140.png

Then I did a valueSearch to get capsules for when the smooth derivative is greater than 0.001 for at least 1 minute, which gave me a capsule for each peak. Then I only focused on the first bump/peak by using intersect to get capsules for when the filtered signal (blue) is greater than 30 and overlapping with the smooth derivative peaks (capsules).

Then I tried to get the minimum value of the signal that lies within the duration of the newest capsule, using the minValue function. However, this did not work, because the newest capsule is actually a condition.

Does anyone know how can I make the condition into a capsule, or get around this issue?
Any help would be greatly appreciated 🙂

PS. I am trying to do this using the Formula tool.

 

 

Link to comment
Share on other sites

  • Seeq Team
  • Solution

Hey there, 

The key here is using the `aggregate` function, with a minValue() argument. The aggregate function handles Conditions, rather than capsules. You can also output the minValue() at the minKey(), which is the timestamp when the minimum value occurs. Then, transforming that value into a new Condition, of zero-length capsules as the start, will create capsules at the minimum point, which will ultimately be used as the starting point to connect to when your signal == 25.2

$searchCondition = $originalCondition.removeLongerThan(30d).grow(1hr)  //notice the .grow(1hour) to expand your capsules in case the minimum happens earlier

// Assuming $signal is your signal of interest and $originalCondition is the condition with the capsules of interest
$minValueTimes = $signal.aggregate(minValue(), $searchCondition, minKey())

// Convert the times of minimum values into a new condition with zero-length capsules
$newConditionAtMinValues = $minValueTimes.toCondition().starts()

// Output the new condition
$newConditionAtMinValues

Then create a Value Search to find when your Signal = 25.2 (no screenshot for this one 🙂 )

Finally, you can use the Composite Condition tool to "join" the two capsules:

image.png

 

And your ultimate goal was calculating the duration between those periods, so you can use the "Signal from Condition" tool to calculate it's Duration like this:

image.png

 

Performing it all in one, giant Formula, would look like this:

where $originalCondition is your derivative > .001 condition, and $signal is your base signal. 

$searchCondition = $originalCondition.removeLongerThan(30d).grow(1hr)

// Assuming $signal is your signal of interest and $originalCondition is the condition with the capsules of interest
$minValueTimes = $signal.aggregate(minValue(), $searchCondition, minKey())

// Convert the times of minimum values into a new condition with zero-length capsules
$newConditionAtMinValues = $minValueTimes.toCondition().starts()

// Perform your value search
$valueSearch = $signal < 36.2

// Join the two conditions
$JoinedCondition = $newConditionAtMinValues.join($valueSearch.beforeStart(0ns), 40hr, true)

// Calculate the duration of the joined Condition
$JoinedCondition.aggregate(totalDuration('hours'), $JoinedCondition, durationKey())

 

Hope that helps!!

-Chris Orr

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...