Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -993,10 +993,10 @@ def generate_genesis_prediction_monthly(month, oni_value, year=2025):
|
|
| 993 |
storm_predictions = []
|
| 994 |
for i, genesis in enumerate(genesis_events):
|
| 995 |
storm_track = generate_storm_track_from_genesis(
|
| 996 |
-
genesis['lat'],
|
| 997 |
-
genesis['lon'],
|
| 998 |
-
genesis['day'],
|
| 999 |
-
month,
|
| 1000 |
oni_value,
|
| 1001 |
storm_id=i+1
|
| 1002 |
)
|
|
@@ -1008,6 +1008,10 @@ def generate_genesis_prediction_monthly(month, oni_value, year=2025):
|
|
| 1008 |
'track': storm_track,
|
| 1009 |
'uncertainty': calculate_track_uncertainty(storm_track)
|
| 1010 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1011 |
|
| 1012 |
return {
|
| 1013 |
'month': month,
|
|
@@ -3014,12 +3018,19 @@ def create_interface():
|
|
| 3014 |
try:
|
| 3015 |
# Generate monthly prediction using GPI
|
| 3016 |
prediction_data = generate_genesis_prediction_monthly(month, oni, year=2025)
|
|
|
|
|
|
|
|
|
|
| 3017 |
|
| 3018 |
# Create animation figure
|
| 3019 |
genesis_fig = create_genesis_animation(prediction_data, animation)
|
| 3020 |
|
| 3021 |
-
# Convert to HTML for
|
| 3022 |
-
genesis_html = pio.to_html(
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3023 |
|
| 3024 |
# Generate summary
|
| 3025 |
summary_text = create_prediction_summary(prediction_data)
|
|
@@ -3031,7 +3042,7 @@ def create_interface():
|
|
| 3031 |
error_msg = f"Genesis prediction failed: {str(e)}\n\nDetails:\n{traceback.format_exc()}"
|
| 3032 |
logging.error(error_msg)
|
| 3033 |
err_fig = create_error_plot(error_msg)
|
| 3034 |
-
err_html = pio.to_html(err_fig, include_plotlyjs='
|
| 3035 |
return err_html, error_msg
|
| 3036 |
|
| 3037 |
generate_genesis_btn.click(
|
|
|
|
| 993 |
storm_predictions = []
|
| 994 |
for i, genesis in enumerate(genesis_events):
|
| 995 |
storm_track = generate_storm_track_from_genesis(
|
| 996 |
+
genesis['lat'],
|
| 997 |
+
genesis['lon'],
|
| 998 |
+
genesis['day'],
|
| 999 |
+
month,
|
| 1000 |
oni_value,
|
| 1001 |
storm_id=i+1
|
| 1002 |
)
|
|
|
|
| 1008 |
'track': storm_track,
|
| 1009 |
'uncertainty': calculate_track_uncertainty(storm_track)
|
| 1010 |
})
|
| 1011 |
+
|
| 1012 |
+
logging.info(
|
| 1013 |
+
f"Monthly genesis prediction: {len(genesis_events)} events, {len(storm_predictions)} tracks"
|
| 1014 |
+
)
|
| 1015 |
|
| 1016 |
return {
|
| 1017 |
'month': month,
|
|
|
|
| 3018 |
try:
|
| 3019 |
# Generate monthly prediction using GPI
|
| 3020 |
prediction_data = generate_genesis_prediction_monthly(month, oni, year=2025)
|
| 3021 |
+
logging.info(
|
| 3022 |
+
f"Genesis prediction run for month={month}, oni={oni}: {len(prediction_data.get('genesis_events', []))} events"
|
| 3023 |
+
)
|
| 3024 |
|
| 3025 |
# Create animation figure
|
| 3026 |
genesis_fig = create_genesis_animation(prediction_data, animation)
|
| 3027 |
|
| 3028 |
+
# Convert to HTML with inline Plotly JS for HF Spaces without CDN access
|
| 3029 |
+
genesis_html = pio.to_html(
|
| 3030 |
+
genesis_fig,
|
| 3031 |
+
include_plotlyjs='inline',
|
| 3032 |
+
full_html=False
|
| 3033 |
+
)
|
| 3034 |
|
| 3035 |
# Generate summary
|
| 3036 |
summary_text = create_prediction_summary(prediction_data)
|
|
|
|
| 3042 |
error_msg = f"Genesis prediction failed: {str(e)}\n\nDetails:\n{traceback.format_exc()}"
|
| 3043 |
logging.error(error_msg)
|
| 3044 |
err_fig = create_error_plot(error_msg)
|
| 3045 |
+
err_html = pio.to_html(err_fig, include_plotlyjs='inline', full_html=False)
|
| 3046 |
return err_html, error_msg
|
| 3047 |
|
| 3048 |
generate_genesis_btn.click(
|