fluxQuery =
`import "math"
import "experimental"
import "date"
gradient_clumping = 0.2 // 10.0 would mean it's clumped to 0, 0.1, 0.2, 0.3, ...
float_glitch_correction = 10.0 // no need to change this, I guess - https://stackoverflow.com/a/18908122/1633985
from(bucket: "weather_5m")
|> range(start: 2019-01-01, stop: 2020-01-01)
|> filter(fn: (r) => r._measurement == "Temp_Avg" and r._field == "value") //r._measurement == "RadSol_Avg" or
|> pivot(
rowKey:["_time"],
columnKey: ["_field"],
valueColumn: "_value"
)
|> rename(columns: {value : "_value"})
|> window(every: 1d)
|> reduce(fn: (r, accumulator) => ({
r with
min: math.mMin(x: accumulator.min, y: r._value),
max: math.mMax(x: accumulator.max, y: r._value),
count: accumulator.count + 1,
total: accumulator.total + r._value,
avg: (accumulator.total + r._value) / float(v: accumulator.count)
}),
identity: {min: 100000.0, max:-100000.0, count: 1, total: 0.0, avg: 0.0}
)`