Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -731,9 +731,11 @@ st.markdown("""
|
|
| 731 |
# Filter semua data (termasuk alarm normal)
|
| 732 |
alarm_data = dff.copy()
|
| 733 |
|
| 734 |
-
|
|
|
|
|
|
|
| 735 |
|
| 736 |
-
# ===============
|
| 737 |
with col1:
|
| 738 |
# Position 1 Pagi
|
| 739 |
st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 1 (06:00β18:00)</h6>', unsafe_allow_html=True)
|
|
@@ -794,6 +796,7 @@ with col1:
|
|
| 794 |
else:
|
| 795 |
st.warning("No data for Position 1")
|
| 796 |
|
|
|
|
| 797 |
# Position 1 Sore
|
| 798 |
st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 1 (18:00β06:00)</h6>', unsafe_allow_html=True)
|
| 799 |
if not alarm_data[alarm_data['Position'] == 1].empty:
|
|
@@ -856,14 +859,15 @@ with col1:
|
|
| 856 |
else:
|
| 857 |
st.warning("No data for Position 1")
|
| 858 |
|
| 859 |
-
|
| 860 |
-
|
| 861 |
-
|
| 862 |
-
|
| 863 |
-
|
|
|
|
| 864 |
|
| 865 |
-
if not
|
| 866 |
-
hourly_status_counts =
|
| 867 |
|
| 868 |
hourly_normal = hourly_status_counts.get('No Alarm', pd.Series(0, index=range(6, 18))).reindex(range(6, 18), fill_value=0)
|
| 869 |
hourly_amber = hourly_status_counts.get('Amber High Pressure', pd.Series(0, index=range(6, 18))).reindex(range(6, 18), fill_value=0)
|
|
@@ -911,18 +915,19 @@ with col1:
|
|
| 911 |
)
|
| 912 |
st.plotly_chart(fig3, use_container_width=True)
|
| 913 |
else:
|
| 914 |
-
st.warning("No data for Position
|
| 915 |
else:
|
| 916 |
-
st.warning("No data for Position
|
| 917 |
|
| 918 |
-
|
| 919 |
-
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
|
|
|
|
| 923 |
|
| 924 |
-
if not
|
| 925 |
-
hourly_status_counts =
|
| 926 |
|
| 927 |
hourly_normal = pd.concat([hourly_status_counts.get('No Alarm', pd.Series(0, index=range(18, 24))).reindex(range(18, 24), fill_value=0),
|
| 928 |
hourly_status_counts.get('No Alarm', pd.Series(0, index=range(0, 6))).reindex(range(0, 6), fill_value=0)]).values
|
|
@@ -973,20 +978,20 @@ with col1:
|
|
| 973 |
)
|
| 974 |
st.plotly_chart(fig4, use_container_width=True)
|
| 975 |
else:
|
| 976 |
-
st.warning("No data for Position
|
| 977 |
else:
|
| 978 |
-
st.warning("No data for Position
|
| 979 |
|
| 980 |
-
# ===============
|
| 981 |
-
with
|
| 982 |
-
# Position
|
| 983 |
-
st.markdown('<h6 style="text-align:center; margin-top: 0;">Position
|
| 984 |
-
if not alarm_data[alarm_data['Position'] ==
|
| 985 |
-
|
| 986 |
-
|
| 987 |
|
| 988 |
-
if not
|
| 989 |
-
hourly_status_counts =
|
| 990 |
|
| 991 |
hourly_normal = hourly_status_counts.get('No Alarm', pd.Series(0, index=range(6, 18))).reindex(range(6, 18), fill_value=0)
|
| 992 |
hourly_amber = hourly_status_counts.get('Amber High Pressure', pd.Series(0, index=range(6, 18))).reindex(range(6, 18), fill_value=0)
|
|
@@ -1034,18 +1039,19 @@ with col2:
|
|
| 1034 |
)
|
| 1035 |
st.plotly_chart(fig5, use_container_width=True)
|
| 1036 |
else:
|
| 1037 |
-
st.warning("No data for Position
|
| 1038 |
else:
|
| 1039 |
-
st.warning("No data for Position
|
| 1040 |
|
| 1041 |
-
|
| 1042 |
-
|
| 1043 |
-
|
| 1044 |
-
|
| 1045 |
-
|
|
|
|
| 1046 |
|
| 1047 |
-
if not
|
| 1048 |
-
hourly_status_counts =
|
| 1049 |
|
| 1050 |
hourly_normal = pd.concat([hourly_status_counts.get('No Alarm', pd.Series(0, index=range(18, 24))).reindex(range(18, 24), fill_value=0),
|
| 1051 |
hourly_status_counts.get('No Alarm', pd.Series(0, index=range(0, 6))).reindex(range(0, 6), fill_value=0)]).values
|
|
@@ -1096,10 +1102,11 @@ with col2:
|
|
| 1096 |
)
|
| 1097 |
st.plotly_chart(fig6, use_container_width=True)
|
| 1098 |
else:
|
| 1099 |
-
st.warning("No data for Position
|
| 1100 |
else:
|
| 1101 |
-
st.warning("No data for Position
|
| 1102 |
|
|
|
|
| 1103 |
# Position 4 Pagi
|
| 1104 |
st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 4 (06:00β18:00)</h6>', unsafe_allow_html=True)
|
| 1105 |
if not alarm_data[alarm_data['Position'] == 4].empty:
|
|
@@ -1159,6 +1166,7 @@ with col2:
|
|
| 1159 |
else:
|
| 1160 |
st.warning("No data for Position 4")
|
| 1161 |
|
|
|
|
| 1162 |
# Position 4 Sore
|
| 1163 |
st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 4 (18:00β06:00)</h6>', unsafe_allow_html=True)
|
| 1164 |
if not alarm_data[alarm_data['Position'] == 4].empty:
|
|
@@ -1265,7 +1273,6 @@ st.markdown(f"""
|
|
| 1265 |
</div>
|
| 1266 |
</div>
|
| 1267 |
""", unsafe_allow_html=True)
|
| 1268 |
-
|
| 1269 |
# ================= OBJECTIVE 3 =================
|
| 1270 |
st.markdown('<h3 class="objective-title">OBJECTIVE 4: Correlation β How Does Heat Influence Pressure and Which Tyres Trigger Red Alarms?</h3>', unsafe_allow_html=True)
|
| 1271 |
|
|
|
|
| 731 |
# Filter semua data (termasuk alarm normal)
|
| 732 |
alarm_data = dff.copy()
|
| 733 |
|
| 734 |
+
# Buat 2 baris Γ 4 kolom
|
| 735 |
+
col1, col2, col3, col4 = st.columns(4)
|
| 736 |
+
col5, col6, col7, col8 = st.columns(4)
|
| 737 |
|
| 738 |
+
# =============== ROW 1: Position 1 & 2 (Pagi & Sore) ===============
|
| 739 |
with col1:
|
| 740 |
# Position 1 Pagi
|
| 741 |
st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 1 (06:00β18:00)</h6>', unsafe_allow_html=True)
|
|
|
|
| 796 |
else:
|
| 797 |
st.warning("No data for Position 1")
|
| 798 |
|
| 799 |
+
with col2:
|
| 800 |
# Position 1 Sore
|
| 801 |
st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 1 (18:00β06:00)</h6>', unsafe_allow_html=True)
|
| 802 |
if not alarm_data[alarm_data['Position'] == 1].empty:
|
|
|
|
| 859 |
else:
|
| 860 |
st.warning("No data for Position 1")
|
| 861 |
|
| 862 |
+
with col3:
|
| 863 |
+
# Position 2 Pagi
|
| 864 |
+
st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 2 (06:00β18:00)</h6>', unsafe_allow_html=True)
|
| 865 |
+
if not alarm_data[alarm_data['Position'] == 2].empty:
|
| 866 |
+
pos2_data = alarm_data[alarm_data['Position'] == 2].copy()
|
| 867 |
+
pos2_data = pos2_data[pos2_data['hour'].between(6, 17, inclusive='both')]
|
| 868 |
|
| 869 |
+
if not pos2_data.empty:
|
| 870 |
+
hourly_status_counts = pos2_data.groupby(['hour', 'Alarm Status']).size().unstack(fill_value=0)
|
| 871 |
|
| 872 |
hourly_normal = hourly_status_counts.get('No Alarm', pd.Series(0, index=range(6, 18))).reindex(range(6, 18), fill_value=0)
|
| 873 |
hourly_amber = hourly_status_counts.get('Amber High Pressure', pd.Series(0, index=range(6, 18))).reindex(range(6, 18), fill_value=0)
|
|
|
|
| 915 |
)
|
| 916 |
st.plotly_chart(fig3, use_container_width=True)
|
| 917 |
else:
|
| 918 |
+
st.warning("No data for Position 2 (06:00β18:00)")
|
| 919 |
else:
|
| 920 |
+
st.warning("No data for Position 2")
|
| 921 |
|
| 922 |
+
with col4:
|
| 923 |
+
# Position 2 Sore
|
| 924 |
+
st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 2 (18:00β06:00)</h6>', unsafe_allow_html=True)
|
| 925 |
+
if not alarm_data[alarm_data['Position'] == 2].empty:
|
| 926 |
+
pos2_data = alarm_data[alarm_data['Position'] == 2].copy()
|
| 927 |
+
pos2_data = pos2_data[~pos2_data['hour'].between(6, 17, inclusive='both')]
|
| 928 |
|
| 929 |
+
if not pos2_data.empty:
|
| 930 |
+
hourly_status_counts = pos2_data.groupby(['hour', 'Alarm Status']).size().unstack(fill_value=0)
|
| 931 |
|
| 932 |
hourly_normal = pd.concat([hourly_status_counts.get('No Alarm', pd.Series(0, index=range(18, 24))).reindex(range(18, 24), fill_value=0),
|
| 933 |
hourly_status_counts.get('No Alarm', pd.Series(0, index=range(0, 6))).reindex(range(0, 6), fill_value=0)]).values
|
|
|
|
| 978 |
)
|
| 979 |
st.plotly_chart(fig4, use_container_width=True)
|
| 980 |
else:
|
| 981 |
+
st.warning("No data for Position 2 (18:00β06:00)")
|
| 982 |
else:
|
| 983 |
+
st.warning("No data for Position 2")
|
| 984 |
|
| 985 |
+
# =============== ROW 2: Position 3 & 4 (Pagi & Sore) ===============
|
| 986 |
+
with col5:
|
| 987 |
+
# Position 3 Pagi
|
| 988 |
+
st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 3 (06:00β18:00)</h6>', unsafe_allow_html=True)
|
| 989 |
+
if not alarm_data[alarm_data['Position'] == 3].empty:
|
| 990 |
+
pos3_data = alarm_data[alarm_data['Position'] == 3].copy()
|
| 991 |
+
pos3_data = pos3_data[pos3_data['hour'].between(6, 17, inclusive='both')]
|
| 992 |
|
| 993 |
+
if not pos3_data.empty:
|
| 994 |
+
hourly_status_counts = pos3_data.groupby(['hour', 'Alarm Status']).size().unstack(fill_value=0)
|
| 995 |
|
| 996 |
hourly_normal = hourly_status_counts.get('No Alarm', pd.Series(0, index=range(6, 18))).reindex(range(6, 18), fill_value=0)
|
| 997 |
hourly_amber = hourly_status_counts.get('Amber High Pressure', pd.Series(0, index=range(6, 18))).reindex(range(6, 18), fill_value=0)
|
|
|
|
| 1039 |
)
|
| 1040 |
st.plotly_chart(fig5, use_container_width=True)
|
| 1041 |
else:
|
| 1042 |
+
st.warning("No data for Position 3 (06:00β18:00)")
|
| 1043 |
else:
|
| 1044 |
+
st.warning("No data for Position 3")
|
| 1045 |
|
| 1046 |
+
with col6:
|
| 1047 |
+
# Position 3 Sore
|
| 1048 |
+
st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 3 (18:00β06:00)</h6>', unsafe_allow_html=True)
|
| 1049 |
+
if not alarm_data[alarm_data['Position'] == 3].empty:
|
| 1050 |
+
pos3_data = alarm_data[alarm_data['Position'] == 3].copy()
|
| 1051 |
+
pos3_data = pos3_data[~pos3_data['hour'].between(6, 17, inclusive='both')]
|
| 1052 |
|
| 1053 |
+
if not pos3_data.empty:
|
| 1054 |
+
hourly_status_counts = pos3_data.groupby(['hour', 'Alarm Status']).size().unstack(fill_value=0)
|
| 1055 |
|
| 1056 |
hourly_normal = pd.concat([hourly_status_counts.get('No Alarm', pd.Series(0, index=range(18, 24))).reindex(range(18, 24), fill_value=0),
|
| 1057 |
hourly_status_counts.get('No Alarm', pd.Series(0, index=range(0, 6))).reindex(range(0, 6), fill_value=0)]).values
|
|
|
|
| 1102 |
)
|
| 1103 |
st.plotly_chart(fig6, use_container_width=True)
|
| 1104 |
else:
|
| 1105 |
+
st.warning("No data for Position 3 (18:00β06:00)")
|
| 1106 |
else:
|
| 1107 |
+
st.warning("No data for Position 3")
|
| 1108 |
|
| 1109 |
+
with col7:
|
| 1110 |
# Position 4 Pagi
|
| 1111 |
st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 4 (06:00β18:00)</h6>', unsafe_allow_html=True)
|
| 1112 |
if not alarm_data[alarm_data['Position'] == 4].empty:
|
|
|
|
| 1166 |
else:
|
| 1167 |
st.warning("No data for Position 4")
|
| 1168 |
|
| 1169 |
+
with col8:
|
| 1170 |
# Position 4 Sore
|
| 1171 |
st.markdown('<h6 style="text-align:center; margin-top: 0;">Position 4 (18:00β06:00)</h6>', unsafe_allow_html=True)
|
| 1172 |
if not alarm_data[alarm_data['Position'] == 4].empty:
|
|
|
|
| 1273 |
</div>
|
| 1274 |
</div>
|
| 1275 |
""", unsafe_allow_html=True)
|
|
|
|
| 1276 |
# ================= OBJECTIVE 3 =================
|
| 1277 |
st.markdown('<h3 class="objective-title">OBJECTIVE 4: Correlation β How Does Heat Influence Pressure and Which Tyres Trigger Red Alarms?</h3>', unsafe_allow_html=True)
|
| 1278 |
|