comparison pkg/common/nashsutcliffe.go @ 2969:b92a8d088d8a unified_import

merge with default
author Thomas Junk <thomas.junk@intevation.de>
date Tue, 02 Apr 2019 10:07:48 +0200
parents 4f66a3ba424b
children 014be2194bd1
comparison
equal deleted inserted replaced
2968:8b32574bed09 2969:b92a8d088d8a
12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de> 12 // * Sascha L. Teichmann <sascha.teichmann@intevation.de>
13 13
14 package common 14 package common
15 15
16 import ( 16 import (
17 "math"
17 "sort" 18 "sort"
18 "time" 19 "time"
19 ) 20 )
20 21
21 type NSMeasurement struct { 22 type NSMeasurement struct {
22 When time.Time 23 When time.Time
23 Predicted float64 24 Predicted float64
24 Observed float64 25 Observed float64
26 }
27
28 func (m NSMeasurement) Valid() bool {
29 return !m.When.IsZero() && !math.IsNaN(m.Predicted) && !math.IsNaN(m.Observed)
25 } 30 }
26 31
27 func NashSutcliffeSort(measurements []NSMeasurement) { 32 func NashSutcliffeSort(measurements []NSMeasurement) {
28 sort.Slice(measurements, func(i, j int) bool { 33 sort.Slice(measurements, func(i, j int) bool {
29 return measurements[i].When.Before(measurements[j].When) 34 return measurements[i].When.Before(measurements[j].When)