Mercurial > gemma
comparison pkg/controllers/gauges.go @ 4097:472aedc8927d timezone
Merged default into timezone branch.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Fri, 26 Jul 2019 09:54:08 +0200 |
parents | 80bdcd137a1d 1562a5fb36dc |
children | 1458c9b0fdaa |
comparison
equal
deleted
inserted
replaced
4086:23f88a6c1e88 | 4097:472aedc8927d |
---|---|
634 predicted = append(predicted, p) | 634 predicted = append(predicted, p) |
635 observed = append(observed, values[j].observed) | 635 observed = append(observed, values[j].observed) |
636 } | 636 } |
637 } | 637 } |
638 | 638 |
639 cs[i].Value = common.NashSutcliffe(predicted, observed) | 639 cs[i].Value = sanitizeFloat64(common.NashSutcliffe(predicted, observed)) |
640 cs[i].Samples = len(predicted) | 640 cs[i].Samples = len(predicted) |
641 | 641 |
642 predicted = predicted[:0] | 642 predicted = predicted[:0] |
643 observed = observed[:0] | 643 observed = observed[:0] |
644 } | 644 } |
648 When: models.ImportTime{Time: when}, | 648 When: models.ImportTime{Time: when}, |
649 Coeffs: cs, | 649 Coeffs: cs, |
650 }, | 650 }, |
651 } | 651 } |
652 return | 652 return |
653 } | |
654 | |
655 func sanitizeFloat64(x float64) float64 { | |
656 switch { | |
657 case math.IsNaN(x): | |
658 return 0 | |
659 case math.IsInf(x, +1): | |
660 return math.MaxFloat64 | |
661 case math.IsInf(x, -1): | |
662 return -math.MaxFloat64 | |
663 } | |
664 return x | |
653 } | 665 } |
654 | 666 |
655 func waterlevels(rw http.ResponseWriter, req *http.Request) { | 667 func waterlevels(rw http.ResponseWriter, req *http.Request) { |
656 gauge := mux.Vars(req)["gauge"] | 668 gauge := mux.Vars(req)["gauge"] |
657 | 669 |