Spaces:
Runtime error
Runtime error
Commit ·
c56b1d8
1
Parent(s): 82f78ef
refactor: improve code readability and formatting in app.py
Browse files224 unmodified lines225226227228228229230231232417 unmodified lines650651652652653654655656286 unmodified lines94394494594594694794894995095119 unmodified lines97197297397197297397497597497597697797897919 unmodified lines9991000100110011002100310041005100210031007100810091010101110121013100410051006100710081009101010111012224 unmodified lines county_intensity[county] = intensity_label else: # 保留較高的震度 if convert_intensity(intensity_label) > convert_intensity(county_intensity[county]): if convert_intensity(intensity_label) > convert_intensity( county_intensity[county]): county_intensity[county] = intensity_label
# 生成報告417 unmodified lines mode="markers", marker=dict( size=8, color="rgba(128, 128, 128, 0.3)", # 半透明灰色 color="rgba(128, 128, 128, 0.7)", # 半透明灰色 ), text=input_station_texts, hovertemplate="%{text}<extra></extra>",286 unmodified lines )
# 生成警報文字報告 (duration from waveform length: 3000 samples / 100 Hz = 30 seconds) duration = cached_waveforms[0].shape[0] / 100 if cached_waveforms is not None and len(cached_waveforms) > 0 else 30 duration = cached_waveforms[0].shape[ 0] / 100 if cached_waveforms is not None and len( cached_waveforms) > 0 else 30 alert_report = generate_earthquake_alert_report( pga_list, target_names, event_name, duration )19 unmodified lines gr.Markdown("## 使用說明") gr.Markdown( """ - **選擇地震事件**:自動載入測站並執行預測 - **調整時間滑桿**:即時更新波形與震度預測 系統會自動選擇距離震央最近的 25 個測站,並快取資料避免重複讀檔。 """ - **選擇地震事件**:自動載入測站並執行預測 - **調整時間滑桿**:即時更新波形與震度預測 """ ) with gr.Column(scale=1): event_dropdown = gr.Dropdown(19 unmodified lines
# ========== 下層:合併地圖 vs 實際觀測 ========== with gr.Row(): # 實際觀測震度圖
# 合併後的地圖(輸入測站 + 預測震度) with gr.Column(scale=1): predicted_intensity_map = gr.Plot(label="合併地圖") predicted_intensity_map = gr.Plot(label="合併地圖")
with gr.Column(scale=1): observed_intensity_image = gr.Image( label="實際觀測震度", type="filepath", value=load_observed_intensity_image( list(earthquake_metadata.keys())[0]), ) observed_intensity_image = gr.Image( label="實際觀測震度", type="filepath", value=load_observed_intensity_image( list(earthquake_metadata.keys())[0]), )
# ========== 隱藏的 State 變數(用於快取中間結果)========== cached_stream = gr.State(None) # ObsPy Stream objectapp.py+16-20