ageraustine commited on
Commit
8be96b1
Β·
verified Β·
1 Parent(s): 10de347

Upload folder using huggingface_hub

Browse files
Files changed (1) hide show
  1. src/gradio_app.py +4 -29
src/gradio_app.py CHANGED
@@ -1,7 +1,6 @@
1
  """
2
- Gradio river network explorer β€” click directly on the river line (or
3
- use the slider) to read interpolated elevation and estimated groundwater
4
- level at that point.
5
 
6
  Usage:
7
  python app.py --data-root datasets
@@ -232,7 +231,7 @@ def build_figure_real(info, basin_name: str, color: str, wells_df=None, marker_l
232
  hoverinfo="skip", showlegend=False,
233
  ))
234
  fig.update_layout(
235
- title=f"{basin_name} β€” click the line",
236
  xaxis_title="Longitude", yaxis_title="Latitude",
237
  yaxis=dict(scaleanchor="x", scaleratio=1),
238
  height=520, margin=dict(l=10, r=10, t=40, b=10),
@@ -261,7 +260,7 @@ def build_figure_schematic(targets, basin_name: str, color: str, marker_x=None,
261
  hoverinfo="skip", showlegend=False,
262
  ))
263
  fig.update_layout(
264
- title=f"{basin_name} β€” click the line (schematic, no digitized centerline)",
265
  xaxis_title="Position along river (upstream β†’ downstream)", yaxis_title="Elevation (m)",
266
  xaxis=dict(showticklabels=False), height=340,
267
  margin=dict(l=10, r=10, t=40, b=10),
@@ -445,30 +444,6 @@ with gr.Blocks(title="River Network Explorer") as demo:
445
 
446
  slider.change(compute_position, inputs=[basin_radio, slider], outputs=[plot_output, metric_elev, metric_dist, metric_gw, coords_md, plot_waterlevel, plot_discharge, plot_rating])
447
 
448
- def on_plot_select(basin_id, select_data: gr.SelectData):
449
- if not select_data or select_data.index is None:
450
- return gr.skip()
451
- try:
452
- point_idx = select_data.index
453
- nodes, edges = get_graph(DATA_ROOT)
454
- centerlines = get_centerlines(DATA_ROOT, nodes)
455
- if basin_id in centerlines:
456
- targets = centerlines[basin_id]["click_targets"]
457
- if point_idx < len(targets):
458
- km = targets.iloc[point_idx]["distance_from_mouth_km"]
459
- pct = int(round(100 * float(km) / centerlines[basin_id]["total_km"]))
460
- return pct
461
- else:
462
- targets = schematic_click_targets(nodes, edges, basin_id)
463
- if point_idx < len(targets):
464
- frac = targets.iloc[point_idx]["fraction"]
465
- return int(round(100 * float(frac)))
466
- except Exception:
467
- pass
468
- return gr.skip()
469
-
470
- plot_output.select(on_plot_select, inputs=[basin_radio], outputs=[slider])
471
-
472
  demo.load(update_view, inputs=[view_radio, basin_radio], outputs=[explore_group, validation_group, status_md, plot_output, slider])
473
 
474
  # if __name__ == "__main__":
 
1
  """
2
+ Gradio river network explorer β€” slide to read interpolated elevation
3
+ and estimated groundwater level along the river.
 
4
 
5
  Usage:
6
  python app.py --data-root datasets
 
231
  hoverinfo="skip", showlegend=False,
232
  ))
233
  fig.update_layout(
234
+ title=f"{basin_name} β€” use slider to navigate",
235
  xaxis_title="Longitude", yaxis_title="Latitude",
236
  yaxis=dict(scaleanchor="x", scaleratio=1),
237
  height=520, margin=dict(l=10, r=10, t=40, b=10),
 
260
  hoverinfo="skip", showlegend=False,
261
  ))
262
  fig.update_layout(
263
+ title=f"{basin_name} β€” use slider to navigate (schematic)",
264
  xaxis_title="Position along river (upstream β†’ downstream)", yaxis_title="Elevation (m)",
265
  xaxis=dict(showticklabels=False), height=340,
266
  margin=dict(l=10, r=10, t=40, b=10),
 
444
 
445
  slider.change(compute_position, inputs=[basin_radio, slider], outputs=[plot_output, metric_elev, metric_dist, metric_gw, coords_md, plot_waterlevel, plot_discharge, plot_rating])
446
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
447
  demo.load(update_view, inputs=[view_radio, basin_radio], outputs=[explore_group, validation_group, status_md, plot_output, slider])
448
 
449
  # if __name__ == "__main__":