changeset 3208:3bba82bcb6a6

Second fix to waterlevel classification. Set the bounds of the intervals correctly.
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Wed, 08 May 2019 17:53:08 +0200
parents ba7bc3740fb3
children 5b8916b78cea
files pkg/controllers/bottlenecks.go
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/pkg/controllers/bottlenecks.go	Wed May 08 17:43:18 2019 +0200
+++ b/pkg/controllers/bottlenecks.go	Wed May 08 17:53:08 2019 +0200
@@ -155,6 +155,8 @@
 		return common.InterpolateValueByTime(p1.when, access(p1), p2.when, access(p2))
 	}
 
+	// var total time.Duration
+
 pairs:
 	for i := 0; i < len(measurements)-1; i++ {
 		p1 := &measurements[i]
@@ -182,7 +184,7 @@
 			f, _ := v(from)
 			t, _ := v(to)
 			classify(common.InterpolateTimeByValue(from, f, to, t))
-			start, end = from, to
+			start, end = p1.when, p2.when
 
 		case p1.when.After(from):
 			// from is inside segment
@@ -219,6 +221,8 @@
 			continue pairs
 		}
 
+		// total += end.Sub(start)
+
 		for i := len(cvs) - 1; i >= 0; i-- {
 			switch cvs[i].kind {
 			case common.ValueAbove:
@@ -241,6 +245,9 @@
 		result[0] += end.Sub(start)
 	}
 
+	// log.Printf("total all: %f\n", to.Sub(from).Hours())
+	// log.Printf("total: %f\n", total.Hours())
+
 	return result
 }
 
@@ -676,10 +683,10 @@
 		)
 
 		record[0] = label
-		record[1] = fmt.Sprintf("%.3f", ldc[1].Hours()/24)
+		record[1] = fmt.Sprintf("%.3f", ldc[1].Hours())
 
 		for i, d := range ranges {
-			record[2+i] = fmt.Sprintf("%.3f", d.Hours()/24)
+			record[2+i] = fmt.Sprintf("%.3f", d.Hours())
 		}
 
 		if err := out.Write(record); err != nil {