Jump to content

Recommended Posts

  • Seeq Team

Use Case Background

In certain cases, it can be advantageous to delay or shift your time series data by some amount of time.  Perhaps a process variable signal lags a set point by a known amount of time, or you are working on a clever analysis where you are shifting signals in a plug flow reactor or conveyor belt style production by known periods of time so that all of the signals line up for each widget or volume of flow to enable simplified cause and effect style analysis. 

Delaying or shifting the time stamp of a signal is easily accomplished in Seeq using the Formula tool:

Using Delay()

If I simply want to delay a given signal, say signal $measuredData, by 5 seconds i can use the delay() function in formula as follows

1. Search and select the relevant signal in the Seeq Data tab so that the trend is showing in the display pane and the signal name is showing in the Details pane.

2. Click the Tools tab and select the Formula tool.

3. Give the formula an appropriate name and enter the following formula:

$measuredData.delay(5s)

A new signal (with the name given in step 3) should appear where all of the time stamps are delayed by the given amount of time, in this case 5s. Now you can continue with your analysis! To shift a signal ahead in time instead of delaying it, we use the same delay() signal but would give a negative time value to shift the signal forward by 5 seconds:

$measuredData.delay(-5s)

Using delay() Signal

The delay() function can also accept signals as the time delay input and requires some maximum delay value. We would typically only want to delay one signal, say $measuredData, by another signal, say $delaySignal, where $delaySignal is relatively consistent in its value. We typically wouldn't want the $delaySignal to jump between seconds and days. A great example of where this might be helpful would be delaying signal $measuredData by signal $delaySignal where $delaySignal is the speed of a conveyor belt and $measuredData is one of a series of measurements made on the widgets being produced on the conveyor belt. In this way we can dynamically shift all of our measurement signals by conveyor belt speed so that each widget produced has one "time stamp" associated with it for all of its measurement signals to ease further analysis. 

1. Identify the signal to delay, in my case i will use $measuredData, and a delay signal, I will use $delaySignal

2. In the tools tab, open the Formula tool

3. Give the formula an appropriate name and enter the following formula:

$measuredData.delay($delaySignal, 5h)

image.pngHere, my $measuredData will be delayed by a $delaySignal amount of time up to the maximum of a 5 hour delay. Any timestamp with a $delaySignal value of greater than 5 hours will result in my $measuredData only being delayed by 5 hours.

Using correlationOffset()

One final way we can delay or shift a signal is by using the correlationOffset() function. This function is a bit more advanced and will be covered in a follow up post. We can use this function to compute the required delay between two signals such that the two signals have a maximum correlation. This is a very useful tool for finding a delay between two signals when the amount of the delay is uncertain but the signals are known to be correlated. More information about this can be found in the Seeq Formula documentation within Seeq. Play around with it and see what you can find!

Link to comment
Share on other sites

  • Seeq Team

As stated in the previous post, correlationOffset() can be a useful tool for identifying what the optimum delay value should be in order to obtain a maximum correlation between two variables. This function is quite helpful, but in general should be applied when you as the user recognize or suspect that two signals might be correlated. While it will generate a value for any two given signals, the value may not be meaningful if the two signals are not inherently related.

Lets say we have a temperature sensor in a reactor. At some point downstream of this temperature measurement, we have a relative humidity sensor that is sensing the same volume of air, but due to the positioning of the two sensors, we are certain they are offset but measuring the same volume of air, but are unsure of the offset between the two. This would be an excellent application of correlation offset!

image.png

Here we can see the temperature leads the RH signal and the two are definitely inversely correlated, however we don't know what the delay between the two signals is.

The code used to determine the offset is:

$offset = $relativeHumidity.correlationOffset((1/$temperature),
               $correlationDetectionPeriod.toGroup(capsule('2019-06')), 
               -6h, 6h, 5min, 0.9)
$relativeHumidity.delay($offset)

The correlationOffset function takes the following arguments $signal.correlationOffset($GoalSignal, Group of Capsules to Calculate Correlation On, Min Offset, Max Offset, Grid Period, Min R^2). In the above code, we are determining the correlation offset between relative humidity and 1/temperature (because the two are inversely correlated) using the $correlationDetectionPeriod condition during the month of June, with a minimum offset of -6 hours, a maximum offset of 6 hours, re-sampling the data to a 5 minute grid, and a minimum R^2 of 0.9

Implementing the code gives us:

image.png

The new Shifted Relative Humidity signal in orange seems to track quite well with the temperature signal in green (when temperature is at a maximum, the relative humidity is at a minimum) when compared to the original relative humidity signal in purple. 

This analysis was done in Seeq version R21.042

Link to comment
Share on other sites

  • 4 months later...

Hi tatalarata,

the function correlationOffset() needs a training window used for calculating the offset. That parameter has to be a group of capsules. I think in this case the condition $correlationDetectionPeriod is custom condition that is converted to a group of capsules inside a surrounding capsule. Another example for that would be using a condition for times of production inside a specified period.

 

Link to comment
Share on other sites

  • 11 months later...
  • Seeq Team

Starting in R22.0.49, the Delay operator functionality has been rolled into the .move() function, which has long acted like the delay operator, but for capsules. Hopefully this will simplify the number of fomula operators that we need to know to work with our data in Seeq! 
If you search for delay in the formula documentation, it will bring up the move formula with updated documentation to represent the change. 

Link to comment
Share on other sites

  • 1 year later...
  • Super Seeqer

Brett, 

There is not currently a direct equivalent function that would allow you to move a capsule using a variable amount. 

However, below is a formula that does the same thing in a couple of steps. It comes with a couple of caveats however

  1. If you have capsule properties on the first calculation they will not be transferred over to the delayed signal
  2. This formula will delay the start and end of the capsule the same amount as defined by the value of your delay signal at the capsule start. You could probably extend this to do more complex transformations if needed 
$step1 = $condition.aggregate(totalDuration("min"), $condition, startKey(), 0s) 

$step2 = $step1.move($timeShiftSignal,2h)

$step2.toCapsules($sample -> capsule($sample.key(),$sample.key()+$sample.value()),30d)

image.png

Let me know if this helps get you on the right track. Also I am curious to understand more about your use case so that we can help improve the built-in functions in the future. 

Shamus

  • Like 1
Link to comment
Share on other sites

Hi Shamus,

Thanks for this, this does help with what I'm after. The use case is to align conditions upstream of a variable speed conveyor belt with events downstream. Ideally the signal to adjust by would be an integral of the conveyor speed speed (i.e. integral of conveyor belt speed until it reaches total travel distance, for example if it travelled constantly at 6m/s and conveyor distance was 6,000m the offset time would be 1,000 seconds).

The other tricky part is given the majority of the analysis is downstream of the variable speed conveyor (so uses the downstream point as the base reference of time). I'd ideally like to set the integral up to calculate 'backwards' from the downstream event (i.e. integrate values backwards from a downstream reference point until it reaches the conveyor distance of 6,000m). This would then determine the correct time offset for the capsule/window for the upstream events.

Regards,

Brett

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