Transforming Data

Within the Waves application in TekDrive, you can use Real-Time Expressions to transform your data. This allows you to make changes and calculations on your data without having to export your data to another application.

 

Syntax

Expressions are prefixed with the "=" character.

 

Signal Identifiers

Input signals are enclosed in [ ].

example: =[temp_f]*2


Number Literal

Numbers can be specified as integers (0 1234), hexadecimal integers (0xF 0x123F), binary integers (0b1 0b1011), decimals (0.21 123.456), and scientific notation (0e6 10e+5 0.1e-8).

 

String Literal

Strings are enclosed " ".

example: =[message1] == "hello"

 

Escape Sequence

Special characters can be escaped using \ .

example: =[signal\[0\]]*2
Unicode escape sequences: \u00 \x0000 \{#00000}

 

Multiple Inputs, Operators, and Methods in one Expression

Any number of input data streams, operators, and functions can be combined into a single expression. Data streams, operators, and functions can be repeated as many times as desired in a single expression. 

example (computes dew point °F from temperature °F and relative humidity by converting to Celsius then back to Fahrenheit): 
=convert(convert([Temperature (F)],"F","C")-((100-[Relative Humidity])/5),"C","F")

 

Long Expressions - Multi-Line Editing

Whitespace characters (newlines, tabs, spaces) are ignored in all expressions. Newlines will automatically increase the height of the edit field.

 

Constant Assignment

You can assign an expression to a constant (e.g. =1, ="hello"). This is particularly useful when you want to set a default value for an expression to display in a tile in case the evaluated expression returns an empty set (e.g. =([temp_f] < -60) | "No Values Under -60 Found!" ).  

 

Operators 

Operator Description Example
+ Add two numbers =[temp_f]+2
- Subtract two numbers =[temp_f]-3
* Multiply two numbers =[temp_f]*4
/ Divide two numbers =[temp_f]/5
- Negative of a number =-[temp_f]
^ Exponential =[temp_f]^2
% Modulo =[temp_f]%2
& Concatenate two strings (more info) =[message1] & [message2]
| Union of two signals (more info) =[signal1] | [signal2] 
== Equality (Exact Match) Operator (more info) =[message1] == "hello"
!= Inequality Operator (more info) =[message1] != "error"
~ Partial Match Operator (more info) =[message1] ~ "err"
!~ No Partial Match Operator (more info) =[message1] !~ "err"
< Less Than Operator (more info) =[temp_f] < 90
<= Less Than or Equal Operator (more info) =[temp_f] <= 70
> Greater Than Operator (more info) =[temp_f] > 0
>= Greater Than Or Equal Operator (more info) =[temp_f] >= 1
() Group  =([temp_f]+2)/3
. Member Operator =math.max([temp_f], 32)
: Map Operator (more info) =([temp_f]>80):"hot"
$ Use Selected Signal in Waves (more info) =$+2

 

Global Methods 

Method Description Example
convert Numerical Unit Conversion (more info) =convert([temp_f], "f", "c")
smooth Line Graph Curve Smoothing (more info) =smooth([temp_f])
math.round Numerical Rounding (more info) =math.round([temp_f], 2)
math.sum Cumulative sum (more info) =math.sum([data_stream])
math.mean Cumulative average (more info) =math.mean([data_stream])
math.variance Cumulative variance (more info) =math.variance([data_stream])
math.stdDev Cumulative standard deviation (more info) =math.stdDev([data_stream])
math.min Take the lesser of two numbers =math.min([temp_f], 100)
math.max Take the greater of two numbers =math.max([temp_f], 32)
math.sqrt Square root of a number =math.sqrt([data_stream])
math.sin Sine of a number =math.sin([data_stream])
math.cos Cosine of a number =math.cos([data_stream])
math.tan Tangent of a number =math.tan([data_stream])
math.PI π (constant) =math.PI
math.delta Change in value (more info) =math.delta([data_stream])
math.timeDelta Change in time (more info) =math.timeDelta([data_stream], "sec")
math.timeDerivative Time derivative (more info) =math.timeDerivative([data_stream], "sec")
i2c.addr i2c address decode =i2c.addr([i2c_scl],[i2c_sda])
i2c.data i2c data decode =i2c.data([i2c_scl],[i2c_sda])
i2c.rw i2c read/write decode =i2c.rw([i2c_scl],[i2c_sda])

 

Rounding Decimals

Round the number of decimal places in a data stream to something more readable.\

Syntax: =math.round([data stream], numberDecimalPlaces)

Example: =math.round([voltage], 1)

 

Unit Conversion

Apply a unit conversion to each value in a selected data stream. You can find the complete list of supported units here

Syntax: =convert([data stream], "fromUnit", "toUnit")

Example: =convert([temp_f], "f", "c")

 

Filter Out Unwanted Data

Filter out unwanted data by removing specific data points and/or ranges of data values. The filter operation utilizes the real-time expression comparison operators (!==, ==, <, <=, >, >=). Comparison operations can be chained together to apply multiple filters.

Single Filter

Syntax: =[data stream] <operator> <value>

Example: =[pitch] < 3 

Multiple Filters

Syntax: =[data stream] <operator1> <value1> <operator2> <value2> <operator3><value3>  

Example: =[pitch] < 3 != 2.64

 

Search Inside a Data Stream

Search for and mark specific values or ranges inside a data stream in Waves.

Single Condition

Sytax: =[data stream] <operator> <value>

Example: =[voltage] > 10

Multiple Conditions

Syntax: =[data stream] <operator1> <value1> <operator2> <value2> <operator3><value3> 

 

Smooth Out a Noisy Signal

Apply a smoothing filter on a numerical data stream viewed as a line graph.

Default Smoothing (assumed of a smooth factor of 0.7)

Syntax: =smooth([data stream])

Example: =smooth([gyro_x]) 

Specific Smooth Factor

Syntax: =smooth([data stream], smoothFactor)

Example: =smooth([gyro_x], 0.9)

 

Mathematically Combine Multiple Data Streams

Real-time expressions allow any number of signal combinations to be inputted into a given mathematical transformation. 

Syntax: =[signal1]+[signal2]

Example: =[temperature]-((100-[humidity])/5)

 

Merge Multiple Data Streams Into One

Merge the data points of multiple data streams into a single data stream. This operation is like interleaving the individual data points from each data stream together. This operation uses the timestamp of each data point to create a single, merged data stream. If there are two or more data points with the same timestamp, the leftmost specified data stream will take precedence. 

Merge Two Signals Into One

Syntax: =[signal1] | [signal2] 

Example: =[status] | [Switch]

Merge Multiple Signals Into One

Syntax: =[signal1] | [signal2] | [signal3] | ... 

 

Cumulative Sum

math.sum performs a cumulative sum of numerical values in a data stream.

Syntax: =math.sum([data stream])

 

Mean

math.mean performs a cumulative average of numerical values in a data stream.

Syntax: =math.mean([data stream])

 

Delta

math.delta calculates the change in value between adjacent numerical values in a data stream.

Syntax: =math.delta([data stream])

 

Time Delta

math.timeDelta calculates the change in time between adjacent data points in a data stream. The "unit" can be "ns", "us", "ms", "sec", "min", "hr", "day".

Syntax:=math.timeDelta([data stream], "unit")

 

Derivative

math.timeDerivative calculates the change in value between adjacent data points divided by the change in time between adjacent data points in a data stream.  The "unit" can be "ns", "us", "ms", "sec", "min", "hr", "day".

Syntax: =math.timeDerivative([data stream], "unit")

 

Variance

math.variance calculates the cumulative variance of numerical values in a data stream.

This is equivalent to =math.mean([data stream]^2) - math.mean([data stream])^2. 

Syntax: =math.variance([data stream])

 

Standard Deviation 

math.stdDev calculates the cumulative (population) standard deviation of numerical values in a data stream. This is equivalent to =math.sqrt(math.variance([data stream]).

Syntax: =math.stdDev([data stream])