Jump to content

Create constant signal as Max/Min of signal


Recommended Posts

I am trying to create a signal that is the maximum or minimum of a signal.  If I use agggregate, I get a single value in time, not a signal that applies to all time periods:

image.thumb.jpeg.ac2dfca7a503e45469ebf20ac2c5215a.jpeg

What I want is the equivalent of what you get with a constant, but instead of a hard coded value I want the max or min of a signal.  As you see below, the constant signal is for all time periods

image.thumb.jpeg.569d18272afab4fa66b8b12f61d02054.jpeg

I thought toScalars might help, but it doesn't work:

image.jpeg.b74954cdde1d5fbaf17f9763cf3fc54a.jpeg

Any ideas?

seeq_max_formula_2022-07-27 at 6.36.31 PM.jpg

Link to comment
Share on other sites

  • Seeq Team

Hi patjdixon,

For the aggregate function, you currently are using “startkey”, which means that the value of the aggregate is placed at the start time stamp of the capsule you are aggregating over. Instead, if you switch that to “durationkey”, it will place the value as a constant straight line across the length of the capsule.

Link to comment
Share on other sites

  • Super Seeqer

I think what you are going for will look like the formula below 

Where $SearchArea is the total range where any of your valid data capsule could fall (you can be very conservative with these dates). This formula will work if you have multiple valid data range capsules as long as they all fall within the $SearchArea

$SearchArea = capsule("2020-01-01T00:00:00Z","2022-07-28T00:00:00Z")

$Signal.within($ValidData).maxValue($SearchArea).toSignal()

image.png

  • Like 1
Link to comment
Share on other sites

Shamus, that is fantastic, we are really close!

The missing piece is the capsule.  I do not want to hard code the dates in.  I would like to use all capsules in the "Data valid" condition.  In my case there is only one capsule for "Data valid", but regardless I would like that condition to determine when to obtain the max or min.  Is there a way to do that?

image.thumb.jpeg.619d83afe69535d0fc7c358cf8ff3406.jpeg

image.jpeg

Link to comment
Share on other sites

  • Super Seeqer

It is possible to create a moving window for the SearchArea --- please read below

$SearchArea = capsule("2020-01-01T00:00:00Z",now())

However there could be some performance impacts if there are a lot of downstream calculations dependent on this value. Since this value would need to be continuously evaluated Seeq will not be able to cache the result and so this number as well as any calculations which are dependent on it will show up as dotted lines indicating that the results are subject to change. 

If this is just for a visualization or the number of datapoints is not that large it may not be a problem, however if you are seeing performance issues consider moving the SearchArea back to a fixed range

Link to comment
Share on other sites

There seems to be a misunderstanding.  I do not want to find the max for a moving window.  I want to find the max for "Data valid".  I want to specify the condition for "Data valid" and find the max for capsules with that condition.  In my case I have only 1 capsule for this condition. Whatever that max value is, I want the signal to apply for all time, like a constant.  We have accomplished creating the signal for all time, but the capsule("2020-01-01T00:00:00Z","2022-07-28T00:00:00Z") uses a fixed time period instead of the "Data valid" condition.  If there is a way to use "Data valid" instead of hard coded times, I will have what I want.

 

Link to comment
Share on other sites

  • Super Seeqer

The first response with the hard coded dates will give you the answer you are looking for as long as you do anticipate adding new capsules to the "Data Valid" condition in the future. 

The part of the formula that limits the scope of the search is the $signal.within($ValidData) section. This means that only data that falls within capsules part of the ValidData condition AND within the capsule("2020-01-01T00:00:00Z","2022-07-28T00:00:00Z")  date range

  • Like 1
Link to comment
Share on other sites

Now I see!  I was assuming maxValue($SearchArea) was hard coding the search.  Your explanation makes sense: maxValue is returning a search result, but then $signal.within($ValidData) is only passing the capsules in the condition to it.  Therefore, as long as $SearchArea fully includes the capsules in $ValidData it will work.  I just need to hard code dates well before and well after any capsules I would use.

Thanks!

  • 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...