feat(pvforecast): keep outages out of the local provider's calibration

A battery or inverter failure limits PV to local demand for days. The
calibration read that as the plant's true output and learned it as a permanent
model loss, so one outage degraded the forecast long after the hardware was
fixed.

Calibration now estimates the healthy plant ratio over
`calibration_reference_days`, excludes days below `calibration_outage_threshold`
of it, and falls back to the most recent `calibration_min_healthy_days` when the
normal window is contaminated. `calibration_outage_filter_enabled` turns this
off for plants where measured curtailment, not available potential, is the
prediction target.

The fit also uses native 15-minute meter readings when every configured PV meter
supplies them - never interpolating hourly counters into an invented
quarter-hour profile - interpolates azimuth factors smoothly between bin centres
instead of stepping the EMS input curve, and normalizes the shape per forecast
day so it redistributes energy without changing that day's kWh correction. The
default azimuth bin widens from 15 to 45 degrees, which is what a typical
window actually supports.

Fixes the calibration window itself: it was derived from the measurement store
as a whole rather than from the configured PV production meters. A load meter
reaching further than the PV meter placed the window where no PV reading exists,
so calibration silently fell back to hourly fitting or skipped itself.

Also fixes `Measurement.load()`, which discarded every stored record. It
validated the file into a "temporary" Measurement, but Measurement is a
singleton, so that instance was the live one and the parsed records were
dropped.
This commit is contained in:
Andreas
2026-09-09 07:56:55 +02:00
parent a2f4ef6f54
commit 6dc58c33e2
8 changed files with 700 additions and 77 deletions
+19
View File
@@ -822,6 +822,25 @@ factor is clamped to `[calibration_min_factor, calibration_max_factor]` so a bro
either. The fitted factors and the resulting change in mean absolute error are logged at INFO
level on every update.
By default, calibration also rejects probable outage or curtailment days. It estimates the
healthy plant ratio from `calibration_reference_days`, excludes days below
`calibration_outage_threshold` of that reference, and falls back to the most recent
`calibration_min_healthy_days` when the normal calibration window contains an outage. This keeps
a battery or inverter failure that limits PV to local demand from becoming a permanent forecast
loss. Set `calibration_outage_filter_enabled` to false only when measured curtailed production,
rather than available PV potential, is the intended prediction target.
The measurement cadence controls the detail that can be learned. Hourly cumulative meter
readings calibrate hourly energy while the native Open-Meteo/pvlib chain continues to supply the
15-minute shape. If every configured PV meter supplies genuine 15-minute readings, calibration
automatically uses those native slots as well. It never interpolates hourly counters into an
invented quarter-hour profile. Azimuth factors are interpolated smoothly between bin centres so
they do not introduce steps into the EMS input curve. The shape fit uses all healthy days in the
reference window, while the global factor still follows the shorter recent window. Finally, the
shape is normalized per forecast day: it redistributes the calibrated energy across the day's
15-minute slots without changing that day's global kWh correction (unless the physical inverter
limit clips a peak).
Calibration requires `measurement.pv_production_emr_keys` to be configured and fed with
cumulative PV production meter readings in kWh: