Search the Community
Showing results for tags 'delay()'.
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) Here, 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!
This method demonstrates how to apply time warping to a signal which can shorten the time between sample points while retaining the signal’s characteristic shape. This is useful for batch processes where batches may have different durations or for aligning data from multi-step processes with different durations. Note that this method is distinct from the more complex Dynamic Time Warping. The following example is based upon the Area A Compressor Power signal available in the Example Data. A single condition was created to capture each compressor run, as shown in the following image. Step 1: Specify a Time Normalization Factor The user uses the Formula tool to specifiy a time duration (scalar value), set to 4 hours for this example. The compressor power signal for each compressor run will be normalized to this time duration. There is no single correct value; the value needs to be shorter than the minimum time duration for all signals to be normalized. // User specified time duration (scalar value). 4 hours Step 2: Create the Normalized Condition Use Formula to create the normalized Compressor Run condition based on the user-specified time normalization factor. This condition will be used later when the calculated signal delay is used for normalization. $CompressorRuns.afterStart($nF) Step 3: Calculate the Run Duration Use the Signal from Condition tool to calculate the duration for each compressor run. This value will be used later for determining the calculated signal delay applied to each compressor run. Step 4: Calculate the Elapsed Time During Each Run Use the Formula tool to calculate the elapsed time during each compressor run. This value will be used later for determining the calculated signal delay applied to each compressor run. timeSince($CompressorRuns, 0.25min).convertUnits('h') Step 5: Calculate the Signal Delay Factor Needed for Time Warping Each sample (timestamp) for compressor power will be shifted to the left by a calculated amount to time warp the power signal from its original time period (Compressor Runs) to the normalized time period (Compressor Runs Normalized). The first sample point in each run will have no delay, and the last sample point will have the greatest delay. For example, if the original time period is 10 hours and we are normalizing to a time period of 4 hours, then the last sample point in the run will be shifted to the left by 6 hours (Delay Factor = -6 hrs). // This Formula first creates a signal with a value of 0 (default delay), then splice in the calculated delay during each compressor run. 0.toSignal(0.25min).convertUnits('hr').splice($ElapsedTime*($nF/$RunDuration-1),$CompressorRuns) At this point we zoom in to a single compressor run and use the Capsule Time view to better visualize the results of our intermediate calculations. For this compressor run lasting 10.9 hours, the Compressor Run Elapsed Time finishes at the correct value (10.9 hours) and the Delay Factor correctly decreases from 0 hours (beginning of run) to -6.9 hours (end of run). Step 6: Apply the Signal Delay to Time Warp the Signal Now that the appropriate delay factor is calculated for each sample point during the compressor runs, we apply it to the Area A Compressor Power signal using the delay() function in Formula. This generates the time warped signal called Compressor Power Normalized. $CompressorPower.delay($delayFactor,24h).within($CompressorRunsN) When applying the signal delay, we are required to specify a maximum delay. This is important for the Seeq calculations going on in the background, so that the queries know how far back and forward to go when requesting input data. The maximum delay also provides a convenient way for the user to limit the applied delay, if they have some reason to do so. In our case, we just want the chosen value to be longer than the longest expected compressor run duration. Results Now that the compressor power signal has been normalized, Capsule Time view gives a nice comparison of the power signal behavior across the 3 runs contained in the Display Range: