Spaces:
Sleeping
Sleeping
ok6
Browse files- .DS_Store +0 -0
- __pycache__/app.cpython-313.pyc +0 -0
- app.py +58 -77
.DS_Store
ADDED
Binary file (6.15 kB). View file
|
|
__pycache__/app.cpython-313.pyc
ADDED
Binary file (22 kB). View file
|
|
app.py
CHANGED
@@ -28,91 +28,72 @@ class RainViewerMap:
|
|
28 |
active_storms = []
|
29 |
error_messages = []
|
30 |
|
31 |
-
# Try multiple approaches to get hurricane data
|
32 |
try:
|
33 |
-
#
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
'source': 'NHC CurrentStorms',
|
42 |
-
'data': storm,
|
43 |
-
'type': 'current_storms'
|
44 |
-
})
|
45 |
-
except Exception as e:
|
46 |
-
error_messages.append(f"CurrentStorms.json failed: {e}")
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
51 |
try:
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
except Exception as e:
|
83 |
-
error_messages.append(f"Layer {layer_id} query failed: {e}")
|
84 |
except Exception as e:
|
85 |
-
error_messages.append(f"
|
86 |
|
87 |
-
#
|
88 |
if not active_storms:
|
89 |
-
|
90 |
-
'source': 'Sample Data',
|
91 |
-
'type': 'sample',
|
92 |
-
'geojson': {
|
93 |
-
'type': 'FeatureCollection',
|
94 |
-
'features': [
|
95 |
-
{
|
96 |
-
'type': 'Feature',
|
97 |
-
'geometry': {
|
98 |
-
'type': 'Point',
|
99 |
-
'coordinates': [-80.0, 26.0]
|
100 |
-
},
|
101 |
-
'properties': {
|
102 |
-
'STORMNAME': 'Sample Hurricane',
|
103 |
-
'STORMTYPE': 'Hurricane',
|
104 |
-
'MAXWIND': '75',
|
105 |
-
'MSLP': '980',
|
106 |
-
'FHOUR': 'Current'
|
107 |
-
}
|
108 |
-
}
|
109 |
-
]
|
110 |
-
}
|
111 |
-
}
|
112 |
-
active_storms.append(sample_storm)
|
113 |
-
error_messages.append("No real storm data available, showing sample data")
|
114 |
|
115 |
-
# Store
|
116 |
self.storm_cache['errors'] = error_messages
|
117 |
self.storm_cache['last_update'] = datetime.now().isoformat()
|
118 |
|
|
|
28 |
active_storms = []
|
29 |
error_messages = []
|
30 |
|
|
|
31 |
try:
|
32 |
+
# Get specific Eastern Pacific storms (EP1-EP5) and Atlantic storms (AT1-AT5)
|
33 |
+
storm_layers = [
|
34 |
+
{'name': 'EP1', 'forecast_points_id': 136, 'forecast_track_id': 137, 'forecast_cone_id': 138},
|
35 |
+
{'name': 'EP2', 'forecast_points_id': 154, 'forecast_track_id': 155, 'forecast_cone_id': 156},
|
36 |
+
{'name': 'AT1', 'forecast_points_id': 6, 'forecast_track_id': 7, 'forecast_cone_id': 8},
|
37 |
+
{'name': 'AT2', 'forecast_points_id': 24, 'forecast_track_id': 25, 'forecast_cone_id': 26},
|
38 |
+
{'name': 'AT3', 'forecast_points_id': 42, 'forecast_track_id': 43, 'forecast_cone_id': 44}
|
39 |
+
]
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
+
for storm_info in storm_layers:
|
42 |
+
storm_name = storm_info['name']
|
43 |
+
points_id = storm_info['forecast_points_id']
|
44 |
+
track_id = storm_info['forecast_track_id']
|
45 |
+
cone_id = storm_info['forecast_cone_id']
|
46 |
+
|
47 |
try:
|
48 |
+
# Get forecast points
|
49 |
+
points_url = f"{self.nhc_api_base}/{points_id}/query"
|
50 |
+
points_params = {
|
51 |
+
'where': '1=1',
|
52 |
+
'outFields': '*',
|
53 |
+
'f': 'geojson',
|
54 |
+
'returnGeometry': 'true'
|
55 |
+
}
|
56 |
+
|
57 |
+
points_response = requests.get(points_url, params=points_params, timeout=15)
|
58 |
+
if points_response.status_code == 200:
|
59 |
+
points_data = points_response.json()
|
60 |
+
if points_data.get('features'):
|
61 |
+
# Get track data
|
62 |
+
track_url = f"{self.nhc_api_base}/{track_id}/query"
|
63 |
+
track_response = requests.get(track_url, params=points_params, timeout=15)
|
64 |
+
track_data = None
|
65 |
+
if track_response.status_code == 200:
|
66 |
+
track_data = track_response.json()
|
67 |
|
68 |
+
# Get cone data
|
69 |
+
cone_url = f"{self.nhc_api_base}/{cone_id}/query"
|
70 |
+
cone_response = requests.get(cone_url, params=points_params, timeout=15)
|
71 |
+
cone_data = None
|
72 |
+
if cone_response.status_code == 200:
|
73 |
+
cone_data = cone_response.json()
|
74 |
+
|
75 |
+
active_storms.append({
|
76 |
+
'source': f'NOAA NHC {storm_name}',
|
77 |
+
'storm_id': storm_name,
|
78 |
+
'forecast_points': points_data,
|
79 |
+
'forecast_track': track_data,
|
80 |
+
'forecast_cone': cone_data,
|
81 |
+
'type': 'nhc_storm'
|
82 |
+
})
|
83 |
+
|
84 |
+
# Get storm name from first feature for logging
|
85 |
+
first_feature = points_data['features'][0]
|
86 |
+
storm_actual_name = first_feature['properties'].get('stormname', storm_name)
|
87 |
+
error_messages.append(f"Successfully loaded {storm_actual_name} ({storm_name})")
|
88 |
+
|
|
|
|
|
89 |
except Exception as e:
|
90 |
+
error_messages.append(f"Error fetching {storm_name}: {e}")
|
91 |
|
92 |
+
# If no real storms found, add informational message
|
93 |
if not active_storms:
|
94 |
+
error_messages.append("No active storms found - this could mean no storms are currently active")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
|
96 |
+
# Store debug info
|
97 |
self.storm_cache['errors'] = error_messages
|
98 |
self.storm_cache['last_update'] = datetime.now().isoformat()
|
99 |
|