bichle commited on
Commit
1c15970
·
verified ·
1 Parent(s): 66760b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -18
app.py CHANGED
@@ -812,26 +812,32 @@ with tab4:
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
 
@@ -841,19 +847,9 @@ with tab4:
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ờ
859
 
 
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
+ # Tính Timestamp cho các dự báo điểm (T+2h và T+3h)
816
+ forecast_t2_ts = forecast_start_ts + pd.Timedelta(hours=2)
817
+ forecast_t3_ts = forecast_start_ts + pd.Timedelta(hours=3)
818
+ forecast_t24_ts = forecast_start_ts + pd.Timedelta(hours=24)
819
 
820
+ # --- 1. Metric T+2h ---
821
  with col_t2:
822
  st.metric(
823
+ # SỬA: Dùng forecast_t2_ts để hiển thị giờ thực tế (+2h)
824
+ label=f"Forecast @ {forecast_t2_ts.strftime('%H:%M')}",
825
  value=f"{t_plus_2h_value:.1f}°C"
826
  )
827
 
828
  # --- 2. Metric T+3h ---
829
  with col_t3:
830
  st.metric(
831
+ # SỬA: Dùng forecast_t3_ts để hiển thị giờ thực tế (+3h)
832
+ label=f"Forecast @ {forecast_t3_ts.strftime('%H:%M')}",
833
  value=f"{t_plus_3h_value:.1f}°C"
834
  )
835
 
836
  # --- 3. Metric T+24h (Giữ lại để đối chiếu) ---
837
  with col_t24:
 
838
  st.metric(
839
+ # SỬA: Dùng forecast_t24_ts để hiển thị giờ thực tế (+24h)
840
+ label=f"Forecast @ {forecast_t24_ts.strftime('%H:%M')}",
841
  value=f"{t_plus_24h_metric_value:.1f}°C"
842
  )
843
 
 
847
 
848
  # --- 5. Metric Max (Sử dụng bố cục ngang) ---
849
  with col_max:
850
+ st.metric(label="Next 24h Max Temp", value=f"{np.nanmax(predictions_24h):.1f}°C",
851
+ delta="Peak Heat")
852
+
 
 
 
 
 
 
 
 
 
 
853
 
854
  # 5. Graph: Nhiệt độ Từng Giờ
855