feat: snapshot #2

Merged
Noel merged 4 commits from feat/snapshot into main 2026-11-14 05:37:49 +00:00
43 changed files with 4513 additions and 45 deletions
Showing only changes of commit 7ec4fc8bb3 - Show all commits

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
.git
.gitignore
.venv
__pycache__
*.py[cod]
.pytest_cache
.ruff_cache
data/raw
data/cache
tests
dist
build
*.egg-info
.env
+43
View File
@@ -0,0 +1,43 @@
# syntax=docker/dockerfile:1
FROM python:3.12-slim AS builder
COPY --from=ghcr.io/astral-sh/uv:0.10.4 /uv /uvx /bin/
ENV UV_COMPILE_BYTECODE=1 \
UV_LINK_MODE=copy \
UV_PYTHON_DOWNLOADS=never
WORKDIR /app
COPY pyproject.toml uv.lock README.md ./
RUN uv sync --frozen --no-dev --no-install-project
COPY src ./src
RUN uv sync --frozen --no-dev --no-editable
FROM python:3.12-slim AS runtime
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1 \
PULSECAST_ROOT=/app \
PULSECAST_ARTIFACTS=/app/artifacts \
PULSECAST_WEATHER=/app/artifacts \
PULSECAST_MODELS=/tmp/pulsecast/models \
PULSECAST_UPLOADS=/tmp/pulsecast/uploads \
PATH=/app/.venv/bin:$PATH
RUN groupadd --system app \
&& useradd --system --gid app --home-dir /app --shell /usr/sbin/nologin app \
&& mkdir -p /tmp/pulsecast/models /tmp/pulsecast/uploads \
&& chown -R app:app /tmp/pulsecast
WORKDIR /app
COPY --chown=app:app --from=builder /app/.venv /app/.venv
COPY --chown=app:app artifacts ./artifacts
COPY --chown=app:app main.py README.md model_card.md ./
USER app
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8000/healthz', timeout=2)"
CMD ["uvicorn", "pulsecast.server:app", "--host", "0.0.0.0", "--port", "8000"]
+31
View File
@@ -0,0 +1,31 @@
UV ?= uv
.PHONY: help data train test serve docker clean
help:
@printf '%s\n' \
'make data parse/clean the raw CSV, join weather + holidays, export JSON' \
'make train fit the 28-day holdout model, export metrics/forecasts/model' \
'make test run pytest' \
'make serve run the FastAPI service on :8000' \
'make docker build the multi-stage image (pulsecast-ml:local)' \
'make clean remove caches and generated artifacts (keeps data/raw)'
data:
$(UV) run python -m pulsecast.pipeline
train:
$(UV) run python -m pulsecast.train
test:
$(UV) run pytest
serve:
$(UV) run uvicorn pulsecast.server:app --host 0.0.0.0 --port 8000
docker:
docker build -t pulsecast-ml:local .
clean:
rm -rf data/cache artifacts .pytest_cache
find . -type d -name __pycache__ -prune -exec rm -rf {} +
+166
View File
@@ -0,0 +1,166 @@
# PulseCast ML
Footfall pipeline, weather-aware 7-day forecast, scenario engine, and FastAPI
service for the PulseCast staffing copilot.
The reusable asset is the pipeline: raw 15-minute PAX counters → clean hourly
series → observed weather + Baden-Württemberg holidays → global model →
honest holdout metrics → JSON artifacts → decision-ready API.
## Results
28-day time-based holdout: 2026-10-10 23:00 UTC → 2026-11-07 23:00 UTC,
5,350 evaluation rows, 8 sensors.
| Model | MAE | WAPE | R² |
|---|---:|---:|---:|
| Seasonal naive (exact 168-row lag) | 5.40 | 44.7% | 0.462 |
| Day-ahead, no weather | 3.96 | 32.8% | 0.706 |
| Day-ahead, + holiday flag | 3.84 | 31.8% | 0.732 |
| Day-ahead, + temperature/rain | 3.36 | 27.8% | 0.763 |
| 7-day-safe, no weather | 4.08 | 33.8% | 0.697 |
| **7-day-safe, + temperature/rain (production)** | **3.32** | **27.5%** | **0.777** |
The seasonal-naive row reproduces the mission reference exactly
(5.40 / 44.7% / 0.462), and the day-ahead weather row matches 3.36 / 27.8%.
Weather cuts error by ~19% versus the no-weather 7-day model and ~38% versus
seasonal naive. The production model is slightly better than the reference
because its seasonal feature uses the previous *observed* same weekday/hour
across sensor gaps; the baseline uses the exact 168-row lag.
Small busy-hour classifier (baked for the "train new data" demo):
| Accuracy | Precision | Recall | F1 | ROC-AUC | Train rows | Test rows |
|---:|---:|---:|---:|---:|---:|---:|
| 0.708 | 0.360 | 0.574 | 0.443 | 0.726 | 18,242 | 5,710 |
The classifier predicts `busy` = hourly footfall above the sensor's p75 using
hour, weekday, weekend, temperature, rain, and holiday. It trains in under a
second on the challenge CSV and is retrained from an uploaded CSV through
`POST /train`.
## Quick start
Requirements: Python 3.12 and `uv` (the repo also works with a plain venv).
```bash
uv sync
make data # needs the raw CSV, first run also fetches Open-Meteo weather
make train # writes artifacts/model.joblib, metrics.json, forecasts.json
make test
make serve # http://localhost:8000
```
The raw challenge CSV is **never committed**. Put it at:
```text
/home/noel/Documents/Hackathon_2026/data/raw/schwarz-pax.csv
```
or point `PULSECAST_RAW_CSV` at it. `data/raw/` and `data/cache/` are git-ignored.
The generated `artifacts/` (JSON + joblib + compact weather frames) are
committed so the API and Docker image work without the raw file or network.
## Artifacts
| File | Purpose |
|---|---|
| `artifacts/sensors.json` | 8 sensors: id, name, lat/lon, mean, p95, battery |
| `artifacts/series.json` + `series/<id>.json` | Hourly series per sensor |
| `artifacts/forecasts.json` | 48h + 7d forecasts for 4 scenarios |
| `artifacts/metrics.json` | Versions, coverage, headline metrics, ablation, limits |
| `artifacts/context.json` | Current + 7-day weather, BW holidays |
| `artifacts/data_audit.json` | Row/sensor checks against `mission/data.md` |
| `artifacts/model.joblib` | Baked HistGB forecast bundle |
| `artifacts/small_model.joblib` | Baked busy classifier |
| `artifacts/weather_*.parquet` | Baked weather frames for retraining/inference |
## API
Shapes follow `CONTRACT.md`. The service is internal; Go exposes it publicly.
| Method | Path | Notes |
|---|---|---|
| `GET` | `/healthz` | `{"ok":true}` |
| `GET` | `/readyz` | `{"ok":true,"model":true}`, 503 if no model |
| `GET` | `/meta` | Versions, coverage, metrics, features, holiday effect |
| `POST` | `/predict` | `{sensor,horizon,scenario,weather?,is_holiday?}` → `points` |
| `POST` | `/simulate` | Scenario forecast for all or selected sensors |
| `POST` | `/train` | Control token; multipart CSV or JSON path; 202 job |
| `GET` | `/train/{job_id}` | Status, metrics, model_version, error |
Horizons: `15m` (1 point), `1h` (4 points), `48h` (48 points), `7d` (168
points). Scenarios: `base`, `sunny-saturday-market`, `rainy-saturday`,
`weekday-event`.
```bash
curl -s localhost:8000/predict \
-H 'content-type: application/json' \
-d '{"sensor":"hn-stadtgalerie-01","horizon":"7d","scenario":"base"}'
curl -s localhost:8000/simulate \
-H 'content-type: application/json' \
-d '{"scenario":"sunny-saturday-market","sensors":"all"}'
# Training requires CONTROL_TOKEN and one job at a time.
CONTROL_TOKEN=change-me make serve
curl -s -X POST localhost:8000/train \
-H "Authorization: Bearer change-me" \
-F model=small -F file=@new-data.csv
curl -s localhost:8000/train/<job_id> \
-H "Authorization: Bearer change-me"
```
Training runs in a background thread, hot-swaps the in-memory model on success,
and persists to `PULSECAST_MODELS` (default `/tmp/pulsecast/models`). A restart
falls back to the baked model. `model=small` is the fast demo; `model=forecast`
retrains the global HistGB (slower, still background).
## Docker
```bash
make docker
docker run --rm -p 8000:8000 -e CONTROL_TOKEN=change-me pulsecast-ml:local
```
Multi-stage `python:3.12-slim`, non-root user, model and artifacts baked in,
writable paths only under `/tmp`.
## Configuration
| Variable | Default | Use |
|---|---|---|
| `PULSECAST_RAW_CSV` | challenge path | Raw CSV location |
| `PULSECAST_ARTIFACTS` | `./artifacts` | Baked JSON/model output |
| `PULSECAST_CACHE` | `./data/cache` | Parquet/weather cache |
| `PULSECAST_MODELS` | `/tmp/pulsecast/models` | Retrained model persistence |
| `PULSECAST_UPLOADS` | `/tmp/pulsecast/uploads` | Multipart upload landing |
| `CONTROL_TOKEN` | unset | Required by `/train`; service returns 503 if unset |
## Layout
```text
src/pulsecast/
config.py paths, sensors, holidays, scenarios, feature sets
parse.py CSV validation, exclusions, density-01 device merge
features.py hourly aggregation, leakage-safe lags/rollups
weather.py Open-Meteo archive/forecast with cache
pipeline.py `make data`
model.py HistGB fit, inference frame, bands, scenario overlay
train.py `make train`, ablation, artifacts
small.py busy classifier + flexible CSV parser
retrain.py runtime forecast retraining from upload
server.py FastAPI app and training job manager
tests/ schema, health, prediction, small-training job
model_card.md features, split, baseline, ablation, limits, leakage
```
## Limits
- Values are estimated devices detected by PAX counters, not a count of people.
- Eight sensors in a ~580 m inner-city cluster; no city-wide claim.
- Five months of multi-sensor data; no annual-seasonality claim.
- Weather is observed in training and forecast in the demo/scenarios.
- Holidays are context and a small feature, not a large accuracy claim.
- No POS, sales, queue, or labor-cost data; staffing is decision support with
explicit assumptions.
File diff suppressed because it is too large. Load diff
+98
View File
@@ -0,0 +1,98 @@
{
"raw_rows": 192464,
"density_rows": 96232,
"battery_rows": 96232,
"device_ids": 12,
"sensor_names": 11,
"usable_sensors": 8,
"sensor_ids": [
"density-01",
"hn-goetzentuem-01",
"hn-hagenbuchersee-01",
"hn-hagenbuchersee-02",
"hn-marahaus-01",
"hn-neckarufer-01",
"hn-soleo-01",
"hn-stadtgalerie-01"
],
"excluded_sensors": {
"maker-fair": {
"rows": 73,
"reason": "test installation in Hannover, 73 readings, outside the inner city"
},
"niklas-01": {
"rows": 8,
"reason": "8 readings, outside the inner-city cluster"
},
"hn-bollwerksturm-01": {
"rows": 5,
"reason": "5 readings, insufficient coverage"
}
},
"density_01_devices": {
"863f75b0": {
"rows": 8075,
"first": "2025-10-16T21:17:59Z",
"last": "2026-03-12T18:28:06Z"
},
"f8c19730": {
"rows": 17585,
"first": "2026-04-16T23:25:31Z",
"last": "2026-11-07T23:48:49Z"
}
},
"density_01_rows_multi_sensor": 12670,
"time_range": {
"from": "2025-10-16T21:17:59Z",
"to": "2026-11-07T23:51:57Z"
},
"multi_sensor_from": "2026-06-12T00:13:21Z",
"cadence_median_min": 15.31,
"dropped_out_of_range": 0,
"duplicate_keys_dropped": 0,
"checks": [
{
"name": "raw_rows",
"expected": 192464,
"actual": 192464,
"ok": true
},
{
"name": "density_rows",
"expected": 96232,
"actual": 96232,
"ok": true
},
{
"name": "battery_rows",
"expected": 96232,
"actual": 96232,
"ok": true
},
{
"name": "device_ids",
"expected": 12,
"actual": 12,
"ok": true
},
{
"name": "sensor_names",
"expected": 11,
"actual": 11,
"ok": true
},
{
"name": "usable_sensors",
"expected": 8,
"actual": 8,
"ok": true
},
{
"name": "density_01_rows_multi_sensor",
"expected": 12670,
"actual": 12670,
"ok": true
}
],
"all_checks_ok": true
}
+1
View File
@@ -0,0 +1 @@
{"data_version": "2026-11-07T23:51:00Z", "model_version": "histgb-2026-11-14", "context_version": "2026-11-14T03:47:09Z", "generated_at": "2026-11-14T04:03:38Z", "forecast_start": "2026-11-14T05:00:00Z", "forecasts": {"density-01": {"48h": {"base": [{"t": "2026-11-14T05:00:00Z", "v": 1.17, "lo": 0.0, "hi": 6.04}, {"t": "2026-11-14T06:00:00Z", "v": 1.95, "lo": 0.0, "hi": 6.83}, {"t": "2026-11-14T07:00:00Z", "v": 2.94, "lo": 0.0, "hi": 7.81}, {"t": "2026-11-14T08:00:00Z", "v": 4.08, "lo": 0.0, "hi": 8.96}, {"t": "2026-11-14T09:00:00Z", "v": 5.68, "lo": 0.85, "hi": 10.55}, {"t": "2026-11-14T10:00:00Z", "v": 8.5, "lo": 3.67, "hi": 13.38}, {"t": "2026-11-14T11:00:00Z", "v": 9.66, "lo": 4.84, "hi": 14.54}, {"t": "2026-11-14T12:00:00Z", "v": 11.39, "lo": 6.56, "hi": 16.26}, {"t": "2026-11-14T13:00:00Z", "v": 11.32, "lo": 6.5, "hi": 16.2}, {"t": "2026-11-14T14:00:00Z", "v": 12.63, "lo": 7.81, "hi": 17.51}, {"t": "2026-11-14T15:00:00Z", "v": 14.78, "lo": 9.96, "hi": 19.66}, {"t": "2026-11-14T16:00:00Z", "v": 14.21, "lo": 9.39, "hi": 19.09}, {"t": "2026-11-14T17:00:00Z", "v": 14.52, "lo": 9.7, "hi": 19.4}, {"t": "2026-11-14T18:00:00Z", "v": 15.67, "lo": 10.84, "hi": 20.55}, {"t": "2026-11-14T19:00:00Z", "v": 14.37, "lo": 9.55, "hi": 19.25}, {"t": "2026-11-14T20:00:00Z", "v": 12.64, "lo": 7.81, "hi": 17.51}, {"t": "2026-11-14T21:00:00Z", "v": 14.52, "lo": 9.7, "hi": 19.4}, {"t": "2026-11-14T22:00:00Z", "v": 12.33, "lo": 7.5, "hi": 17.21}, {"t": "2026-11-14T23:00:00Z", "v": 9.87, "lo": 5.04, "hi": 14.74}, {"t": "2026-11-15T00:00:00Z", "v": 3.94, "lo": 0.0, "hi": 8.82}, {"t": "2026-11-15T01:00:00Z", "v": 1.34, "lo": 0.0, "hi": 6.22}, {"t": "2026-11-15T02:00:00Z", "v": 1.13, "lo": 0.0, "hi": 6.01}, {"t": "2026-11-15T03:00:00Z", "v": 0.99, "lo": 0.0, "hi": 5.86}, {"t": "2026-11-15T04:00:00Z", "v": 0.99, "lo": 0.0, "hi": 5.86}, {"t": "2026-11-15T05:00:00Z", "v": 1.01, "lo": 0.0, "hi": 5.88}, {"t": "2026-11-15T06:00:00Z", "v": 1.04, "lo": 0.0, "hi": 5.92}, {"t": "2026-11-15T07:00:00Z", "v": 1.55, "lo": 0.0, "hi": 6.43}, {"t": "2026-11-15T08:00:00Z", "v": 1.65, "lo": 0.0, "hi": 6.53}, {"t": "2026-11-15T09:00:00Z", "v": 5.61, "lo": 0.78, "hi": 10.48}, {"t": "2026-11-15T10:00:00Z", "v": 6.5, "lo": 1.68, "hi": 11.38}, {"t": "2026-11-15T11:00:00Z", "v": 7.51, "lo": 2.69, "hi": 12.39}, {"t": "2026-11-15T12:00:00Z", "v": 9.58, "lo": 4.76, "hi": 14.46}, {"t": "2026-11-15T13:00:00Z", "v": 11.7, "lo": 6.88, "hi": 16.58}, {"t": "2026-11-15T14:00:00Z", "v": 18.36, "lo": 13.54, "hi": 23.24}, {"t": "2026-11-15T15:00:00Z", "v": 17.33, "lo": 12.5, "hi": 22.21}, {"t": "2026-11-15T16:00:00Z", "v": 16.04, "lo": 11.21, "hi": 20.91}, {"t": "2026-11-15T17:00:00Z", "v": 11.34, "lo": 6.51, "hi": 16.21}, {"t": "2026-11-15T18:00:00Z", "v": 10.87, "lo": 6.05, "hi": 15.75}, {"t": "2026-11-15T19:00:00Z", "v": 8.45, "lo": 3.63, "hi": 13.33}, {"t": "2026-11-15T20:00:00Z", "v": 5.82, "lo": 0.99, "hi": 10.7}, {"t": "2026-11-15T21:00:00Z", "v": 3.71, "lo": 0.0, "hi": 8.59}, {"t": "2026-11-15T22:00:00Z", "v": 2.11, "lo": 0.0, "hi": 6.99}, {"t": "2026-11-15T23:00:00Z", "v": 1.47, "lo": 0.0, "hi": 6.34}, {"t": "2026-11-16T00:00:00Z", "v": 0.91, "lo": 0.0, "hi": 5.79}, {"t": "2026-11-16T01:00:00Z", "v": 0.88, "lo": 0.0, "hi": 5.76}, {"t": "2026-11-16T02:00:00Z", "v": 1.15, "lo": 0.0, "hi": 6.03}, {"t": "2026-11-16T03:00:00Z", "v": 1.15, "lo": 0.0, "hi": 6.03}, {"t": "2026-11-16T04:00:00Z", "v": 1.74, "lo": 0.0, "hi": 6.62}], "sunny-saturday-market": [{"t": "2026-11-14T05:00:00Z", "v": 1.17, "lo": 0.0, "hi": 6.04}, {"t": "2026-11-14T06:00:00Z", "v": 1.95, "lo": 0.0, "hi": 6.83}, {"t": "2026-11-14T07:00:00Z", "v": 2.94, "lo": 0.0, "hi": 7.81}, {"t": "2026-11-14T08:00:00Z", "v": 4.08, "lo": 0.0, "hi": 8.96}, {"t": "2026-11-14T09:00:00Z", "v": 7.63, "lo": 2.81, "hi": 12.51}, {"t": "2026-11-14T10:00:00Z", "v": 10.14, "lo": 5.32, "hi": 15.02}, {"t": "2026-11-14T11:00:00Z", "v": 11.16, "lo": 6.34, "hi": 16.04}, {"t": "2026-11-14T12:00:00Z", "v": 12.88, "lo": 8.05, "hi": 17.76}, {"t": "2026-11-14T13:00:00Z", "v": 12.02, "lo": 7.2, "hi": 16.9}, {"t": "2026-11-14T14:00:00Z", "v": 17.24, "lo": 12.42, "hi": 22.12}, {"t": "2026-11-14T15:00:00Z", "v": 15.8, "lo": 10.97, "hi": 20.67}, {"t": "2026-11-14T16:00:00Z", "v": 15.97, "lo": 11.15, "hi": 20.85}, {"t": "2026-11-14T17:00:00Z", "v": 15.77, "lo": 10.94, "hi": 20.65}, {"t": "2026-11-14T18:00:00Z", "v": 16.1, "lo": 11.27, "hi": 20.97}, {"t": "2026-11-14T19:00:00Z", "v": 17.49, "lo": 12.67, "hi": 22.37}, {"t": "2026-11-14T20:00:00Z", "v": 12.64, "lo": 7.81, "hi": 17.51}, {"t": "2026-11-14T21:00:00Z", "v": 14.52, "lo": 9.7, "hi": 19.4}, {"t": "2026-11-14T22:00:00Z", "v": 12.33, "lo": 7.5, "hi": 17.21}, {"t": "2026-11-14T23:00:00Z", "v": 9.87, "lo": 5.04, "hi": 14.74}, {"t": "2026-11-15T00:00:00Z", "v": 3.94, "lo": 0.0, "hi": 8.82}, {"t": "2026-11-15T01:00:00Z", "v": 1.34, "lo": 0.0, "hi": 6.22}, {"t": "2026-11-15T02:00:00Z", "v": 1.13, "lo": 0.0, "hi": 6.01}, {"t": "2026-11-15T03:00:00Z", "v": 0.99, "lo": 0.0, "hi": 5.86}, {"Line truncated
+100
View File
@@ -0,0 +1,100 @@
{
"data_version": "2026-11-07T23:51:00Z",
"model_version": "histgb-2026-11-14",
"context_version": "2026-11-14T03:47:09Z",
"coverage": {
"sensors": 8,
"from": "2026-06-12T00:00:00Z",
"to": "2026-11-07T23:51:00Z",
"cadence_min": 15
},
"metrics": {
"model": "weather-7d",
"mae": 3.32,
"wape": 27.5,
"r2": 0.777,
"baseline": "seasonal_naive",
"baseline_mae": 5.4,
"baseline_wape": 44.7,
"baseline_r2": 0.462,
"n_eval": 5350
},
"trained_at": "2026-11-14T04:03:37Z",
"train_from": "2026-06-12T00:00:00Z",
"train_to": "2026-11-07T23:00:00Z",
"test_from": "2026-10-10T23:00:00Z",
"test_to": "2026-11-07T23:00:00Z",
"features": [
"hour",
"weekday",
"month",
"is_weekend",
"is_holiday",
"sensor_code",
"lag_week",
"seasonal_mean_4w",
"temp_c",
"precip_mm"
],
"holiday_effect": {
"mae_delta": -0.12,
"note": "Holiday flag alone changes MAE by this amount on the holdout; weather is the main driver, holidays are context."
},
"ablation": [
{
"name": "seasonal_naive",
"description": "exact 168-row lag (same observed hour last week)",
"mae": 5.4,
"wape": 44.7,
"r2": 0.462,
"n": 5350
},
{
"name": "day_no_weather",
"description": "calendar + lags 24/48/168 + 24h/168h rolling means",
"mae": 3.96,
"wape": 32.8,
"r2": 0.706,
"n": 5350
},
{
"name": "day_holiday",
"description": "day-ahead + Baden-Württemberg holiday flag",
"mae": 3.84,
"wape": 31.8,
"r2": 0.732,
"n": 5350
},
{
"name": "day_weather",
"description": "day-ahead + temperature + rain (observed weather)",
"mae": 3.36,
"wape": 27.8,
"r2": 0.763,
"n": 5350
},
{
"name": "week_no_weather",
"description": "7-day-safe calendar + previous same weekday/hour values",
"mae": 4.08,
"wape": 33.8,
"r2": 0.697,
"n": 5350
},
{
"name": "week_weather",
"description": "7-day-safe + temperature + rain (production model)",
"mae": 3.32,
"wape": 27.5,
"r2": 0.777,
"n": 5350
}
],
"limits": [
"estimated devices, not people",
"8 sensors in a ~580 m inner-city cluster",
"5 months of multi-sensor data; no annual seasonality claim",
"observed weather in training, forecast weather in scenarios",
"holidays are context, not a large accuracy claim"
]
}
Binary file not shown.
+82
View File
@@ -0,0 +1,82 @@
[
{
"id": "density-01",
"name": "Density 01",
"lat": 49.143404,
"lon": 9.217465,
"mean": 9.9,
"p95": 28.0,
"battery": 11,
"last_seen": "2026-11-07T23:48:49Z"
},
{
"id": "hn-goetzentuem-01",
"name": "Götzenturm",
"lat": 49.139958,
"lon": 9.214804,
"mean": 11.1,
"p95": 29.4,
"battery": 0,
"last_seen": "2026-11-07T23:39:53Z"
},
{
"id": "hn-hagenbuchersee-01",
"name": "Hagenbuchersee 1",
"lat": 49.144402,
"lon": 9.217198,
"mean": 13.0,
"p95": 49.7,
"battery": 43,
"last_seen": "2026-11-07T23:46:49Z"
},
{
"id": "hn-hagenbuchersee-02",
"name": "Hagenbuchersee 2",
"lat": 49.14391,
"lon": 9.21695,
"mean": 19.3,
"p95": 64.4,
"battery": 27,
"last_seen": "2026-11-07T23:51:57Z"
},
{
"id": "hn-marahaus-01",
"name": "Marahaus",
"lat": 49.141541,
"lon": 9.215912,
"mean": 13.7,
"p95": 38.5,
"battery": 87,
"last_seen": "2026-11-07T23:49:35Z"
},
{
"id": "hn-neckarufer-01",
"name": "Neckarufer",
"lat": 49.143313,
"lon": 9.216612,
"mean": 19.2,
"p95": 61.6,
"battery": 11,
"last_seen": "2026-11-07T23:49:20Z"
},
{
"id": "hn-soleo-01",
"name": "Soleo",
"lat": 49.144933,
"lon": 9.217393,
"mean": 10.6,
"p95": 28.0,
"battery": 26,
"last_seen": "2026-11-07T23:32:32Z"
},
{
"id": "hn-stadtgalerie-01",
"name": "Stadtgalerie",
"lat": 49.140242,
"lon": 9.218699,
"mean": 21.1,
"p95": 67.2,
"battery": 75,
"last_seen": "2026-11-07T23:26:29Z"
}
]
+1
View File
@@ -0,0 +1 @@
{"step": "1h", "data_version": "2026-11-07T23:51:00Z", "series": {"density-01": [{"t": "2026-06-12T00:00:00Z", "v": 0.93}, {"t": "2026-06-12T01:00:00Z", "v": 0.7}, {"t": "2026-06-12T02:00:00Z", "v": 1.05}, {"t": "2026-06-12T03:00:00Z", "v": 1.57}, {"t": "2026-06-12T04:00:00Z", "v": 2.57}, {"t": "2026-06-12T05:00:00Z", "v": 4.72}, {"t": "2026-06-12T06:00:00Z", "v": 5.42}, {"t": "2026-06-12T07:00:00Z", "v": 6.77}, {"t": "2026-06-12T08:00:00Z", "v": 6.3}, {"t": "2026-06-12T09:00:00Z", "v": 10.15}, {"t": "2026-06-12T10:00:00Z", "v": 9.62}, {"t": "2026-06-12T11:00:00Z", "v": 8.17}, {"t": "2026-06-12T12:00:00Z", "v": 6.82}, {"t": "2026-06-12T13:00:00Z", "v": 9.1}, {"t": "2026-06-12T14:00:00Z", "v": 8.75}, {"t": "2026-06-12T15:00:00Z", "v": 12.78}, {"t": "2026-06-12T16:00:00Z", "v": 13.12}, {"t": "2026-06-12T17:00:00Z", "v": 12.25}, {"t": "2026-06-12T18:00:00Z", "v": 12.37}, {"t": "2026-06-12T19:00:00Z", "v": 17.85}, {"t": "2026-06-12T20:00:00Z", "v": 14.7}, {"t": "2026-06-12T21:00:00Z", "v": 11.67}, {"t": "2026-06-12T22:00:00Z", "v": 7.35}, {"t": "2026-06-12T23:00:00Z", "v": 4.03}, {"t": "2026-06-13T00:00:00Z", "v": 3.15}, {"t": "2026-06-13T01:00:00Z", "v": 3.5}, {"t": "2026-06-13T02:00:00Z", "v": 2.27}, {"t": "2026-06-13T03:00:00Z", "v": 2.45}, {"t": "2026-06-13T04:00:00Z", "v": 0.23}, {"t": "2026-06-13T05:00:00Z", "v": 1.23}, {"t": "2026-06-13T06:00:00Z", "v": 1.05}, {"t": "2026-06-13T07:00:00Z", "v": 4.2}, {"t": "2026-06-13T08:00:00Z", "v": 8.4}, {"t": "2026-06-13T09:00:00Z", "v": 6.47}, {"t": "2026-06-13T10:00:00Z", "v": 12.43}, {"t": "2026-06-13T11:00:00Z", "v": 11.43}, {"t": "2026-06-13T12:00:00Z", "v": 17.32}, {"t": "2026-06-13T13:00:00Z", "v": 17.85}, {"t": "2026-06-13T14:00:00Z", "v": 20.82}, {"t": "2026-06-13T15:00:00Z", "v": 22.87}, {"t": "2026-06-13T16:00:00Z", "v": 26.25}, {"t": "2026-06-13T17:00:00Z", "v": 33.95}, {"t": "2026-06-13T18:00:00Z", "v": 35.52}, {"t": "2026-06-13T19:00:00Z", "v": 33.13}, {"t": "2026-06-13T20:00:00Z", "v": 22.4}, {"t": "2026-06-13T21:00:00Z", "v": 16.62}, {"t": "2026-06-13T22:00:00Z", "v": 11.67}, {"t": "2026-06-13T23:00:00Z", "v": 8.57}, {"t": "2026-06-14T00:00:00Z", "v": 4.9}, {"t": "2026-06-14T01:00:00Z", "v": 2.1}, {"t": "2026-06-14T02:00:00Z", "v": 1.63}, {"t": "2026-06-14T03:00:00Z", "v": 1.23}, {"t": "2026-06-14T04:00:00Z", "v": 2.62}, {"t": "2026-06-14T05:00:00Z", "v": 1.63}, {"t": "2026-06-14T06:00:00Z", "v": 3.5}, {"t": "2026-06-14T07:00:00Z", "v": 7.0}, {"t": "2026-06-14T08:00:00Z", "v": 7.47}, {"t": "2026-06-14T09:00:00Z", "v": 8.87}, {"t": "2026-06-14T10:00:00Z", "v": 10.5}, {"t": "2026-06-14T11:00:00Z", "v": 11.9}, {"t": "2026-06-14T12:00:00Z", "v": 13.07}, {"t": "2026-06-14T13:00:00Z", "v": 15.57}, {"t": "2026-06-14T14:00:00Z", "v": 19.25}, {"t": "2026-06-14T15:00:00Z", "v": 14.88}, {"t": "2026-06-14T16:00:00Z", "v": 20.3}, {"t": "2026-06-14T17:00:00Z", "v": 21.18}, {"t": "2026-06-14T18:00:00Z", "v": 25.55}, {"t": "2026-06-14T19:00:00Z", "v": 17.85}, {"t": "2026-06-14T20:00:00Z", "v": 12.6}, {"t": "2026-06-14T21:00:00Z", "v": 10.68}, {"t": "2026-06-14T22:00:00Z", "v": 3.5}, {"t": "2026-06-14T23:00:00Z", "v": 3.5}, {"t": "2026-06-15T00:00:00Z", "v": 2.1}, {"t": "2026-06-15T01:00:00Z", "v": 0.52}, {"t": "2026-06-15T02:00:00Z", "v": 1.4}, {"t": "2026-06-15T03:00:00Z", "v": 1.57}, {"t": "2026-06-15T04:00:00Z", "v": 3.15}, {"t": "2026-06-15T05:00:00Z", "v": 3.68}, {"t": "2026-06-15T06:00:00Z", "v": 5.13}, {"t": "2026-06-15T07:00:00Z", "v": 6.12}, {"t": "2026-06-15T08:00:00Z", "v": 7.0}, {"t": "2026-06-15T09:00:00Z", "v": 10.5}, {"t": "2026-06-15T10:00:00Z", "v": 13.3}, {"t": "2026-06-15T11:00:00Z", "v": 11.03}, {"t": "2026-06-15T12:00:00Z", "v": 7.35}, {"t": "2026-06-15T13:00:00Z", "v": 14.47}, {"t": "2026-06-15T14:00:00Z", "v": 11.9}, {"t": "2026-06-15T15:00:00Z", "v": 19.25}, {"t": "2026-06-15T16:00:00Z", "v": 15.63}, {"t": "2026-06-15T17:00:00Z", "v": 12.78}, {"t": "2026-06-15T18:00:00Z", "v": 12.07}, {"t": "2026-06-15T19:00:00Z", "v": 10.32}, {"t": "2026-06-15T20:00:00Z", "v": 5.37}, {"t": "2026-06-15T21:00:00Z", "v": 8.93}, {"t": "2026-06-15T22:00:00Z", "v": 5.25}, {"t": "2026-06-15T23:00:00Z", "v": 3.5}, {"t": "2026-06-16T00:00:00Z", "v": 3.27}, {"t": "2026-06-16T01:00:00Z", "v": 2.8}, {"t": "2026-06-16T02:00:00Z", "v": 2.8}, {"t": "2026-06-16T03:00:00Z", "v": 2.57}, {"t": "2026-06-16T04:00:00Z", "v": 3.33}, {"t": "2026-06-16T05:00:00Z", "v": 4.9}, {"t": "2026-06-16T06:00:00Z", "v": 6.83}, {"t": "2026-06-16T07:00:00Z", "v": 6.53}, {"t": "2026-06-16T08:00:00Z", "v": 10.32}, {"t": "2026-06-16T09:00:00Z", "v": 7.53}, {"t": "2026-06-16T10:00:00Z", "v": 13.53}, {"t": "2026-06-16T11:00:00Z", "v": 11.03}, {"t": "2026-06-16T12:00:00Z", "v": 9.8}, {"t": "2026-06-16T13:00:00Z", "v": 12.42}, {"t": "2026-06-16T14:00:00Z", "v": 13.77}, {"t": "2026-06-16T15:00:00Z", "v": 16.45}, {"t": "2026-06-16T16:00:00Z", "v": 16.45}, {"t": "2026-06-16T17:00:00Z", "v": 28.47}, {"t": "2026-06-16T18:00:00Z", "v": 24.5}, {"t": "2026-06-16T19:00:00Z", "v": 17.5}, {"t": "2026-06-16T20:00:Line truncated
+1
View File
@@ -0,0 +1 @@
{"sensor": "density-01", "step": "1h", "points": [{"t": "2026-06-12T00:00:00Z", "v": 0.93}, {"t": "2026-06-12T01:00:00Z", "v": 0.7}, {"t": "2026-06-12T02:00:00Z", "v": 1.05}, {"t": "2026-06-12T03:00:00Z", "v": 1.57}, {"t": "2026-06-12T04:00:00Z", "v": 2.57}, {"t": "2026-06-12T05:00:00Z", "v": 4.72}, {"t": "2026-06-12T06:00:00Z", "v": 5.42}, {"t": "2026-06-12T07:00:00Z", "v": 6.77}, {"t": "2026-06-12T08:00:00Z", "v": 6.3}, {"t": "2026-06-12T09:00:00Z", "v": 10.15}, {"t": "2026-06-12T10:00:00Z", "v": 9.62}, {"t": "2026-06-12T11:00:00Z", "v": 8.17}, {"t": "2026-06-12T12:00:00Z", "v": 6.82}, {"t": "2026-06-12T13:00:00Z", "v": 9.1}, {"t": "2026-06-12T14:00:00Z", "v": 8.75}, {"t": "2026-06-12T15:00:00Z", "v": 12.78}, {"t": "2026-06-12T16:00:00Z", "v": 13.12}, {"t": "2026-06-12T17:00:00Z", "v": 12.25}, {"t": "2026-06-12T18:00:00Z", "v": 12.37}, {"t": "2026-06-12T19:00:00Z", "v": 17.85}, {"t": "2026-06-12T20:00:00Z", "v": 14.7}, {"t": "2026-06-12T21:00:00Z", "v": 11.67}, {"t": "2026-06-12T22:00:00Z", "v": 7.35}, {"t": "2026-06-12T23:00:00Z", "v": 4.03}, {"t": "2026-06-13T00:00:00Z", "v": 3.15}, {"t": "2026-06-13T01:00:00Z", "v": 3.5}, {"t": "2026-06-13T02:00:00Z", "v": 2.27}, {"t": "2026-06-13T03:00:00Z", "v": 2.45}, {"t": "2026-06-13T04:00:00Z", "v": 0.23}, {"t": "2026-06-13T05:00:00Z", "v": 1.23}, {"t": "2026-06-13T06:00:00Z", "v": 1.05}, {"t": "2026-06-13T07:00:00Z", "v": 4.2}, {"t": "2026-06-13T08:00:00Z", "v": 8.4}, {"t": "2026-06-13T09:00:00Z", "v": 6.47}, {"t": "2026-06-13T10:00:00Z", "v": 12.43}, {"t": "2026-06-13T11:00:00Z", "v": 11.43}, {"t": "2026-06-13T12:00:00Z", "v": 17.32}, {"t": "2026-06-13T13:00:00Z", "v": 17.85}, {"t": "2026-06-13T14:00:00Z", "v": 20.82}, {"t": "2026-06-13T15:00:00Z", "v": 22.87}, {"t": "2026-06-13T16:00:00Z", "v": 26.25}, {"t": "2026-06-13T17:00:00Z", "v": 33.95}, {"t": "2026-06-13T18:00:00Z", "v": 35.52}, {"t": "2026-06-13T19:00:00Z", "v": 33.13}, {"t": "2026-06-13T20:00:00Z", "v": 22.4}, {"t": "2026-06-13T21:00:00Z", "v": 16.62}, {"t": "2026-06-13T22:00:00Z", "v": 11.67}, {"t": "2026-06-13T23:00:00Z", "v": 8.57}, {"t": "2026-06-14T00:00:00Z", "v": 4.9}, {"t": "2026-06-14T01:00:00Z", "v": 2.1}, {"t": "2026-06-14T02:00:00Z", "v": 1.63}, {"t": "2026-06-14T03:00:00Z", "v": 1.23}, {"t": "2026-06-14T04:00:00Z", "v": 2.62}, {"t": "2026-06-14T05:00:00Z", "v": 1.63}, {"t": "2026-06-14T06:00:00Z", "v": 3.5}, {"t": "2026-06-14T07:00:00Z", "v": 7.0}, {"t": "2026-06-14T08:00:00Z", "v": 7.47}, {"t": "2026-06-14T09:00:00Z", "v": 8.87}, {"t": "2026-06-14T10:00:00Z", "v": 10.5}, {"t": "2026-06-14T11:00:00Z", "v": 11.9}, {"t": "2026-06-14T12:00:00Z", "v": 13.07}, {"t": "2026-06-14T13:00:00Z", "v": 15.57}, {"t": "2026-06-14T14:00:00Z", "v": 19.25}, {"t": "2026-06-14T15:00:00Z", "v": 14.88}, {"t": "2026-06-14T16:00:00Z", "v": 20.3}, {"t": "2026-06-14T17:00:00Z", "v": 21.18}, {"t": "2026-06-14T18:00:00Z", "v": 25.55}, {"t": "2026-06-14T19:00:00Z", "v": 17.85}, {"t": "2026-06-14T20:00:00Z", "v": 12.6}, {"t": "2026-06-14T21:00:00Z", "v": 10.68}, {"t": "2026-06-14T22:00:00Z", "v": 3.5}, {"t": "2026-06-14T23:00:00Z", "v": 3.5}, {"t": "2026-06-15T00:00:00Z", "v": 2.1}, {"t": "2026-06-15T01:00:00Z", "v": 0.52}, {"t": "2026-06-15T02:00:00Z", "v": 1.4}, {"t": "2026-06-15T03:00:00Z", "v": 1.57}, {"t": "2026-06-15T04:00:00Z", "v": 3.15}, {"t": "2026-06-15T05:00:00Z", "v": 3.68}, {"t": "2026-06-15T06:00:00Z", "v": 5.13}, {"t": "2026-06-15T07:00:00Z", "v": 6.12}, {"t": "2026-06-15T08:00:00Z", "v": 7.0}, {"t": "2026-06-15T09:00:00Z", "v": 10.5}, {"t": "2026-06-15T10:00:00Z", "v": 13.3}, {"t": "2026-06-15T11:00:00Z", "v": 11.03}, {"t": "2026-06-15T12:00:00Z", "v": 7.35}, {"t": "2026-06-15T13:00:00Z", "v": 14.47}, {"t": "2026-06-15T14:00:00Z", "v": 11.9}, {"t": "2026-06-15T15:00:00Z", "v": 19.25}, {"t": "2026-06-15T16:00:00Z", "v": 15.63}, {"t": "2026-06-15T17:00:00Z", "v": 12.78}, {"t": "2026-06-15T18:00:00Z", "v": 12.07}, {"t": "2026-06-15T19:00:00Z", "v": 10.32}, {"t": "2026-06-15T20:00:00Z", "v": 5.37}, {"t": "2026-06-15T21:00:00Z", "v": 8.93}, {"t": "2026-06-15T22:00:00Z", "v": 5.25}, {"t": "2026-06-15T23:00:00Z", "v": 3.5}, {"t": "2026-06-16T00:00:00Z", "v": 3.27}, {"t": "2026-06-16T01:00:00Z", "v": 2.8}, {"t": "2026-06-16T02:00:00Z", "v": 2.8}, {"t": "2026-06-16T03:00:00Z", "v": 2.57}, {"t": "2026-06-16T04:00:00Z", "v": 3.33}, {"t": "2026-06-16T05:00:00Z", "v": 4.9}, {"t": "2026-06-16T06:00:00Z", "v": 6.83}, {"t": "2026-06-16T07:00:00Z", "v": 6.53}, {"t": "2026-06-16T08:00:00Z", "v": 10.32}, {"t": "2026-06-16T09:00:00Z", "v": 7.53}, {"t": "2026-06-16T10:00:00Z", "v": 13.53}, {"t": "2026-06-16T11:00:00Z", "v": 11.03}, {"t": "2026-06-16T12:00:00Z", "v": 9.8}, {"t": "2026-06-16T13:00:00Z", "v": 12.42}, {"t": "2026-06-16T14:00:00Z", "v": 13.77}, {"t": "2026-06-16T15:00:00Z", "v": 16.45}, {"t": "2026-06-16T16:00:00Z", "v": 16.45}, {"t": "2026-06-16T17:00:00Z", "v": 28.47}, {"t": "2026-06-16T18:00:00Z", "v": 24.5}, {"t": "2026-06-16T19:00:00Z", "v": 17.5}, {"t": "2026-06-16T20:00:00Z", "v": 9.8}, {"t": "2026-06Line truncated
+1
View File
@@ -0,0 +1 @@
{"sensor": "hn-goetzentuem-01", "step": "1h", "points": [{"t": "2026-06-12T12:00:00Z", "v": 10.5}, {"t": "2026-06-17T16:00:00Z", "v": 33.25}, {"t": "2026-06-17T17:00:00Z", "v": 33.83}, {"t": "2026-06-17T18:00:00Z", "v": 31.03}, {"t": "2026-06-17T19:00:00Z", "v": 16.57}, {"t": "2026-06-17T20:00:00Z", "v": 11.9}, {"t": "2026-06-17T21:00:00Z", "v": 9.57}, {"t": "2026-06-17T22:00:00Z", "v": 7.17}, {"t": "2026-06-17T23:00:00Z", "v": 1.75}, {"t": "2026-06-18T00:00:00Z", "v": 2.33}, {"t": "2026-06-18T01:00:00Z", "v": 0.35}, {"t": "2026-06-18T02:00:00Z", "v": 1.75}, {"t": "2026-06-18T03:00:00Z", "v": 1.75}, {"t": "2026-06-18T04:00:00Z", "v": 4.9}, {"t": "2026-06-18T05:00:00Z", "v": 4.9}, {"t": "2026-06-18T06:00:00Z", "v": 8.63}, {"t": "2026-06-18T07:00:00Z", "v": 8.17}, {"t": "2026-06-18T08:00:00Z", "v": 6.12}, {"t": "2026-06-18T09:00:00Z", "v": 10.85}, {"t": "2026-06-18T10:00:00Z", "v": 12.13}, {"t": "2026-06-18T11:00:00Z", "v": 10.5}, {"t": "2026-06-18T12:00:00Z", "v": 11.72}, {"t": "2026-06-18T13:00:00Z", "v": 11.9}, {"t": "2026-06-18T14:00:00Z", "v": 15.93}, {"t": "2026-06-18T15:00:00Z", "v": 25.9}, {"t": "2026-06-18T16:00:00Z", "v": 43.4}, {"t": "2026-06-18T17:00:00Z", "v": 55.3}, {"t": "2026-06-18T18:00:00Z", "v": 98.17}, {"t": "2026-06-18T19:00:00Z", "v": 121.97}, {"t": "2026-06-18T20:00:00Z", "v": 101.5}, {"t": "2026-06-18T21:00:00Z", "v": 69.07}, {"t": "2026-06-18T22:00:00Z", "v": 24.5}, {"t": "2026-06-18T23:00:00Z", "v": 2.1}, {"t": "2026-06-19T00:00:00Z", "v": 2.98}, {"t": "2026-06-19T01:00:00Z", "v": 1.05}, {"t": "2026-06-19T02:00:00Z", "v": 2.8}, {"t": "2026-06-19T03:00:00Z", "v": 0.0}, {"t": "2026-06-19T04:00:00Z", "v": 3.73}, {"t": "2026-06-19T05:00:00Z", "v": 6.3}, {"t": "2026-06-19T06:00:00Z", "v": 8.93}, {"t": "2026-06-19T07:00:00Z", "v": 7.35}, {"t": "2026-06-19T08:00:00Z", "v": 7.93}, {"t": "2026-06-19T09:00:00Z", "v": 8.22}, {"t": "2026-06-19T10:00:00Z", "v": 12.6}, {"t": "2026-06-19T11:00:00Z", "v": 9.28}, {"t": "2026-06-19T12:00:00Z", "v": 10.5}, {"t": "2026-06-19T13:00:00Z", "v": 17.27}, {"t": "2026-06-19T14:00:00Z", "v": 21.23}, {"t": "2026-06-19T15:00:00Z", "v": 26.6}, {"t": "2026-06-19T16:00:00Z", "v": 41.53}, {"t": "2026-06-19T17:00:00Z", "v": 81.9}, {"t": "2026-06-19T18:00:00Z", "v": 130.03}, {"t": "2026-06-19T19:00:00Z", "v": 180.25}, {"t": "2026-06-19T20:00:00Z", "v": 186.43}, {"t": "2026-06-19T21:00:00Z", "v": 132.53}, {"t": "2026-06-19T22:00:00Z", "v": 58.8}, {"t": "2026-06-19T23:00:00Z", "v": 7.0}, {"t": "2026-06-20T00:00:00Z", "v": 1.93}, {"t": "2026-06-20T01:00:00Z", "v": 0.7}, {"t": "2026-06-20T02:00:00Z", "v": 0.93}, {"t": "2026-06-20T03:00:00Z", "v": 0.47}, {"t": "2026-06-20T04:00:00Z", "v": 2.33}, {"t": "2026-06-20T05:00:00Z", "v": 3.85}, {"t": "2026-06-20T06:00:00Z", "v": 9.8}, {"t": "2026-06-20T07:00:00Z", "v": 24.85}, {"t": "2026-06-20T08:00:00Z", "v": 37.1}, {"t": "2026-06-20T09:00:00Z", "v": 77.0}, {"t": "2026-06-20T10:00:00Z", "v": 112.93}, {"t": "2026-06-20T11:00:00Z", "v": 112.0}, {"t": "2026-06-20T12:00:00Z", "v": 132.12}, {"t": "2026-06-20T13:00:00Z", "v": 111.12}, {"t": "2026-06-20T14:00:00Z", "v": 127.57}, {"t": "2026-06-20T15:00:00Z", "v": 113.87}, {"t": "2026-06-20T16:00:00Z", "v": 105.7}, {"t": "2026-06-20T17:00:00Z", "v": 91.17}, {"t": "2026-06-20T18:00:00Z", "v": 150.73}, {"t": "2026-06-20T19:00:00Z", "v": 154.88}, {"t": "2026-06-20T20:00:00Z", "v": 175.23}, {"t": "2026-06-20T21:00:00Z", "v": 133.88}, {"t": "2026-06-20T22:00:00Z", "v": 65.45}, {"t": "2026-06-20T23:00:00Z", "v": 14.93}, {"t": "2026-06-21T00:00:00Z", "v": 6.83}, {"t": "2026-06-21T01:00:00Z", "v": 7.47}, {"t": "2026-06-21T02:00:00Z", "v": 2.98}, {"t": "2026-06-21T03:00:00Z", "v": 2.8}, {"t": "2026-06-21T04:00:00Z", "v": 1.17}, {"t": "2026-06-21T05:00:00Z", "v": 2.1}, {"t": "2026-06-21T06:00:00Z", "v": 5.37}, {"t": "2026-06-21T07:00:00Z", "v": 11.02}, {"t": "2026-06-21T08:00:00Z", "v": 14.7}, {"t": "2026-06-21T09:00:00Z", "v": 8.4}, {"t": "2026-06-21T10:00:00Z", "v": 8.75}, {"t": "2026-06-21T11:00:00Z", "v": 8.75}, {"t": "2026-06-21T12:00:00Z", "v": 9.28}, {"t": "2026-06-21T13:00:00Z", "v": 9.45}, {"t": "2026-06-21T14:00:00Z", "v": 11.43}, {"t": "2026-06-21T15:00:00Z", "v": 8.17}, {"t": "2026-06-21T16:00:00Z", "v": 14.35}, {"t": "2026-06-21T17:00:00Z", "v": 14.18}, {"t": "2026-06-21T18:00:00Z", "v": 17.68}, {"t": "2026-06-21T19:00:00Z", "v": 12.78}, {"t": "2026-06-21T20:00:00Z", "v": 8.57}, {"t": "2026-06-21T21:00:00Z", "v": 4.55}, {"t": "2026-06-21T22:00:00Z", "v": 2.45}, {"t": "2026-06-21T23:00:00Z", "v": 2.33}, {"t": "2026-06-22T00:00:00Z", "v": 0.93}, {"t": "2026-06-22T01:00:00Z", "v": 0.88}, {"t": "2026-06-22T02:00:00Z", "v": 0.7}, {"t": "2026-06-22T03:00:00Z", "v": 1.75}, {"t": "2026-06-22T04:00:00Z", "v": 3.5}, {"t": "2026-06-22T05:00:00Z", "v": 8.87}, {"t": "2026-06-22T06:00:00Z", "v": 7.0}, {"t": "2026-06-22T07:00:00Z", "v": 4.03}, {"t": "2026-06-22T08:00:00Z", "v": 8.4}, {"t": "2026-06-22T09:00:00Z", "v": 8.87}, {"t": "2026-06-22T10:00:00Z", "v": 8.75}, {"t": "2026-06-22T11:00:00Z", "vLine truncated
@@ -0,0 +1 @@
{"sensor": "hn-hagenbuchersee-01", "step": "1h", "points": [{"t": "2026-06-12T12:00:00Z", "v": 8.4}, {"t": "2026-06-16T18:00:00Z", "v": 54.6}, {"t": "2026-06-16T19:00:00Z", "v": 48.65}, {"t": "2026-06-16T20:00:00Z", "v": 27.48}, {"t": "2026-06-16T21:00:00Z", "v": 19.25}, {"t": "2026-06-16T22:00:00Z", "v": 5.95}, {"t": "2026-06-16T23:00:00Z", "v": 1.63}, {"t": "2026-06-17T00:00:00Z", "v": 3.15}, {"t": "2026-06-17T01:00:00Z", "v": 2.1}, {"t": "2026-06-17T02:00:00Z", "v": 2.1}, {"t": "2026-06-17T03:00:00Z", "v": 2.1}, {"t": "2026-06-17T04:00:00Z", "v": 2.27}, {"t": "2026-06-17T05:00:00Z", "v": 5.08}, {"t": "2026-06-17T06:00:00Z", "v": 5.95}, {"t": "2026-06-17T07:00:00Z", "v": 8.93}, {"t": "2026-06-17T08:00:00Z", "v": 5.6}, {"t": "2026-06-17T09:00:00Z", "v": 13.3}, {"t": "2026-06-17T10:00:00Z", "v": 14.18}, {"t": "2026-06-17T11:00:00Z", "v": 14.18}, {"t": "2026-06-17T12:00:00Z", "v": 7.88}, {"t": "2026-06-17T13:00:00Z", "v": 18.2}, {"t": "2026-06-17T14:00:00Z", "v": 18.38}, {"t": "2026-06-17T15:00:00Z", "v": 28.35}, {"t": "2026-06-17T16:00:00Z", "v": 43.05}, {"t": "2026-06-17T17:00:00Z", "v": 70.7}, {"t": "2026-06-17T18:00:00Z", "v": 79.33}, {"t": "2026-06-17T19:00:00Z", "v": 84.7}, {"t": "2026-06-17T20:00:00Z", "v": 46.2}, {"t": "2026-06-17T21:00:00Z", "v": 25.2}, {"t": "2026-06-17T22:00:00Z", "v": 9.28}, {"t": "2026-06-17T23:00:00Z", "v": 4.38}, {"t": "2026-06-18T00:00:00Z", "v": 3.67}, {"t": "2026-06-18T01:00:00Z", "v": 0.7}, {"t": "2026-06-18T02:00:00Z", "v": 1.4}, {"t": "2026-06-18T03:00:00Z", "v": 0.88}, {"t": "2026-06-18T04:00:00Z", "v": 1.63}, {"t": "2026-06-18T05:00:00Z", "v": 3.85}, {"t": "2026-06-18T06:00:00Z", "v": 5.6}, {"t": "2026-06-18T07:00:00Z", "v": 6.47}, {"t": "2026-06-18T08:00:00Z", "v": 5.42}, {"t": "2026-06-18T09:00:00Z", "v": 12.43}, {"t": "2026-06-18T10:00:00Z", "v": 13.3}, {"t": "2026-06-18T11:00:00Z", "v": 12.78}, {"t": "2026-06-18T12:00:00Z", "v": 10.97}, {"t": "2026-06-18T13:00:00Z", "v": 11.9}, {"t": "2026-06-18T14:00:00Z", "v": 16.57}, {"t": "2026-06-18T15:00:00Z", "v": 46.38}, {"t": "2026-06-18T16:00:00Z", "v": 79.33}, {"t": "2026-06-18T17:00:00Z", "v": 123.2}, {"t": "2026-06-18T18:00:00Z", "v": 201.6}, {"t": "2026-06-18T19:00:00Z", "v": 198.28}, {"t": "2026-06-18T20:00:00Z", "v": 231.88}, {"t": "2026-06-18T21:00:00Z", "v": 196.53}, {"t": "2026-06-18T22:00:00Z", "v": 47.95}, {"t": "2026-06-18T23:00:00Z", "v": 18.43}, {"t": "2026-06-19T00:00:00Z", "v": 2.8}, {"t": "2026-06-19T01:00:00Z", "v": 2.27}, {"t": "2026-06-19T02:00:00Z", "v": 2.27}, {"t": "2026-06-19T03:00:00Z", "v": 1.75}, {"t": "2026-06-19T04:00:00Z", "v": 1.05}, {"t": "2026-06-19T05:00:00Z", "v": 4.2}, {"t": "2026-06-19T06:00:00Z", "v": 5.42}, {"t": "2026-06-19T07:00:00Z", "v": 5.6}, {"t": "2026-06-19T08:00:00Z", "v": 6.83}, {"t": "2026-06-19T09:00:00Z", "v": 10.73}, {"t": "2026-06-19T10:00:00Z", "v": 12.07}, {"t": "2026-06-19T11:00:00Z", "v": 10.32}, {"t": "2026-06-19T12:00:00Z", "v": 6.12}, {"t": "2026-06-19T13:00:00Z", "v": 10.15}, {"t": "2026-06-19T14:00:00Z", "v": 13.12}, {"t": "2026-06-19T15:00:00Z", "v": 32.2}, {"t": "2026-06-19T16:00:00Z", "v": 56.93}, {"t": "2026-06-19T17:00:00Z", "v": 122.85}, {"t": "2026-06-19T18:00:00Z", "v": 173.95}, {"t": "2026-06-19T19:00:00Z", "v": 222.6}, {"t": "2026-06-19T20:00:00Z", "v": 238.0}, {"t": "2026-06-19T21:00:00Z", "v": 230.12}, {"t": "2026-06-19T22:00:00Z", "v": 94.5}, {"t": "2026-06-19T23:00:00Z", "v": 26.95}, {"t": "2026-06-20T00:00:00Z", "v": 4.72}, {"t": "2026-06-20T01:00:00Z", "v": 1.4}, {"t": "2026-06-20T02:00:00Z", "v": 2.62}, {"t": "2026-06-20T03:00:00Z", "v": 2.33}, {"t": "2026-06-20T04:00:00Z", "v": 1.93}, {"t": "2026-06-20T05:00:00Z", "v": 2.98}, {"t": "2026-06-20T06:00:00Z", "v": 6.47}, {"t": "2026-06-20T07:00:00Z", "v": 7.7}, {"t": "2026-06-20T08:00:00Z", "v": 6.65}, {"t": "2026-06-20T09:00:00Z", "v": 11.2}, {"t": "2026-06-20T10:00:00Z", "v": 17.15}, {"t": "2026-06-20T11:00:00Z", "v": 25.73}, {"t": "2026-06-20T12:00:00Z", "v": 36.92}, {"t": "2026-06-20T13:00:00Z", "v": 56.18}, {"t": "2026-06-20T14:00:00Z", "v": 60.38}, {"t": "2026-06-20T15:00:00Z", "v": 91.17}, {"t": "2026-06-20T16:00:00Z", "v": 109.43}, {"t": "2026-06-20T17:00:00Z", "v": 121.8}, {"t": "2026-06-20T18:00:00Z", "v": 182.7}, {"t": "2026-06-20T19:00:00Z", "v": 199.5}, {"t": "2026-06-20T20:00:00Z", "v": 208.25}, {"t": "2026-06-20T21:00:00Z", "v": 206.68}, {"t": "2026-06-20T22:00:00Z", "v": 120.22}, {"t": "2026-06-20T23:00:00Z", "v": 55.82}, {"t": "2026-06-21T00:00:00Z", "v": 15.05}, {"t": "2026-06-21T01:00:00Z", "v": 9.62}, {"t": "2026-06-21T02:00:00Z", "v": 4.73}, {"t": "2026-06-21T03:00:00Z", "v": 2.98}, {"t": "2026-06-21T04:00:00Z", "v": 4.02}, {"t": "2026-06-21T05:00:00Z", "v": 2.98}, {"t": "2026-06-21T06:00:00Z", "v": 3.15}, {"t": "2026-06-21T07:00:00Z", "v": 6.77}, {"t": "2026-06-21T08:00:00Z", "v": 4.55}, {"t": "2026-06-21T09:00:00Z", "v": 5.25}, {"t": "2026-06-21T10:00:00Z", "v": 8.05}, {"t": "2026-06-21T11:00:00Z", "v": 6.47}, {"t": "2026-06-21T12:00:00Z", "v": 11.55}, {"t": "2026-06-21T13Line truncated
@@ -0,0 +1 @@
{"sensor": "hn-hagenbuchersee-02", "step": "1h", "points": [{"t": "2026-06-12T12:00:00Z", "v": 7.0}, {"t": "2026-06-16T18:00:00Z", "v": 73.03}, {"t": "2026-06-16T19:00:00Z", "v": 64.4}, {"t": "2026-06-16T20:00:00Z", "v": 64.17}, {"t": "2026-06-16T21:00:00Z", "v": 41.3}, {"t": "2026-06-16T22:00:00Z", "v": 8.87}, {"t": "2026-06-16T23:00:00Z", "v": 7.0}, {"t": "2026-06-17T00:00:00Z", "v": 4.72}, {"t": "2026-06-17T01:00:00Z", "v": 4.2}, {"t": "2026-06-17T02:00:00Z", "v": 4.03}, {"t": "2026-06-17T03:00:00Z", "v": 2.45}, {"t": "2026-06-17T04:00:00Z", "v": 3.5}, {"t": "2026-06-17T05:00:00Z", "v": 7.17}, {"t": "2026-06-17T06:00:00Z", "v": 9.28}, {"t": "2026-06-17T07:00:00Z", "v": 12.43}, {"t": "2026-06-17T08:00:00Z", "v": 12.42}, {"t": "2026-06-17T09:00:00Z", "v": 12.78}, {"t": "2026-06-17T10:00:00Z", "v": 26.6}, {"t": "2026-06-17T11:00:00Z", "v": 21.47}, {"t": "2026-06-17T12:00:00Z", "v": 20.3}, {"t": "2026-06-17T13:00:00Z", "v": 31.5}, {"t": "2026-06-17T14:00:00Z", "v": 42.35}, {"t": "2026-06-17T15:00:00Z", "v": 45.5}, {"t": "2026-06-17T16:00:00Z", "v": 58.1}, {"t": "2026-06-17T17:00:00Z", "v": 67.2}, {"t": "2026-06-17T18:00:00Z", "v": 90.07}, {"t": "2026-06-17T19:00:00Z", "v": 94.85}, {"t": "2026-06-17T20:00:00Z", "v": 93.98}, {"t": "2026-06-17T21:00:00Z", "v": 72.45}, {"t": "2026-06-17T22:00:00Z", "v": 43.4}, {"t": "2026-06-17T23:00:00Z", "v": 10.5}, {"t": "2026-06-18T00:00:00Z", "v": 7.88}, {"t": "2026-06-18T01:00:00Z", "v": 4.72}, {"t": "2026-06-18T02:00:00Z", "v": 5.37}, {"t": "2026-06-18T03:00:00Z", "v": 5.6}, {"t": "2026-06-18T04:00:00Z", "v": 4.67}, {"t": "2026-06-18T05:00:00Z", "v": 5.95}, {"t": "2026-06-18T06:00:00Z", "v": 8.05}, {"t": "2026-06-18T07:00:00Z", "v": 11.38}, {"t": "2026-06-18T08:00:00Z", "v": 12.13}, {"t": "2026-06-18T09:00:00Z", "v": 15.23}, {"t": "2026-06-18T10:00:00Z", "v": 19.43}, {"t": "2026-06-18T11:00:00Z", "v": 14.17}, {"t": "2026-06-18T12:00:00Z", "v": 15.05}, {"t": "2026-06-18T13:00:00Z", "v": 18.9}, {"t": "2026-06-18T14:00:00Z", "v": 31.97}, {"t": "2026-06-18T15:00:00Z", "v": 39.38}, {"t": "2026-06-18T16:00:00Z", "v": 70.0}, {"t": "2026-06-18T17:00:00Z", "v": 102.55}, {"t": "2026-06-18T18:00:00Z", "v": 126.0}, {"t": "2026-06-18T19:00:00Z", "v": 129.5}, {"t": "2026-06-18T20:00:00Z", "v": 135.28}, {"t": "2026-06-18T21:00:00Z", "v": 118.47}, {"t": "2026-06-18T22:00:00Z", "v": 70.47}, {"t": "2026-06-18T23:00:00Z", "v": 22.75}, {"t": "2026-06-19T00:00:00Z", "v": 14.0}, {"t": "2026-06-19T01:00:00Z", "v": 4.9}, {"t": "2026-06-19T02:00:00Z", "v": 5.25}, {"t": "2026-06-19T03:00:00Z", "v": 5.6}, {"t": "2026-06-19T04:00:00Z", "v": 6.47}, {"t": "2026-06-19T05:00:00Z", "v": 5.42}, {"t": "2026-06-19T06:00:00Z", "v": 8.4}, {"t": "2026-06-19T07:00:00Z", "v": 8.05}, {"t": "2026-06-19T08:00:00Z", "v": 8.93}, {"t": "2026-06-19T09:00:00Z", "v": 18.38}, {"t": "2026-06-19T10:00:00Z", "v": 24.97}, {"t": "2026-06-19T11:00:00Z", "v": 26.25}, {"t": "2026-06-19T12:00:00Z", "v": 25.2}, {"t": "2026-06-19T13:00:00Z", "v": 24.68}, {"t": "2026-06-19T14:00:00Z", "v": 29.05}, {"t": "2026-06-19T15:00:00Z", "v": 39.02}, {"t": "2026-06-19T16:00:00Z", "v": 65.8}, {"t": "2026-06-19T17:00:00Z", "v": 97.3}, {"t": "2026-06-19T18:00:00Z", "v": 150.68}, {"t": "2026-06-19T19:00:00Z", "v": 155.17}, {"t": "2026-06-19T20:00:00Z", "v": 179.55}, {"t": "2026-06-19T21:00:00Z", "v": 170.62}, {"t": "2026-06-19T22:00:00Z", "v": 117.95}, {"t": "2026-06-19T23:00:00Z", "v": 50.58}, {"t": "2026-06-20T00:00:00Z", "v": 11.2}, {"t": "2026-06-20T01:00:00Z", "v": 6.65}, {"t": "2026-06-20T02:00:00Z", "v": 4.43}, {"t": "2026-06-20T03:00:00Z", "v": 5.6}, {"t": "2026-06-20T04:00:00Z", "v": 5.08}, {"t": "2026-06-20T05:00:00Z", "v": 7.88}, {"t": "2026-06-20T06:00:00Z", "v": 13.77}, {"t": "2026-06-20T07:00:00Z", "v": 11.72}, {"t": "2026-06-20T08:00:00Z", "v": 13.65}, {"t": "2026-06-20T09:00:00Z", "v": 12.95}, {"t": "2026-06-20T10:00:00Z", "v": 19.13}, {"t": "2026-06-20T11:00:00Z", "v": 32.38}, {"t": "2026-06-20T12:00:00Z", "v": 32.55}, {"t": "2026-06-20T13:00:00Z", "v": 44.27}, {"t": "2026-06-20T14:00:00Z", "v": 36.92}, {"t": "2026-06-20T15:00:00Z", "v": 61.78}, {"t": "2026-06-20T16:00:00Z", "v": 67.2}, {"t": "2026-06-20T17:00:00Z", "v": 97.47}, {"t": "2026-06-20T18:00:00Z", "v": 151.9}, {"t": "2026-06-20T19:00:00Z", "v": 152.83}, {"t": "2026-06-20T20:00:00Z", "v": 155.75}, {"t": "2026-06-20T21:00:00Z", "v": 145.43}, {"t": "2026-06-20T22:00:00Z", "v": 133.35}, {"t": "2026-06-20T23:00:00Z", "v": 94.67}, {"t": "2026-06-21T00:00:00Z", "v": 60.9}, {"t": "2026-06-21T01:00:00Z", "v": 21.23}, {"t": "2026-06-21T02:00:00Z", "v": 6.83}, {"t": "2026-06-21T03:00:00Z", "v": 4.43}, {"t": "2026-06-21T04:00:00Z", "v": 8.22}, {"t": "2026-06-21T05:00:00Z", "v": 6.3}, {"t": "2026-06-21T06:00:00Z", "v": 5.83}, {"t": "2026-06-21T07:00:00Z", "v": 8.75}, {"t": "2026-06-21T08:00:00Z", "v": 6.83}, {"t": "2026-06-21T09:00:00Z", "v": 11.38}, {"t": "2026-06-21T10:00:00Z", "v": 10.68}, {"t": "2026-06-21T11:00:00Z", "v": 15.87}, {"t": "2026-06-21T12:00:00Z", "v": 15.93}, {"t":Line truncated
+1
View File
@@ -0,0 +1 @@
{"sensor": "hn-marahaus-01", "step": "1h", "points": [{"t": "2026-06-12T12:00:00Z", "v": 7.0}, {"t": "2026-06-17T16:00:00Z", "v": 21.7}, {"t": "2026-06-17T17:00:00Z", "v": 28.18}, {"t": "2026-06-17T18:00:00Z", "v": 22.23}, {"t": "2026-06-17T19:00:00Z", "v": 21.7}, {"t": "2026-06-17T20:00:00Z", "v": 18.9}, {"t": "2026-06-17T21:00:00Z", "v": 11.9}, {"t": "2026-06-17T22:00:00Z", "v": 6.3}, {"t": "2026-06-17T23:00:00Z", "v": 2.33}, {"t": "2026-06-18T00:00:00Z", "v": 3.73}, {"t": "2026-06-18T01:00:00Z", "v": 2.45}, {"t": "2026-06-18T02:00:00Z", "v": 4.2}, {"t": "2026-06-18T03:00:00Z", "v": 3.67}, {"t": "2026-06-18T04:00:00Z", "v": 3.15}, {"t": "2026-06-18T05:00:00Z", "v": 5.95}, {"t": "2026-06-18T06:00:00Z", "v": 6.83}, {"t": "2026-06-18T07:00:00Z", "v": 8.4}, {"t": "2026-06-18T08:00:00Z", "v": 14.93}, {"t": "2026-06-18T09:00:00Z", "v": 23.28}, {"t": "2026-06-18T10:00:00Z", "v": 17.85}, {"t": "2026-06-18T11:00:00Z", "v": 32.73}, {"t": "2026-06-18T12:00:00Z", "v": 16.33}, {"t": "2026-06-18T13:00:00Z", "v": 17.5}, {"t": "2026-06-18T14:00:00Z", "v": 17.68}, {"t": "2026-06-18T15:00:00Z", "v": 22.87}, {"t": "2026-06-18T16:00:00Z", "v": 33.95}, {"t": "2026-06-18T18:00:00Z", "v": 61.6}, {"t": "2026-06-18T19:00:00Z", "v": 87.85}, {"t": "2026-06-18T20:00:00Z", "v": 83.65}, {"t": "2026-06-18T21:00:00Z", "v": 47.08}, {"t": "2026-06-18T22:00:00Z", "v": 24.68}, {"t": "2026-06-18T23:00:00Z", "v": 11.72}, {"t": "2026-06-19T00:00:00Z", "v": 1.4}, {"t": "2026-06-19T01:00:00Z", "v": 1.75}, {"t": "2026-06-19T02:00:00Z", "v": 1.93}, {"t": "2026-06-19T03:00:00Z", "v": 0.7}, {"t": "2026-06-19T04:00:00Z", "v": 2.27}, {"t": "2026-06-19T05:00:00Z", "v": 5.78}, {"t": "2026-06-19T06:00:00Z", "v": 6.12}, {"t": "2026-06-19T07:00:00Z", "v": 6.48}, {"t": "2026-06-19T08:00:00Z", "v": 6.77}, {"t": "2026-06-19T09:00:00Z", "v": 11.2}, {"t": "2026-06-19T10:00:00Z", "v": 17.73}, {"t": "2026-06-19T11:00:00Z", "v": 18.2}, {"t": "2026-06-19T12:00:00Z", "v": 14.52}, {"t": "2026-06-19T13:00:00Z", "v": 14.0}, {"t": "2026-06-19T14:00:00Z", "v": 17.5}, {"t": "2026-06-19T15:00:00Z", "v": 22.57}, {"t": "2026-06-19T16:00:00Z", "v": 88.9}, {"t": "2026-06-19T17:00:00Z", "v": 70.35}, {"t": "2026-06-19T18:00:00Z", "v": 101.33}, {"t": "2026-06-19T19:00:00Z", "v": 126.23}, {"t": "2026-06-19T20:00:00Z", "v": 189.0}, {"t": "2026-06-19T21:00:00Z", "v": 156.1}, {"t": "2026-06-19T22:00:00Z", "v": 53.02}, {"t": "2026-06-19T23:00:00Z", "v": 15.63}, {"t": "2026-06-20T00:00:00Z", "v": 10.27}, {"t": "2026-06-20T01:00:00Z", "v": 3.32}, {"t": "2026-06-20T02:00:00Z", "v": 3.67}, {"t": "2026-06-20T03:00:00Z", "v": 3.5}, {"t": "2026-06-20T04:00:00Z", "v": 4.38}, {"t": "2026-06-20T05:00:00Z", "v": 4.2}, {"t": "2026-06-20T06:00:00Z", "v": 8.05}, {"t": "2026-06-20T07:00:00Z", "v": 9.1}, {"t": "2026-06-20T08:00:00Z", "v": 9.1}, {"t": "2026-06-20T09:00:00Z", "v": 17.5}, {"t": "2026-06-20T10:00:00Z", "v": 37.1}, {"t": "2026-06-20T11:00:00Z", "v": 32.43}, {"t": "2026-06-20T12:00:00Z", "v": 44.8}, {"t": "2026-06-20T13:00:00Z", "v": 29.4}, {"t": "2026-06-20T14:00:00Z", "v": 32.43}, {"t": "2026-06-20T15:00:00Z", "v": 37.45}, {"t": "2026-06-20T16:00:00Z", "v": 50.05}, {"t": "2026-06-20T17:00:00Z", "v": 63.52}, {"t": "2026-06-20T18:00:00Z", "v": 95.2}, {"t": "2026-06-20T19:00:00Z", "v": 128.45}, {"t": "2026-06-20T20:00:00Z", "v": 124.95}, {"t": "2026-06-20T21:00:00Z", "v": 131.83}, {"t": "2026-06-20T22:00:00Z", "v": 55.07}, {"t": "2026-06-20T23:00:00Z", "v": 28.35}, {"t": "2026-06-21T00:00:00Z", "v": 13.07}, {"t": "2026-06-21T01:00:00Z", "v": 8.93}, {"t": "2026-06-21T02:00:00Z", "v": 4.72}, {"t": "2026-06-21T03:00:00Z", "v": 5.6}, {"t": "2026-06-21T04:00:00Z", "v": 4.2}, {"t": "2026-06-21T05:00:00Z", "v": 3.33}, {"t": "2026-06-21T06:00:00Z", "v": 4.38}, {"t": "2026-06-21T07:00:00Z", "v": 18.73}, {"t": "2026-06-21T08:00:00Z", "v": 22.87}, {"t": "2026-06-21T09:00:00Z", "v": 14.18}, {"t": "2026-06-21T10:00:00Z", "v": 16.33}, {"t": "2026-06-21T11:00:00Z", "v": 21.0}, {"t": "2026-06-21T12:00:00Z", "v": 13.3}, {"t": "2026-06-21T13:00:00Z", "v": 12.07}, {"t": "2026-06-21T14:00:00Z", "v": 12.6}, {"t": "2026-06-21T15:00:00Z", "v": 22.17}, {"t": "2026-06-21T16:00:00Z", "v": 21.52}, {"t": "2026-06-21T17:00:00Z", "v": 32.9}, {"t": "2026-06-21T18:00:00Z", "v": 29.93}, {"t": "2026-06-21T19:00:00Z", "v": 27.12}, {"t": "2026-06-21T20:00:00Z", "v": 27.12}, {"t": "2026-06-21T21:00:00Z", "v": 15.17}, {"t": "2026-06-21T22:00:00Z", "v": 11.38}, {"t": "2026-06-21T23:00:00Z", "v": 2.45}, {"t": "2026-06-22T00:00:00Z", "v": 1.87}, {"t": "2026-06-22T01:00:00Z", "v": 2.1}, {"t": "2026-06-22T02:00:00Z", "v": 2.62}, {"t": "2026-06-22T03:00:00Z", "v": 2.57}, {"t": "2026-06-22T04:00:00Z", "v": 4.03}, {"t": "2026-06-22T05:00:00Z", "v": 4.2}, {"t": "2026-06-22T06:00:00Z", "v": 8.93}, {"t": "2026-06-22T07:00:00Z", "v": 9.98}, {"t": "2026-06-22T08:00:00Z", "v": 6.3}, {"t": "2026-06-22T09:00:00Z", "v": 9.45}, {"t": "2026-06-22T10:00:00Z", "v": 17.27}, {"t": "2026-06-22T11:00:00Z", "v": 18.2}, {"t": "2026-06-22T12:00:00Z", "v"Line truncated
+1
View File
@@ -0,0 +1 @@
{"sensor": "hn-neckarufer-01", "step": "1h", "points": [{"t": "2026-06-12T12:00:00Z", "v": 9.8}, {"t": "2026-06-17T16:00:00Z", "v": 10.5}, {"t": "2026-06-17T17:00:00Z", "v": 59.67}, {"t": "2026-06-17T18:00:00Z", "v": 63.52}, {"t": "2026-06-17T19:00:00Z", "v": 56.88}, {"t": "2026-06-17T20:00:00Z", "v": 50.4}, {"t": "2026-06-17T21:00:00Z", "v": 41.48}, {"t": "2026-06-17T22:00:00Z", "v": 14.53}, {"t": "2026-06-17T23:00:00Z", "v": 3.27}, {"t": "2026-06-18T00:00:00Z", "v": 2.97}, {"t": "2026-06-18T01:00:00Z", "v": 2.62}, {"t": "2026-06-18T02:00:00Z", "v": 2.27}, {"t": "2026-06-18T03:00:00Z", "v": 5.13}, {"t": "2026-06-18T04:00:00Z", "v": 2.62}, {"t": "2026-06-18T05:00:00Z", "v": 3.33}, {"t": "2026-06-18T06:00:00Z", "v": 7.0}, {"t": "2026-06-18T07:00:00Z", "v": 9.28}, {"t": "2026-06-18T08:00:00Z", "v": 12.07}, {"t": "2026-06-18T09:00:00Z", "v": 13.12}, {"t": "2026-06-18T10:00:00Z", "v": 11.43}, {"t": "2026-06-18T11:00:00Z", "v": 13.82}, {"t": "2026-06-18T12:00:00Z", "v": 14.7}, {"t": "2026-06-18T13:00:00Z", "v": 13.82}, {"t": "2026-06-18T14:00:00Z", "v": 26.83}, {"t": "2026-06-18T15:00:00Z", "v": 44.62}, {"t": "2026-06-18T16:00:00Z", "v": 67.2}, {"t": "2026-06-18T17:00:00Z", "v": 101.5}, {"t": "2026-06-18T18:00:00Z", "v": 137.9}, {"t": "2026-06-18T19:00:00Z", "v": 138.25}, {"t": "2026-06-18T20:00:00Z", "v": 148.22}, {"t": "2026-06-18T21:00:00Z", "v": 110.08}, {"t": "2026-06-18T22:00:00Z", "v": 43.05}, {"t": "2026-06-18T23:00:00Z", "v": 10.73}, {"t": "2026-06-19T00:00:00Z", "v": 8.4}, {"t": "2026-06-19T01:00:00Z", "v": 8.17}, {"t": "2026-06-19T02:00:00Z", "v": 3.73}, {"t": "2026-06-19T03:00:00Z", "v": 3.33}, {"t": "2026-06-19T04:00:00Z", "v": 2.27}, {"t": "2026-06-19T05:00:00Z", "v": 4.03}, {"t": "2026-06-19T06:00:00Z", "v": 3.5}, {"t": "2026-06-19T07:00:00Z", "v": 8.93}, {"t": "2026-06-19T08:00:00Z", "v": 9.33}, {"t": "2026-06-19T09:00:00Z", "v": 8.75}, {"t": "2026-06-19T10:00:00Z", "v": 11.67}, {"t": "2026-06-19T11:00:00Z", "v": 11.9}, {"t": "2026-06-19T12:00:00Z", "v": 14.0}, {"t": "2026-06-19T13:00:00Z", "v": 15.05}, {"t": "2026-06-19T14:00:00Z", "v": 16.33}, {"t": "2026-06-19T15:00:00Z", "v": 36.92}, {"t": "2026-06-19T16:00:00Z", "v": 56.7}, {"t": "2026-06-19T17:00:00Z", "v": 102.55}, {"t": "2026-06-19T18:00:00Z", "v": 155.93}, {"t": "2026-06-19T19:00:00Z", "v": 227.03}, {"t": "2026-06-19T20:00:00Z", "v": 230.07}, {"t": "2026-06-19T21:00:00Z", "v": 193.43}, {"t": "2026-06-19T22:00:00Z", "v": 84.47}, {"t": "2026-06-19T23:00:00Z", "v": 22.87}, {"t": "2026-06-20T00:00:00Z", "v": 14.0}, {"t": "2026-06-20T01:00:00Z", "v": 5.08}, {"t": "2026-06-20T02:00:00Z", "v": 5.6}, {"t": "2026-06-20T03:00:00Z", "v": 4.03}, {"t": "2026-06-20T04:00:00Z", "v": 5.08}, {"t": "2026-06-20T05:00:00Z", "v": 6.65}, {"t": "2026-06-20T06:00:00Z", "v": 9.33}, {"t": "2026-06-20T07:00:00Z", "v": 8.4}, {"t": "2026-06-20T08:00:00Z", "v": 9.62}, {"t": "2026-06-20T09:00:00Z", "v": 14.93}, {"t": "2026-06-20T10:00:00Z", "v": 15.57}, {"t": "2026-06-20T11:00:00Z", "v": 24.5}, {"t": "2026-06-20T12:00:00Z", "v": 31.85}, {"t": "2026-06-20T13:00:00Z", "v": 34.47}, {"t": "2026-06-20T14:00:00Z", "v": 43.63}, {"t": "2026-06-20T15:00:00Z", "v": 91.35}, {"t": "2026-06-20T16:00:00Z", "v": 87.97}, {"t": "2026-06-20T17:00:00Z", "v": 104.3}, {"t": "2026-06-20T18:00:00Z", "v": 157.15}, {"t": "2026-06-20T19:00:00Z", "v": 185.85}, {"t": "2026-06-20T20:00:00Z", "v": 213.33}, {"t": "2026-06-20T21:00:00Z", "v": 154.88}, {"t": "2026-06-20T22:00:00Z", "v": 99.92}, {"t": "2026-06-20T23:00:00Z", "v": 45.03}, {"t": "2026-06-21T00:00:00Z", "v": 37.8}, {"t": "2026-06-21T01:00:00Z", "v": 14.7}, {"t": "2026-06-21T02:00:00Z", "v": 7.23}, {"t": "2026-06-21T03:00:00Z", "v": 5.43}, {"t": "2026-06-21T04:00:00Z", "v": 5.37}, {"t": "2026-06-21T05:00:00Z", "v": 4.2}, {"t": "2026-06-21T06:00:00Z", "v": 4.2}, {"t": "2026-06-21T07:00:00Z", "v": 5.78}, {"t": "2026-06-21T08:00:00Z", "v": 5.42}, {"t": "2026-06-21T09:00:00Z", "v": 8.4}, {"t": "2026-06-21T10:00:00Z", "v": 8.4}, {"t": "2026-06-21T11:00:00Z", "v": 9.45}, {"t": "2026-06-21T12:00:00Z", "v": 10.32}, {"t": "2026-06-21T13:00:00Z", "v": 14.0}, {"t": "2026-06-21T14:00:00Z", "v": 25.55}, {"t": "2026-06-21T15:00:00Z", "v": 16.45}, {"t": "2026-06-21T16:00:00Z", "v": 36.17}, {"t": "2026-06-21T17:00:00Z", "v": 34.77}, {"t": "2026-06-21T18:00:00Z", "v": 35.52}, {"t": "2026-06-21T19:00:00Z", "v": 38.67}, {"t": "2026-06-21T20:00:00Z", "v": 29.93}, {"t": "2026-06-21T21:00:00Z", "v": 23.1}, {"t": "2026-06-21T22:00:00Z", "v": 11.72}, {"t": "2026-06-21T23:00:00Z", "v": 5.6}, {"t": "2026-06-22T00:00:00Z", "v": 4.38}, {"t": "2026-06-22T01:00:00Z", "v": 3.73}, {"t": "2026-06-22T02:00:00Z", "v": 3.73}, {"t": "2026-06-22T03:00:00Z", "v": 4.67}, {"t": "2026-06-22T04:00:00Z", "v": 7.47}, {"t": "2026-06-22T05:00:00Z", "v": 8.75}, {"t": "2026-06-22T06:00:00Z", "v": 10.85}, {"t": "2026-06-22T07:00:00Z", "v": 11.2}, {"t": "2026-06-22T08:00:00Z", "v": 10.73}, {"t": "2026-06-22T09:00:00Z", "v": 8.4}, {"t": "2026-06-22T10:00:00Z", "v": 15.57}, {"t": "2026-06-Line truncated
+1
View File
@@ -0,0 +1 @@
{"sensor": "hn-soleo-01", "step": "1h", "points": [{"t": "2026-06-12T11:00:00Z", "v": 9.8}, {"t": "2026-06-16T18:00:00Z", "v": 18.2}, {"t": "2026-06-16T19:00:00Z", "v": 10.32}, {"t": "2026-06-16T20:00:00Z", "v": 8.05}, {"t": "2026-06-16T21:00:00Z", "v": 6.3}, {"t": "2026-06-16T22:00:00Z", "v": 7.53}, {"t": "2026-06-16T23:00:00Z", "v": 4.38}, {"t": "2026-06-17T00:00:00Z", "v": 3.85}, {"t": "2026-06-17T01:00:00Z", "v": 4.9}, {"t": "2026-06-17T02:00:00Z", "v": 3.85}, {"t": "2026-06-17T03:00:00Z", "v": 3.85}, {"t": "2026-06-17T04:00:00Z", "v": 4.67}, {"t": "2026-06-17T05:00:00Z", "v": 7.88}, {"t": "2026-06-17T06:00:00Z", "v": 10.5}, {"t": "2026-06-17T07:00:00Z", "v": 8.4}, {"t": "2026-06-17T08:00:00Z", "v": 11.67}, {"t": "2026-06-17T09:00:00Z", "v": 6.12}, {"t": "2026-06-17T10:00:00Z", "v": 12.95}, {"t": "2026-06-17T11:00:00Z", "v": 11.9}, {"t": "2026-06-17T12:00:00Z", "v": 12.25}, {"t": "2026-06-17T13:00:00Z", "v": 14.93}, {"t": "2026-06-17T14:00:00Z", "v": 11.55}, {"t": "2026-06-17T15:00:00Z", "v": 14.0}, {"t": "2026-06-17T16:00:00Z", "v": 14.7}, {"t": "2026-06-17T17:00:00Z", "v": 8.63}, {"t": "2026-06-17T18:00:00Z", "v": 12.25}, {"t": "2026-06-17T19:00:00Z", "v": 6.65}, {"t": "2026-06-17T20:00:00Z", "v": 3.15}, {"t": "2026-06-17T21:00:00Z", "v": 2.57}, {"t": "2026-06-17T22:00:00Z", "v": 1.4}, {"t": "2026-06-17T23:00:00Z", "v": 1.23}, {"t": "2026-06-18T00:00:00Z", "v": 0.93}, {"t": "2026-06-18T01:00:00Z", "v": 0.7}, {"t": "2026-06-18T02:00:00Z", "v": 0.47}, {"t": "2026-06-18T03:00:00Z", "v": 1.92}, {"t": "2026-06-18T04:00:00Z", "v": 2.1}, {"t": "2026-06-18T05:00:00Z", "v": 5.08}, {"t": "2026-06-18T06:00:00Z", "v": 5.13}, {"t": "2026-06-18T07:00:00Z", "v": 5.25}, {"t": "2026-06-18T08:00:00Z", "v": 4.38}, {"t": "2026-06-18T09:00:00Z", "v": 7.93}, {"t": "2026-06-18T10:00:00Z", "v": 9.1}, {"t": "2026-06-18T11:00:00Z", "v": 9.97}, {"t": "2026-06-18T12:00:00Z", "v": 7.35}, {"t": "2026-06-18T13:00:00Z", "v": 8.93}, {"t": "2026-06-18T14:00:00Z", "v": 10.68}, {"t": "2026-06-18T15:00:00Z", "v": 17.85}, {"t": "2026-06-18T16:00:00Z", "v": 30.27}, {"t": "2026-06-18T17:00:00Z", "v": 41.07}, {"t": "2026-06-18T18:00:00Z", "v": 46.2}, {"t": "2026-06-18T19:00:00Z", "v": 64.22}, {"t": "2026-06-18T20:00:00Z", "v": 50.23}, {"t": "2026-06-18T21:00:00Z", "v": 28.18}, {"t": "2026-06-18T22:00:00Z", "v": 11.72}, {"t": "2026-06-18T23:00:00Z", "v": 3.97}, {"t": "2026-06-19T00:00:00Z", "v": 3.67}, {"t": "2026-06-19T01:00:00Z", "v": 1.22}, {"t": "2026-06-19T02:00:00Z", "v": 2.62}, {"t": "2026-06-19T03:00:00Z", "v": 1.93}, {"t": "2026-06-19T04:00:00Z", "v": 2.45}, {"t": "2026-06-19T05:00:00Z", "v": 3.5}, {"t": "2026-06-19T06:00:00Z", "v": 9.1}, {"t": "2026-06-19T07:00:00Z", "v": 7.53}, {"t": "2026-06-19T08:00:00Z", "v": 1.93}, {"t": "2026-06-19T09:00:00Z", "v": 7.0}, {"t": "2026-06-19T10:00:00Z", "v": 5.42}, {"t": "2026-06-19T11:00:00Z", "v": 9.98}, {"t": "2026-06-19T12:00:00Z", "v": 7.0}, {"t": "2026-06-19T13:00:00Z", "v": 4.9}, {"t": "2026-06-19T14:00:00Z", "v": 5.6}, {"t": "2026-06-19T15:00:00Z", "v": 12.07}, {"t": "2026-06-19T16:00:00Z", "v": 24.15}, {"t": "2026-06-19T17:00:00Z", "v": 38.85}, {"t": "2026-06-19T18:00:00Z", "v": 73.73}, {"t": "2026-06-19T19:00:00Z", "v": 91.23}, {"t": "2026-06-19T20:00:00Z", "v": 86.45}, {"t": "2026-06-19T21:00:00Z", "v": 81.2}, {"t": "2026-06-19T22:00:00Z", "v": 35.88}, {"t": "2026-06-19T23:00:00Z", "v": 3.85}, {"t": "2026-06-20T00:00:00Z", "v": 3.15}, {"t": "2026-06-20T01:00:00Z", "v": 0.17}, {"t": "2026-06-20T02:00:00Z", "v": 0.88}, {"t": "2026-06-20T03:00:00Z", "v": 4.43}, {"t": "2026-06-20T04:00:00Z", "v": 1.63}, {"t": "2026-06-20T05:00:00Z", "v": 3.15}, {"t": "2026-06-20T06:00:00Z", "v": 1.22}, {"t": "2026-06-20T07:00:00Z", "v": 2.8}, {"t": "2026-06-20T08:00:00Z", "v": 3.33}, {"t": "2026-06-20T09:00:00Z", "v": 5.6}, {"t": "2026-06-20T10:00:00Z", "v": 4.38}, {"t": "2026-06-20T11:00:00Z", "v": 7.53}, {"t": "2026-06-20T12:00:00Z", "v": 7.88}, {"t": "2026-06-20T13:00:00Z", "v": 11.72}, {"t": "2026-06-20T14:00:00Z", "v": 13.3}, {"t": "2026-06-20T15:00:00Z", "v": 16.1}, {"t": "2026-06-20T16:00:00Z", "v": 35.35}, {"t": "2026-06-20T17:00:00Z", "v": 44.1}, {"t": "2026-06-20T18:00:00Z", "v": 70.0}, {"t": "2026-06-20T19:00:00Z", "v": 75.78}, {"t": "2026-06-20T20:00:00Z", "v": 74.03}, {"t": "2026-06-20T21:00:00Z", "v": 63.47}, {"t": "2026-06-20T22:00:00Z", "v": 40.6}, {"t": "2026-06-20T23:00:00Z", "v": 13.77}, {"t": "2026-06-21T00:00:00Z", "v": 11.9}, {"t": "2026-06-21T01:00:00Z", "v": 2.8}, {"t": "2026-06-21T02:00:00Z", "v": 3.15}, {"t": "2026-06-21T03:00:00Z", "v": 1.92}, {"t": "2026-06-21T04:00:00Z", "v": 2.1}, {"t": "2026-06-21T05:00:00Z", "v": 2.1}, {"t": "2026-06-21T06:00:00Z", "v": 2.8}, {"t": "2026-06-21T07:00:00Z", "v": 2.8}, {"t": "2026-06-21T08:00:00Z", "v": 3.85}, {"t": "2026-06-21T09:00:00Z", "v": 5.37}, {"t": "2026-06-21T10:00:00Z", "v": 5.6}, {"t": "2026-06-21T11:00:00Z", "v": 4.67}, {"t": "2026-06-21T12:00:00Z", "v": 7.0}, {"t": "2026-06-21T13:00:00Z", "v": 6.83}, {"t": "2026-06-21T14:00:00Z",Line truncated
+1
View File
@@ -0,0 +1 @@
{"sensor": "hn-stadtgalerie-01", "step": "1h", "points": [{"t": "2026-06-12T12:00:00Z", "v": 10.5}, {"t": "2026-06-17T16:00:00Z", "v": 12.95}, {"t": "2026-06-17T17:00:00Z", "v": 46.9}, {"t": "2026-06-17T18:00:00Z", "v": 16.33}, {"t": "2026-06-17T19:00:00Z", "v": 12.37}, {"t": "2026-06-17T20:00:00Z", "v": 5.42}, {"t": "2026-06-17T21:00:00Z", "v": 2.45}, {"t": "2026-06-17T22:00:00Z", "v": 4.2}, {"t": "2026-06-17T23:00:00Z", "v": 3.5}, {"t": "2026-06-18T00:00:00Z", "v": 1.75}, {"t": "2026-06-18T01:00:00Z", "v": 1.23}, {"t": "2026-06-18T02:00:00Z", "v": 1.75}, {"t": "2026-06-18T03:00:00Z", "v": 1.63}, {"t": "2026-06-18T04:00:00Z", "v": 3.27}, {"t": "2026-06-18T05:00:00Z", "v": 7.93}, {"t": "2026-06-18T06:00:00Z", "v": 15.75}, {"t": "2026-06-18T07:00:00Z", "v": 28.7}, {"t": "2026-06-18T08:00:00Z", "v": 31.15}, {"t": "2026-06-18T09:00:00Z", "v": 41.3}, {"t": "2026-06-18T10:00:00Z", "v": 54.6}, {"t": "2026-06-18T11:00:00Z", "v": 44.1}, {"t": "2026-06-18T12:00:00Z", "v": 37.8}, {"t": "2026-06-18T13:00:00Z", "v": 34.48}, {"t": "2026-06-18T14:00:00Z", "v": 41.53}, {"t": "2026-06-18T15:00:00Z", "v": 38.33}, {"t": "2026-06-18T16:00:00Z", "v": 45.97}, {"t": "2026-06-18T17:00:00Z", "v": 35.47}, {"t": "2026-06-18T18:00:00Z", "v": 15.23}, {"t": "2026-06-18T19:00:00Z", "v": 11.43}, {"t": "2026-06-18T20:00:00Z", "v": 8.22}, {"t": "2026-06-18T21:00:00Z", "v": 3.5}, {"t": "2026-06-18T22:00:00Z", "v": 2.45}, {"t": "2026-06-18T23:00:00Z", "v": 3.67}, {"t": "2026-06-19T00:00:00Z", "v": 1.93}, {"t": "2026-06-19T01:00:00Z", "v": 1.4}, {"t": "2026-06-19T02:00:00Z", "v": 1.17}, {"t": "2026-06-19T03:00:00Z", "v": 0.88}, {"t": "2026-06-19T04:00:00Z", "v": 3.03}, {"t": "2026-06-19T05:00:00Z", "v": 5.78}, {"t": "2026-06-19T06:00:00Z", "v": 8.4}, {"t": "2026-06-19T07:00:00Z", "v": 25.55}, {"t": "2026-06-19T08:00:00Z", "v": 26.83}, {"t": "2026-06-19T09:00:00Z", "v": 36.23}, {"t": "2026-06-19T10:00:00Z", "v": 42.52}, {"t": "2026-06-19T11:00:00Z", "v": 36.4}, {"t": "2026-06-19T12:00:00Z", "v": 44.8}, {"t": "2026-06-19T13:00:00Z", "v": 44.45}, {"t": "2026-06-19T14:00:00Z", "v": 39.9}, {"t": "2026-06-19T15:00:00Z", "v": 37.33}, {"t": "2026-06-19T16:00:00Z", "v": 40.08}, {"t": "2026-06-19T17:00:00Z", "v": 34.77}, {"t": "2026-06-19T18:00:00Z", "v": 19.95}, {"t": "2026-06-19T19:00:00Z", "v": 14.0}, {"t": "2026-06-19T20:00:00Z", "v": 16.1}, {"t": "2026-06-19T21:00:00Z", "v": 12.78}, {"t": "2026-06-19T22:00:00Z", "v": 8.4}, {"t": "2026-06-19T23:00:00Z", "v": 4.72}, {"t": "2026-06-20T00:00:00Z", "v": 0.93}, {"t": "2026-06-20T01:00:00Z", "v": 1.23}, {"t": "2026-06-20T02:00:00Z", "v": 1.17}, {"t": "2026-06-20T03:00:00Z", "v": 1.05}, {"t": "2026-06-20T04:00:00Z", "v": 3.5}, {"t": "2026-06-20T05:00:00Z", "v": 4.9}, {"t": "2026-06-20T06:00:00Z", "v": 8.22}, {"t": "2026-06-20T07:00:00Z", "v": 23.57}, {"t": "2026-06-20T08:00:00Z", "v": 37.1}, {"t": "2026-06-20T09:00:00Z", "v": 47.83}, {"t": "2026-06-20T10:00:00Z", "v": 54.95}, {"t": "2026-06-20T11:00:00Z", "v": 41.53}, {"t": "2026-06-20T12:00:00Z", "v": 47.25}, {"t": "2026-06-20T13:00:00Z", "v": 47.13}, {"t": "2026-06-20T14:00:00Z", "v": 49.35}, {"t": "2026-06-20T15:00:00Z", "v": 39.02}, {"t": "2026-06-20T16:00:00Z", "v": 39.43}, {"t": "2026-06-20T17:00:00Z", "v": 49.35}, {"t": "2026-06-20T18:00:00Z", "v": 26.37}, {"t": "2026-06-20T19:00:00Z", "v": 22.93}, {"t": "2026-06-20T20:00:00Z", "v": 11.2}, {"t": "2026-06-20T21:00:00Z", "v": 13.3}, {"t": "2026-06-20T22:00:00Z", "v": 11.55}, {"t": "2026-06-20T23:00:00Z", "v": 7.0}, {"t": "2026-06-21T00:00:00Z", "v": 3.03}, {"t": "2026-06-21T01:00:00Z", "v": 1.57}, {"t": "2026-06-21T02:00:00Z", "v": 1.63}, {"t": "2026-06-21T03:00:00Z", "v": 1.4}, {"t": "2026-06-21T04:00:00Z", "v": 1.17}, {"t": "2026-06-21T05:00:00Z", "v": 1.57}, {"t": "2026-06-21T06:00:00Z", "v": 1.17}, {"t": "2026-06-21T07:00:00Z", "v": 5.08}, {"t": "2026-06-21T08:00:00Z", "v": 2.8}, {"t": "2026-06-21T09:00:00Z", "v": 7.47}, {"t": "2026-06-21T10:00:00Z", "v": 4.03}, {"t": "2026-06-21T11:00:00Z", "v": 2.57}, {"t": "2026-06-21T12:00:00Z", "v": 2.8}, {"t": "2026-06-21T13:00:00Z", "v": 4.67}, {"t": "2026-06-21T14:00:00Z", "v": 5.95}, {"t": "2026-06-21T15:00:00Z", "v": 6.53}, {"t": "2026-06-21T16:00:00Z", "v": 8.22}, {"t": "2026-06-21T17:00:00Z", "v": 8.87}, {"t": "2026-06-21T18:00:00Z", "v": 7.7}, {"t": "2026-06-21T19:00:00Z", "v": 4.72}, {"t": "2026-06-21T20:00:00Z", "v": 4.43}, {"t": "2026-06-21T21:00:00Z", "v": 4.72}, {"t": "2026-06-21T22:00:00Z", "v": 2.1}, {"t": "2026-06-21T23:00:00Z", "v": 1.4}, {"t": "2026-06-22T00:00:00Z", "v": 3.85}, {"t": "2026-06-22T01:00:00Z", "v": 0.88}, {"t": "2026-06-22T02:00:00Z", "v": 1.17}, {"t": "2026-06-22T03:00:00Z", "v": 1.22}, {"t": "2026-06-22T04:00:00Z", "v": 2.57}, {"t": "2026-06-22T05:00:00Z", "v": 7.88}, {"t": "2026-06-22T06:00:00Z", "v": 10.5}, {"t": "2026-06-22T07:00:00Z", "v": 23.8}, {"t": "2026-06-22T08:00:00Z", "v": 26.95}, {"t": "2026-06-22T09:00:00Z", "v": 33.13}, {"t": "2026-06-22T10:00:00Z", "v": 44.27}, {"t": "2026-06-22T11:00:00Z", "v": 42.35}, {"tLine truncated
+37
View File
@@ -0,0 +1,37 @@
{
"model_version": "logit-20261114-040339",
"trained_at": "2026-11-14T04:03:39Z",
"features": [
"hour",
"weekday",
"is_weekend",
"temp_c",
"precip_mm",
"is_holiday"
],
"train_from": "2026-06-12T00:00:00Z",
"train_to": "2026-10-09T01:00:00Z",
"test_from": "2026-10-09T02:00:00Z",
"test_to": "2026-11-07T23:00:00Z",
"thresholds": {
"density-01": 15.23,
"hn-goetzentuem-01": 15.4,
"hn-hagenbuchersee-01": 18.2,
"hn-hagenbuchersee-02": 29.17,
"hn-marahaus-01": 22.23,
"hn-neckarufer-01": 28.35,
"hn-soleo-01": 11.38,
"hn-stadtgalerie-01": 38.41
},
"metrics": {
"accuracy": 0.708,
"precision": 0.36,
"recall": 0.574,
"f1": 0.443,
"roc_auc": 0.726,
"n_train": 18242,
"n_test": 5710,
"positive_rate": 0.202,
"sensors": 8
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
+16
View File
@@ -0,0 +1,16 @@
{
"fetched_at": "2026-11-14T03:47:09Z",
"current": {
"t": "2026-11-14T03:45",
"temp_c": -0.6,
"precip_mm": 0.0,
"cloud_pct": 100,
"wind_kmh": 1.5,
"humidity_pct": 100
},
"grid": {
"latitude": 49.13525,
"longitude": 9.202922
},
"source": "open-meteo"
}
+25 -2
View File
@@ -1,5 +1,28 @@
def main():
print("Hello from ml-py!")
"""PulseCast ML entrypoint.
Use ``make serve`` or ``python main.py --port 8000``. The ASGI app itself lives
in ``pulsecast.server:app``.
"""
from __future__ import annotations
import argparse
import uvicorn
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--host", default="0.0.0.0")
parser.add_argument("--port", type=int, default=8000)
parser.add_argument("--reload", action="store_true")
args = parser.parse_args()
uvicorn.run(
"pulsecast.server:app",
host=args.host,
port=args.port,
reload=args.reload,
)
if __name__ == "__main__":
+128
View File
@@ -0,0 +1,128 @@
# Model card — PulseCast footfall forecast
## Model
One global `HistGradientBoostingRegressor` predicts hourly footfall density for
all eight inner-city sensors. A separately trained logistic regression predicts
a binary `busy` hour for the training demo. Both are batch-trained; no model
tunes itself at inference time.
- Forecast version: `histgb-YYYY-MM-DD` (baked), `histgb-YYYYMMDD-HHMMSS` after
a runtime retrain.
- Small classifier version: `logit-YYYYMMDD-HHMMSS`.
- Framework: scikit-learn 1.9, pandas 3.1, Python 3.12.
## Intended use
Decision support for a store manager: next 7 days of footfall, an uncertainty
band, and a transparent staffing heuristic on top. The model is not a census of
people, not a city-wide heatmap, and not an automated labor optimizer.
## Features (forecast)
| Group | Features |
|---|---|
| Calendar | `hour`, `weekday`, `month`, `is_weekend`, `is_holiday`, `sensor_code` |
| Seasonal | `lag_week` (previous observed same weekday/hour), `seasonal_mean_4w` |
| Weather | `temp_c`, `precip_mm` |
The production 7-day model uses only features that are at least 168 hours old.
Day-ahead ablation models additionally use `lag_day`, `lag_2d`, `roll_24`,
`roll_168`.
## Target and data
- Target: mean of 15-minute `densityData` readings in a UTC hour, per sensor.
- Training window: 2026-06-12 → 2026-10-10; holdout: 2026-10-10 → 2026-11-07.
- Eight usable sensors after excluding `maker-fair` (73 rows, Hannover),
`niklas-01` (8 rows), `hn-bollwerksturm-01` (5 rows).
- `density-01` merges two physical devices (`863f75b0`, `f8c19730`) into one
logical location. The older device history is outside the 8-sensor window and
is not used for the production model.
- Weather: Open-Meteo historical archive for training, forecast for inference
and scenarios, Heilbronn grid cell.
- Holidays: explicit Baden-Württemberg 2025–2026 calendar.
## Evaluation
Time-based 28-day holdout, no shuffling. Seasonal naive is the baseline. WAPE is
`sum(|error|) / sum(|actual|)`. R² is computed on the same 5,350 rows.
| Model | MAE | WAPE | R² |
|---|---:|---:|---:|
| Seasonal naive (exact 168-row lag) | 5.40 | 44.7% | 0.462 |
| Day-ahead, no weather | 3.96 | 32.8% | 0.706 |
| Day-ahead, + holiday flag | 3.84 | 31.8% | 0.732 |
| Day-ahead, + temperature/rain | 3.36 | 27.8% | 0.763 |
| 7-day-safe, no weather | 4.08 | 33.8% | 0.697 |
| **7-day-safe, + temperature/rain (production)** | **3.32** | **27.5%** | **0.777** |
Weather is the useful signal: adding temperature and rain cuts MAE by ~19%
versus the 7-day no-weather model and ~38% versus seasonal naive. The holiday
flag alone changes day-ahead MAE by −0.12 in this run; holidays are context, not
a headline accuracy claim.
The seasonal-naive row reproduces the mission reference exactly
(5.40 / 44.7% / 0.462), and the day-ahead weather row matches 3.36 / 27.8%. The
production model is slightly better than the reference because `lag_week` uses
the previous *observed* same weekday/hour across sensor gaps, while the baseline
uses the exact 168-row lag. R² differs slightly from the reference 0.779
(0.777 here) because of that feature choice.
## Uncertainty band
The `lo`/`hi` band is the 10th/90th percentile of holdout residuals added to the
point forecast, clipped at zero. It is an empirical 80% band, not a calibrated
guarantee.
## Small classifier
- Target: `busy` = hourly footfall strictly above that sensor's p75, where the
p75 is computed on the training window only.
- Features: `hour`, `weekday`, `is_weekend`, `temp_c`, `precip_mm`, `is_holiday`.
- Model: standardized logistic regression, `class_weight="balanced"`.
- Split: last 20% of hourly timestamps, time-ordered.
- Result: accuracy 0.708, precision 0.360, recall 0.574, F1 0.443, ROC-AUC 0.726.
- Trains in ~0.25 s on the challenge CSV and under 1 s on a small upload.
- The low precision reflects a hard p75 threshold and a deliberately tiny model;
it is a demo artifact, not the production forecast.
## No-leakage rules
- All splits are time-based; no random shuffling.
- The seasonal-naive baseline uses an exact 168-row lag. The model's
`lag_week` uses the previous *observed* same weekday/hour; future lags are
never filled from future targets.
- Rolling means are shifted at least 24 hours back.
- The production 7-day model uses only ≥168-hour-old information, so a 168-hour
forecast needs no recursion.
- Weather in the holdout is observed, not forecast. The demo uses forecast
weather, so live accuracy will be lower than the holdout number.
- The holdout is used for reporting the headline; the production bundle is
refit on all observed rows only after the holdout is evaluated.
## Limitations
- PAX counters detect discoverable devices; penetration is unknown. Values are
an index of estimated devices, not people.
- Eight sensors cover ~580 m; the data does not support a city-wide surface or a
store-location recommender.
- Five months of multi-sensor history; no annual seasonality claim. `density-01`
has a longer single-sensor history, but that cannot represent the network.
- Sensor gaps of 4–6 days remain. The model tolerates missing lags but cannot
recover unobserved footfall.
- No events, markets, school holidays, bridge days, or promotions are modeled.
Scenario uplifts are explicit assumptions, not causal estimates.
- Weather is observed in training and forecast in the demo; forecast error is
not included in the reported metrics.
- The staffing heuristic assumes visitors-per-staff-hour, shift length, safety
factor, and labor cost. There is no POS, queue, sales, or labor-cost data.
## Ethical and operational notes
- No PII, MAC addresses, or individual tracking is stored or exposed.
- Public API reads are open; training is token-protected and internal.
- Model artifacts and derived aggregates are committed; the raw challenge CSV is
not. No secrets are baked into the image.
- On restart the service falls back to the baked model; retrained models persist
only in `/tmp` and are not assumed to survive a pod restart.
+4 -2
View File
@@ -11,7 +11,7 @@ dependencies = [
"numpy>=2.5.4",
"pandas>=3.1.1",
"pyarrow>=26.0.1",
"pytest>=9.2.0",
"python-multipart>=0.0.20",
"scikit-learn>=1.9.1",
"uvicorn[standard]>=0.54.0",
]
@@ -28,4 +28,6 @@ testpaths = ["tests"]
addopts = "-q"
[dependency-groups]
dev = []
dev = [
"pytest>=9.2.0",
]
+22
View File
@@ -45,6 +45,24 @@ def raw_csv_path() -> Path:
)
def weather_dir() -> Path:
"""Baked weather frames live beside the other exported artifacts."""
return Path(os.environ.get("PULSECAST_WEATHER", artifacts_dir())).resolve()
def model_dir() -> Path:
"""Writable model persistence for training jobs (/tmp inside a container)."""
return Path(os.environ.get("PULSECAST_MODELS", "/tmp/pulsecast/models")).resolve()
def upload_dir() -> Path:
return Path(os.environ.get("PULSECAST_UPLOADS", "/tmp/pulsecast/uploads")).resolve()
def control_token() -> str:
return os.environ.get("CONTROL_TOKEN", "").strip()
# --------------------------------------------------------------------------- data
# Multi-sensor window documented in mission/data.md. density-01 has older
@@ -171,6 +189,10 @@ FEATURE_DAY_HOLIDAY = FEATURE_DAY + ["is_holiday"] # is_holiday already present
FEATURE_WEEK_NO_WEATHER = FEATURE_WEEK
FEATURE_WEEK_WEATHER = FEATURE_WEEK + FEATURE_WEATHER
# Small classifier ("I coded an AI" artifact). Contract features, deliberately
# no lags: this model is cheap to retrain on an uploaded CSV in a few seconds.
SMALL_FEATURES = ["hour", "weekday", "is_weekend", "temp_c", "precip_mm", "is_holiday"]
# Scenario presets. Weather adjustments apply on the event's weekdays; the
# event uplift is a transparent multiplicative overlay applied after the model.
# These are decision-support assumptions, not causal estimates.
+10 -3
View File
@@ -11,7 +11,6 @@ Design rules:
from __future__ import annotations
import numpy as np
import pandas as pd
from . import config
@@ -71,8 +70,16 @@ def _add_rollups(grid: pd.DataFrame) -> pd.DataFrame:
def _add_seasonal_lags(df: pd.DataFrame) -> pd.DataFrame:
"""Previous observed same weekday/hour values, strictly in the past."""
out = df.sort_values(["sensor", "weekday", "hour", "t"]).copy()
"""Previous observed same weekday/hour values, strictly in the past.
``lag_168`` is the exact 168-row (one observed week) lag used as the
seasonal-naive baseline. The model's ``lag_week`` deliberately uses the
previous *observed* same weekday/hour instead, so sensor gaps do not make
the feature unusable.
"""
chrono = df.sort_values(["sensor", "t"]).copy()
chrono["lag_168"] = chrono.groupby("sensor", observed=True)["y"].shift(168)
out = chrono.sort_values(["sensor", "weekday", "hour", "t"]).copy()
grouped = out.groupby(["sensor", "weekday", "hour"], observed=True)["y"]
out["lag_week"] = grouped.shift(1)
prior = pd.concat(
+231
View File
@@ -0,0 +1,231 @@
"""Forecast model bundle: fit, inference frame, prediction bands, scenarios.
The production model is one global HistGradientBoostingRegressor over all eight
sensors. It only uses features that are at least 168 h old (7-day-safe), so a
168 h forecast can be produced in one pass without recursive leakage.
"""
from __future__ import annotations
import numpy as np
import pandas as pd
from sklearn.ensemble import HistGradientBoostingRegressor
from sklearn.metrics import r2_score
from . import config
from .features import SENSOR_CODES, future_calendar
# Fixed, deliberately small model. No tuning beyond a short sanity pass: the
# 28-day holdout is the honest signal, not the training loss.
HISTGB_PARAMS = {
"loss": "squared_error",
"learning_rate": 0.06,
"max_iter": 300,
"max_leaf_nodes": 31,
"min_samples_leaf": 20,
"l2_regularization": 1.0,
"early_stopping": False,
"random_state": 42,
}
def fit(frame: pd.DataFrame, columns: list[str] | tuple[str, ...]):
"""Fit the global HistGB on rows with an observed target."""
data = frame[frame["y"].notna()]
model = HistGradientBoostingRegressor(**HISTGB_PARAMS)
model.fit(data[list(columns)], data["y"].astype(float))
return model
def predict(bundle: dict, frame: pd.DataFrame) -> np.ndarray:
"""Predict non-negative footfall density for a feature frame."""
values = bundle["model"].predict(frame[list(bundle["features"])])
return np.clip(np.asarray(values, dtype=float), 0.0, None)
def metrics(y_true, y_pred) -> dict:
"""MAE, WAPE and R² on a common evaluation frame."""
y = np.asarray(y_true, dtype=float)
p = np.asarray(y_pred, dtype=float)
abs_err = np.abs(y - p)
denominator = float(np.sum(np.abs(y)))
return {
"mae": float(np.mean(abs_err)),
"wape": (100.0 * float(np.sum(abs_err)) / denominator) if denominator else 0.0,
"r2": float(r2_score(y, p)) if len(y) > 1 else 0.0,
"n": len(y),
}
def residual_quantiles(eval_frame: pd.DataFrame, pred: np.ndarray) -> dict:
"""80% prediction band offsets from the honest holdout residuals."""
residual = np.asarray(eval_frame["y"], dtype=float) - np.asarray(pred, dtype=float)
return {
"p10": round(float(np.quantile(residual, 0.10)), 4),
"p50": round(float(np.quantile(residual, 0.50)), 4),
"p90": round(float(np.quantile(residual, 0.90)), 4),
}
def weather_climatology(archive: pd.DataFrame) -> dict:
"""Month x local-hour weather means, used when forecast weather is absent."""
default = {"temp_c": 14.0, "precip_mm": 0.0}
if archive is None or archive.empty or "temp_c" not in archive.columns:
return {"default": default}
frame = archive.copy()
local = frame["time"].dt.tz_convert(config.TIMEZONE)
frame["month"] = local.dt.month.astype(int)
frame["hour"] = local.dt.hour.astype(int)
grouped = (
frame.groupby(["month", "hour"], observed=True)
.agg(temp_c=("temp_c", "mean"), precip_mm=("precip_mm", "mean"))
.reset_index()
)
out = {
"default": {
"temp_c": round(float(frame["temp_c"].mean()), 3),
"precip_mm": round(float(frame["precip_mm"].mean()), 3),
}
}
for row in grouped.itertuples(index=False):
out[f"{int(row.month)}|{int(row.hour)}"] = {
"temp_c": round(float(row.temp_c), 3),
"precip_mm": round(float(row.precip_mm), 3),
}
return out
def _lookup_values(
bundle: dict, frame: pd.DataFrame, sensor: str
) -> tuple[pd.Series, pd.Series]:
"""Return (last observed, 4-week mean) per future weekday/hour."""
lookup = bundle.get("seasonal_lookup") or {}
fallback = float(bundle.get("sensor_mean", {}).get(sensor, 10.0))
last_values = []
mean_values = []
for weekday, hour in zip(frame["weekday"], frame["hour"], strict=True):
entry = lookup.get(f"{sensor}|{int(weekday)}|{int(hour)}", {})
mean4 = float(entry.get("mean4", fallback))
mean_values.append(mean4)
last_values.append(float(entry.get("last", mean4)))
return (
pd.Series(last_values, index=frame.index, dtype=float),
pd.Series(mean_values, index=frame.index, dtype=float),
)
def _fill_weather(bundle: dict, frame: pd.DataFrame) -> pd.DataFrame:
climatology = bundle.get("weather_climatology") or {}
default = climatology.get("default") or {"temp_c": 14.0, "precip_mm": 0.0}
keys = [f"{int(m)}|{int(h)}" for m, h in zip(frame["month"], frame["hour"], strict=True)]
temp = [
float(climatology.get(key, default)["temp_c"])
for key in keys
]
precip = [
float(climatology.get(key, default)["precip_mm"])
for key in keys
]
frame["temp_c"] = frame["temp_c"].fillna(pd.Series(temp, index=frame.index))
frame["precip_mm"] = frame["precip_mm"].fillna(pd.Series(precip, index=frame.index))
return frame
def future_frame(
bundle: dict,
sensor: str,
start: pd.Timestamp,
periods: int,
weather_forecast: pd.DataFrame | None = None,
*,
temp_delta: float = 0.0,
precip_mm: float | None = None,
weather_mask: np.ndarray | None = None,
holiday_override: bool | None = None,
) -> pd.DataFrame:
"""Build a leakage-free inference frame for one sensor and horizon.
``weather_mask`` selects the rows where the scenario weather adjustment
applies (for example, Saturday store hours). Rows outside the mask keep the
baked forecast weather.
"""
frame = future_calendar(start, periods)
frame["sensor"] = sensor
frame["sensor_code"] = SENSOR_CODES.get(sensor, -1)
last_values, mean_values = _lookup_values(bundle, frame, sensor)
frame["lag_week"] = last_values
frame["seasonal_mean_4w"] = mean_values
if weather_forecast is not None and not weather_forecast.empty:
weather = weather_forecast.rename(columns={"time": "t"}).copy()
weather["t"] = pd.to_datetime(weather["t"], utc=True)
weather = (
weather[["t", "temp_c", "precip_mm"]]
.sort_values("t")
.drop_duplicates("t", keep="last")
)
frame = pd.merge_asof(
frame.sort_values("t"),
weather,
on="t",
direction="nearest",
tolerance=pd.Timedelta("3h"),
)
else:
frame["temp_c"] = np.nan
frame["precip_mm"] = np.nan
frame = _fill_weather(bundle, frame)
mask = (
np.ones(len(frame), dtype=bool)
if weather_mask is None
else np.asarray(weather_mask, dtype=bool)
)
if temp_delta:
frame.loc[mask, "temp_c"] = frame.loc[mask, "temp_c"] + float(temp_delta)
if precip_mm is not None:
frame.loc[mask, "precip_mm"] = float(precip_mm)
if holiday_override is not None:
frame["is_holiday"] = int(bool(holiday_override))
frame["holiday_name"] = None
return frame.sort_values("t").reset_index(drop=True)
def event_multiplier(frame: pd.DataFrame, scenario: dict) -> np.ndarray:
"""Transparent multiplicative overlay for a scenario's event hours."""
event = scenario.get("event")
if not event:
return np.ones(len(frame), dtype=float)
mask = frame["weekday"].isin(event.get("weekdays", [])).to_numpy(dtype=bool, copy=True)
hours = event.get("hours")
if hours is not None:
mask &= frame["hour"].isin(hours).to_numpy(dtype=bool, copy=True)
return np.where(mask, 1.0 + float(event.get("uplift", 0.0)), 1.0)
def _rfc3339(ts) -> str:
return pd.Timestamp(ts).tz_convert("UTC").strftime("%Y-%m-%dT%H:%M:%SZ")
def points(frame: pd.DataFrame, pred: np.ndarray, bundle: dict, sensor: str) -> list[dict]:
"""Contract point shape: t, v, lo, hi (80% band)."""
band = bundle.get("residual_quantiles") or {"p10": -5.0, "p90": 5.0}
p10 = float(band.get("p10", -5.0))
p90 = float(band.get("p90", 5.0))
out = []
for timestamp, value in zip(frame["t"], pred, strict=True):
v = max(float(value), 0.0)
lo = max(v + p10, 0.0)
hi = max(v + p90, lo)
out.append(
{
"t": _rfc3339(timestamp),
"v": round(v, 2),
"lo": round(lo, 2),
"hi": round(hi, 2),
}
)
return out
+6 -4
View File
@@ -78,8 +78,10 @@ def clean(df: pd.DataFrame) -> tuple[pd.DataFrame, pd.DataFrame, dict]:
)
multi = density[density["time"] >= pd.Timestamp(config.MULTI_SENSOR_START)]
# The device merge spans the full history: the old device is outside the
# 8-sensor window, so counting only `multi` would hide it.
density_01_devices = (
multi[multi["sensor"] == "density-01"]
density[density["sensor"] == "density-01"]
.groupby("sensor_id", observed=True)
.agg(rows=("value", "size"), first=("time", "min"), last=("time", "max"))
)
@@ -99,9 +101,9 @@ def clean(df: pd.DataFrame) -> tuple[pd.DataFrame, pd.DataFrame, dict]:
)
audit = {
"raw_rows": int(len(df)),
"density_rows": int(len(df[df["type"] == "densityData"])),
"battery_rows": int(len(df[df["type"] == "batteryData"])),
"raw_rows": len(df),
"density_rows": len(df[df["type"] == "densityData"]),
"battery_rows": len(df[df["type"] == "batteryData"]),
"device_ids": int(df["sensor_id"].nunique()),
"sensor_names": int(df["name"].nunique()),
"usable_sensors": len(usable),
+211
View File
@@ -0,0 +1,211 @@
"""`make data`: parse CSV, aggregate hourly, join weather/holidays, export JSON."""
from __future__ import annotations
import argparse
import json
import logging
import pandas as pd
from . import config
from .features import build_features, to_hourly
from .parse import clean, load_raw, write_audit
from .weather import ensure_weather
log = logging.getLogger(__name__)
def rfc3339(ts) -> str:
return pd.Timestamp(ts).tz_convert("UTC").strftime("%Y-%m-%dT%H:%M:%SZ")
def minute_iso(value: str | None) -> str | None:
if not value:
return None
return pd.Timestamp(value).tz_convert("UTC").floor("min").strftime("%Y-%m-%dT%H:%M:%SZ")
def _series_points(frame: pd.DataFrame) -> list[dict]:
return [
{"t": rfc3339(t), "v": round(float(v), 2)}
for t, v in zip(frame["t"], frame["v"], strict=True)
]
def export_sensors(density: pd.DataFrame, battery: pd.DataFrame) -> list[dict]:
multi = density[density["time"] >= pd.Timestamp(config.MULTI_SENSOR_START)]
battery_latest = (
battery.sort_values("time").groupby("sensor", observed=True).tail(1).set_index("sensor")
)
out = []
for sensor in sorted(config.USABLE_SENSORS):
rows = multi[multi["sensor"] == sensor]
last = density[density["sensor"] == sensor]["time"].max()
out.append(
{
"id": sensor,
"name": config.DISPLAY_NAMES[sensor],
"lat": round(float(rows["latitude"].median()), 6),
"lon": round(float(rows["longitude"].median()), 6),
"mean": round(float(rows["value"].mean()), 1),
"p95": round(float(rows["value"].quantile(0.95)), 1),
"battery": (
round(float(battery_latest.loc[sensor, "value"]))
if sensor in battery_latest.index
else None
),
"last_seen": rfc3339(last),
}
)
return out
def export_series(hourly: pd.DataFrame, data_version: str) -> dict:
artifacts = config.artifacts_dir()
series_dir = artifacts / "series"
series_dir.mkdir(parents=True, exist_ok=True)
per_sensor: dict[str, list[dict]] = {}
for sensor in sorted(config.USABLE_SENSORS):
frame = hourly[hourly["sensor"] == sensor]
pts = _series_points(frame)
per_sensor[sensor] = pts
(series_dir / f"{sensor}.json").write_text(
json.dumps(
{"sensor": sensor, "step": "1h", "points": pts}, ensure_ascii=False
)
+ "\n"
)
payload = {"step": "1h", "data_version": data_version, "series": per_sensor}
(artifacts / "series.json").write_text(json.dumps(payload, ensure_ascii=False) + "\n")
return payload
def _weather_now(forecast: pd.DataFrame, meta: dict) -> dict:
current = meta.get("current") or {}
now_t = current.get("t")
if now_t:
ts = pd.Timestamp(now_t, tz="UTC") if pd.Timestamp(now_t).tz is None else pd.Timestamp(now_t).tz_convert("UTC")
else:
ts = pd.Timestamp(meta["fetched_at"]).tz_convert("UTC")
row = forecast.iloc[(forecast["time"] - ts).abs().argmin()]
return {
"t": rfc3339(ts),
"temp_c": round(float(current.get("temp_c", row["temp_c"])), 1),
"precip_mm": round(float(current.get("precip_mm", row["precip_mm"])), 2),
"cloud_pct": round(float(current.get("cloud_pct", row["cloud_pct"]))),
"wind_kmh": round(float(current.get("wind_kmh", row["wind_kmh"])), 1),
"humidity_pct": round(float(current.get("humidity_pct", row["humidity_pct"]))),
}
def export_context(forecast: pd.DataFrame, meta: dict) -> dict:
now = _weather_now(forecast, meta)
start = pd.Timestamp(now["t"]).floor("h")
window = forecast[(forecast["time"] >= start) & (forecast["time"] < start + pd.Timedelta(days=7))]
points = [
{
"t": rfc3339(row.time),
"temp_c": round(float(row.temp_c), 1),
"precip_mm": round(float(row.precip_mm), 2),
"cloud_pct": round(float(row.cloud_pct)),
"wind_kmh": round(float(row.wind_kmh), 1),
"humidity_pct": round(float(row.humidity_pct)),
}
for row in window.itertuples(index=False)
]
holidays = [
{"date": date, "name": name} for date, name in sorted(config.HOLIDAYS.items())
]
payload = {
"weather": {"now": now, "forecast": points},
"holidays": holidays,
"updated_at": meta["fetched_at"],
"cached": False,
}
(config.artifacts_dir() / "context.json").write_text(
json.dumps(payload, indent=2, ensure_ascii=False) + "\n"
)
return payload
def run_data(*, refresh_weather: bool = False) -> dict:
logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s")
artifacts = config.artifacts_dir()
cache = config.cache_dir()
artifacts.mkdir(parents=True, exist_ok=True)
cache.mkdir(parents=True, exist_ok=True)
raw = load_raw()
density, battery, audit = clean(raw)
write_audit(audit)
# The product window is the 8-sensor period. density-01 has 13 months of
# history, but using it alone would add single-sensor annual seasonality that
# the other seven locations cannot support. Keep the full-file audit above.
window_start = pd.Timestamp(config.MULTI_SENSOR_START)
density = density[density["time"] >= window_start].copy()
battery = battery[battery["time"] >= window_start].copy()
density[["time", "sensor", "sensor_id", "value"]].to_parquet(
cache / "density_clean.parquet", index=False
)
battery[["time", "sensor", "sensor_id", "value"]].to_parquet(
cache / "battery_clean.parquet", index=False
)
log.info(
"parsed %s rows; %s usable sensors; %s density rows in the 8-sensor window",
audit["raw_rows"],
audit["usable_sensors"],
len(density),
)
hourly = to_hourly(density)
hourly.to_parquet(cache / "hourly.parquet", index=False)
archive, forecast, meta = ensure_weather(
density["time"].min(), density["time"].max(), refresh=refresh_weather
)
features = build_features(hourly, archive)
features.to_parquet(cache / "hourly_features.parquet", index=False)
log.info("built %s hourly feature rows", len(features))
# Bake compact weather frames beside the JSON so the FastAPI image can
# retrain and serve /predict without the git-ignored data/cache directory.
archive.to_parquet(artifacts / "weather_archive.parquet", index=False)
forecast.to_parquet(artifacts / "weather_forecast.parquet", index=False)
(artifacts / "weather_meta.json").write_text(
json.dumps(meta, indent=2, ensure_ascii=False) + "\n"
)
data_version = minute_iso(audit["time_range"]["to"])
sensors = export_sensors(density, battery)
(artifacts / "sensors.json").write_text(
json.dumps(sensors, indent=2, ensure_ascii=False) + "\n"
)
series = export_series(hourly, data_version)
context = export_context(forecast, meta)
summary = {
"sensors": len(sensors),
"series_sensors": len(series["series"]),
"hourly_rows": len(hourly),
"feature_rows": len(features),
"weather_rows": len(archive),
"context_forecast_hours": len(context["weather"]["forecast"]),
"data_version": data_version,
"audit_ok": audit["all_checks_ok"],
}
log.info("data artifacts written to %s: %s", artifacts, json.dumps(summary))
return summary
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--refresh-weather", action="store_true")
args = parser.parse_args()
run_data(refresh_weather=args.refresh_weather)
if __name__ == "__main__":
main()
+88
View File
@@ -0,0 +1,88 @@
"""Runtime retraining from an uploaded CSV.
The API must not depend on the raw challenge file or on the git-ignored cache.
Forecast retraining therefore reuses the baked weather archive and the same
leakage-safe feature builder as ``make train``.
"""
from __future__ import annotations
import json
import logging
from datetime import UTC, datetime
from pathlib import Path
import pandas as pd
from . import config
from .features import build_features
from .small import load_hourly_csv
from .train import train_bundle
log = logging.getLogger(__name__)
def _read_weather() -> tuple[pd.DataFrame, dict]:
weather_dir = config.weather_dir()
archive_path = weather_dir / "weather_archive.parquet"
meta_path = weather_dir / "weather_meta.json"
if archive_path.exists():
archive = pd.read_parquet(archive_path)
else:
archive = pd.DataFrame(
{
"time": pd.to_datetime([], utc=True),
"temp_c": pd.Series(dtype=float),
"precip_mm": pd.Series(dtype=float),
}
)
log.warning("no baked weather archive; forecast training uses missing weather")
meta = (
json.loads(meta_path.read_text())
if meta_path.exists()
else {
"fetched_at": datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%SZ"),
"source": "missing",
}
)
return archive, meta
def train_forecast_from_csv(path: Path | str) -> tuple[dict, dict, dict]:
"""Retrain the global forecast model from an uploaded PAX-style CSV."""
hourly = load_hourly_csv(path)
hourly = hourly[hourly["sensor"].isin(config.USABLE_SENSORS)].copy()
if hourly.empty:
raise ValueError(
"CSV has none of the eight known sensors; forecast retraining needs "
"sensor names from the challenge data"
)
start = pd.Timestamp(config.MULTI_SENSOR_START)
hourly = hourly[hourly["t"] >= start][["sensor", "t", "v"]].copy()
if len(hourly) < 500:
raise ValueError("not enough hourly rows for a 28-day holdout")
archive, meta = _read_weather()
features = build_features(hourly, archive)
audit = {
"usable_sensors": int(hourly["sensor"].nunique()),
"cadence_median_min": 60,
"time_range": {
"from": hourly["t"].min().strftime("%Y-%m-%dT%H:%M:%SZ"),
"to": hourly["t"].max().strftime("%Y-%m-%dT%H:%M:%SZ"),
},
}
bundle, metrics_payload, _ = train_bundle(hourly, features, archive, meta, audit)
trained_at = bundle["metadata"]["trained_at"]
version = f"histgb-{trained_at[:10].replace('-', '')}-{trained_at[11:19].replace(':', '')}"
bundle["metadata"]["model_version"] = version
metrics_payload["model_version"] = version
log.info(
"forecast retrained from %s: %s MAE %.2f WAPE %.1f%%",
path,
version,
metrics_payload["metrics"]["mae"],
metrics_payload["metrics"]["wape"],
)
return bundle, metrics_payload, audit
+630
View File
@@ -0,0 +1,630 @@
"""FastAPI ML service: /healthz, /readyz, /meta, /predict, /simulate, /train.
Shapes follow CONTRACT.md. The service is internal: only Go exposes it publicly,
and the training routes require a bearer control token.
"""
from __future__ import annotations
import hmac
import json
import logging
import threading
import uuid
from contextlib import asynccontextmanager
from dataclasses import dataclass, field
from datetime import UTC, datetime
from pathlib import Path
from typing import Any
import joblib
import numpy as np
import pandas as pd
from fastapi import FastAPI, Header, HTTPException, Request
from fastapi.exceptions import RequestValidationError
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from pydantic import BaseModel, ConfigDict
from . import config
from .features import future_calendar
from .model import event_multiplier, future_frame, points, predict
from .retrain import train_forecast_from_csv
from .small import train_small_from_csv
log = logging.getLogger(__name__)
MAX_UPLOAD_BYTES = 60 * 1024 * 1024
ACTIVE_STATUSES = {"queued", "running"}
def _utc_now() -> str:
return datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%SZ")
@dataclass
class Runtime:
bundle: dict | None = None
metrics: dict | None = None
weather: pd.DataFrame | None = None
weather_meta: dict | None = None
small_bundle: dict | None = None
small_metrics: dict | None = None
model_source: str = "baked"
jobs: dict[str, dict[str, Any]] = field(default_factory=dict)
jobs_lock: threading.Lock = field(default_factory=threading.Lock)
schedule_lock: threading.Lock = field(default_factory=threading.Lock)
def _load_runtime(runtime: Runtime) -> None:
artifacts = config.artifacts_dir()
model_path = artifacts / "model.joblib"
metrics_path = artifacts / "metrics.json"
if model_path.exists() and metrics_path.exists():
runtime.bundle = joblib.load(model_path)
runtime.metrics = json.loads(metrics_path.read_text())
log.info("loaded baked model %s", runtime.metrics.get("model_version"))
else:
log.warning("baked model missing under %s; /readyz will fail", artifacts)
weather_path = config.weather_dir() / "weather_forecast.parquet"
if weather_path.exists():
runtime.weather = pd.read_parquet(weather_path)
meta_path = config.weather_dir() / "weather_meta.json"
runtime.weather_meta = (
json.loads(meta_path.read_text()) if meta_path.exists() else None
)
small_path = artifacts / "small_model.joblib"
small_metrics_path = artifacts / "small_metrics.json"
if small_path.exists():
runtime.small_bundle = joblib.load(small_path)
if small_metrics_path.exists():
runtime.small_metrics = json.loads(small_metrics_path.read_text())
# --------------------------------------------------------------------------- schemas
class WeatherOverride(BaseModel):
model_config = ConfigDict(extra="ignore")
temp_c: float | None = None
precip_mm: float | None = None
class PredictRequest(BaseModel):
model_config = ConfigDict(extra="ignore")
sensor: str
horizon: str = "7d"
scenario: str = "base"
weather: WeatherOverride | None = None
is_holiday: bool | None = None
class SimulateWeather(BaseModel):
model_config = ConfigDict(extra="ignore")
temp_delta_c: float = 0.0
precip_mm: float | None = None
class SimulateRequest(BaseModel):
model_config = ConfigDict(extra="ignore")
scenario: str = "base"
weather: SimulateWeather | None = None
sensors: str | list[str] = "all"
is_holiday: bool | None = None
# --------------------------------------------------------------------------- helpers
def _require_token(authorization: str | None) -> None:
expected = config.control_token()
if not expected:
raise HTTPException(503, "CONTROL_TOKEN is not configured")
if not authorization or not authorization.startswith("Bearer "):
raise HTTPException(401, "missing control token")
token = authorization.removeprefix("Bearer ").strip()
if not hmac.compare_digest(token, expected):
raise HTTPException(401, "invalid control token")
def _scenario_weather_mask(calendar: pd.DataFrame, scenario: dict) -> np.ndarray | None:
event = scenario.get("event")
if not event:
return None
mask = calendar["weekday"].isin(event.get("weekdays", [])).to_numpy(dtype=bool, copy=True)
hours = event.get("hours")
if hours is not None:
mask &= calendar["hour"].isin(hours).to_numpy(dtype=bool, copy=True)
return mask
def _override_weather(runtime: Runtime, override: WeatherOverride | None) -> pd.DataFrame | None:
if override is None or runtime.weather is None:
return runtime.weather
weather = runtime.weather.copy()
if override.temp_c is not None:
weather["temp_c"] = float(override.temp_c)
if override.precip_mm is not None:
weather["precip_mm"] = float(override.precip_mm)
return weather
def _hourly_points(
runtime: Runtime,
sensor: str,
scenario_name: str,
periods: int,
weather_override: WeatherOverride | None = None,
holiday_override: bool | None = None,
*,
start: pd.Timestamp | None = None,
temp_delta_override: float | None = None,
precip_override: float | None = None,
) -> list[dict]:
assert runtime.bundle is not None
scenario = config.SCENARIOS[scenario_name]
start = start or pd.Timestamp.now(tz="UTC").ceil("h")
calendar = future_calendar(start, periods)
mask = _scenario_weather_mask(calendar, scenario)
explicit_weather = weather_override is not None and (
weather_override.temp_c is not None or weather_override.precip_mm is not None
)
temp_delta = 0.0 if explicit_weather else scenario["temp_delta_c"]
precip = None if explicit_weather else scenario["precip_mm"]
if temp_delta_override is not None:
temp_delta = float(temp_delta_override)
if precip_override is not None:
precip = precip_override
frame = future_frame(
runtime.bundle,
sensor,
start,
periods,
_override_weather(runtime, weather_override),
temp_delta=temp_delta,
precip_mm=precip,
weather_mask=mask,
holiday_override=holiday_override,
)
pred = predict(runtime.bundle, frame) * event_multiplier(frame, scenario)
return points(frame, pred, runtime.bundle, sensor)
def _quarter_hour_points(
runtime: Runtime,
sensor: str,
scenario_name: str,
count: int,
weather_override: WeatherOverride | None = None,
holiday_override: bool | None = None,
*,
first: pd.Timestamp | None = None,
temp_delta_override: float | None = None,
precip_override: float | None = None,
) -> list[dict]:
"""Interpolate the hourly model to the next 15-minute points (15m/1h)."""
first = first or pd.Timestamp.now(tz="UTC").ceil("15min")
hourly = _hourly_points(
runtime,
sensor,
scenario_name,
periods=3,
weather_override=weather_override,
holiday_override=holiday_override,
start=first.floor("h"),
temp_delta_override=temp_delta_override,
precip_override=precip_override,
)
source_times = pd.to_datetime([point["t"] for point in hourly], utc=True)
targets = pd.date_range(first, periods=count, freq="15min")
x = source_times.astype("int64").to_numpy() // 10**9
tx = targets.astype("int64").to_numpy() // 10**9
out = []
for target, target_x in zip(targets, tx, strict=True):
row = {"t": target.strftime("%Y-%m-%dT%H:%M:%SZ")}
for key in ("v", "lo", "hi"):
values = np.array([point[key] for point in hourly], dtype=float)
row[key] = round(max(float(np.interp(target_x, x, values)), 0.0), 2)
out.append(row)
return out
def _forecast(
runtime: Runtime,
sensor: str,
horizon: str,
scenario_name: str,
weather_override: WeatherOverride | None,
holiday_override: bool | None,
) -> list[dict]:
if horizon == "15m":
return _quarter_hour_points(
runtime, sensor, scenario_name, 1, weather_override, holiday_override
)
if horizon == "1h":
return _quarter_hour_points(
runtime, sensor, scenario_name, 4, weather_override, holiday_override
)
return _hourly_points(
runtime,
sensor,
scenario_name,
config.HORIZON_STEPS[horizon],
weather_override,
holiday_override,
)
def _validate_sensor(sensor: str) -> None:
if sensor not in config.USABLE_SENSORS:
raise HTTPException(404, f"unknown sensor: {sensor}")
def _validate_scenario(scenario: str) -> None:
if scenario not in config.SCENARIOS:
raise HTTPException(400, f"unknown scenario: {scenario}")
def _validate_horizon(horizon: str) -> None:
if horizon not in config.HORIZON_STEPS:
raise HTTPException(400, f"unknown horizon: {horizon}")
async def _parse_train_request(request: Request) -> tuple[str, Path]:
content_type = request.headers.get("content-type", "")
model = "small"
path: Path | None = None
if content_type.startswith("multipart/form-data"):
form = await request.form()
model = str(form.get("model") or "small")
upload = form.get("file")
path_field = form.get("path")
if upload is not None and hasattr(upload, "read"):
upload_dir = config.upload_dir()
upload_dir.mkdir(parents=True, exist_ok=True)
suffix = Path(getattr(upload, "filename", "") or "upload.csv").suffix or ".csv"
destination = upload_dir / f"{uuid.uuid4().hex}{suffix}"
size = 0
with destination.open("wb") as handle:
while chunk := await upload.read(1024 * 1024):
size += len(chunk)
if size > MAX_UPLOAD_BYTES:
destination.unlink(missing_ok=True)
raise HTTPException(413, "uploaded CSV is too large")
handle.write(chunk)
path = destination
elif path_field:
path = Path(str(path_field))
else:
raise HTTPException(400, "multipart request needs a file field")
elif content_type.startswith("application/json"):
payload = await request.json()
if not isinstance(payload, dict):
raise HTTPException(400, "JSON body must be an object")
model = str(payload.get("model") or "small")
if not payload.get("path"):
raise HTTPException(400, "JSON request needs path")
path = Path(str(payload["path"]))
else:
raise HTTPException(400, "use multipart/form-data or application/json")
if model not in {"small", "forecast"}:
raise HTTPException(400, f"unknown model: {model}")
if path is None or not path.exists() or not path.is_file():
raise HTTPException(400, f"CSV not found: {path}")
if path.stat().st_size > MAX_UPLOAD_BYTES:
raise HTTPException(413, "uploaded CSV is too large")
return model, path
def _run_job(runtime: Runtime, job_id: str, model: str, path: Path) -> None:
with runtime.jobs_lock:
job = runtime.jobs[job_id]
job["status"] = "running"
job["started_at"] = _utc_now()
try:
if model == "small":
bundle, payload = train_small_from_csv(path)
job_metrics = payload["metrics"]
else:
bundle, payload, _ = train_forecast_from_csv(path)
job_metrics = {
**payload["metrics"],
"ablation": payload.get("ablation", []),
}
version = payload["model_version"]
models = config.model_dir()
models.mkdir(parents=True, exist_ok=True)
latest = models / ("small_latest.joblib" if model == "small" else "forecast_latest.joblib")
joblib.dump(bundle, latest)
joblib.dump(bundle, models / f"{job_id}-{model}.joblib")
with runtime.jobs_lock:
if model == "small":
runtime.small_bundle = bundle
runtime.small_metrics = payload
else:
runtime.bundle = bundle
runtime.metrics = payload
runtime.model_source = "retrained"
job.update(
status="succeeded",
metrics=job_metrics,
model_version=version,
finished_at=_utc_now(),
error=None,
)
log.info("training job %s (%s) succeeded: %s", job_id, model, version)
except Exception as exc: # surfaced verbatim in GET /train/{job_id}
log.exception("training job %s (%s) failed", job_id, model)
with runtime.jobs_lock:
job.update(
status="failed",
metrics=None,
finished_at=_utc_now(),
error=str(exc) or exc.__class__.__name__,
)
# --------------------------------------------------------------------------- app
def create_app() -> FastAPI:
@asynccontextmanager
async def lifespan(app: FastAPI):
runtime = Runtime()
_load_runtime(runtime)
app.state.runtime = runtime
yield
app = FastAPI(
title="PulseCast ML",
version="0.1.0",
description="Weather-aware footfall forecast, scenarios, and small-model retraining.",
lifespan=lifespan,
)
app.add_middleware(
CORSMiddleware,
allow_origins=["https://pulse.noelsabia.dev", "http://localhost:3000"],
allow_methods=["GET", "POST", "OPTIONS"],
allow_headers=["Content-Type", "Authorization"],
)
@app.exception_handler(HTTPException)
async def http_error(_: Request, exc: HTTPException) -> JSONResponse:
codes = {
400: "bad_request",
401: "unauthorized",
404: "not_found",
409: "conflict",
413: "payload_too_large",
503: "unavailable",
}
return JSONResponse(
status_code=exc.status_code,
content={
"error": {
"code": codes.get(exc.status_code, "error"),
"message": str(exc.detail),
}
},
)
@app.exception_handler(RequestValidationError)
async def validation_error(_: Request, exc: RequestValidationError) -> JSONResponse:
message = "; ".join(
f"{'.'.join(str(part) for part in error['loc'])}: {error['msg']}"
for error in exc.errors()
)
return JSONResponse(
status_code=400,
content={"error": {"code": "bad_request", "message": message or "invalid request"}},
)
@app.exception_handler(Exception)
async def unhandled_error(_: Request, exc: Exception) -> JSONResponse:
log.exception("unhandled error")
return JSONResponse(
status_code=500,
content={"error": {"code": "internal", "message": "internal server error"}},
)
def runtime() -> Runtime:
return app.state.runtime
@app.get("/healthz")
def healthz() -> dict:
return {"ok": True}
@app.get("/readyz")
def readyz() -> JSONResponse:
ready = runtime().bundle is not None
return JSONResponse(
status_code=200 if ready else 503,
content={"ok": ready, "model": ready},
)
@app.get("/meta")
def meta() -> dict:
state = runtime()
if state.metrics is None:
raise HTTPException(503, "model metadata is not loaded")
payload = dict(state.metrics)
payload["model_source"] = state.model_source
payload["weather_updated_at"] = (
(state.weather_meta or {}).get("fetched_at") or state.metrics.get("context_version")
)
if state.small_metrics:
payload["small_model"] = {
"model_version": state.small_metrics.get("model_version"),
"trained_at": state.small_metrics.get("trained_at"),
"features": state.small_metrics.get("features"),
"metrics": state.small_metrics.get("metrics"),
}
return payload
@app.post("/predict")
def predict_endpoint(body: PredictRequest) -> dict:
state = runtime()
if state.bundle is None:
raise HTTPException(503, "model is not loaded")
_validate_sensor(body.sensor)
_validate_horizon(body.horizon)
_validate_scenario(body.scenario)
forecast = _forecast(
state, body.sensor, body.horizon, body.scenario, body.weather, body.is_holiday
)
bundle_meta = state.bundle["metadata"]
return {
"sensor": body.sensor,
"horizon": body.horizon,
"scenario": body.scenario,
"points": forecast,
"data_version": bundle_meta.get("data_version"),
"model_version": bundle_meta.get("model_version"),
"context_version": bundle_meta.get("context_version"),
}
@app.post("/simulate")
def simulate_endpoint(body: SimulateRequest) -> dict:
state = runtime()
if state.bundle is None:
raise HTTPException(503, "model is not loaded")
_validate_scenario(body.scenario)
if body.sensors == "all":
sensors = sorted(config.USABLE_SENSORS)
elif isinstance(body.sensors, list) and body.sensors:
for sensor in body.sensors:
_validate_sensor(sensor)
sensors = list(body.sensors)
else:
raise HTTPException(400, "sensors must be 'all' or a non-empty list")
scenario = config.SCENARIOS[body.scenario]
# An explicit weather body overrides the scenario preset; it is not an
# additional delta on top of it.
temp_delta = (
float(body.weather.temp_delta_c)
if body.weather is not None
else scenario["temp_delta_c"]
)
precip = (
body.weather.precip_mm
if body.weather is not None and body.weather.precip_mm is not None
else scenario["precip_mm"]
)
now = pd.Timestamp.now(tz="UTC")
start = now.ceil("h")
first = now.ceil("15min")
forecasts: dict[str, dict[str, list[dict]]] = {}
for sensor in sensors:
calendar = future_calendar(start, config.HORIZON_STEPS["7d"])
mask = _scenario_weather_mask(calendar, scenario)
frame = future_frame(
state.bundle,
sensor,
start,
config.HORIZON_STEPS["7d"],
_override_weather(state, None),
temp_delta=temp_delta,
precip_mm=precip,
weather_mask=mask,
holiday_override=body.is_holiday,
)
pred = predict(state.bundle, frame) * event_multiplier(frame, scenario)
pts = points(frame, pred, state.bundle, sensor)
forecasts[sensor] = {
"15m": _quarter_hour_points(
state,
sensor,
body.scenario,
1,
None,
body.is_holiday,
first=first,
temp_delta_override=temp_delta,
precip_override=precip,
),
"1h": _quarter_hour_points(
state,
sensor,
body.scenario,
4,
None,
body.is_holiday,
first=first,
temp_delta_override=temp_delta,
precip_override=precip,
),
"48h": pts[: config.HORIZON_STEPS["48h"]],
"7d": pts,
}
bundle_meta = state.bundle["metadata"]
return {
"scenario": body.scenario,
"generated_at": _utc_now(),
"forecasts": forecasts,
"data_version": bundle_meta.get("data_version"),
"model_version": bundle_meta.get("model_version"),
"context_version": bundle_meta.get("context_version"),
}
@app.post("/train", status_code=202)
async def train_endpoint(
request: Request, authorization: str | None = Header(default=None)
) -> dict:
_require_token(authorization)
state = runtime()
model, path = await _parse_train_request(request)
with state.schedule_lock:
with state.jobs_lock:
if any(job["status"] in ACTIVE_STATUSES for job in state.jobs.values()):
raise HTTPException(409, "a training job is already running")
job_id = uuid.uuid4().hex
submitted_at = _utc_now()
state.jobs[job_id] = {
"job_id": job_id,
"status": "queued",
"model": model,
"submitted_at": submitted_at,
"started_at": None,
"finished_at": None,
"metrics": None,
"model_version": None,
"error": None,
}
thread = threading.Thread(
target=_run_job,
args=(state, job_id, model, path),
name=f"train-{job_id[:8]}",
daemon=True,
)
thread.start()
return {
"job_id": job_id,
"status": "queued",
"model": model,
"submitted_at": submitted_at,
}
@app.get("/train/{job_id}")
def train_status(job_id: str, authorization: str | None = Header(default=None)) -> dict:
_require_token(authorization)
with runtime().jobs_lock:
job = runtime().jobs.get(job_id)
if job is None:
raise HTTPException(404, f"unknown job: {job_id}")
return dict(job)
return app
app = create_app()
+305
View File
@@ -0,0 +1,305 @@
"""Small "busy hour" classifier used by the training demo.
Target: ``busy`` = hourly footfall above that sensor's p75. Features are the
contract's six cheap signals: hour, weekday, weekend, temperature, rain,
holiday. Logistic regression on a time-based split; retrains in well under 5 s
on the full challenge CSV and accepts simpler uploaded CSVs too.
"""
from __future__ import annotations
import logging
from datetime import UTC, datetime
from pathlib import Path
import numpy as np
import pandas as pd
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import (
accuracy_score,
f1_score,
precision_score,
recall_score,
roc_auc_score,
)
from sklearn.pipeline import Pipeline
from sklearn.preprocessing import StandardScaler
from . import config
log = logging.getLogger(__name__)
TIME_COLUMNS = ("time", "timestamp", "datetime", "date", "hour")
VALUE_COLUMNS = ("value", "density", "footfall", "count", "pax", "visitors")
SENSOR_COLUMNS = ("sensor", "sensor_id", "site", "location", "name", "id")
TEMP_COLUMNS = ("temp_c", "temperature", "temperature_2m")
PRECIP_COLUMNS = ("precip_mm", "precipitation", "rain", "rain_mm")
LOGIT_PARAMS = {
"C": 1.0,
"max_iter": 1000,
"class_weight": "balanced",
"solver": "lbfgs",
"random_state": 42,
}
def _utc_now() -> str:
return datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%SZ")
def _iso(ts) -> str:
return pd.Timestamp(ts).tz_convert("UTC").strftime("%Y-%m-%dT%H:%M:%SZ")
def _first_column(columns: list[str], candidates: tuple[str, ...]) -> str | None:
for name in candidates:
if name in columns:
return name
return None
def _sensor_column(columns: list[str]) -> str | None:
# ``name`` is the human/logical sensor label in the challenge CSV; prefer it
# over the physical device id so the density-01 merge is automatic.
if "name" in columns:
return "name"
return _first_column(columns, SENSOR_COLUMNS)
def _attach_weather(hourly: pd.DataFrame, archive: pd.DataFrame | None) -> pd.DataFrame:
frame = hourly.copy()
for column in ("temp_c", "precip_mm"):
if column not in frame.columns:
frame[column] = np.nan
frame[column] = pd.to_numeric(frame[column], errors="coerce")
if archive is not None and not archive.empty and "time" in archive.columns:
weather = archive[["time", "temp_c", "precip_mm"]].rename(columns={"time": "t"})
weather["t"] = pd.to_datetime(weather["t"], utc=True)
weather = weather.sort_values("t").drop_duplicates("t", keep="last")
frame = pd.merge_asof(
frame.sort_values("t"),
weather,
on="t",
direction="nearest",
tolerance=pd.Timedelta("3h"),
suffixes=("", "_archive"),
)
for column in ("temp_c", "precip_mm"):
archive_column = f"{column}_archive"
if archive_column in frame.columns:
frame[column] = frame[column].where(frame[column].notna(), frame[archive_column])
frame = frame.drop(columns=[archive_column])
# Honest fallback: no weather available for the uploaded window. Constant
# values keep the other features useful; the job metrics show the effect.
frame["temp_c"] = frame["temp_c"].fillna(14.0)
frame["precip_mm"] = frame["precip_mm"].fillna(0.0)
return frame
def _add_calendar(frame: pd.DataFrame) -> pd.DataFrame:
local = frame["t"].dt.tz_convert(config.TIMEZONE)
out = frame.copy()
out["local_date"] = local.dt.strftime("%Y-%m-%d")
out["hour"] = local.dt.hour.astype("int8")
out["weekday"] = local.dt.day_of_week.astype("int8")
out["is_weekend"] = (out["weekday"] >= 5).astype("int8")
out["is_holiday"] = out["local_date"].map(config.HOLIDAYS).notna().astype("int8")
return out
def load_hourly_csv(path: Path | str) -> pd.DataFrame:
"""Read a raw challenge CSV or a simple upload into hourly sensor means.
Accepted time/value/sensor column names are intentionally liberal. Raw PAX
files are detected by their ``type`` column and filtered to densityData.
"""
path = Path(path)
frame = pd.read_csv(path, low_memory=False)
frame.columns = [str(column).strip().lower() for column in frame.columns]
if "type" in frame.columns:
frame = frame[
frame["type"].astype(str).str.lower().isin({"densitydata", "density"})
].copy()
time_column = _first_column(list(frame.columns), TIME_COLUMNS)
value_column = _first_column(list(frame.columns), VALUE_COLUMNS)
if time_column is None or value_column is None:
raise ValueError(
f"CSV needs a time column ({', '.join(TIME_COLUMNS)}) and a value column "
f"({', '.join(VALUE_COLUMNS)}); got {list(frame.columns)}"
)
frame["_t"] = pd.to_datetime(frame[time_column], utc=True, errors="coerce")
frame["_v"] = pd.to_numeric(frame[value_column], errors="coerce")
frame = frame[frame["_t"].notna() & frame["_v"].notna()].copy()
if frame.empty:
raise ValueError("CSV has no valid time/value rows")
sensor_column = _sensor_column(list(frame.columns))
if sensor_column is None:
frame["_sensor"] = "upload"
else:
frame["_sensor"] = frame[sensor_column].astype(str).str.strip()
frame.loc[frame["_sensor"].isin({"", "nan", "None"}), "_sensor"] = "upload"
frame["_t"] = frame["_t"].dt.floor("h")
aggregations: dict[str, tuple[str, str]] = {"v": ("_v", "mean")}
for column in TEMP_COLUMNS:
if column in frame.columns:
frame[column] = pd.to_numeric(frame[column], errors="coerce")
aggregations["temp_c"] = (column, "mean")
break
for column in PRECIP_COLUMNS:
if column in frame.columns:
frame[column] = pd.to_numeric(frame[column], errors="coerce")
aggregations["precip_mm"] = (column, "mean")
break
hourly = (
frame.groupby(["_sensor", "_t"], observed=True)
.agg(**aggregations)
.reset_index()
.rename(columns={"_sensor": "sensor", "_t": "t"})
)
hourly = hourly[~hourly["sensor"].isin(config.EXCLUDED_SENSORS)].copy()
if hourly.empty:
raise ValueError("CSV contains only excluded sensors")
hourly["v"] = hourly["v"].astype(float)
return hourly.sort_values(["sensor", "t"]).reset_index(drop=True)
def _load_archive(archive: pd.DataFrame | None) -> pd.DataFrame | None:
if archive is not None:
return archive
for candidate in (
config.weather_dir() / "weather_archive.parquet",
config.cache_dir() / "weather_archive.parquet",
):
if candidate.exists():
try:
return pd.read_parquet(candidate)
except Exception: # noqa: BLE001 - corrupt cache must not block a job
log.warning("could not read weather archive at %s", candidate)
return None
def _metrics(bundle_metrics: dict) -> dict:
out = {}
for key, value in bundle_metrics.items():
if isinstance(value, float):
out[key] = None if not np.isfinite(value) else round(value, 3)
elif isinstance(value, dict):
out[key] = {k: round(float(v), 1) for k, v in value.items()}
else:
out[key] = value
return out
def train_small_from_csv(
path: Path | str,
*,
archive: pd.DataFrame | None = None,
start: pd.Timestamp | str | None = None,
) -> tuple[dict, dict]:
"""Train the busy classifier and return (bundle, metrics payload)."""
hourly = load_hourly_csv(path)
if start is not None:
hourly = hourly[hourly["t"] >= pd.Timestamp(start)].copy()
if hourly.empty:
raise ValueError("no rows after the requested training start")
hourly = _add_calendar(_attach_weather(hourly, _load_archive(archive)))
times = np.sort(hourly["t"].unique())
if len(times) < 4:
raise ValueError("need at least four hourly timestamps to train")
cut = times[int(len(times) * 0.8)]
train = hourly[hourly["t"] < cut].copy()
test = hourly[hourly["t"] >= cut].copy()
if train.empty or test.empty:
split = max(1, int(len(hourly) * 0.8))
train = hourly.iloc[:split].copy()
test = hourly.iloc[split:].copy()
# The busy label is defined by the sensor's p75 in the TRAINING window.
# Using the full upload would leak the holdout distribution into the label.
thresholds = train.groupby("sensor", observed=True)["v"].quantile(0.75).to_dict()
global_threshold = float(train["v"].quantile(0.75))
if not np.isfinite(global_threshold):
global_threshold = 0.0
for frame in (train, test):
frame["threshold"] = (
frame["sensor"].map(thresholds).astype(float).fillna(global_threshold)
)
frame["busy"] = (frame["v"] > frame["threshold"]).astype("int8")
if train["busy"].nunique() < 2:
raise ValueError("training window contains only one busy class")
model = Pipeline(
[
("scale", StandardScaler()),
("clf", LogisticRegression(**LOGIT_PARAMS)),
]
)
model.fit(train[config.SMALL_FEATURES], train["busy"])
proba = model.predict_proba(test[config.SMALL_FEATURES])[:, 1]
predicted = (proba >= 0.5).astype("int8")
truth = test["busy"].to_numpy(dtype=int)
try:
roc_auc = float(roc_auc_score(truth, proba)) if len(np.unique(truth)) > 1 else None
except ValueError:
roc_auc = None
trained_at = _utc_now()
model_version = f"logit-{trained_at[:10].replace('-', '')}-{trained_at[11:19].replace(':', '')}"
metrics_payload = {
"model_version": model_version,
"trained_at": trained_at,
"features": list(config.SMALL_FEATURES),
"train_from": _iso(train["t"].min()),
"train_to": _iso(train["t"].max()),
"test_from": _iso(test["t"].min()),
"test_to": _iso(test["t"].max()),
"thresholds": {str(k): round(float(v), 2) for k, v in thresholds.items()},
"metrics": _metrics(
{
"accuracy": float(accuracy_score(truth, predicted)),
"precision": float(precision_score(truth, predicted, zero_division=0)),
"recall": float(recall_score(truth, predicted, zero_division=0)),
"f1": float(f1_score(truth, predicted, zero_division=0)),
"roc_auc": roc_auc,
"n_train": len(train),
"n_test": len(test),
"positive_rate": float(truth.mean()),
"sensors": int(hourly["sensor"].nunique()),
}
),
}
bundle = {
"model": model,
"features": list(config.SMALL_FEATURES),
"thresholds": {str(k): float(v) for k, v in thresholds.items()},
"global_threshold": global_threshold,
"trained_at": trained_at,
"model_version": model_version,
"metadata": metrics_payload,
}
log.info(
"small model %s: accuracy %.3f f1 %.3f roc_auc %s (%s train / %s test rows)",
model_version,
metrics_payload["metrics"]["accuracy"],
metrics_payload["metrics"]["f1"],
metrics_payload["metrics"]["roc_auc"],
len(train),
len(test),
)
return bundle, metrics_payload
def busy_probability(bundle: dict, frame: pd.DataFrame) -> np.ndarray:
"""Probability of a busy hour for a feature frame (used by demos/tests)."""
return bundle["model"].predict_proba(frame[list(bundle["features"])])[:, 1]
+311
View File
@@ -0,0 +1,311 @@
"""`make train`: fit the global model, evaluate, export metrics/forecasts/model."""
from __future__ import annotations
import json
import logging
from datetime import UTC, datetime
import joblib
import numpy as np
import pandas as pd
from . import config
from .features import future_calendar, seasonal_lookup
from .model import (
event_multiplier,
fit,
future_frame,
metrics,
points,
predict,
residual_quantiles,
weather_climatology,
)
from .pipeline import run_data
from .small import train_small_from_csv
from .weather import load_cached_weather
log = logging.getLogger(__name__)
MODEL_SPECS = [
("seasonal_naive", None, "exact 168-row lag (same observed hour last week)"),
(
"day_no_weather",
config.FEATURE_DAY_NO_HOLIDAY,
"calendar + lags 24/48/168 + 24h/168h rolling means",
),
(
"day_holiday",
config.FEATURE_DAY,
"day-ahead + Baden-Württemberg holiday flag",
),
(
"day_weather",
config.FEATURE_DAY_WEATHER,
"day-ahead + temperature + rain (observed weather)",
),
(
"week_no_weather",
config.FEATURE_WEEK_NO_WEATHER,
"7-day-safe calendar + previous same weekday/hour values",
),
(
"week_weather",
config.FEATURE_WEEK_WEATHER,
"7-day-safe + temperature + rain (production model)",
),
]
def _utc_now() -> str:
return datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%SZ")
def _iso(ts) -> str:
return pd.Timestamp(ts).tz_convert("UTC").strftime("%Y-%m-%dT%H:%M:%SZ")
def _load_inputs() -> tuple[pd.DataFrame, pd.DataFrame, pd.DataFrame, pd.DataFrame, dict, dict]:
cache = config.cache_dir()
if not (cache / "hourly_features.parquet").exists():
log.info("feature cache missing; running the data pipeline")
run_data()
hourly = pd.read_parquet(cache / "hourly.parquet")
features = pd.read_parquet(cache / "hourly_features.parquet")
try:
archive, forecast, meta = load_cached_weather()
except FileNotFoundError:
# The Docker image only carries the baked artifacts, not data/cache.
archive = pd.read_parquet(config.weather_dir() / "weather_archive.parquet")
forecast = pd.read_parquet(config.weather_dir() / "weather_forecast.parquet")
meta = json.loads((config.weather_dir() / "weather_meta.json").read_text())
audit = json.loads((config.artifacts_dir() / "data_audit.json").read_text())
return hourly, features, archive, forecast, meta, audit
def _round_row(row: dict) -> dict:
return {
"name": row["name"],
"description": row["description"],
"mae": round(row["mae"], 2),
"wape": round(row["wape"], 1),
"r2": round(row["r2"], 3),
"n": row["n"],
}
def train_bundle(
hourly: pd.DataFrame,
features: pd.DataFrame,
archive: pd.DataFrame,
meta: dict,
audit: dict,
) -> tuple[dict, dict, list[dict]]:
"""Evaluate on the time holdout, refit production, return (bundle, metrics, rows)."""
data_end = hourly["t"].max()
test_start = data_end.floor("h") - pd.Timedelta(days=config.TEST_DAYS)
train = features[features["t"] < test_start].copy()
test = features[features["t"] >= test_start].copy()
eval_frame = test[test["lag_168"].notna() & test["y"].notna()].copy()
if eval_frame.empty:
raise RuntimeError("holdout has no rows with a seasonal-naive baseline")
if len(train) < 100:
raise RuntimeError("not enough training rows for a 28-day holdout")
log.info(
"split: train=%s rows (%s..%s), test=%s rows, eval=%s rows (%s..%s)",
len(train),
_iso(train["t"].min()),
_iso(train["t"].max()),
len(test),
len(eval_frame),
_iso(eval_frame["t"].min()),
_iso(eval_frame["t"].max()),
)
results: list[dict] = []
preds: dict[str, np.ndarray] = {}
for name, cols, description in MODEL_SPECS:
if name == "seasonal_naive":
pred = eval_frame["lag_168"].to_numpy(dtype=float)
else:
assert cols is not None
model = fit(train, cols)
pred = np.clip(model.predict(eval_frame[cols]), 0.0, None)
preds[name] = pred
m = metrics(eval_frame["y"], pred)
results.append({"name": name, "description": description, **m})
log.info("%-16s MAE %.2f WAPE %.1f%% R2 %.3f", name, m["mae"], m["wape"], m["r2"])
by_name = {row["name"]: row for row in results}
baseline = by_name["seasonal_naive"]
headline = by_name["week_weather"]
# Production model: refit on all observed rows after the honest holdout.
production = fit(features, config.FEATURE_WEEK_WEATHER)
residual = residual_quantiles(eval_frame, preds["week_weather"])
sensor_mean = hourly.groupby("sensor", observed=True)["v"].mean().round(4).to_dict()
trained_at = _utc_now()
model_version = f"histgb-{trained_at[:10]}"
data_version = pd.Timestamp(audit["time_range"]["to"]).floor("min").strftime(
"%Y-%m-%dT%H:%M:%SZ"
)
context_version = meta.get("fetched_at") or trained_at
bundle = {
"model": production,
"features": list(config.FEATURE_WEEK_WEATHER),
"seasonal_lookup": seasonal_lookup(hourly),
"sensor_mean": sensor_mean,
"residual_quantiles": residual,
"weather_climatology": weather_climatology(archive),
"metadata": {
"model_version": model_version,
"data_version": data_version,
"context_version": context_version,
"trained_at": trained_at,
"train_from": _iso(train["t"].min()),
"train_to": _iso(features["t"].max()),
},
}
holiday_effect = {
"mae_delta": round(by_name["day_holiday"]["mae"] - by_name["day_no_weather"]["mae"], 2),
"note": (
"Holiday flag alone changes MAE by this amount on the holdout; "
"weather is the main driver, holidays are context."
),
}
metrics_payload = {
"data_version": data_version,
"model_version": model_version,
"context_version": context_version,
"coverage": {
"sensors": audit["usable_sensors"],
"from": config.MULTI_SENSOR_START,
"to": data_version,
"cadence_min": round(audit["cadence_median_min"]),
},
"metrics": {
"model": "weather-7d",
"mae": round(headline["mae"], 2),
"wape": round(headline["wape"], 1),
"r2": round(headline["r2"], 3),
"baseline": "seasonal_naive",
"baseline_mae": round(baseline["mae"], 2),
"baseline_wape": round(baseline["wape"], 1),
"baseline_r2": round(baseline["r2"], 3),
"n_eval": int(headline["n"]),
},
"trained_at": trained_at,
"train_from": bundle["metadata"]["train_from"],
"train_to": bundle["metadata"]["train_to"],
"test_from": _iso(test_start),
"test_to": _iso(data_end),
"features": list(config.FEATURE_WEEK_WEATHER),
"holiday_effect": holiday_effect,
"ablation": [_round_row(row) for row in results],
"limits": list(config.LIMITS),
}
return bundle, metrics_payload, results
def _scenario_mask(calendar: pd.DataFrame, scenario: dict) -> np.ndarray | None:
event = scenario.get("event")
if not event:
return None
mask = calendar["weekday"].isin(event.get("weekdays", [])).to_numpy(dtype=bool, copy=True)
hours = event.get("hours")
if hours is not None:
mask &= calendar["hour"].isin(hours).to_numpy(dtype=bool, copy=True)
return mask
def _export_forecasts(bundle: dict, forecast: pd.DataFrame, start: pd.Timestamp) -> dict:
periods = config.HORIZON_STEPS["7d"]
sensors = sorted(config.USABLE_SENSORS)
out: dict[str, dict[str, dict[str, list[dict]]]] = {
sensor: {"48h": {}, "7d": {}} for sensor in sensors
}
for name, scenario in config.SCENARIOS.items():
for sensor in sensors:
calendar = future_calendar(start, periods)
mask = _scenario_mask(calendar, scenario)
frame = future_frame(
bundle=bundle,
sensor=sensor,
start=start,
periods=periods,
weather_forecast=forecast,
temp_delta=scenario["temp_delta_c"],
precip_mm=scenario["precip_mm"],
weather_mask=mask,
)
pred = predict(bundle, frame) * event_multiplier(frame, scenario)
pts = points(frame, pred, bundle, sensor)
out[sensor]["7d"][name] = pts
out[sensor]["48h"][name] = pts[: config.HORIZON_STEPS["48h"]]
return {
"data_version": bundle["metadata"]["data_version"],
"model_version": bundle["metadata"]["model_version"],
"context_version": bundle["metadata"]["context_version"],
"generated_at": _utc_now(),
"forecast_start": _iso(start),
"forecasts": out,
}
def run_train() -> dict:
logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s")
artifacts = config.artifacts_dir()
artifacts.mkdir(parents=True, exist_ok=True)
hourly, features, archive, forecast, meta, audit = _load_inputs()
bundle, metrics_payload, _ = train_bundle(hourly, features, archive, meta, audit)
joblib.dump(bundle, artifacts / "model.joblib")
(artifacts / "metrics.json").write_text(
json.dumps(metrics_payload, indent=2, ensure_ascii=False) + "\n"
)
start = pd.Timestamp.now(tz="UTC").ceil("h")
forecasts = _export_forecasts(bundle, forecast, start)
(artifacts / "forecasts.json").write_text(
json.dumps(forecasts, ensure_ascii=False) + "\n"
)
# Bake the small classifier too, so /train has a working before/after demo
# even before an upload and the image contains the full artifact set.
small_bundle, small_metrics = train_small_from_csv(
config.raw_csv_path(),
archive=archive,
start=pd.Timestamp(config.MULTI_SENSOR_START),
)
joblib.dump(small_bundle, artifacts / "small_model.joblib")
(artifacts / "small_metrics.json").write_text(
json.dumps(small_metrics, indent=2, ensure_ascii=False) + "\n"
)
log.info(
"wrote metrics.json, forecasts.json (%s..%s), model.joblib, small_model.joblib",
start,
start + pd.Timedelta(hours=167),
)
return {
"headline": metrics_payload["metrics"],
"ablation": metrics_payload["ablation"],
"model_version": bundle["metadata"]["model_version"],
"forecast_start": _iso(start),
"small": small_metrics["metrics"],
}
def main() -> None:
run_train()
if __name__ == "__main__":
main()
+5 -5
View File
@@ -10,7 +10,7 @@ from __future__ import annotations
import json
import logging
import time
from datetime import date, datetime, timedelta, timezone
from datetime import UTC, date, datetime, timedelta
from pathlib import Path
import httpx
@@ -40,7 +40,7 @@ def _get_json(url: str, params: dict, *, retries: int = 3) -> dict:
if payload.get("error"):
raise RuntimeError(f"Open-Meteo error: {payload.get('reason', payload)}")
return payload
except Exception as exc: # network / HTTP / payload
except Exception as exc: # noqa: BLE001 - network/HTTP/payload retry boundary
last = exc
if attempt < retries - 1:
time.sleep(2**attempt)
@@ -113,7 +113,7 @@ def fetch_forecast(days: int = 8) -> tuple[pd.DataFrame, dict, dict]:
}
grid = {"latitude": payload.get("latitude"), "longitude": payload.get("longitude")}
meta = {
"fetched_at": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
"fetched_at": datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%SZ"),
"current": now,
"grid": grid,
"source": "open-meteo",
@@ -158,7 +158,7 @@ def ensure_weather(
if not meta:
meta = {
"fetched_at": datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ"),
"fetched_at": datetime.now(UTC).strftime("%Y-%m-%dT%H:%M:%SZ"),
"current": None,
"grid": {"latitude": config.LATITUDE, "longitude": config.LONGITUDE},
"source": "cache",
@@ -181,7 +181,7 @@ def load_cached_weather() -> tuple[pd.DataFrame, pd.DataFrame, dict]:
def refresh_weather() -> None:
archive, forecast, meta = ensure_weather(refresh=True)
archive, forecast, _ = ensure_weather(refresh=True)
log.info("weather refreshed: archive=%s forecast=%s", len(archive), len(forecast))
+53
View File
@@ -0,0 +1,53 @@
from __future__ import annotations
import os
from pathlib import Path
import numpy as np
import pandas as pd
import pytest
from fastapi.testclient import TestClient
CONTROL_TOKEN = "test-token"
@pytest.fixture(scope="session")
def client(tmp_path_factory):
os.environ["CONTROL_TOKEN"] = CONTROL_TOKEN
os.environ["PULSECAST_MODELS"] = str(tmp_path_factory.mktemp("models"))
os.environ["PULSECAST_UPLOADS"] = str(tmp_path_factory.mktemp("uploads"))
from pulsecast.server import app
with TestClient(app) as test_client:
yield test_client
@pytest.fixture(scope="session")
def auth_headers() -> dict[str, str]:
return {"Authorization": f"Bearer {CONTROL_TOKEN}"}
@pytest.fixture(scope="session")
def synthetic_csv(tmp_path_factory) -> Path:
"""Two sensors, 60 days hourly, clear daily/weekly pattern + weather."""
rng = np.random.default_rng(7)
hours = pd.date_range("2026-06-01", periods=24 * 60, freq="h", tz="UTC")
rows = []
for sensor in ("test-store-a", "test-store-b"):
for timestamp in hours:
local = timestamp.tz_convert("Europe/Berlin")
daily = 35.0 * np.exp(-((local.hour - 19) ** 2) / 18.0)
weekend = 12.0 if local.day_of_week == 5 else 0.0
value = max(0.0, 8.0 + daily + weekend + rng.normal(0, 4))
rows.append(
{
"time": timestamp.strftime("%Y-%m-%dT%H:%M:%SZ"),
"sensor": sensor,
"value": round(value, 3),
"temp_c": round(15.0 + rng.normal(0, 5), 2),
"precip_mm": round(max(0.0, rng.normal(0, 1)), 2),
}
)
path = tmp_path_factory.mktemp("csv") / "upload.csv"
pd.DataFrame(rows).to_csv(path, index=False)
return path
+78
View File
@@ -0,0 +1,78 @@
from __future__ import annotations
import json
from pulsecast import config
def _load(name: str):
return json.loads((config.artifacts_dir() / name).read_text())
def test_sensors_schema():
sensors = _load("sensors.json")
assert len(sensors) == 8
assert {sensor["id"] for sensor in sensors} == set(config.USABLE_SENSORS)
assert [sensor["id"] for sensor in sensors] == sorted(sensor["id"] for sensor in sensors)
for sensor in sensors:
for key in ("id", "name", "lat", "lon", "mean", "p95", "battery"):
assert key in sensor
assert sensor["p95"] >= sensor["mean"]
assert sensor["battery"] is None or 0 <= sensor["battery"] <= 100
def test_series_schema():
series = _load("series.json")
assert series["step"] == "1h"
assert set(series["series"]) == set(config.USABLE_SENSORS)
for points in series["series"].values():
assert len(points) > 1000
assert {"t", "v"} == set(points[0])
assert points[0]["t"].endswith("Z")
assert all(point["v"] >= 0 for point in points)
def test_forecasts_schema():
forecasts = _load("forecasts.json")
assert forecasts["forecasts"].keys() == set(config.USABLE_SENSORS)
for by_horizon in forecasts["forecasts"].values():
assert set(by_horizon) == {"48h", "7d"}
assert set(by_horizon["7d"]) == set(config.SCENARIOS)
assert len(by_horizon["7d"]["base"]) == 168
assert len(by_horizon["48h"]["base"]) == 48
for points in by_horizon["7d"].values():
assert all({"t", "v", "lo", "hi"} == set(point) for point in points)
assert all(point["lo"] <= point["v"] <= point["hi"] for point in points)
def test_context_schema():
context = _load("context.json")
assert context["cached"] is False
assert context["updated_at"].endswith("Z")
now = context["weather"]["now"]
for key in ("t", "temp_c", "precip_mm", "cloud_pct", "wind_kmh", "humidity_pct"):
assert key in now
assert len(context["weather"]["forecast"]) == 168
holiday_dates = {holiday["date"] for holiday in context["holidays"]}
assert "2026-11-01" in holiday_dates
assert "2025-01-01" in holiday_dates
assert "2026-12-26" in holiday_dates
def test_metrics_and_audit():
metrics = _load("metrics.json")
assert metrics["ablation"][0]["name"] == "seasonal_naive"
assert metrics["ablation"][-1]["name"] == "week_weather"
assert metrics["metrics"]["mae"] < metrics["metrics"]["baseline_mae"]
assert metrics["metrics"]["wape"] < metrics["metrics"]["baseline_wape"]
assert len(metrics["features"]) == 10
assert len(metrics["limits"]) >= 4
audit = _load("data_audit.json")
assert audit["all_checks_ok"] is True
assert audit["raw_rows"] == 192_464
assert audit["usable_sensors"] == 8
assert set(audit["density_01_devices"]) == {"863f75b0", "f8c19730"}
assert (config.artifacts_dir() / "model.joblib").exists()
assert (config.artifacts_dir() / "small_model.joblib").exists()
+55
View File
@@ -0,0 +1,55 @@
from __future__ import annotations
def test_healthz(client):
response = client.get("/healthz")
assert response.status_code == 200
assert response.json() == {"ok": True}
def test_readyz(client):
response = client.get("/readyz")
assert response.status_code == 200
assert response.json() == {"ok": True, "model": True}
def test_meta_contract(client):
response = client.get("/meta")
assert response.status_code == 200
payload = response.json()
for key in (
"data_version",
"model_version",
"context_version",
"coverage",
"metrics",
"trained_at",
"train_from",
"train_to",
"features",
"holiday_effect",
):
assert key in payload, key
assert payload["coverage"]["sensors"] == 8
assert payload["coverage"]["cadence_min"] == 15
assert payload["coverage"]["from"].endswith("Z")
headline = payload["metrics"]
assert headline["mae"] < headline["baseline_mae"]
assert headline["wape"] < headline["baseline_wape"]
assert headline["r2"] > headline["baseline_r2"]
assert 0 < headline["wape"] < 100
assert 0.5 < headline["r2"] <= 1.0
assert "small_model" in payload
assert payload["small_model"]["features"] == [
"hour",
"weekday",
"is_weekend",
"temp_c",
"precip_mm",
"is_holiday",
]
assert 0.5 < payload["small_model"]["metrics"]["accuracy"] <= 1.0
+125
View File
@@ -0,0 +1,125 @@
from __future__ import annotations
import pandas as pd
SENSOR = "hn-stadtgalerie-01"
def _assert_points(points: list[dict]) -> None:
assert points
for point in points:
assert set(point) == {"t", "v", "lo", "hi"}
assert point["t"].endswith("Z")
assert point["v"] >= 0
assert point["lo"] <= point["v"] <= point["hi"]
def test_predict_7d(client):
response = client.post(
"/predict", json={"sensor": SENSOR, "horizon": "7d", "scenario": "base"}
)
assert response.status_code == 200
payload = response.json()
assert payload["sensor"] == SENSOR
assert payload["horizon"] == "7d"
assert payload["scenario"] == "base"
assert len(payload["points"]) == 168
assert payload["model_version"].startswith("histgb-")
_assert_points(payload["points"])
def test_predict_all_horizons(client):
expected = {"15m": 1, "1h": 4, "48h": 48, "7d": 168}
for horizon, count in expected.items():
response = client.post("/predict", json={"sensor": SENSOR, "horizon": horizon})
assert response.status_code == 200, response.text
assert len(response.json()["points"]) == count, horizon
def test_predict_weather_override_changes_values(client):
cold = client.post(
"/predict",
json={"sensor": SENSOR, "horizon": "48h", "weather": {"temp_c": -8.0, "precip_mm": 6.0}},
)
warm = client.post(
"/predict",
json={"sensor": SENSOR, "horizon": "48h", "weather": {"temp_c": 30.0, "precip_mm": 0.0}},
)
assert cold.status_code == warm.status_code == 200
assert cold.json()["points"] != warm.json()["points"]
def test_predict_unknown_sensor(client):
response = client.post("/predict", json={"sensor": "nope", "horizon": "7d"})
assert response.status_code == 404
assert response.json()["error"]["code"] == "not_found"
def test_predict_bad_horizon_and_scenario(client):
response = client.post("/predict", json={"sensor": SENSOR, "horizon": "9d"})
assert response.status_code == 400
assert response.json()["error"]["code"] == "bad_request"
response = client.post("/predict", json={"sensor": SENSOR, "scenario": "snow"})
assert response.status_code == 400
assert response.json()["error"]["code"] == "bad_request"
def test_predict_validation_error_shape(client):
response = client.post("/predict", json={"horizon": "7d"})
assert response.status_code == 400
assert response.json()["error"]["code"] == "bad_request"
assert "sensor" in response.json()["error"]["message"]
def test_simulate_all_sensors_and_scenarios(client):
response = client.post(
"/simulate",
json={
"scenario": "sunny-saturday-market",
"weather": {"temp_delta_c": 4, "precip_mm": 0},
"sensors": "all",
},
)
assert response.status_code == 200
payload = response.json()
assert payload["scenario"] == "sunny-saturday-market"
assert len(payload["forecasts"]) == 8
for sensor_forecast in payload["forecasts"].values():
assert set(sensor_forecast) == {"15m", "1h", "48h", "7d"}
assert len(sensor_forecast["15m"]) == 1
assert len(sensor_forecast["1h"]) == 4
assert len(sensor_forecast["48h"]) == 48
assert len(sensor_forecast["7d"]) == 168
_assert_points(sensor_forecast["7d"])
def test_simulate_changes_saturday_store_hours(client):
def points(scenario: str):
response = client.post(
"/simulate", json={"scenario": scenario, "sensors": [SENSOR]}
)
assert response.status_code == 200
return response.json()["forecasts"][SENSOR]["7d"]
base = points("base")
sunny = points("sunny-saturday-market")
changed = []
for left, right in zip(base, sunny, strict=True):
local = pd.Timestamp(left["t"]).tz_convert("Europe/Berlin")
if local.day_of_week == 5 and 10 <= local.hour < 21:
changed.append(left["v"] != right["v"])
assert changed and any(changed)
rainy = points("rainy-saturday")
rainy_changed = [
left["v"] != right["v"]
for left, right in zip(sunny, rainy, strict=True)
]
assert any(rainy_changed)
def test_simulate_unknown_sensor(client):
response = client.post("/simulate", json={"scenario": "base", "sensors": ["nope"]})
assert response.status_code == 404
assert response.json()["error"]["code"] == "not_found"
+125
View File
@@ -0,0 +1,125 @@
from __future__ import annotations
import os
import time
from pathlib import Path
def _wait_for_job(client, job_id: str, headers: dict[str, str], timeout: float = 20.0):
deadline = time.monotonic() + timeout
while time.monotonic() < deadline:
response = client.get(f"/train/{job_id}", headers=headers)
assert response.status_code == 200, response.text
job = response.json()
if job["status"] in {"succeeded", "failed"}:
return job
time.sleep(0.1)
raise AssertionError(f"training job {job_id} did not finish in {timeout}s")
def _submit(client, headers, path: Path, model: str = "small"):
return client.post(
"/train",
headers=headers,
files={"file": ("upload.csv", path.read_bytes(), "text/csv")},
data={"model": model},
)
def test_training_requires_token(client, synthetic_csv):
response = _submit(client, {}, synthetic_csv)
assert response.status_code == 401
assert response.json()["error"]["code"] == "unauthorized"
response = _submit(client, {"Authorization": "Bearer wrong"}, synthetic_csv)
assert response.status_code == 401
def test_unknown_job_and_bad_model(client, auth_headers, synthetic_csv):
response = client.get("/train/does-not-exist", headers=auth_headers)
assert response.status_code == 404
assert response.json()["error"]["code"] == "not_found"
response = _submit(client, auth_headers, synthetic_csv, model="giant")
assert response.status_code == 400
assert response.json()["error"]["code"] == "bad_request"
def test_small_training_job(client, auth_headers, synthetic_csv):
started = time.monotonic()
response = _submit(client, auth_headers, synthetic_csv)
assert response.status_code == 202, response.text
submitted = response.json()
assert submitted["status"] == "queued"
assert submitted["model"] == "small"
assert submitted["submitted_at"].endswith("Z")
job = _wait_for_job(client, submitted["job_id"], auth_headers)
elapsed = time.monotonic() - started
assert job["status"] == "succeeded", job
assert job["error"] is None
assert job["model"] == "small"
assert job["started_at"] and job["finished_at"]
assert job["model_version"].startswith("logit-")
metrics = job["metrics"]
for key in ("accuracy", "precision", "recall", "f1", "n_train", "n_test", "positive_rate"):
assert key in metrics, key
assert metrics["accuracy"] > 0.6
assert 0 < metrics["accuracy"] <= 1
assert metrics["n_train"] > 0
assert metrics["n_test"] > 0
assert metrics["roc_auc"] is None or 0.5 < metrics["roc_auc"] <= 1
# Contract requirement: the small model trains in under 5 s.
assert elapsed < 5.0, elapsed
model_dir = Path(os.environ["PULSECAST_MODELS"])
assert (model_dir / "small_latest.joblib").exists()
assert (model_dir / f"{submitted['job_id']}-small.joblib").exists()
meta = client.get("/meta").json()
assert meta["small_model"]["model_version"] == job["model_version"]
assert meta["small_model"]["metrics"]["accuracy"] == metrics["accuracy"]
def test_training_json_path(client, auth_headers, synthetic_csv):
response = client.post(
"/train",
headers=auth_headers,
json={"path": str(synthetic_csv), "model": "small"},
)
assert response.status_code == 202, response.text
job = _wait_for_job(client, response.json()["job_id"], auth_headers)
assert job["status"] == "succeeded", job
assert job["metrics"]["accuracy"] > 0.6
def test_training_missing_file(client, auth_headers):
response = client.post(
"/train",
headers=auth_headers,
json={"path": "/tmp/definitely-not-a-pulsecast-file.csv", "model": "small"},
)
assert response.status_code == 400
assert response.json()["error"]["code"] == "bad_request"
def test_one_job_at_a_time(client, auth_headers, synthetic_csv, monkeypatch):
from pulsecast import server
original = server.train_small_from_csv
def slow_train(*args, **kwargs):
time.sleep(0.6)
return original(*args, **kwargs)
monkeypatch.setattr(server, "train_small_from_csv", slow_train)
first = _submit(client, auth_headers, synthetic_csv)
assert first.status_code == 202
second = _submit(client, auth_headers, synthetic_csv)
assert second.status_code == 409
assert second.json()["error"]["code"] == "conflict"
job = _wait_for_job(client, first.json()["job_id"], auth_headers)
assert job["status"] == "succeeded", job
Generated
+46 -29
View File
@@ -248,35 +248,6 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/18/53/84099323c2ec4be98d935f63c033ac4151ee83836ca1050ede3b3aadf155/joblib-1.6.0-py3-none-any.whl", hash = "sha256:3dbbf9f6e4b592a2357b854608e980fe6390d131d7a82f011a377ef2ebef7aba", size = 306115, upload-time = "2026-08-31T09:39:02.298Z" },
]
[[package]]
name = "ml-py"
version = "0.1.0"
source = { virtual = "." }
dependencies = [
{ name = "fastapi" },
{ name = "httpx" },
{ name = "joblib" },
{ name = "numpy" },
{ name = "pandas" },
{ name = "pyarrow" },
{ name = "pytest" },
{ name = "scikit-learn" },
{ name = "uvicorn", extra = ["standard"] },
]
[package.metadata]
requires-dist = [
{ name = "fastapi", specifier = ">=0.162.7" },
{ name = "httpx", specifier = ">=0.28.1" },
{ name = "joblib", specifier = ">=1.6.0" },
{ name = "numpy", specifier = ">=2.5.4" },
{ name = "pandas", specifier = ">=3.1.1" },
{ name = "pyarrow", specifier = ">=26.0.1" },
{ name = "pytest", specifier = ">=9.2.0" },
{ name = "scikit-learn", specifier = ">=1.9.1" },
{ name = "uvicorn", extras = ["standard"], specifier = ">=0.54.0" },
]
[[package]]
name = "narwhals"
version = "2.28.0"
@@ -451,6 +422,43 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/40/9e/2b38731e0fc536806f16490e1a12d7f0dc2a1235aa8cc07bcc75416a7daa/pluggy-1.7.0-py3-none-any.whl", hash = "sha256:7dd7b0d8832ba3cb632c306926ded123429211b83641b35dc5c41ad2d34f9bec", size = 27082, upload-time = "2026-10-15T09:50:56.808Z" },
]
[[package]]
name = "pulsecast-ml"
version = "0.1.0"
source = { editable = "." }
dependencies = [
{ name = "fastapi" },
{ name = "httpx" },
{ name = "joblib" },
{ name = "numpy" },
{ name = "pandas" },
{ name = "pyarrow" },
{ name = "python-multipart" },
{ name = "scikit-learn" },
{ name = "uvicorn", extra = ["standard"] },
]
[package.dev-dependencies]
dev = [
{ name = "pytest" },
]
[package.metadata]
requires-dist = [
{ name = "fastapi", specifier = ">=0.162.7" },
{ name = "httpx", specifier = ">=0.28.1" },
{ name = "joblib", specifier = ">=1.6.0" },
{ name = "numpy", specifier = ">=2.5.4" },
{ name = "pandas", specifier = ">=3.1.1" },
{ name = "pyarrow", specifier = ">=26.0.1" },
{ name = "python-multipart", specifier = ">=0.0.20" },
{ name = "scikit-learn", specifier = ">=1.9.1" },
{ name = "uvicorn", extras = ["standard"], specifier = ">=0.54.0" },
]
[package.metadata.requires-dev]
dev = [{ name = "pytest", specifier = ">=9.2.0" }]
[[package]]
name = "pyarrow"
version = "26.0.1"
@@ -671,6 +679,15 @@ wheels = [
{ url = "https://files.pythonhosted.org/packages/60/d1/38f3a3405989a89ac18390803e70c6ad7c7760da4f9b83cbeca0c44a0c72/python_dotenv-1.2.4-py3-none-any.whl", hash = "sha256:42269a8a5b3fd54ffa6f3d84b18abed50064717576b4ecf03dc4a55d8aa04fdc", size = 23266, upload-time = "2026-10-01T05:36:08.633Z" },
]
[[package]]
name = "python-multipart"
version = "0.0.33"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/9f/b7/15b905f6142a9a8a68f66900788da1a32e4d4254452783b37ad1eccb0506/python_multipart-0.0.33.tar.gz", hash = "sha256:b8112424a6abd162ec08d390565dd113ad699f2fe6fef3c987b8bbcbfe9e390d", size = 50499, upload-time = "2026-10-31T14:23:47.461Z" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/dd/1b/6b1b4164ec734cac911460ab599bfbe46afedd42c5c9627fe4235942c314/python_multipart-0.0.33-py3-none-any.whl", hash = "sha256:8f16c07b36add9da6b2ee87d3efcaf0a45a6de9c3d0a5dd94e9ccf7675a7bc45", size = 32253, upload-time = "2026-10-31T14:23:46.33Z" },
]
[[package]]
name = "pyyaml"
version = "6.0.3"