6.4 KiB
title | description | menu | weight | flux/v0/tags | introduced | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
experimental.integral() function | `experimental.integral()` computes the area under the curve per unit of time of subsequent non-null records. |
|
101 |
|
0.106.0 |
experimental.integral()
computes the area under the curve per unit of time of subsequent non-null records.
The curve is defined using _time
as the domain and record values as the range.
Input tables must have _start
, _stop,
_time, and
_valuecolumns.
_startand
_stop` must be part of the group key.
Function type signature
(<-tables: stream[{A with _value: B, _time: time}], ?interpolate: string, ?unit: duration) => stream[{A with _value: B}]
{{% caption %}} For more information, see Function type signatures. {{% /caption %}}
Parameters
unit
Time duration used to compute the integral.
interpolate
Type of interpolation to use. Default is ""
(no interpolation).
Use one of the following interpolation options:
- empty string (
""
) for no interpolation - linear
tables
Input data. Default is piped-forward data (<-
).
Examples
Calculate the integral
import "experimental"
import "sampledata"
data =
sampledata.int()
|> range(start: sampledata.start, stop: sampledata.stop)
data
|> experimental.integral(unit: 20s)
{{< expand-wrapper >}} {{% expand "View example input and output" %}}
Input data
*_start | *_stop | _time | _value | *tag |
---|---|---|---|---|
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | t1 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 10 | t1 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 |
*_start | *_stop | _time | _value | *tag |
---|---|---|---|---|
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | 19 | t2 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 4 | t2 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 |
Output data
*_start | *_stop | *tag | _value |
---|---|---|---|
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 25 |
*_start | *_stop | *tag | _value |
---|---|---|---|
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 21.5 |
{{% /expand %}} {{< /expand-wrapper >}}
Calculate the integral with linear interpolation
import "experimental"
import "sampledata"
data =
sampledata.int()
|> range(start: sampledata.start, stop: sampledata.stop)
data
|> experimental.integral(unit: 20s, interpolate: "linear")
{{< expand-wrapper >}} {{% expand "View example input and output" %}}
Input data
*_start | *_stop | _time | _value | *tag |
---|---|---|---|---|
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | -2 | t1 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 10 | t1 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | 7 | t1 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 17 | t1 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 15 | t1 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 4 | t1 |
*_start | *_stop | _time | _value | *tag |
---|---|---|---|---|
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:00Z | 19 | t2 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:10Z | 4 | t2 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:20Z | -3 | t2 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:30Z | 19 | t2 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:40Z | 13 | t2 |
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | 2021-01-01T00:00:50Z | 1 | t2 |
Output data
*_start | *_stop | *tag | _value |
---|---|---|---|
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t1 | 24.25 |
*_start | *_stop | *tag | _value |
---|---|---|---|
2021-01-01T00:00:00Z | 2021-01-01T00:01:00Z | t2 | 19 |
{{% /expand %}} {{< /expand-wrapper >}}