WarpScript is a handy toolkit build for time series manipulation. A common use case could be to detect a sequence of values lasting a given duration

This post describes how to detect in a series of values between 0 and 5, subsequences of value greater or equal to 3 lasting at least 5 seconds.
How to easily manipulate raw binary payloads in WarpScript |
First step
As a first step, we need a dataset. Here, we will generate a random GTS containing 300 values between 0 and 5 spaced by one second. Of course, you can use your own.
Read more about:
NEWGTS, STORE, FOR, NOW, RAND, ROUND, ADDVALUE, DROP
The result is a random time series:

Second step
Now, we will build a sliding window that navigates across this series in order to detect 5 seconds of values greater or equal to 3:
Learn more about:
GET, FILTERBY, SIZE, MACROMAPPER, MAP, RANGECOMPACT
Here, we have a sequence of booleans.

Now, we will remove false values:
Learn more about:
mapper.eq

Last step
Now, we have our original series and a second boolean series corresponding to subsequences starts:

Last thought
If you want to detect the end of subsequences, you have to invert pre- and post-window sizes of the mapper:
You can find the final code and a running example of this sequence of values here: WarpStudio
Read more
Working with Geo Data in Warp 10
2021 recap: new functions and tools in the Warp 10 Platform
Working with GEOSHAPEs: code contest!

Senior Software Engineer