sjednoceni forecastu
This commit is contained in:
@@ -1157,12 +1157,17 @@ async def run_rolling_replan(
|
||||
await _load_site_context(site_id, db)
|
||||
)
|
||||
|
||||
correction_factor, correction_log = await compute_correction_factor(site_id, now, db)
|
||||
|
||||
slots = await _load_slots(site_id, replan_from, horizon_to, db, soc_wh=soc_wh)
|
||||
slots_before_pv_correction = list(slots)
|
||||
|
||||
slots = apply_forecast_correction(slots, now, correction_factor)
|
||||
# PV forecast korekce je kanonicky v DB (delta + rolling faktor + decay),
|
||||
# viz ems.fn_forecast_pv_slots_range_canonical_ab a ems.fn_load_planning_slots_full.
|
||||
correction_factor, correction_log = 1.0, {
|
||||
"window_start": None,
|
||||
"window_end": None,
|
||||
"actual_pv_wh": None,
|
||||
"forecast_pv_wh": None,
|
||||
"correction_factor": None,
|
||||
"reason": "canonical_db",
|
||||
}
|
||||
|
||||
commitment_prev = await _load_previous_plan_charge_commitment_prev_w(site_id, slots, db)
|
||||
|
||||
@@ -1173,7 +1178,7 @@ async def run_rolling_replan(
|
||||
charge_commitment_prev_w=commitment_prev,
|
||||
)
|
||||
|
||||
slot_inputs = _build_slot_inputs(slots_before_pv_correction, slots)
|
||||
slot_inputs = _build_slot_inputs(slots, slots)
|
||||
run_id = await _save_planning_run(
|
||||
site_id,
|
||||
results,
|
||||
@@ -1190,26 +1195,10 @@ async def run_rolling_replan(
|
||||
solver_snapshot=solver_snapshot,
|
||||
)
|
||||
|
||||
await db.execute(
|
||||
"""
|
||||
select ems.fn_forecast_correction_log_insert(
|
||||
$1::int, $2::timestamptz, $3::timestamptz,
|
||||
$4::numeric, $5::numeric, $6::numeric, $7::int
|
||||
)
|
||||
""",
|
||||
site_id,
|
||||
correction_log["window_start"],
|
||||
correction_log["window_end"],
|
||||
correction_log.get("actual_pv_wh"),
|
||||
correction_log.get("forecast_pv_wh"),
|
||||
correction_factor,
|
||||
run_id,
|
||||
)
|
||||
# Historický log rolling korekce: dřív se psal z Pythonu. Nově se rolling faktor počítá v DB
|
||||
# v kanonické PV řadě; log se případně přesune do DB (todo).
|
||||
|
||||
logger.info(
|
||||
f"[site={site_id}] Rolling replan done in {duration_ms} ms "
|
||||
f"(correction={correction_factor:.3f})"
|
||||
)
|
||||
logger.info(f"[site={site_id}] Rolling replan done in {duration_ms} ms (pv=canonical_db)")
|
||||
return run_id, duration_ms
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user