Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -800,23 +800,59 @@ with tab4:
|
|
| 800 |
|
| 801 |
forecast_start_ts = latest_time_for_day + pd.Timedelta(hours=1)
|
| 802 |
|
| 803 |
-
|
| 804 |
-
|
| 805 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 806 |
st.metric(
|
| 807 |
-
label=f"Forecast @ {forecast_start_ts.strftime('%H:%M')}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 808 |
value=f"{t_plus_24h_metric_value:.1f}°C"
|
| 809 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 810 |
|
| 811 |
-
#
|
| 812 |
-
|
| 813 |
-
|
| 814 |
-
|
| 815 |
-
|
| 816 |
-
with
|
| 817 |
-
|
| 818 |
-
|
| 819 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 820 |
st.markdown("---")
|
| 821 |
|
| 822 |
# 5. Graph: Nhiệt độ Từng Giờ
|
|
|
|
| 800 |
|
| 801 |
forecast_start_ts = latest_time_for_day + pd.Timedelta(hours=1)
|
| 802 |
|
| 803 |
+
# Tính các giá trị cho T+2h và T+3h
|
| 804 |
+
# T+2h là index 1; T+3h là index 2
|
| 805 |
+
t_plus_2h_value = predictions_24h[1] if len(predictions_24h) >= 2 else float('nan')
|
| 806 |
+
t_plus_3h_value = predictions_24h[2] if len(predictions_24h) >= 3 else float('nan')
|
| 807 |
+
|
| 808 |
+
# Các giá trị Max/Mean (sử dụng np đã được import)
|
| 809 |
+
avg_temp = np.nanmean(predictions_24h)
|
| 810 |
+
max_temp = np.nanmax(predictions_24h)
|
| 811 |
+
|
| 812 |
+
|
| 813 |
+
# Tạo 5 cột mới để hiển thị các metric (T+2h, T+3h, T+24h, Average, Max)
|
| 814 |
+
col_t2, col_t3, col_t24, col_avg, col_max = st.columns(5)
|
| 815 |
+
|
| 816 |
+
# --- 1. Metric T+2h (Gần nhất) ---
|
| 817 |
+
with col_t2:
|
| 818 |
+
st.metric(
|
| 819 |
+
label=f"Forecast @ {forecast_start_ts.strftime('%H:%M')[:2]} +2h",
|
| 820 |
+
value=f"{t_plus_2h_value:.1f}°C"
|
| 821 |
+
)
|
| 822 |
+
|
| 823 |
+
# --- 2. Metric T+3h ---
|
| 824 |
+
with col_t3:
|
| 825 |
st.metric(
|
| 826 |
+
label=f"Forecast @ {forecast_start_ts.strftime('%H:%M')[:2]} +3h",
|
| 827 |
+
value=f"{t_plus_3h_value:.1f}°C"
|
| 828 |
+
)
|
| 829 |
+
|
| 830 |
+
# --- 3. Metric T+24h (Giữ lại để đối chiếu) ---
|
| 831 |
+
with col_t24:
|
| 832 |
+
# T+24h prediction value is t_plus_24h_metric_value from before (predictions_24h[23])
|
| 833 |
+
st.metric(
|
| 834 |
+
label=f"Forecast @ {forecast_start_ts.strftime('%H:%M')} +24h",
|
| 835 |
value=f"{t_plus_24h_metric_value:.1f}°C"
|
| 836 |
)
|
| 837 |
+
|
| 838 |
+
# --- 4. Metric Average ---
|
| 839 |
+
with col_avg:
|
| 840 |
+
st.metric(label="Next 24h Average Temp", value=f"{avg_temp:.1f}°C")
|
| 841 |
|
| 842 |
+
# --- 5. Metric Max (Sử dụng bố cục ngang) ---
|
| 843 |
+
with col_max:
|
| 844 |
+
st.markdown("Next 24h Max Temp")
|
| 845 |
+
col_value, col_delta = st.columns([1.5, 1])
|
| 846 |
+
|
| 847 |
+
with col_value:
|
| 848 |
+
st.markdown(f"<p style='font-size: 2.5rem; font-weight: 700; color: #004080; line-height: 1.2;'>{max_temp:.1f}°C</p>",
|
| 849 |
+
unsafe_allow_html=True)
|
| 850 |
|
| 851 |
+
with col_delta:
|
| 852 |
+
st.markdown("<br>", unsafe_allow_html=True)
|
| 853 |
+
st.markdown("<p style='font-size: 1rem; font-weight: 600; color: #DC3545;'>Peak Heat</p>",
|
| 854 |
+
unsafe_allow_html=True)
|
| 855 |
+
|
| 856 |
st.markdown("---")
|
| 857 |
|
| 858 |
# 5. Graph: Nhiệt độ Từng Giờ
|