euler314 commited on
Commit
3f150b8
·
verified ·
1 Parent(s): 1f46770

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -11
app.py CHANGED
@@ -366,9 +366,28 @@ def generate_track_video(year, basin, typhoon, standard):
366
 
367
  # Set up the figure (900x700 pixels at 100 DPI)
368
  fig = plt.figure(figsize=(9, 7), dpi=100)
369
- ax = plt.axes([0.05, 0.05, 0.65, 0.90], projection=ccrs.PlateCarree()) # Adjusted to leave space for sidebar
370
  ax.set_extent([min_lon - lon_padding, max_lon + lon_padding, min_lat - lat_padding, max_lat + lat_padding], crs=ccrs.PlateCarree())
371
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
372
  # Add world map features
373
  ax.add_feature(cfeature.LAND, facecolor='lightgray')
374
  ax.add_feature(cfeature.OCEAN, facecolor='lightblue')
@@ -376,7 +395,7 @@ def generate_track_video(year, basin, typhoon, standard):
376
  ax.add_feature(cfeature.BORDERS, linestyle=':', edgecolor='gray')
377
  ax.gridlines(draw_labels=True, linestyle='--', color='gray', alpha=0.5)
378
 
379
- ax.set_title(f"{year} {storm.name} Tropical Cyclone Path")
380
 
381
  # Initialize the line and point
382
  line, = ax.plot([], [], 'b-', linewidth=2, transform=ccrs.PlateCarree())
@@ -1149,16 +1168,17 @@ with gr.Blocks(title="Typhoon Analysis Dashboard") as demo:
1149
  def simplified_track_video(year, basin, typhoon, standard):
1150
  if not typhoon:
1151
  return None
1152
-
1153
- # Extract storm ID and generate video
1154
  typhoon_id = typhoon.split('(')[-1].strip(')')
1155
- return generate_track_video(year, "All", typhoon, standard) # Pass "All" as basin parameter for compatibility
1156
-
1157
- animate_btn.click(
1158
- fn=simplified_track_video,
1159
- inputs=[year_dropdown, basin_dropdown, typhoon_dropdown, standard_dropdown],
1160
- outputs=path_video
1161
- )
 
1162
 
1163
  with gr.Tab("TSNE Cluster"):
1164
  with gr.Row():
 
366
 
367
  # Set up the figure (900x700 pixels at 100 DPI)
368
  fig = plt.figure(figsize=(9, 7), dpi=100)
369
+ ax = plt.axes([0.05, 0.05, 0.65, 0.90], projection=ccrs.PlateCarree())
370
  ax.set_extent([min_lon - lon_padding, max_lon + lon_padding, min_lat - lat_padding, max_lat + lat_padding], crs=ccrs.PlateCarree())
371
 
372
+ # Add basin name to the title
373
+ basin_name = basin
374
+ if basin == "WP":
375
+ basin_name = "Western North Pacific"
376
+ elif basin == "EP":
377
+ basin_name = "Eastern North Pacific"
378
+ elif basin == "NA" or basin == "AL":
379
+ basin_name = "North Atlantic"
380
+ elif basin == "NI" or basin == "IO":
381
+ basin_name = "North Indian Ocean"
382
+ elif basin == "SI":
383
+ basin_name = "South Indian Ocean"
384
+ elif basin == "SP":
385
+ basin_name = "South Pacific"
386
+ elif basin == "SA" or basin == "SL":
387
+ basin_name = "South Atlantic"
388
+ elif basin == "All":
389
+ basin_name = "Global Oceans"
390
+
391
  # Add world map features
392
  ax.add_feature(cfeature.LAND, facecolor='lightgray')
393
  ax.add_feature(cfeature.OCEAN, facecolor='lightblue')
 
395
  ax.add_feature(cfeature.BORDERS, linestyle=':', edgecolor='gray')
396
  ax.gridlines(draw_labels=True, linestyle='--', color='gray', alpha=0.5)
397
 
398
+ ax.set_title(f"{year} {storm.name} - {basin_name}")
399
 
400
  # Initialize the line and point
401
  line, = ax.plot([], [], 'b-', linewidth=2, transform=ccrs.PlateCarree())
 
1168
  def simplified_track_video(year, basin, typhoon, standard):
1169
  if not typhoon:
1170
  return None
1171
+
1172
+ # Extract storm ID from the dropdown selection
1173
  typhoon_id = typhoon.split('(')[-1].strip(')')
1174
+
1175
+ # Extract basin code from the basin selection
1176
+ basin_code = "All"
1177
+ if basin != "All Basins":
1178
+ basin_code = basin.split(' - ')[0]
1179
+
1180
+ # Generate the animation
1181
+ return generate_track_video(year, basin_code, typhoon, standard)
1182
 
1183
  with gr.Tab("TSNE Cluster"):
1184
  with gr.Row():