Fix DAILY_BATTERY_STATE night end and rise, document phase C contract
The night end and rise were anchored on the first daily maximum, which can be the 00:00 tail of the previous evening: 2026-05-05 was read NO_CHARGE despite a +0.079 V rise, 2026-09-30 showed a wrong night end, and 2026-09-26 stayed unknown from 04:00 to 11:00 when evaluated mid-day. The rise now starts from an earlier minimum and the knee is tested on the daily minimum (min_v). VERMONT: 139 / 31 / 14 / 0. Docs: sheet 02 page order, battery_state.py in the CLAUDE.md map, phase C exception to "anomaly = None means UNKNOWN". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eacc0ecd4a
commit
5e039ef3bb
5 files changed
+27
-18
No files matched your search
+13
-6
@@ -29,16 +29,23 @@ def day_facts(day):
|
||||
"""{heure UTC: tension mesurée} d'un jour -> faits et état (fiche analyse_03, « Principe »)."""
|
||||
if not day:
|
||||
return {"state": None, "coverage": 0.0}
|
||||
h_max = max(sorted(day), key=day.get) # première heure où le maximum est atteint
|
||||
max_v = day[h_max]
|
||||
night_end_v = min(v for h, v in day.items() if h <= h_max)
|
||||
rise_v = max_v - night_end_v
|
||||
max_v, min_v = max(day.values()), min(day.values())
|
||||
# Montée du jour : la plus grande hausse depuis un minimum antérieur ; la fin de nuit est ce minimum.
|
||||
# (Le maximum du jour peut être la queue de la soirée précédente, à 00:00 : il ne sert pas de repère.)
|
||||
low = night_end_h = min(day)
|
||||
rise_v = 0.0
|
||||
for h in sorted(day):
|
||||
if day[h] < day[low]:
|
||||
low = h
|
||||
if day[h] - day[low] > rise_v:
|
||||
rise_v, night_end_h = day[h] - day[low], low
|
||||
night_end_v = day[night_end_h] if rise_v else min_v # sans montée : le point le plus bas du jour
|
||||
hours_full = sum(v >= FULL_CHARGE_V for v in day.values())
|
||||
coverage = len(day) / 24
|
||||
# Les états 1 et 2 reposent sur une valeur mesurée : ils passent avant la couverture minimale.
|
||||
if hours_full:
|
||||
state = "FULL_CHARGE"
|
||||
elif night_end_v < PLATEAU_FLOOR_V:
|
||||
elif min_v < PLATEAU_FLOOR_V:
|
||||
state = "BELOW_PLATEAU"
|
||||
elif coverage < MIN_COVERAGE:
|
||||
state = None # UNKNOWN : trop de trous pour conclure à une absence
|
||||
@@ -46,7 +53,7 @@ def day_facts(day):
|
||||
state = "NO_CHARGE"
|
||||
else:
|
||||
state = "PARTIAL_CHARGE"
|
||||
return {"state": state, "max_v": round(max_v, 3), "night_end_v": round(night_end_v, 3),
|
||||
return {"state": state, "max_v": round(max_v, 3), "min_v": round(min_v, 3), "night_end_v": round(night_end_v, 3),
|
||||
"rise_v": round(rise_v, 3), "hours_full": hours_full, "coverage": round(coverage, 3)}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user