OttoYu commited on
Commit
3703659
·
verified ·
1 Parent(s): 76c013a

add sample

Browse files
Files changed (1) hide show
  1. app.py +31 -2
app.py CHANGED
@@ -154,7 +154,6 @@ def tide_analysis_for_month_gradio(month_str):
154
  logs.append(f"Error during processing: {e}")
155
  return "\n".join(logs), None, None, None
156
 
157
- # Gradio UI
158
  with gr.Blocks() as demo:
159
  gr.Markdown("## Tide Time Series Analysis by Month")
160
 
@@ -163,6 +162,14 @@ with gr.Blocks() as demo:
163
  month_input = gr.Textbox(label="Enter Month (YYYY-MM)", placeholder="e.g. 2023-07")
164
  run_btn = gr.Button("Run Analysis")
165
 
 
 
 
 
 
 
 
 
166
  # --- Second Row: Plot Area ---
167
  with gr.Row():
168
  with gr.Column():
@@ -173,10 +180,32 @@ with gr.Blocks() as demo:
173
  plot_pred = gr.Plot(label="Predicted Tide")
174
  status_output = gr.Textbox(label="Status / Error", interactive=False, lines=1)
175
 
 
176
  run_btn.click(fn=tide_analysis_for_month_gradio,
177
  inputs=month_input,
178
  outputs=[status_output, plot_pred, plot_meas, plot_resid])
179
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
180
 
181
  if __name__ == "__main__":
182
- demo.launch()
 
154
  logs.append(f"Error during processing: {e}")
155
  return "\n".join(logs), None, None, None
156
 
 
157
  with gr.Blocks() as demo:
158
  gr.Markdown("## Tide Time Series Analysis by Month")
159
 
 
162
  month_input = gr.Textbox(label="Enter Month (YYYY-MM)", placeholder="e.g. 2023-07")
163
  run_btn = gr.Button("Run Analysis")
164
 
165
+ # --- Sample Storm Surge Buttons (small and inline) ---
166
+ gr.Markdown("#### Sample Storm Surge Months")
167
+ with gr.Row():
168
+ sample_1 = gr.Button("2025-07 (Wipha)", scale=1)
169
+ sample_2 = gr.Button("2021-10 (Lionrock)", scale=1)
170
+ sample_3 = gr.Button("2022-08 (Ma-on)", scale=1)
171
+ sample_4 = gr.Button("2022-11 (Nalgae)", scale=1)
172
+
173
  # --- Second Row: Plot Area ---
174
  with gr.Row():
175
  with gr.Column():
 
180
  plot_pred = gr.Plot(label="Predicted Tide")
181
  status_output = gr.Textbox(label="Status / Error", interactive=False, lines=1)
182
 
183
+ # --- Main Run Button Action ---
184
  run_btn.click(fn=tide_analysis_for_month_gradio,
185
  inputs=month_input,
186
  outputs=[status_output, plot_pred, plot_meas, plot_resid])
187
 
188
+ # --- Sample Buttons Actions ---
189
+ sample_1.click(fn=lambda: "2025-07", inputs=[], outputs=month_input).then(
190
+ fn=tide_analysis_for_month_gradio,
191
+ inputs=month_input,
192
+ outputs=[status_output, plot_pred, plot_meas, plot_resid]
193
+ )
194
+ sample_2.click(fn=lambda: "2021-10", inputs=[], outputs=month_input).then(
195
+ fn=tide_analysis_for_month_gradio,
196
+ inputs=month_input,
197
+ outputs=[status_output, plot_pred, plot_meas, plot_resid]
198
+ )
199
+ sample_3.click(fn=lambda: "2022-08", inputs=[], outputs=month_input).then(
200
+ fn=tide_analysis_for_month_gradio,
201
+ inputs=month_input,
202
+ outputs=[status_output, plot_pred, plot_meas, plot_resid]
203
+ )
204
+ sample_4.click(fn=lambda: "2022-11", inputs=[], outputs=month_input).then(
205
+ fn=tide_analysis_for_month_gradio,
206
+ inputs=month_input,
207
+ outputs=[status_output, plot_pred, plot_meas, plot_resid]
208
+ )
209
 
210
  if __name__ == "__main__":
211
+ demo.launch()