Spaces:
Running
Running
Update app.py
Browse files
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
|
306 |
def categorize_typhoon_by_standard(wind_speed, standard):
|
307 |
if standard == 'taiwan':
|
308 |
wind_speed_ms = wind_speed * 0.514444
|
@@ -355,20 +355,20 @@ def generate_track_video(year, typhoon, standard):
|
|
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())
|
367 |
point, = ax.plot([], [], 'o', markersize=8, transform=ccrs.PlateCarree())
|
368 |
date_text = ax.text(0.02, 0.02, '', transform=ax.transAxes, fontsize=12, bbox=dict(facecolor='white', alpha=0.8))
|
369 |
|
370 |
-
# Add
|
371 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
bbox=dict(facecolor='white', alpha=0.8, boxstyle='round,pad=0.5'))
|
373 |
|
374 |
def init():
|
@@ -384,7 +384,7 @@ def generate_track_video(year, typhoon, standard):
|
|
384 |
point.set_data([storm.lon[frame]], [storm.lat[frame]])
|
385 |
point.set_color(color)
|
386 |
date_text.set_text(storm.time[frame].strftime('%Y-%m-%d %H:%M'))
|
387 |
-
details = f"
|
388 |
f"Date: {storm.time[frame].strftime('%Y-%m-%d %H:%M')}\n" \
|
389 |
f"Wind Speed: {storm.vmax[frame]:.1f} kt\n" \
|
390 |
f"Category: {category}"
|
@@ -620,8 +620,8 @@ with gr.Blocks(title="Typhoon Analysis Dashboard") as demo:
|
|
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 |
-
-
|
624 |
-
- Color legend
|
625 |
""")
|
626 |
|
627 |
def update_typhoon_options(year):
|
|
|
302 |
|
303 |
return tracks_fig, wind_scatter, pressure_scatter, regression_fig, slopes_text
|
304 |
|
305 |
+
# Video animation function with explicit sidebar and color legend
|
306 |
def categorize_typhoon_by_standard(wind_speed, standard):
|
307 |
if standard == 'taiwan':
|
308 |
wind_speed_ms = wind_speed * 0.514444
|
|
|
355 |
|
356 |
ax.set_title(f"{year} {storm.name} Typhoon Path")
|
357 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
358 |
# Initialize the line and point
|
359 |
line, = ax.plot([], [], 'b-', linewidth=2, transform=ccrs.PlateCarree())
|
360 |
point, = ax.plot([], [], 'o', markersize=8, transform=ccrs.PlateCarree())
|
361 |
date_text = ax.text(0.02, 0.02, '', transform=ax.transAxes, fontsize=12, bbox=dict(facecolor='white', alpha=0.8))
|
362 |
|
363 |
+
# Add sidebar with typhoon details on the right
|
364 |
+
details_title = fig.text(0.75, 0.65, "Typhoon Details", fontsize=14, fontweight='bold', verticalalignment='top', horizontalalignment='left')
|
365 |
+
details_text = fig.text(0.75, 0.60, '', fontsize=12, verticalalignment='top', horizontalalignment='left',
|
366 |
+
bbox=dict(facecolor='white', alpha=0.8, boxstyle='round,pad=0.5'))
|
367 |
+
|
368 |
+
# Add color legend below the details
|
369 |
+
standard_dict = atlantic_standard if standard == 'atlantic' else taiwan_standard
|
370 |
+
color_legend_text = "\n".join([f"{cat}: {details['color']}" for cat, details in standard_dict.items()])
|
371 |
+
color_legend = fig.text(0.75, 0.35, f"Color Legend\n{color_legend_text}", fontsize=12, verticalalignment='top', horizontalalignment='left',
|
372 |
bbox=dict(facecolor='white', alpha=0.8, boxstyle='round,pad=0.5'))
|
373 |
|
374 |
def init():
|
|
|
384 |
point.set_data([storm.lon[frame]], [storm.lat[frame]])
|
385 |
point.set_color(color)
|
386 |
date_text.set_text(storm.time[frame].strftime('%Y-%m-%d %H:%M'))
|
387 |
+
details = f"Name: {storm.name}\n" \
|
388 |
f"Date: {storm.time[frame].strftime('%Y-%m-%d %H:%M')}\n" \
|
389 |
f"Wind Speed: {storm.vmax[frame]:.1f} kt\n" \
|
390 |
f"Category: {category}"
|
|
|
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 |
+
- Sidebar on the right showing typhoon details (name, date, wind speed, category)
|
624 |
+
- Color legend below the sidebar explaining what each color represents
|
625 |
""")
|
626 |
|
627 |
def update_typhoon_options(year):
|