Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -859,14 +859,14 @@ with gr.Blocks(title="Typhoon Analysis Dashboard") as demo:
|
|
859 |
- **TSNE Cluster**: Perform t-SNE clustering on WP storm routes using raw merged typhoon+ONI data with detailed error management.
|
860 |
Mean routes and evolving curves (wind and pressure vs. normalized route index) are computed.
|
861 |
""")
|
862 |
-
|
863 |
with gr.Tab("Track Visualization"):
|
864 |
with gr.Row():
|
865 |
start_year = gr.Number(label="Start Year", value=2000, minimum=1900, maximum=2024, step=1)
|
866 |
-
start_month = gr.Dropdown(label="Start Month", choices=list(range(1,13)), value=1)
|
867 |
end_year = gr.Number(label="End Year", value=2024, minimum=1900, maximum=2024, step=1)
|
868 |
-
end_month = gr.Dropdown(label="End Month", choices=list(range(1,13)), value=6)
|
869 |
-
enso_phase = gr.Dropdown(label="ENSO Phase", choices=['all','El Nino','La Nina','Neutral'], value='all')
|
870 |
typhoon_search = gr.Textbox(label="Typhoon Search")
|
871 |
analyze_btn = gr.Button("Generate Tracks")
|
872 |
tracks_plot = gr.Plot(label="Typhoon Tracks", elem_id="tracks_plot")
|
@@ -878,10 +878,10 @@ with gr.Blocks(title="Typhoon Analysis Dashboard") as demo:
|
|
878 |
with gr.Tab("Wind Analysis"):
|
879 |
with gr.Row():
|
880 |
wind_start_year = gr.Number(label="Start Year", value=2000, minimum=1900, maximum=2024, step=1)
|
881 |
-
wind_start_month = gr.Dropdown(label="Start Month", choices=list(range(1,13)), value=1)
|
882 |
wind_end_year = gr.Number(label="End Year", value=2024, minimum=1900, maximum=2024, step=1)
|
883 |
-
wind_end_month = gr.Dropdown(label="End Month", choices=list(range(1,13)), value=6)
|
884 |
-
wind_enso_phase = gr.Dropdown(label="ENSO Phase", choices=['all','El Nino','La Nina','Neutral'], value='all')
|
885 |
wind_typhoon_search = gr.Textbox(label="Typhoon Search")
|
886 |
wind_analyze_btn = gr.Button("Generate Wind Analysis")
|
887 |
wind_scatter = gr.Plot(label="Wind Speed vs ONI")
|
@@ -893,10 +893,10 @@ with gr.Blocks(title="Typhoon Analysis Dashboard") as demo:
|
|
893 |
with gr.Tab("Pressure Analysis"):
|
894 |
with gr.Row():
|
895 |
pressure_start_year = gr.Number(label="Start Year", value=2000, minimum=1900, maximum=2024, step=1)
|
896 |
-
pressure_start_month = gr.Dropdown(label="Start Month", choices=list(range(1,13)), value=1)
|
897 |
pressure_end_year = gr.Number(label="End Year", value=2024, minimum=1900, maximum=2024, step=1)
|
898 |
-
pressure_end_month = gr.Dropdown(label="End Month", choices=list(range(1,13)), value=6)
|
899 |
-
pressure_enso_phase = gr.Dropdown(label="ENSO Phase", choices=['all','El Nino','La Nina','Neutral'], value='all')
|
900 |
pressure_typhoon_search = gr.Textbox(label="Typhoon Search")
|
901 |
pressure_analyze_btn = gr.Button("Generate Pressure Analysis")
|
902 |
pressure_scatter = gr.Plot(label="Pressure vs ONI")
|
@@ -908,10 +908,10 @@ with gr.Blocks(title="Typhoon Analysis Dashboard") as demo:
|
|
908 |
with gr.Tab("Longitude Analysis"):
|
909 |
with gr.Row():
|
910 |
lon_start_year = gr.Number(label="Start Year", value=2000, minimum=1900, maximum=2024, step=1)
|
911 |
-
lon_start_month = gr.Dropdown(label="Start Month", choices=list(range(1,13)), value=1)
|
912 |
lon_end_year = gr.Number(label="End Year", value=2000, minimum=1900, maximum=2024, step=1)
|
913 |
-
lon_end_month = gr.Dropdown(label="End Month", choices=list(range(1,13)), value=6)
|
914 |
-
lon_enso_phase = gr.Dropdown(label="ENSO Phase", choices=['all','El Nino','La Nina','Neutral'], value='all')
|
915 |
lon_typhoon_search = gr.Textbox(label="Typhoon Search (Optional)")
|
916 |
lon_analyze_btn = gr.Button("Generate Longitude Analysis")
|
917 |
regression_plot = gr.Plot(label="Longitude vs ONI")
|
@@ -922,13 +922,13 @@ with gr.Blocks(title="Typhoon Analysis Dashboard") as demo:
|
|
922 |
outputs=[regression_plot, slopes_text, lon_regression_results])
|
923 |
|
924 |
with gr.Tab("Tropical Cyclone Path Animation"):
|
925 |
-
# Basin selection removed. Always use All Basins.
|
926 |
with gr.Row():
|
927 |
-
year_dropdown = gr.Dropdown(label="Year", choices=[str(y) for y in range(1950,2025)], value="2000")
|
928 |
-
#
|
|
|
929 |
with gr.Row():
|
930 |
typhoon_dropdown = gr.Dropdown(label="Tropical Cyclone")
|
931 |
-
standard_dropdown = gr.Dropdown(label="Classification Standard", choices=['atlantic','taiwan'], value='atlantic')
|
932 |
animate_btn = gr.Button("Generate Animation")
|
933 |
path_video = gr.Video(label="Tropical Cyclone Path Animation", format="mp4", interactive=False, elem_id="path_video")
|
934 |
animation_info = gr.Markdown("""
|
@@ -940,20 +940,20 @@ with gr.Blocks(title="Typhoon Analysis Dashboard") as demo:
|
|
940 |
5. The animation displays the storm track on a free stock world map (centered at 180°) with a dynamic sidebar.
|
941 |
The sidebar shows the storm name and basin.
|
942 |
""")
|
|
|
943 |
year_dropdown.change(fn=update_typhoon_options_anim, inputs=[year_dropdown, gr.State("dummy")], outputs=typhoon_dropdown)
|
944 |
animate_btn.click(fn=simplified_track_video,
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
|
949 |
with gr.Tab("TSNE Cluster"):
|
950 |
with gr.Row():
|
951 |
tsne_start_year = gr.Number(label="Start Year", value=2000, minimum=1900, maximum=2024, step=1)
|
952 |
-
tsne_start_month = gr.Dropdown(label="Start Month", choices=list(range(1,13)), value=1)
|
953 |
tsne_end_year = gr.Number(label="End Year", value=2024, minimum=1900, maximum=2024, step=1)
|
954 |
-
tsne_end_month = gr.Dropdown(label="End Month", choices=list(range(1,13)), value=12)
|
955 |
-
tsne_enso_phase = gr.Dropdown(label="ENSO Phase", choices=['all','El Nino','La Nina','Neutral'], value='all')
|
956 |
-
tsne_season = gr.Dropdown(label="Season", choices=['all','summer','winter'], value='all')
|
957 |
tsne_analyze_btn = gr.Button("Analyze")
|
958 |
tsne_plot = gr.Plot(label="t-SNE Clusters")
|
959 |
routes_plot = gr.Plot(label="Typhoon Routes with Mean Routes")
|
@@ -964,3 +964,4 @@ with gr.Blocks(title="Typhoon Analysis Dashboard") as demo:
|
|
964 |
outputs=[tsne_plot, routes_plot, stats_plot, cluster_info])
|
965 |
|
966 |
demo.launch(share=True)
|
|
|
|
859 |
- **TSNE Cluster**: Perform t-SNE clustering on WP storm routes using raw merged typhoon+ONI data with detailed error management.
|
860 |
Mean routes and evolving curves (wind and pressure vs. normalized route index) are computed.
|
861 |
""")
|
862 |
+
|
863 |
with gr.Tab("Track Visualization"):
|
864 |
with gr.Row():
|
865 |
start_year = gr.Number(label="Start Year", value=2000, minimum=1900, maximum=2024, step=1)
|
866 |
+
start_month = gr.Dropdown(label="Start Month", choices=list(range(1, 13)), value=1)
|
867 |
end_year = gr.Number(label="End Year", value=2024, minimum=1900, maximum=2024, step=1)
|
868 |
+
end_month = gr.Dropdown(label="End Month", choices=list(range(1, 13)), value=6)
|
869 |
+
enso_phase = gr.Dropdown(label="ENSO Phase", choices=['all', 'El Nino', 'La Nina', 'Neutral'], value='all')
|
870 |
typhoon_search = gr.Textbox(label="Typhoon Search")
|
871 |
analyze_btn = gr.Button("Generate Tracks")
|
872 |
tracks_plot = gr.Plot(label="Typhoon Tracks", elem_id="tracks_plot")
|
|
|
878 |
with gr.Tab("Wind Analysis"):
|
879 |
with gr.Row():
|
880 |
wind_start_year = gr.Number(label="Start Year", value=2000, minimum=1900, maximum=2024, step=1)
|
881 |
+
wind_start_month = gr.Dropdown(label="Start Month", choices=list(range(1, 13)), value=1)
|
882 |
wind_end_year = gr.Number(label="End Year", value=2024, minimum=1900, maximum=2024, step=1)
|
883 |
+
wind_end_month = gr.Dropdown(label="End Month", choices=list(range(1, 13)), value=6)
|
884 |
+
wind_enso_phase = gr.Dropdown(label="ENSO Phase", choices=['all', 'El Nino', 'La Nina', 'Neutral'], value='all')
|
885 |
wind_typhoon_search = gr.Textbox(label="Typhoon Search")
|
886 |
wind_analyze_btn = gr.Button("Generate Wind Analysis")
|
887 |
wind_scatter = gr.Plot(label="Wind Speed vs ONI")
|
|
|
893 |
with gr.Tab("Pressure Analysis"):
|
894 |
with gr.Row():
|
895 |
pressure_start_year = gr.Number(label="Start Year", value=2000, minimum=1900, maximum=2024, step=1)
|
896 |
+
pressure_start_month = gr.Dropdown(label="Start Month", choices=list(range(1, 13)), value=1)
|
897 |
pressure_end_year = gr.Number(label="End Year", value=2024, minimum=1900, maximum=2024, step=1)
|
898 |
+
pressure_end_month = gr.Dropdown(label="End Month", choices=list(range(1, 13)), value=6)
|
899 |
+
pressure_enso_phase = gr.Dropdown(label="ENSO Phase", choices=['all', 'El Nino', 'La Nina', 'Neutral'], value='all')
|
900 |
pressure_typhoon_search = gr.Textbox(label="Typhoon Search")
|
901 |
pressure_analyze_btn = gr.Button("Generate Pressure Analysis")
|
902 |
pressure_scatter = gr.Plot(label="Pressure vs ONI")
|
|
|
908 |
with gr.Tab("Longitude Analysis"):
|
909 |
with gr.Row():
|
910 |
lon_start_year = gr.Number(label="Start Year", value=2000, minimum=1900, maximum=2024, step=1)
|
911 |
+
lon_start_month = gr.Dropdown(label="Start Month", choices=list(range(1, 13)), value=1)
|
912 |
lon_end_year = gr.Number(label="End Year", value=2000, minimum=1900, maximum=2024, step=1)
|
913 |
+
lon_end_month = gr.Dropdown(label="End Month", choices=list(range(1, 13)), value=6)
|
914 |
+
lon_enso_phase = gr.Dropdown(label="ENSO Phase", choices=['all', 'El Nino', 'La Nina', 'Neutral'], value='all')
|
915 |
lon_typhoon_search = gr.Textbox(label="Typhoon Search (Optional)")
|
916 |
lon_analyze_btn = gr.Button("Generate Longitude Analysis")
|
917 |
regression_plot = gr.Plot(label="Longitude vs ONI")
|
|
|
922 |
outputs=[regression_plot, slopes_text, lon_regression_results])
|
923 |
|
924 |
with gr.Tab("Tropical Cyclone Path Animation"):
|
|
|
925 |
with gr.Row():
|
926 |
+
year_dropdown = gr.Dropdown(label="Year", choices=[str(y) for y in range(1950, 2025)], value="2000")
|
927 |
+
# Create a hidden component for basin constant; always "All Basins"
|
928 |
+
basin_constant = gr.Textbox(value="All Basins", visible=False)
|
929 |
with gr.Row():
|
930 |
typhoon_dropdown = gr.Dropdown(label="Tropical Cyclone")
|
931 |
+
standard_dropdown = gr.Dropdown(label="Classification Standard", choices=['atlantic', 'taiwan'], value='atlantic')
|
932 |
animate_btn = gr.Button("Generate Animation")
|
933 |
path_video = gr.Video(label="Tropical Cyclone Path Animation", format="mp4", interactive=False, elem_id="path_video")
|
934 |
animation_info = gr.Markdown("""
|
|
|
940 |
5. The animation displays the storm track on a free stock world map (centered at 180°) with a dynamic sidebar.
|
941 |
The sidebar shows the storm name and basin.
|
942 |
""")
|
943 |
+
# Update typhoon dropdown using only year (ignore basin since it's fixed)
|
944 |
year_dropdown.change(fn=update_typhoon_options_anim, inputs=[year_dropdown, gr.State("dummy")], outputs=typhoon_dropdown)
|
945 |
animate_btn.click(fn=simplified_track_video,
|
946 |
+
inputs=[year_dropdown, basin_constant, typhoon_dropdown, standard_dropdown],
|
947 |
+
outputs=path_video)
|
|
|
948 |
|
949 |
with gr.Tab("TSNE Cluster"):
|
950 |
with gr.Row():
|
951 |
tsne_start_year = gr.Number(label="Start Year", value=2000, minimum=1900, maximum=2024, step=1)
|
952 |
+
tsne_start_month = gr.Dropdown(label="Start Month", choices=list(range(1, 13)), value=1)
|
953 |
tsne_end_year = gr.Number(label="End Year", value=2024, minimum=1900, maximum=2024, step=1)
|
954 |
+
tsne_end_month = gr.Dropdown(label="End Month", choices=list(range(1, 13)), value=12)
|
955 |
+
tsne_enso_phase = gr.Dropdown(label="ENSO Phase", choices=['all', 'El Nino', 'La Nina', 'Neutral'], value='all')
|
956 |
+
tsne_season = gr.Dropdown(label="Season", choices=['all', 'summer', 'winter'], value='all')
|
957 |
tsne_analyze_btn = gr.Button("Analyze")
|
958 |
tsne_plot = gr.Plot(label="t-SNE Clusters")
|
959 |
routes_plot = gr.Plot(label="Typhoon Routes with Mean Routes")
|
|
|
964 |
outputs=[tsne_plot, routes_plot, stats_plot, cluster_info])
|
965 |
|
966 |
demo.launch(share=True)
|
967 |
+
|