Mercurial > gemma
changeset 5225:c5599966befe new-fwa
find minima of each class.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Tue, 12 May 2020 11:31:54 +0200 |
parents | fc999a902d87 |
children | 755d54cd7fd0 |
files | pkg/controllers/fwa.go |
diffstat | 1 files changed, 19 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/pkg/controllers/fwa.go Tue May 12 11:00:50 2020 +0200 +++ b/pkg/controllers/fwa.go Tue May 12 11:31:54 2020 +0200 @@ -313,6 +313,7 @@ var totalDays, shipableDays int allClasses := make([][]time.Duration, len(validities)) + minClasses := make([]time.Duration, len(validities)) missingLDCs := make([]int, len(validities)) // We step through the time in steps of one day. @@ -348,6 +349,7 @@ ldc.value, (*availMeasurement).getValue) + // If more than half of the day is below LDC -> not shipable. if result[1] < 12*time.Hour { shipable = false } @@ -364,6 +366,8 @@ } totalDays++ + minOfAll(allClasses, minClasses) + // TODO: Accumulate daily statistics into time segment. if finish(next) { @@ -396,6 +400,21 @@ } } +func minOfAll(classes [][]time.Duration, min []time.Duration) { + for i := range min { + var m time.Duration + for _, cl := range classes { + if cl == nil { + continue + } + if cl[i] < m { + m = cl[i] + } + } + min[i] = m + } +} + func dusk(t time.Time) time.Time { return time.Date( t.Year(),