Hi
I want to create a task that collects data from a bucket, do some maths and put it in another bucket.
The problem is that I need to perform a sin() function
Apparently import "math"
does not seem to work inside task
This is what i have
// Task options
option task = {name: "displacement_results", every: 10s, offset: 0m}
import "math"
// Data source
from(bucket: "telegraf")
|> range(start: -task.every)
|> filter(fn: (r) => r["_measurement"] == "I1")
|> filter(fn: (r) => int(v: r.n) > 0)
|> filter(fn: (r) => r["_field"] == "aX")
// Data processing
|> map(fn: (r) => ({r with n: r.n, level: -0.5 + 0.5 * float(v: r["n"])}))
// new column with displacement calculated from angle
|> map(fn: (r) => ({r with _value: r._value, dX: 0.5 * math.sin(x: r._value / 180.0 * 3.1415926)}))
|> map(fn: (r) => ({r with dX: r.dX, cummulative_dX: r.dX}))
|> to(bucket: "results")
SO, how can I import the trigonometric functions to use alongside with flux in Task?
best regards