import json

data = json.load(open("archive_simulations/20251113_170236_scenario_dritto.json"))
sim = data["simulation_results"]["0"]["simulated"]
real = data["simulation_results"]["0"]["real"]

print(f"Total simulated states: {len(sim)}")
print(f"Total real states: {len(real)}")
print(f"Sim range: {sim[0][0]:.2f} to {sim[-1][0]:.2f}")
print(f"Real range: {real[0][0]:.2f} to {real[-1][0]:.2f}")

# Check how many real states find brackets
bracketed = 0
first_bracketed_time = None
last_bracketed_time = None

for real_state in real:
    real_ts = real_state[0]
    # Find bracketing points
    for i in range(len(sim) - 1):
        if sim[i][0] <= real_ts <= sim[i + 1][0]:
            bracketed += 1
            if first_bracketed_time is None:
                first_bracketed_time = real_ts
            last_bracketed_time = real_ts
            break

print(
    f"\nBracketed real states: {bracketed} / {len(real)} ({100*bracketed/len(real):.1f}%)"
)
if first_bracketed_time and last_bracketed_time:
    print(
        f"Bracketed time range: {first_bracketed_time:.2f} to {last_bracketed_time:.2f}"
    )
    print(f"Bracketed duration: {last_bracketed_time - first_bracketed_time:.2f}s")
