Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -725,7 +725,7 @@ st.markdown(f"""
|
|
| 725 |
# """, unsafe_allow_html=True)
|
| 726 |
st.markdown("""
|
| 727 |
<h3 class="objective-title">OBJECTIVE 3: Alarm Frequency Analysis — When, Where, and Which Tyres Matter Most?</h3>
|
| 728 |
-
<small>*Showing all alarm types: Normal, Amber, Red</small>
|
| 729 |
""", unsafe_allow_html=True)
|
| 730 |
|
| 731 |
# Filter semua data (termasuk alarm normal)
|
|
@@ -740,11 +740,11 @@ with col_b:
|
|
| 740 |
if alarm_data.empty:
|
| 741 |
st.warning("No data to display.")
|
| 742 |
else:
|
| 743 |
-
# Group alarm status
|
| 744 |
alarm_data['Alarm_Category'] = alarm_data['Alarm Status'].apply(
|
| 745 |
-
lambda x: 'Normal' if 'No Alarm'
|
| 746 |
-
else '
|
| 747 |
-
else '
|
| 748 |
)
|
| 749 |
|
| 750 |
# Buat 4 donut chart
|
|
@@ -763,7 +763,12 @@ with col_b:
|
|
| 763 |
values = counts.values.tolist()
|
| 764 |
|
| 765 |
# Warna: Hijau (Normal), Kuning (Amber), Merah (Red)
|
| 766 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 767 |
|
| 768 |
fig_donut.add_trace(
|
| 769 |
go.Pie(
|
|
@@ -820,8 +825,12 @@ with col_a:
|
|
| 820 |
lambda x: x.mode().iloc[0] if not x.empty else 'Normal'
|
| 821 |
).reindex(range(24), fill_value='Normal')
|
| 822 |
|
| 823 |
-
# Map warna
|
| 824 |
-
color_map = {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 825 |
colorscale = [color_map.get(cat, '#2E7D32') for cat in dominant_alarm_per_hour]
|
| 826 |
|
| 827 |
# Sudut: jam 0 → 0° (atas), jam 6 → 90° (kanan), jam 12 → 180° (bawah), jam 18 → 270° (kiri)
|
|
@@ -877,9 +886,10 @@ else:
|
|
| 877 |
dominant_pct = (top_bands.iloc[0] / band_counts.sum() * 100) if len(top_bands) > 0 else 0
|
| 878 |
second_pct = (top_bands.iloc[1] / band_counts.sum() * 100) if len(top_bands) > 1 else 0
|
| 879 |
|
| 880 |
-
|
| 881 |
-
|
| 882 |
-
red_alarms = alarm_data[alarm_data['
|
|
|
|
| 883 |
|
| 884 |
insight_lines = [
|
| 885 |
f"• {dominant_band} is the dominant period ({dominant_pct:.1f}% of all data).",
|
|
@@ -896,6 +906,7 @@ st.markdown(f"""
|
|
| 896 |
</div>
|
| 897 |
</div>
|
| 898 |
""", unsafe_allow_html=True)
|
|
|
|
| 899 |
# ================= OBJECTIVE 3 =================
|
| 900 |
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)
|
| 901 |
|
|
|
|
| 725 |
# """, unsafe_allow_html=True)
|
| 726 |
st.markdown("""
|
| 727 |
<h3 class="objective-title">OBJECTIVE 3: Alarm Frequency Analysis — When, Where, and Which Tyres Matter Most?</h3>
|
| 728 |
+
<small>*Showing all alarm types: Normal (Green), Amber (Yellow), Red (Red)</small>
|
| 729 |
""", unsafe_allow_html=True)
|
| 730 |
|
| 731 |
# Filter semua data (termasuk alarm normal)
|
|
|
|
| 740 |
if alarm_data.empty:
|
| 741 |
st.warning("No data to display.")
|
| 742 |
else:
|
| 743 |
+
# Group alarm status sesuai permintaan Anda
|
| 744 |
alarm_data['Alarm_Category'] = alarm_data['Alarm Status'].apply(
|
| 745 |
+
lambda x: 'Normal' if x == 'No Alarm'
|
| 746 |
+
else 'Red Alarm' if x == 'Red High Pressure'
|
| 747 |
+
else 'Amber Alarm' # Semua selain No Alarm dan Red High Pressure
|
| 748 |
)
|
| 749 |
|
| 750 |
# Buat 4 donut chart
|
|
|
|
| 763 |
values = counts.values.tolist()
|
| 764 |
|
| 765 |
# Warna: Hijau (Normal), Kuning (Amber), Merah (Red)
|
| 766 |
+
color_map = {
|
| 767 |
+
'Normal': '#2E7D32', # Hijau
|
| 768 |
+
'Amber Alarm': '#FFC107', # Kuning
|
| 769 |
+
'Red Alarm': '#D32F2F' # Merah
|
| 770 |
+
}
|
| 771 |
+
colors = [color_map[label] for label in labels]
|
| 772 |
|
| 773 |
fig_donut.add_trace(
|
| 774 |
go.Pie(
|
|
|
|
| 825 |
lambda x: x.mode().iloc[0] if not x.empty else 'Normal'
|
| 826 |
).reindex(range(24), fill_value='Normal')
|
| 827 |
|
| 828 |
+
# Map warna sesuai permintaan Anda
|
| 829 |
+
color_map = {
|
| 830 |
+
'Normal': '#2E7D32', # Hijau
|
| 831 |
+
'Amber Alarm': '#FFC107', # Kuning
|
| 832 |
+
'Red Alarm': '#D32F2F' # Merah
|
| 833 |
+
}
|
| 834 |
colorscale = [color_map.get(cat, '#2E7D32') for cat in dominant_alarm_per_hour]
|
| 835 |
|
| 836 |
# Sudut: jam 0 → 0° (atas), jam 6 → 90° (kanan), jam 12 → 180° (bawah), jam 18 → 270° (kiri)
|
|
|
|
| 886 |
dominant_pct = (top_bands.iloc[0] / band_counts.sum() * 100) if len(top_bands) > 0 else 0
|
| 887 |
second_pct = (top_bands.iloc[1] / band_counts.sum() * 100) if len(top_bands) > 1 else 0
|
| 888 |
|
| 889 |
+
# Hitung jumlah masing-masing jenis alarm
|
| 890 |
+
normal_alarms = alarm_data[alarm_data['Alarm Status'] == 'No Alarm'].shape[0]
|
| 891 |
+
red_alarms = alarm_data[alarm_data['Alarm Status'] == 'Red High Pressure'].shape[0]
|
| 892 |
+
amber_alarms = alarm_data[~alarm_data['Alarm Status'].isin(['No Alarm', 'Red High Pressure'])].shape[0]
|
| 893 |
|
| 894 |
insight_lines = [
|
| 895 |
f"• {dominant_band} is the dominant period ({dominant_pct:.1f}% of all data).",
|
|
|
|
| 906 |
</div>
|
| 907 |
</div>
|
| 908 |
""", unsafe_allow_html=True)
|
| 909 |
+
|
| 910 |
# ================= OBJECTIVE 3 =================
|
| 911 |
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)
|
| 912 |
|