import pandas as pd import numpy as np import matplotlib.pyplot as plt # --- Datos de los 32 puntos --- data = [ ("2025-09-10 11:02", 25701, 110, 76.4455, 82.8004), ("2025-09-10 11:07", 25888, 100, 78.0679, 83.8130), ("2025-09-10 11:18", 29082, 100, 81.6084, 85.8667), ("2025-09-10 11:23", 28925, 2268, 83.6576, 86.8695), ("2025-09-10 11:25", 28825, 2368, 84.5224, 87.2927), ("2025-09-10 11:35", 31377, 7303, 88.4720, 88.9386), ("2025-09-10 12:46", 44400, 28950,135.9374, 96.0041), ("2025-09-10 13:20", 48800, 46575,162.9381, 94.0012), ("2025-09-10 13:41", 51556, 48864,175.5298, 91.3748), ("2025-09-10 13:50", 56000, 52000,180.0000, 90.0000), ("2025-09-10 13:51", 56150, 52000,180.5351, 89.8091), ("2025-09-10 13:55", 58600, 56300,182.5981, 89.0732), ("2025-09-10 13:58", 59200, 57650,183.9786, 88.5807), ("2025-09-10 14:00", 58600, 57350,184.5990, 88.3594), ("2025-09-10 14:05", 59882, 57650,186.5288, 87.4463), ("2025-09-10 14:08", 59882, 57650,187.7597, 86.8639), ("2025-09-10 14:14", 60782, 64141,190.1318, 85.7416), ("2025-09-10 14:16", 62796, 64955,190.7264, 85.4112), ("2025-09-10 14:17", 63396, 64505,191.2917, 85.0662), ("2025-09-10 14:23", 63509, 67269,193.2224, 83.8876), ("2025-09-10 14:24", 61861, 67055,193.4570, 83.7444), ("2025-09-10 14:59", 71009, 81607,202.5291, 76.6163), ("2025-09-10 15:14", 73686, 86037,205.5586, 73.3798), ("2025-09-10 15:20", 74695, 90038,206.6519, 72.0440), ("2025-09-10 15:22", 74695, 92138,207.0994, 71.4884), ("2025-09-10 15:26", 75295, 93338,207.7590, 70.6695), ("2025-09-10 15:30", 75895, 94388,208.3731, 69.9010), ("2025-09-10 15:33", 76495, 94988,208.8766, 69.1863), ("2025-09-10 15:35", 76795, 95438,209.2280, 68.6875), ("2025-09-10 15:38", 77395, 97238,209.7314, 67.9729), ("2025-09-10 15:42", 77545, 97238,210.2297, 67.2656), ("2025-09-10 15:47", 77737, 99354,211.1104, 65.9497), ] df = pd.DataFrame(data, columns=["Timestamp","X","Y","Az_corr","Alt_corr"]) df["Zen_corr"] = 90 - df["Alt_corr"] # --- Coefs eje X --- a_x, b_x, c_x = 505.15, 309.41, 957.95 df["X_fit"] = a_x*df["Zen_corr"] + b_x*df["Az_corr"] + c_x # --- Coefs eje Y (cúbico en Az) --- a1, a2, a3, b, c = 4006.56, -21.86, 0.0428, 1480.15, -209162 df["Y_fit"] = (a1*df["Az_corr"] + a2*df["Az_corr"]**2 + a3*df["Az_corr"]**3 + b*df["Zen_corr"] + c) # Convertir Timestamp a hora decimal df["Hora_decimal"] = pd.to_datetime(df["Timestamp"]).dt.hour \ + pd.to_datetime(df["Timestamp"]).dt.minute/60 \ + pd.to_datetime(df["Timestamp"]).dt.second/3600 # --- Gráfico X vs hora decimal --- plt.figure(figsize=(12,5)) plt.plot(df["Hora_decimal"], df["X"], "o-", label="X_real") plt.plot(df["Hora_decimal"], df["X_fit"], "s--", label="X_fit") plt.xlabel("Hora decimal") plt.ylabel("X (pasos)") plt.title("Comparación X real vs modelo") plt.legend() plt.grid(True) plt.tight_layout() plt.show() # --- Gráfico Y vs hora decimal --- plt.figure(figsize=(12,5)) plt.plot(df["Hora_decimal"], df["Y"], "o-", label="Y_real") plt.plot(df["Hora_decimal"], df["Y_fit"], "s--", label="Y_fit") plt.xlabel("Hora decimal") plt.ylabel("Y (pasos)") plt.title("Comparación Y real vs modelo") plt.legend() plt.grid(True) plt.tight_layout() plt.show() # --- Gráfico XY trayectoria --- plt.figure(figsize=(8,8)) plt.plot(df["X"], df["Y"], "o-", label="Trayectoria real") plt.plot(df["X_fit"], df["Y_fit"], "s--", label="Trayectoria modelo") plt.xlabel("X (pasos)") plt.ylabel("Y (pasos)") plt.title("Trayectoria XY: Real vs Modelo") plt.legend() plt.grid(True) plt.tight_layout() plt.show()