96 lines
3.8 KiB
Python
96 lines
3.8 KiB
Python
import re, statistics
|
|
from datetime import datetime
|
|
|
|
path = r'logs_nuevos/log_2026-10-15.txt'
|
|
lines = open(path, encoding='utf-8', errors='ignore').read().splitlines()
|
|
|
|
# X/Y/C/V/P/er samples
|
|
samp = re.compile(r'\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\] X:(-?\d+),Y:(-?\d+),C:(-?\d+),V:(\d+),P:(\d+),S:(\d+),er:(-?\d+)')
|
|
# FineTune lines
|
|
ft = re.compile(r'\[(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})\] FineTune: dC=(-?\d+), dynE=(-?\d+), e=(-?\d+), near=(\d+), CmaxN=(\d+), norm=(-?\d+), prox=([\d.]+)')
|
|
|
|
rows = []
|
|
fts = []
|
|
for l in lines:
|
|
m = samp.search(l)
|
|
if m:
|
|
rows.append((m.group(1), int(m.group(2)), int(m.group(3)), int(m.group(4)), int(m.group(5)), int(m.group(6)), int(m.group(7))))
|
|
continue
|
|
m = ft.search(l)
|
|
if m:
|
|
fts.append((m.group(1), int(m.group(2)), int(m.group(3)), int(m.group(4)), int(m.group(5)), int(m.group(6)), int(m.group(7)), float(m.group(8))))
|
|
|
|
print("samples=%d finetune=%d" % (len(rows), len(fts)))
|
|
print("rango:", rows[0][0], "->", rows[-1][0])
|
|
|
|
def parse(t):
|
|
return datetime.strptime(t, '%Y-%m-%d %H:%M:%S')
|
|
|
|
# --- 1) Deteccion dia/noche por piranometro (P raw) ---
|
|
# P raw ~ 16777000 = saturado negativo (noche). Dia: P pequeno (<~2M?)
|
|
print("\n=== P (piranometro raw) estadisticas por hora ===")
|
|
byhour = {}
|
|
for r in rows:
|
|
h = r[0][11:13]
|
|
byhour.setdefault(h, []).append(r[5])
|
|
for h in sorted(byhour):
|
|
vals = byhour[h]
|
|
print(" %s: n=%5d P_med=%9d P_min=%9d P_max=%9d" % (h, len(vals), int(statistics.median(vals)), min(vals), max(vals)))
|
|
|
|
# --- 2) CmaxN evolucion (valor de pico normalizado) ---
|
|
print("\n=== CmaxN: transiciones a nuevo maximo (solo cambios) ===")
|
|
prev = None
|
|
changes = 0
|
|
for t, dC, dynE, e, near, cmax, norm, prox in fts:
|
|
if prev is None or cmax != prev:
|
|
if cmax >= 5000000 or (prev is not None and prev >= 5000000 and cmax < prev):
|
|
print(" %s CmaxN %s -> %d norm=%d prox=%.2f" % (t[11:], str(prev), cmax, norm, prox))
|
|
changes += 1
|
|
prev = cmax
|
|
print(" (transiciones grandes mostradas: %d)" % changes)
|
|
|
|
# --- 3) Encontrar cuando CmaxN explota ---
|
|
print("\n=== Primer momento en que CmaxN supera 5M / 10M / 18M ===")
|
|
for thr in (5000000, 10000000, 18400000):
|
|
for t, dC, dynE, e, near, cmax, norm, prox in fts:
|
|
if cmax >= thr:
|
|
print(" CmaxN>=%d en %s (norm=%d prox=%.2f dC=%d)" % (thr, t[11:], norm, prox, dC))
|
|
break
|
|
|
|
# --- 4) Contexto: irradiancia (P) en la explosion ---
|
|
# buscar la muestra mas cercana antes de 14:41:57
|
|
t_exp = '14:41:57'
|
|
close = None
|
|
for r in rows:
|
|
if r[0][11:] <= t_exp:
|
|
close = r
|
|
print("\n=== Contexto poco antes de la explosion (14:41:57) ===")
|
|
idx = rows.index(close)
|
|
for r in rows[max(0, idx-6):idx+3]:
|
|
print(" %s C=%6d V=%8d P=%9d" % (r[0][11:], r[3], r[4], r[5]))
|
|
|
|
# --- 5) Movimiento nocturno: pasos acumulados cuando no hay sol (P saturado) ---
|
|
print("\n=== Movimiento por hora (pasos = |dX|+|dY| entre muestras) ===")
|
|
def steps_hour():
|
|
res = {}
|
|
for i in range(1, len(rows)):
|
|
h = rows[i][0][11:13]
|
|
d = abs(rows[i][1]-rows[i-1][1]) + abs(rows[i][2]-rows[i-1][2])
|
|
res.setdefault(h, 0)
|
|
res[h] += d
|
|
return res
|
|
sh = steps_hour()
|
|
for h in sorted(sh):
|
|
tag = ""
|
|
med = int(statistics.median(byhour.get(h, [0])))
|
|
if med > 16000000: tag = " <== NOCHE (piranometro saturado)"
|
|
print(" %s: pasos=%9d P_med=%9d%s" % (h, sh[h], med, tag))
|
|
|
|
# --- 6) Dinamica del error el dia (resumen) ---
|
|
print("\n=== Error dinamico: distribucion de e segun prox ===")
|
|
bins = [(0,0.05),(0.05,0.15),(0.15,0.30),(0.30,0.50),(0.50,1.01)]
|
|
for lo,hi in bins:
|
|
es = [e for (_,_,_,e,_,_,_,prox) in fts if lo<=prox<hi]
|
|
if es:
|
|
print(" prox[%.2f-%.2f): n=%5d e_med=%5d e_min=%d e_max=%d" % (lo,hi,len(es),int(statistics.median(es)),min(es),max(es)))
|