- Residual window shrinks from 168h back to 48h; title 'last 48h' (no
space). Picture now matches the rolling scoreboard window exactly.
- UI order in Results section: residual chart β rolling 48h MAE table
β lifetime MAE table. Eye lands on the picture first, the numbers
underneath.
- Normalize the user-facing 'N h' spacing to 'Nh' (48h, 1h-ahead) on
the chart heading, scoreboard captions, table cells, and the
scoreboard explainer accordion.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add lifetime MAE table; residual chart spans last 7 days; subtitle tweakβ
- forecast_log.scoreboard_at_lag now accepts window_hours=None for 'all
time' MAE.
- render_scoreboard emits two tables: the existing rolling 48 h block,
plus a new 'π° Lifetime MAE' block using window_hours=None, captioned
with the timestamp of the very first logged forecast.
- Residual chart bumped from 48 h β 168 h (last 7 days), title updated
to match.
- Subtitle reworded: 'with a scoreboard tracking who's been more
accurate' (drops the now-misleading 'over the past 48 hours').
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Weekly chart: x-axis tick labels on temperature (top) instead of pressureβ
Plotly's shared_xaxes default puts tick labels on the bottom subplot;
that meant the reader had to scroll past four panels to find out what
day each column was. Move the labels to the top of the Outdoor
temperature subplot (the first panel) so the time axis is obvious from
the first glance. Bumped top margin slightly to make room for the
ticks.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Bump Toto from 4 M to 22 M (small) β same data path, larger modelβ
Datadog/Toto-2.0-22m is the second-smallest variant in the Toto 2.0
family. Tighter confidence bands and lower MAE for ~5Γ the parameter
count, still fits comfortably in CPU memory and runs sub-second per
metric. Patch size is read from model.config at runtime so the
context-trim / pad logic adapts automatically.
Updates the subtitle on the page and the inference doc to reflect
the variant change.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop hero gauge plot; hero table shows 1 decimal for forecastsβ
- Remove hero_gauges and its wiring. Gauge visual didn't earn its
vertical space at any breakpoint vs the existing 3-row hero table.
- hero_markdown forecast rows now show one decimal place (e.g. 62.3Β°F)
instead of rounding to integer, to match the current-temperature row.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Hero gauges: switch to horizontal thermometer bars (mobile-friendly)β
The three radial dial gauges packed badly on portrait phones β they
shrank to thumbnail size with unreadable needles and values. Replace
with three stacked horizontal bars on a shared 20-100Β°F scale:
- π‘ Ecowitt (now) βββββββββββββββ 63.5Β°F
- π€ Toto (next hr) βββββββββββββββ 64.3Β°F (+0.8)
- π NWS (next hr) βββββββββββββββ 61.0Β°F (-2.5)
Same cool/warm background bands as before so the eye still reads
'where on the temperature spectrum'. Bar color matches each source's
chart trace. Delta vs current temperature annotated in muted gray on
the right of each forecast bar. Bars take the full width of the
container so they stay legible at any breakpoint.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- src/weather_ui.py: new hero_gauges() returns three side-by-side
Plotly Indicator gauges β Ecowitt now (black), Toto next hour
(blue), NWS next hour (red). Forecast gauges show a delta vs the
current reading. Background bands tint cool/warm so the eye can
read the temperature regime without checking the axis.
- src/weather_ui.py: hero_markdown target switches from now+1h to
now.ceil('h'). At 3:55 the hero forecast is for 4 PM; at 4:01 it
flips to 5 PM. Row labels read '(next hour)' instead of '(1 h-ahead)'.
- app.py: build the gauge figure each refresh from realtime + the
nearest Toto/NWS values to the next round hour. Render the gauge
trio directly above the hero table.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Hero shows Ecowitt now + Toto and NWS 1 h-ahead predictionsβ
Three rows: π‘ Ecowitt (now), π€ Toto (1 h-ahead), π NWS (1 h-ahead).
Each row carries its own timestamp. Drops the previous NWS 'this hour'
nowcast β the 1 h-ahead Toto/NWS pair is a more interesting at-a-glance
read and lines up with the scoreboard's first row.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Was 9 rows stepping every 3 h up to +24 h, now 3 rows at the same
lookaheads the scoreboard scores on. New 'Lookahead' column ('1 h',
'3 h', '12 h') makes the connection to the scoreboard explicit; offsets
are measured from now rather than from the first forecast hour so the
labels match the user's wall-clock intuition.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Move weekly forecast above the comparison table; timestamps into heroβ
- Lead with the forecast itself: hero β weekly chart β 24h same-hour
table β radar β scoreboard β accordions. The reader sees the live
forecast first, then the side-by-side detail.
- Hero table grows a 'When' column: each row carries its own timestamp
('2:02 PM EDT, Mon May 11' for Ecowitt, '2 PM EDT, Mon May 11' for
the NWS hour). Drops the standalone 'Last Ecowitt readingβ¦' caption
since the same info is now in the table.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Reorder layout, residual to 1h, scoreboard temp+humidity onlyβ
- Drop pressure from the scoreboard table (NWS doesn't forecast pressure
so there's nothing to compare).
- Residual chart now pinned to 1 h-ahead so it matches the first row of
the table.
- Move the scoreboard + residual section below the weekly forecast
chart, under a new 'π How has each model done so far?' heading. The
page now opens with the forecast story (hero β comparison β radar β
72h chart) and only after that asks 'and how well does it actually
do?'. The explainer accordions stay at the bottom.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Scoreboard: per-metric MAE table across 1 h / 3 h / 12 h lookaheadsβ
Latest-pre-target scoring was just measuring 5-15-min-ahead predictions
(since autorefresh runs every 15 min, the 'most recent before target'
forecast is always near-term). That's a trivial test of forecast skill.
Replace the single MAE line per metric with a table of MAE at three
fixed lookaheads β 1 h, 3 h, 12 h β where each lookahead picks the
forecast whose forecast_made_at is closest to (target β N h). Now the
scoreboard tells the actual story of model degradation with horizon.
- forecast_log.scoreboard_at_lag(metric, lag_hours, window_hours) β
ROW_NUMBER over absolute distance to (target β lag), JOIN with
actuals.
- forecast_log.residuals(..., lag_hours=3.0) β residual chart is now
pinned to the middle row of the table so the picture matches a
headline number.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Residual chart uses same picks as the scoreboard MAEβ
The previous residual query picked each model's 3h-ahead forecast,
which is a much harder prediction than the 'latest before target' rule
the scoreboard uses β so the chart made Toto look much worse than its
headline MAE. Aligning both to the same picking rule (most-recent
forecast issued before each target hour) so the residual time series
adds up to the scoreboard number.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add residual chart: Toto vs NWS error for past 48h temp predictionsβ
We log every forecast snapshot, so we already have everything needed to
visualize accuracy over time β not just an aggregate MAE. New chart
under the scoreboard headline:
- For each hourly target in the last 48 h, pick each model's prediction
whose forecast_made_at is closest to (target β 3 h). Fixed lag = like-
for-like comparison.
- Plot signed residual (prediction β actual). Zero line = perfect.
Two lines (Toto blue, NWS red dashed) so the viewer can read 'Toto was
+5Β°F off at 3 AM, NWS was +1Β°F' at a glance.
- forecast_log.residuals(metric, window_hours, lag_hours)
- weather_ui.residual_figure(df)
- app.py wires it under the scoreboard
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Toto fed hourly while chart stays 5-min; drop past overlay entirelyβ
Two changes that fix the 'forecasts look awful at 5-min' regression
and clean up the chart:
1. Decouple display cadence from inference cadence. The chart still
renders at 5-min (display_resample='5min') but Toto consumes an
hourly-resampled view of the same history (forecast_resample='1h').
That brings the input back to a 168-point context + 48-step horizon,
the sequence size where the 4M model produced clean forecasts.
The 5-min view was sending Toto-2.0-4m a 2016+576 sequence β well
outside its sweet spot β and the long auto-regressive rollout
compounded error. Plus a lot of the older 5-min points were really
30-min source rows linearly interpolated, which gave the model fake
high-frequency structure to anchor on.
2. Remove the past Toto overlay from the chart. The sawtooth came from
sparse forecast snapshots in some hours and the smoothing knobs
(fixed-lag, etc.) didn't fully fix it. The scoreboard MAE still
captures the same information as a sβ¦
Past-Toto overlay: fixed 6h-ahead horizon instead of mixed lagsβ
The sawtooth on the past-forecast overlay came from the 'latest-pre-
target' rule: each past hour was scored against whatever forecast
happened to be most-recent before it, so target_ts=13:00 might use a
15-min-ahead prediction while target_ts=14:00 used a 45-min-ahead
prediction. Different lags β different prediction quality β sawtooth.
historical_predictions now defaults to picking the forecast whose
forecast_made_at is closest to (target_ts β 6 h). Constant 6-hour
lookback gives a consistent forecast horizon and a smooth overlay.
Legacy 'latest-pre-target' mode still available via lag_hours=None.
Chart legend updated to 'π€ Toto (6h-ahead, past)' for clarity.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Read history from the SQLite archive, weekly view at 5-min cadenceβ
The autorefresh thread was already syncing 5-min Ecowitt history into
data/ecowitt.db every tick. Now the live display + Toto inference also
read from that archive instead of hitting the Ecowitt API on every page
load, so we (a) accumulate true 5-min granularity over time, beyond
Ecowitt's own 24-30h 5-min retention window, and (b) stop wasting API
quota on data we already have.
- src/storage.py: new read_history_dataframe(conn, since, until,
cycle_type, resample) β pivots readings into a UTC-indexed DataFrame
with one column per metric in HISTORY_FIELDS.
- app.py: fetch_history now queries the archive first (5-min cadence)
and falls back to a one-shot API pull only if the archive is empty.
- app.py: VIEW_WEEK switches to cycle_type=5min / resample=5min /
history=7d / horizon=72h. 7d Γ 288 = 2016 context points (63 patches),
72h Γ 12 = 864 horizon steps per metric.
- app.py: autorefresh reorders to sync-then-refresh so the live page
always sees the latest data the API has β¦
Past-Toto overlay: re-enable, capped at last Ecowitt actualβ
Bring the translucent Toto p50 overlay back on the historical side of
the chart but strictly cap target_ts <= last_actual_ts so it can't bleed
into the forecast window.
historical_predictions() now takes an explicit until_unix parameter
(default = now) and includes it in the WHERE clause.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop zoom view, remove past-Toto overlay, dated x-axisβ
- app.py: remove VIEW_ZOOM and zoom_plot. Only the weekly view renders.
- app.py + src/weather_ui.py: stop building / passing past_toto into
combined_figure. The 'past forecasts' overlay used MAX(forecast_made_at)
per target hour, which sampled forecasts at wildly different lags
depending on autorefresh timing β that's where the sawtooth came from,
not from Toto. The scoreboard MAE is the honest single number; the
chart overlay was the wrong abstraction. (A fixed-horizon overlay is
a future option.)
- src/weather_ui.py: explicit x-axis tick format 'Month day\nhour AM/PM'
so dates are unambiguous on a 7-day-plus-72h chart.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Past-forecast overlay: keep Toto only, drop the NWS traceβ
The NWS past-forecast line added visual clutter on top of the NWS future
forecast line on the same panel; the scoreboard already conveys NWS
accuracy with a single number. Keep only the translucent Toto past-p50
overlay.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Overlay past Toto and NWS forecasts on the historical chartβ
Every refresh already logs each forecast (p10/p50/p90) keyed by both
forecast_made_at and target_ts. Use that history to plot, for each past
hour, the most-recent forecast that was issued *before* that hour β for
both Toto and NWS β alongside the Ecowitt actuals on every metric panel.
- src/forecast_log.py: historical_predictions(source, metric, since_unix)
joins the forecast table back onto itself per (source, target_ts) to
pick the latest pre-target snapshot, returns a tidy ts-indexed DF.
- app.py: build past_toto / past_nws dicts per metric over the visible
history window, pass them into combined_figure.
- src/weather_ui.py: render two new dimmer overlay traces β a solid
semi-transparent blue line for past Toto p50, dashed semi-transparent
red for past NWS β so the viewer can see at a glance how each model
has been doing on this exact station.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Use /device/real_time for the hero so 'now' is truly liveβ
The hourly history bucket only fills once Ecowitt has at least one
reading inside that hour; the GW3000B uploads every 30 minutes so the
current-hour bucket can lag real time by up to half an hour. The hero
now reads /device/real_time on a 60s TTL and reports its minute-level
timestamp, so the user sees the actual most recent device reading
instead of the previous hour's average.
The hourly history is still used for the chart and for forecast input.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Switch to 15-min autorefresh, drop manual button, sync all cycle archivesβ
- app.py: AUTO_REFRESH_SECONDS = 15 min, CACHE_TTL = 14 min so the next
autorefresh always misses the cache.
- app.py: remove the 'Refresh forecast' button and replace with a status
line. Dropdowns still trigger re-render (cheap β they hit the cache).
- app.py: each autorefresh tick now also calls sync.sync_cycle for every
cycle_type (5min / 30min / 4hour) so the all-channel Ecowitt archive
in data/ecowitt.db stays current. Rate-limit aware.
- src/persist.py: push_all / pull_all / push_all_async β multi-file
commit that ships forecasts.db + ecowitt.db together to the HF
Dataset. push_db_async on user-triggered refresh stays as before
for snappier round-trips; the autorefresh thread does the full push.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add rainfall subplot and label NWS hero row with the actual hourβ
- src/ecowitt.py: HISTORY_FIELDS gains rain_in_hr (rainfall_piezo.rain_rate).
- app.py: include rainfall_piezo channel in the call_back; add 'Rainfall
rate' as a fourth metric (above humidity, between temperature and
humidity in the stacked plot). NWS doesn't expose rain rate so the
rainfall subplot shows Ecowitt past + Toto forecast only.
- src/weather_ui.py: hero second row now reads e.g. 'NWS forecast for
4 PM EDT' instead of 'this hour' so the comparison time is unambiguous.
- src/weather_ui.py: bump combined plot height 720 β 900 to fit 4 panels.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Slim hero to temp+source; drop high/low cards; align forecast on hourβ
- src/weather_ui.py: hero table is now Source Γ Temperature only,
followed by a 'Last Ecowitt reading at 4:30 PM EDT on Sun May 10'
caption. Humidity / pressure / conditions removed.
- src/weather_ui.py: aligned_comparison_markdown now starts at the first
forecast hour (i.e. the next round hour after the most recent Ecowitt
reading) and steps every 3 hours up to +24h. Labels show '5 PM' for
same-day rows and 'Mon 5 AM' once the day rolls over.
- app.py: removed the Toto / NWS high-low cards. The aligned same-hour
table is now the only forecast headline above the chart.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Clarify now-snapshot, align Toto vs NWS forecast in text and chartβ
- src/weather_ui.py: hero now shows two explicit rows β 'π‘ Ecowitt now'
(measured) and 'π NWS this hour' (predicted) β with the gap between
them surfaced inline so the model error is visible at a glance.
- src/weather_ui.py: new aligned_comparison_markdown produces a +6h /
+12h / +18h / +24h table with Toto and NWS predictions for the same
wall-clock hour, side by side, plus a Ξ column. Replaces the previous
high/low layout where the two models' peak times rarely matched.
- src/weather_ui.py: combined_figure traces now set mode='lines'
explicitly and a fully-transparent line on the band polygon so Plotly
doesn't auto-add markers at the band vertices. Toto median switches
from dashed to solid; NWS forecast from dotted to dashed.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pad short series for Toto + persist forecast log to HF Datasetβ
- src/forecast.py: when context is shorter than one Toto patch (32), left-
pad with the first value and set target_mask False on padded steps so
the model ignores them. Fixes the 4-hour cadence dropdown error when the
station has fewer than 32 four-hour points (~5 days of data).
- src/persist.py: pull/push the forecast SQLite to a private HF Dataset
(default bitsofchris/toto-weather-forecast-log) so the scoreboard
survives Space rebuilds. Push is locked + coalesced (60s min interval),
fired async after each refresh; pull runs once at startup.
- app.py: call persist.pull_db() on launch and persist.push_db_async()
at the end of refresh().
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fix headline forecast layout: split into two markdown columnsβ
Markdown table cells can't contain blank-line blocks, so the previous
side-by-side render leaked literal pipes. Switch to two gr.Markdown
components inside a gr.Row.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- src/forecast_log.py: SQLite tables for forecast_snapshots and actuals,
upsert helpers, and a scoreboard query computing rolling MAE per source
using each target's most-recently-issued forecast.
- app.py: write actuals + Toto + NWS forecasts on every refresh; render a
markdown scoreboard panel above the plots; daemon thread that re-runs
refresh() hourly so snapshots accumulate without a user visit.
- app.py: drop the NWS first period that overlaps Ecowitt's last actual
hour so all forecasts begin one bucket past the last observed value.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Truncate Toto input to a multiple of patch_size (32)β
Toto-2.0-4m requires its context tensor to be (batch, n_var, k * patch_size)
or einops fails with "Shape mismatch, can't divide axis of length N in
chunks of P". With ~5 days of hourly Ecowitt data we got 118 points; trim
to the largest multiple of 32 (96) before inference.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add NWS client, Toto forecast wrapper, and Gradio appβ
- src/nws.py: two-step /points β forecastHourly fetcher; returns a
UTC-indexed DataFrame with columns aligned to Ecowitt (temp_f, humidity).
- src/forecast.py: Toto 2.0 (4M) wrapper. Lazy-imports torch/toto2 so the
module is importable without those installed; loads on first call.
- src/plotting.py: per-metric Plotly figure (history + Toto p10/p50/p90
band + NWS overlay + 'now' marker).
- app.py: Gradio Blocks app β three metric plots, 1h TTL cache, refresh
button.
- requirements.txt: pin torch>=2.4.0 and toto-2 from the DataDog/toto repo.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add Ecowitt API client and incremental SQLite archiveβ
- src/ecowitt.py: Ecowitt Cloud API v3 client (info, real_time, history)
with typed errors and a history β DataFrame helper.
- src/storage.py: SQLite schema and idempotent upsert keyed on
(cycle_type, channel, metric, ts_unix); handles deeply nested payloads.
- src/sync.py: incremental sync that resumes from MAX(ts_unix) per
cycle_type, chunks long ranges, and backs off on rate-limit.
- docs/plan.md: high-level project plan.
- docs/ecowitt-notes.md: API findings (valid cycle_types, call_back
rejecting 'all' for history, rate-limit code -1) and run-it-yourself docs.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>