ladime a ladime
Some checks failed
CI and deploy / migration-check (push) Failing after 12s
CI and deploy / deploy (push) Has been skipped

This commit is contained in:
Dusan Vojacek
2026-04-22 21:05:14 +02:00
parent bc0966e4c4
commit 5a66cfa63f
7 changed files with 14 additions and 51 deletions

View File

@@ -24,13 +24,11 @@ as $fn$
from ems.site s
where s.id = p_site_id
),
-- Cutoff z analýzy DB (EMS Postgres): u site_id=2 (`home-01`) začíná být
-- `forecast_accuracy.actual_power_w` spolehlivě vyplněné pro celé kalendářní dny
-- od 2026-04-11 (Europe/Prague). Před tímto datem se v `forecast_accuracy` objevují
-- ustřelené hodnoty (abs(error_w) ~ 65k) způsobené historickým bugem v telemetrii
-- (signed/unsigned). Cutoff je fixní záměrně, aby se delta profil neučil z nekonzistentní historie.
-- Cutoff: učení delty jen od začátku kalendářního dne 2026-04-12 (Europe/Prague).
-- (UTC okamžik odpovídá DST v dubnu: půlnoc v Praze = předchozí den 22:00 UTC.)
-- Před tím mohou být v `forecast_accuracy` nekonzistentní historická data (telemetrie signed/unsigned).
cutoff as (
select timestamptz '2026-04-10T22:00:00Z' as min_ts
select timestamptz '2026-04-11T22:00:00Z' as min_ts
),
bounds as (
select
@@ -229,4 +227,4 @@ as $fn$
$fn$;
comment on function ems.fn_pv_forecast_delta_profile is
'Aditivní delta profil chyby PV forecastu po 15min slotu dne (96 slotů). Zdroj: forecast_accuracy, vážení exp(-age/half_life_days) * day_weight (clear-ish dny) * volitelně top_n_days (jen N nejlepších kalendářních dní podle w_energy*w_smooth, ostatní ztlumené) * power(day_weight, day_weight_gamma). Vrací JSON {deltas:[{slot_of_day, delta_w, sample_count}], ...}. Cutoff dat od 2026-04-11 Europe/Prague.';
'Aditivní delta profil chyby PV forecastu po 15min slotu dne (96 slotů). Zdroj: forecast_accuracy, vážení exp(-age/half_life_days) * day_weight (clear-ish dny) * volitelně top_n_days (jen N nejlepších kalendářních dní podle w_energy*w_smooth, ostatní ztlumené) * power(day_weight, day_weight_gamma). Vrací JSON {deltas:[{slot_of_day, delta_w, sample_count}], ...}. Cutoff dat od 2026-04-12 Europe/Prague.';

View File

@@ -12,10 +12,7 @@ create or replace function ems.fn_forecast_pv_slots_range_corrected(
p_delta_data_from timestamptz,
p_delta_data_to timestamptz default now(),
p_half_life_days numeric default 14,
p_threshold_w int default 150,
p_top_n_days int default null,
p_non_top_day_factor numeric default 0.02,
p_day_weight_gamma numeric default 1.0
p_threshold_w int default 150
)
returns jsonb
language sql
@@ -72,10 +69,7 @@ as $fn$
p_delta_data_from,
p_delta_data_to,
p_half_life_days,
p_threshold_w,
p_top_n_days,
p_non_top_day_factor,
p_day_weight_gamma
p_threshold_w
) as j
),
deltas as (
@@ -128,4 +122,4 @@ as $fn$
$fn$;
comment on function ems.fn_forecast_pv_slots_range_corrected is
'JSON pole {interval_start, pv_forecast_total_w, pv_forecast_corrected_w, slot_of_day} po 15 min pro [p_from, p_to). Korekce je aditivní delta profil z fn_pv_forecast_delta_profile (top_n_days / non_top_day_factor / day_weight_gamma). Horizont je omezený na max. 60 dní.';
'JSON pole {interval_start, pv_forecast_total_w, pv_forecast_corrected_w, slot_of_day} po 15 min pro [p_from, p_to). Korekce je aditivní delta profil z fn_pv_forecast_delta_profile (parametry delty = defaulty v té funkci). Horizont je omezený na max. 60 dní.';