Spaces:
Sleeping
Sleeping
Commit
·
54f91c5
1
Parent(s):
d8b2ffe
good
Browse files
app.py
ADDED
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import pandas as pd
|
3 |
+
|
4 |
+
# Initialiser l'état de la session
|
5 |
+
if 'phases' not in st.session_state:
|
6 |
+
st.session_state['phases'] = []
|
7 |
+
|
8 |
+
# Titre
|
9 |
+
st.title('Gestion des erreurs de mélange de béton')
|
10 |
+
|
11 |
+
|
12 |
+
|
13 |
+
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
st.header('Entrées les norme de calcul')
|
18 |
+
g1_norme = st.number_input('G1 norme',value=575.0 ,format="%.2f")
|
19 |
+
g2_norme= st.number_input('G2 norme',value=1000.0 ,format="%.2f")
|
20 |
+
sb_norme= st.number_input('SB norme',value=1237.0 ,format="%.2f")
|
21 |
+
cube_norme= st.number_input('Cube norme',value=1.5 ,format="%.2f")
|
22 |
+
|
23 |
+
# Section d'entrée pour la phase
|
24 |
+
st.header('Entrées pour la phase')
|
25 |
+
g1_input = st.number_input('G1',format="%.2f")
|
26 |
+
|
27 |
+
g2_input = st.number_input('G2',format="%.2f")
|
28 |
+
sb_input = st.number_input('SB', format="%.2f")
|
29 |
+
cubes_input = st.number_input('Cubes', value=1.5, format="%.2f")
|
30 |
+
|
31 |
+
# Ajouter la phase
|
32 |
+
if st.button('Ajouter la phase'):
|
33 |
+
phase_data = {
|
34 |
+
'G1': g1_input,
|
35 |
+
'G2': g2_input,
|
36 |
+
'SB': sb_input,
|
37 |
+
'Cubes': cubes_input,
|
38 |
+
'G1_Error': g1_input- (g1_norme/cube_norme * cubes_input) ,
|
39 |
+
'G2_Error': (g2_input - g1_input)-(g2_norme/cube_norme * cubes_input) ,
|
40 |
+
'SB_Error': (sb_input - g2_input)-(sb_norme /cube_norme* cubes_input) ,
|
41 |
+
}
|
42 |
+
st.session_state['phases'].append(phase_data)
|
43 |
+
|
44 |
+
# Afficher les phases
|
45 |
+
st.header('Phases')
|
46 |
+
phases_df = pd.DataFrame(st.session_state['phases'])
|
47 |
+
st.write(phases_df)
|
48 |
+
|
49 |
+
# Calculer les erreurs totales
|
50 |
+
st.header('Calcul des erreurs')
|
51 |
+
try:
|
52 |
+
total_g1_error = phases_df['G1_Error'].sum()
|
53 |
+
total_g2_error = phases_df['G2_Error'].sum()
|
54 |
+
total_sb_error = phases_df['SB_Error'].sum()
|
55 |
+
|
56 |
+
st.write(f"Erreur totale G1: {total_g1_error}")
|
57 |
+
st.write(f"Erreur totale G2: {total_g2_error}")
|
58 |
+
st.write(f"Erreur totale SB: {total_sb_error}")
|
59 |
+
except KeyError as e:
|
60 |
+
st.error(f"Erreur dans les données: {e}")
|
61 |
+
|
62 |
+
# Correction des erreurs en fonction des cubes restants
|
63 |
+
st.header('Correction des erreurs')
|
64 |
+
remaining_cubes = st.number_input('Cubes restants', value=1.0, format="%.2f")
|
65 |
+
if st.button('Corriger les erreurs'):
|
66 |
+
try:
|
67 |
+
correction_g1 = g1_norme/cube_norme *remaining_cubes - total_g1_error
|
68 |
+
correction_g2 = g2_norme/cube_norme *remaining_cubes - total_g2_error
|
69 |
+
correction_sb = sb_norme/cube_norme *remaining_cubes - total_sb_error
|
70 |
+
|
71 |
+
st.write(f"Correction G1 par cube: {correction_g1}")
|
72 |
+
st.write(f"Correction G2 par cube: {correction_g2}")
|
73 |
+
st.write(f"Correction SB par cube: {correction_sb}")
|
74 |
+
except ZeroDivisionError:
|
75 |
+
st.error("Le nombre de cubes restants doit être supérieur à zéro pour corriger les erreurs.")
|
76 |
+
|
77 |
+
# Générer un rapport détaillé des erreurs
|
78 |
+
st.header('Rapport détaillé des erreurs')
|
79 |
+
if st.button('Générer le rapport'):
|
80 |
+
try:
|
81 |
+
report = f"""
|
82 |
+
## Rapport détaillé des erreurs
|
83 |
+
### Erreurs totales
|
84 |
+
- Erreur G1: {total_g1_error}
|
85 |
+
- Erreur G2: {total_g2_error}
|
86 |
+
- Erreur SB: {total_sb_error}
|
87 |
+
|
88 |
+
### Correction nécessaire
|
89 |
+
- G1 par cube: {correction_g1}
|
90 |
+
- G2 par cube: {correction_g2}
|
91 |
+
- SB par cube: {correction_sb}
|
92 |
+
|
93 |
+
### Phases
|
94 |
+
{phases_df.to_markdown()}
|
95 |
+
"""
|
96 |
+
st.markdown(report)
|
97 |
+
except Exception as e:
|
98 |
+
st.error(f"Erreur lors de la génération du rapport: {e}")
|
99 |
+
|
100 |
+
# Enregistrer le rapport
|
101 |
+
st.header('Enregistrer le rapport')
|
102 |
+
if st.button('Enregistrer le rapport'):
|
103 |
+
try:
|
104 |
+
with open("rapport_erreurs.txt", "w") as file:
|
105 |
+
file.write(report)
|
106 |
+
st.write('Rapport enregistré sous le nom rapport_erreurs.txt')
|
107 |
+
except Exception as e:
|
108 |
+
st.error(f"Erreur lors de l'enregistrement du rapport: {e}")
|