Sampling Feature for archived and fresh data

This commit is contained in:
Aditya Ujeniya
2024-08-22 14:29:51 +02:00
parent e74e506ffe
commit ceb3a095d8
14 changed files with 358 additions and 95 deletions

25
pkg/resampler/util.go Normal file
View File

@@ -0,0 +1,25 @@
package resampler
import (
"math"
"github.com/ClusterCockpit/cc-backend/pkg/schema"
)
func calculateTriangleArea(paX, paY, pbX, pbY, pcX, pcY schema.Float) float64 {
area := ((paX-pcX)*(pbY-paY) - (paX-pbX)*(pcY-paY)) * 0.5
return math.Abs(float64(area))
}
func calculateAverageDataPoint(points []schema.Float, xStart int64) (avgX schema.Float, avgY schema.Float) {
for _, point := range points {
avgX += schema.Float(xStart)
avgY += point
xStart++
}
l := schema.Float(len(points))
avgX /= l
avgY /= l
return avgX, avgY
}