euler314 commited on
Commit
351cc17
·
verified ·
1 Parent(s): 269833c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -8
app.py CHANGED
@@ -302,7 +302,7 @@ def generate_main_analysis(start_year, start_month, end_year, end_month, enso_ph
302
 
303
  return tracks_fig, wind_scatter, pressure_scatter, regression_fig, slopes_text
304
 
305
- # Video animation function with adjusted scale
306
  def categorize_typhoon_by_standard(wind_speed, standard):
307
  if standard == 'taiwan':
308
  wind_speed_ms = wind_speed * 0.514444
@@ -342,7 +342,7 @@ def generate_track_video(year, typhoon, standard):
342
  lon_padding = max((max_lon - min_lon) * 0.3, 5)
343
 
344
  # Set up the figure with Gradio-friendly scale (1000x700 pixels at 100 DPI)
345
- fig = plt.figure(figsize=(20, 10), dpi=300) # 10x7 inches = 1000x700 pixels
346
  ax = plt.axes([0.05, 0.05, 0.65, 0.9], projection=ccrs.PlateCarree()) # Map on left 65% of figure
347
  ax.set_extent([min_lon - lon_padding, max_lon + lon_padding, min_lat - lat_padding, max_lat + lat_padding], crs=ccrs.PlateCarree())
348
 
@@ -355,11 +355,12 @@ def generate_track_video(year, typhoon, standard):
355
 
356
  ax.set_title(f"{year} {storm.name} Typhoon Path")
357
 
358
- # Legend for categories
359
  standard_dict = atlantic_standard if standard == 'atlantic' else taiwan_standard
360
- for cat, details in standard_dict.items():
361
- ax.plot([], [], 'o', color=details['color'], label=cat)
362
- ax.legend(loc='upper left', bbox_to_anchor=(1.7, 1))
 
363
 
364
  # Initialize the line and point
365
  line, = ax.plot([], [], 'b-', linewidth=2, transform=ccrs.PlateCarree())
@@ -449,7 +450,7 @@ with gr.Blocks(title="Typhoon Analysis Dashboard") as demo:
449
  ### Features:
450
  - **Track Visualization**: View typhoon tracks by time period and ENSO phase
451
  - **Statistical Analysis**: Examine relationships between ONI values and typhoon characteristics
452
- - **Path Animation**: Watch an animated typhoon path with video controls, world map, and details sidebar
453
  - **Regression Analysis**: Perform statistical regression on typhoon data
454
 
455
  Select a tab above to begin your analysis.
@@ -617,7 +618,10 @@ with gr.Blocks(title="Typhoon Analysis Dashboard") as demo:
617
  2. Choose a classification standard (Atlantic or Taiwan)
618
  3. Click "Generate Animation"
619
  4. Use the video player's built-in controls to play, pause, or scrub through the animation
620
- 5. The animation shows the typhoon track growing over a world map, with date on the bottom left and details on the right
 
 
 
621
  """)
622
 
623
  def update_typhoon_options(year):
 
302
 
303
  return tracks_fig, wind_scatter, pressure_scatter, regression_fig, slopes_text
304
 
305
+ # Video animation function with color legend and typhoon details
306
  def categorize_typhoon_by_standard(wind_speed, standard):
307
  if standard == 'taiwan':
308
  wind_speed_ms = wind_speed * 0.514444
 
342
  lon_padding = max((max_lon - min_lon) * 0.3, 5)
343
 
344
  # Set up the figure with Gradio-friendly scale (1000x700 pixels at 100 DPI)
345
+ fig = plt.figure(figsize=(10, 7), dpi=100) # 10x7 inches = 1000x700 pixels
346
  ax = plt.axes([0.05, 0.05, 0.65, 0.9], projection=ccrs.PlateCarree()) # Map on left 65% of figure
347
  ax.set_extent([min_lon - lon_padding, max_lon + lon_padding, min_lat - lat_padding, max_lat + lat_padding], crs=ccrs.PlateCarree())
348
 
 
355
 
356
  ax.set_title(f"{year} {storm.name} Typhoon Path")
357
 
358
+ # Legend for categories with explicit color meanings
359
  standard_dict = atlantic_standard if standard == 'atlantic' else taiwan_standard
360
+ legend_elements = [plt.Line2D([0], [0], marker='o', color='w', label=f"{cat} ({details['color']})",
361
+ markerfacecolor=details['color'], markersize=10)
362
+ for cat, details in standard_dict.items()]
363
+ ax.legend(handles=legend_elements, loc='upper left', bbox_to_anchor=(1.7, 0.5), title="Intensity Categories")
364
 
365
  # Initialize the line and point
366
  line, = ax.plot([], [], 'b-', linewidth=2, transform=ccrs.PlateCarree())
 
450
  ### Features:
451
  - **Track Visualization**: View typhoon tracks by time period and ENSO phase
452
  - **Statistical Analysis**: Examine relationships between ONI values and typhoon characteristics
453
+ - **Path Animation**: Watch an animated typhoon path with video controls, world map, color legend, and details sidebar
454
  - **Regression Analysis**: Perform statistical regression on typhoon data
455
 
456
  Select a tab above to begin your analysis.
 
618
  2. Choose a classification standard (Atlantic or Taiwan)
619
  3. Click "Generate Animation"
620
  4. Use the video player's built-in controls to play, pause, or scrub through the animation
621
+ 5. The animation shows the typhoon track growing over a world map, with:
622
+ - Date on the bottom left
623
+ - Details (name, date, wind speed, category) on the right
624
+ - Color legend showing intensity categories on the right
625
  """)
626
 
627
  def update_typhoon_options(year):