76 lines
2.8 KiB
Python
76 lines
2.8 KiB
Python
# -*- coding: utf-8 -*-
|
|
"""Exploracion rapida del log 2026-10-15: rangos, saturacion y picos de C/V/P."""
|
|
import re
|
|
from collections import defaultdict
|
|
|
|
LOG = r"C:\Users\fdavalos\OneDrive - up.edu.mx\microtracking\MicrotrackingFer\logs_nuevos\log_2026-10-15.txt"
|
|
|
|
RE = re.compile(
|
|
r"LOG:\[(?P<t>[^\]]+)\]\s*"
|
|
r"X:(?P<x>-?\d+),Y:(?P<y>-?\d+),C:(?P<c>-?\d+),V:(?P<v>-?\d+),"
|
|
r"P:(?P<p>-?\d+),S:(?P<s>-?\d+),er:(?P<er>-?\d+)"
|
|
)
|
|
|
|
rows = []
|
|
with open(LOG, "r", encoding="utf-8", errors="replace") as f:
|
|
for line in f:
|
|
m = RE.search(line)
|
|
if m:
|
|
rows.append({
|
|
"t": m.group("t"),
|
|
"x": int(m.group("x")), "y": int(m.group("y")),
|
|
"c": int(m.group("c")), "v": int(m.group("v")),
|
|
"p": int(m.group("p")), "s": int(m.group("s")),
|
|
"er": int(m.group("er")),
|
|
})
|
|
|
|
print("Total lineas LOG:", len(rows))
|
|
if not rows:
|
|
raise SystemExit
|
|
|
|
ts = [r["t"] for r in rows]
|
|
print("Rango de tiempo:", ts[0], "->", ts[-1])
|
|
|
|
xs = [r["x"] for r in rows]; ys = [r["y"] for r in rows]
|
|
print("X: min=%d max=%d | posiciones unicas X=%d" % (min(xs), max(xs), len(set(xs))))
|
|
print("Y: min=%d max=%d | posiciones unicas Y=%d" % (min(ys), max(ys), len(set(ys))))
|
|
print("Posiciones (X,Y) unicas:", len(set((r['x'], r['y']) for r in rows)))
|
|
|
|
SAT = 16777215
|
|
for k, name in [("c", "C (corriente)"), ("v", "V (Voc)"), ("p", "P (piranometro)")]:
|
|
vals = [r[k] for r in rows]
|
|
n_sat = sum(1 for x in vals if x >= SAT - 100)
|
|
print("%s: min=%9d max=%9d media=%9.1f | n_saturado(>=%d)=%d"
|
|
% (name, min(vals), max(vals), sum(vals)/len(vals), SAT, n_sat))
|
|
|
|
|
|
def sign24(raw):
|
|
raw &= 0xFFFFFF
|
|
if raw & 0x00800000:
|
|
raw -= 0x1000000
|
|
return raw
|
|
|
|
|
|
print("\n--- P con extencion de signo (raw -> signed) ---")
|
|
ps = [sign24(r["p"]) for r in rows]
|
|
print("P signed: min=%9d max=%9d media=%9.1f" % (min(ps), max(ps), sum(ps)/len(ps)))
|
|
print("P signed < 0 (noche):", sum(1 for x in ps if x < 0))
|
|
|
|
byhour = defaultdict(list)
|
|
for r in rows:
|
|
byhour[r["t"][11:13]].append(r)
|
|
print("\n--- Media por hora ---")
|
|
print("hora n C_med P_med(signed) V_med")
|
|
for h in sorted(byhour):
|
|
grp = byhour[h]
|
|
cm = sum(g["c"] for g in grp)/len(grp)
|
|
pm = sum(sign24(g["p"]) for g in grp)/len(grp)
|
|
vm = sum(g["v"] for g in grp)/len(grp)
|
|
print("%s %4d %9.0f %14.0f %12.0f" % (h, len(grp), cm, pm, vm))
|
|
|
|
rmaxC = max(rows, key=lambda r: r["c"])
|
|
rmaxP = max(rows, key=lambda r: sign24(r["p"]))
|
|
print("\nPico C -> t=%s X=%d Y=%d C=%d" % (rmaxC["t"], rmaxC["x"], rmaxC["y"], rmaxC["c"]))
|
|
print("Pico P -> t=%s X=%d Y=%d P=%d (signed %d)" %
|
|
(rmaxP["t"], rmaxP["x"], rmaxP["y"], rmaxP["p"], sign24(rmaxP["p"])))
|