# -*- coding: utf-8 -*-
"""
Created on Wed Jan 28 04:28:34 2026

@author: pjaub
"""

import numpy as np
import matplotlib.pyplot as plt

plt.close('all')

def hms_to_minutes(s):
    h, m, sec = int(s[:2]), int(s[3:5]), int(s[6:8])
    return (3600*h + 60*m + sec)/60


with open("diagonale_des_fous_temps_2025.txt", "r", encoding="utf-8") as f:
    temps = [hms_to_minutes(line.strip()) for line in f if line.strip()]
T_2025 = sorted(temps)

with open("diagonale_des_fous_temps_2024.txt", "r", encoding="utf-8") as f:
    temps = [hms_to_minutes(line.strip()) for line in f if line.strip()]
T_2024 = sorted(temps)


with open("diagonale_des_fous_temps_2023.txt", "r", encoding="utf-8") as f:
    temps = [hms_to_minutes(line.strip()) for line in f if line.strip()]
T_2023 = sorted(temps)


with open("diagonale_des_fous_temps_2022.txt", "r", encoding="utf-8") as f:
    temps = [hms_to_minutes(line.strip()) for line in f if line.strip()]
T_2022 = sorted(temps)



plt.figure('Diagonale du Fou - Fréquences cumulées(Fonct. de répartition)')

N = len(T_2025)
x = []
y = []
for k in range(N):
    x.append(T_2025[k])
    y.append((k+1)/N)
plt.plot(x,y, label="2025")


N = len(T_2024)
x = []
y = []
for k in range(N):
    x.append(T_2024[k])
    y.append((k+1)/N)
plt.plot(x,y, label="2024")




N = len(T_2023)
x = []
y = []
for k in range(N):
    x.append(T_2023[k])
    y.append((k+1)/N)
plt.plot(x,y, label="2023")



N = len(T_2022)
x = []
y = []
for k in range(N):
    x.append(T_2022[k])
    y.append((k+1)/N)
plt.plot(x,y, label="2022")




plt.legend()
plt.show()




plt.figure("Diagonale du Fou - histogrammes (densités)")
bins = 50

plt.hist(T_2025, bins=bins, density=True, histtype="step", label="2025")
plt.hist(T_2024, bins=bins, density=True, histtype="step", label="2024")
plt.hist(T_2023, bins=bins, density=True, histtype="step", label="2023")
plt.hist(T_2022, bins=bins, density=True, histtype="step", label="2022")

plt.xlabel("Temps (minutes)")
plt.ylabel("densité (1/min)")
plt.grid(True, alpha=0.3)
plt.legend()
plt.show()


