add model training
This commit is contained in:
@@ -15,15 +15,17 @@ type ObservationPoint struct {
|
||||
TempC *float64 `json:"temp_c,omitempty"`
|
||||
RH *float64 `json:"rh,omitempty"`
|
||||
PressureHPA *float64 `json:"pressure_hpa,omitempty"`
|
||||
WindMS *float64 `json:"wind_m_s,omitempty"`
|
||||
WindGustMS *float64 `json:"wind_gust_m_s,omitempty"`
|
||||
WindDirDeg *float64 `json:"wind_dir_deg,omitempty"`
|
||||
UVI *float64 `json:"uvi,omitempty"`
|
||||
LightLux *float64 `json:"light_lux,omitempty"`
|
||||
BatteryMV *float64 `json:"battery_mv,omitempty"`
|
||||
SupercapV *float64 `json:"supercap_v,omitempty"`
|
||||
RainMM *float64 `json:"rain_mm,omitempty"`
|
||||
RainStart *int64 `json:"rain_start,omitempty"`
|
||||
// PressureTrend1h is the change in pressure over the last hour (hPa).
|
||||
PressureTrend1h *float64 `json:"pressure_trend_1h,omitempty"`
|
||||
WindMS *float64 `json:"wind_m_s,omitempty"`
|
||||
WindGustMS *float64 `json:"wind_gust_m_s,omitempty"`
|
||||
WindDirDeg *float64 `json:"wind_dir_deg,omitempty"`
|
||||
UVI *float64 `json:"uvi,omitempty"`
|
||||
LightLux *float64 `json:"light_lux,omitempty"`
|
||||
BatteryMV *float64 `json:"battery_mv,omitempty"`
|
||||
SupercapV *float64 `json:"supercap_v,omitempty"`
|
||||
RainMM *float64 `json:"rain_mm,omitempty"`
|
||||
RainStart *int64 `json:"rain_start,omitempty"`
|
||||
}
|
||||
|
||||
type ForecastPoint struct {
|
||||
@@ -147,6 +149,23 @@ func (d *DB) ObservationSeries(ctx context.Context, site, bucket string, start,
|
||||
return nil, rows.Err()
|
||||
}
|
||||
|
||||
indexByTime := make(map[time.Time]int, len(points))
|
||||
for i := range points {
|
||||
indexByTime[points[i].TS] = i
|
||||
}
|
||||
for i := range points {
|
||||
if points[i].PressureHPA == nil {
|
||||
continue
|
||||
}
|
||||
target := points[i].TS.Add(-1 * time.Hour)
|
||||
j, ok := indexByTime[target]
|
||||
if !ok || points[j].PressureHPA == nil {
|
||||
continue
|
||||
}
|
||||
trend := *points[i].PressureHPA - *points[j].PressureHPA
|
||||
points[i].PressureTrend1h = &trend
|
||||
}
|
||||
|
||||
return points, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user