From ce0ef7d291ae06a8f98fb50a072f86386ca55ae7 Mon Sep 17 00:00:00 2001 From: Ryan McGuire Date: Tue, 28 Jan 2025 19:26:40 -0500 Subject: [PATCH] Clear invalid measurements --- pkg/weather/enrich.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pkg/weather/enrich.go b/pkg/weather/enrich.go index fbe54e8..dff72a4 100644 --- a/pkg/weather/enrich.go +++ b/pkg/weather/enrich.go @@ -15,11 +15,21 @@ func (u *WeatherUpdate) Enrich(weatherStations ...*config.WeatherStation) { return } + // Clear invalid measurements + if u.BaromAbsoluteIn != nil && *u.BaromAbsoluteIn < 20 { + u.BaromAbsoluteIn = nil + } + if u.BaromRelativeIn != nil && *u.BaromRelativeIn < 20 { + u.BaromRelativeIn = nil + } + + // Calculate Wind Chill if u.WindChillF == nil && u.TempOutdoorF != nil && u.WindSpeedMPH != nil { wc := CalculateWindChill(*u.TempOutdoorF, *u.WindSpeedMPH) u.WindChillF = &wc } + // Calculate Dew Point if u.DewPointF == nil && (u.TempOutdoorF != nil && u.HumidityOudoor != nil) { if *u.TempOutdoorF != 0 || *u.HumidityOudoor != 0 { dp := CalculateDewPoint(*u.TempOutdoorF, float64(*u.HumidityOudoor)) @@ -27,6 +37,7 @@ func (u *WeatherUpdate) Enrich(weatherStations ...*config.WeatherStation) { } } + // Use relative pressure if absolute isn't provided if u.BaromAbsoluteIn == nil && u.BaromRelativeIn != nil { u.BaromAbsoluteIn = u.BaromRelativeIn }