fix rain data for wunderground
This commit is contained in:
@@ -121,20 +121,13 @@ func (l *Latest) computeRainIncrement(rainMM float64) float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Decide mode (unknown):
|
// Decide mode (unknown):
|
||||||
// If delta is consistently positive when rainMM > 0, cumulative is likely.
|
// Default to cumulative once we see any non-zero rain value. This avoids
|
||||||
// If delta is ~0 while rainMM occasionally > 0, incremental is likely.
|
// wildly overcounting when the service starts and rain_mm is a cumulative counter.
|
||||||
//
|
|
||||||
// Single-sample heuristic:
|
|
||||||
// - if rainMM > 0 and delta > 0 => lean cumulative
|
|
||||||
// - if rainMM > 0 and delta ~ 0 => lean incremental
|
|
||||||
if rainMM > 0 {
|
if rainMM > 0 {
|
||||||
|
l.mode = rainModeCumulative
|
||||||
if delta > 0.0009 {
|
if delta > 0.0009 {
|
||||||
l.mode = rainModeCumulative
|
|
||||||
return delta
|
return delta
|
||||||
}
|
}
|
||||||
// delta near zero but rainMM nonzero suggests incremental
|
|
||||||
l.mode = rainModeIncremental
|
|
||||||
return rainMM
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|||||||
Reference in New Issue
Block a user