Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -45,21 +45,26 @@ class EnhancedOceanClimateAgent:
|
|
45 |
}
|
46 |
|
47 |
try:
|
|
|
|
|
48 |
response = requests.get(self.noaa_base_url, params=params, timeout=30)
|
|
|
|
|
|
|
49 |
if response.status_code == 200:
|
50 |
data = response.json()
|
51 |
if 'data' in data:
|
|
|
52 |
return pd.DataFrame(data['data'])
|
|
|
|
|
53 |
else:
|
54 |
-
print(f"
|
55 |
-
return None
|
56 |
else:
|
57 |
-
print(f"API error {response.status_code}
|
58 |
-
|
59 |
-
except Exception as e:
|
60 |
-
print(f"Error fetching {product}: {str(e)}")
|
61 |
return None
|
62 |
-
|
63 |
def get_comprehensive_station_data(self, station_name, days_back=30):
|
64 |
"""Get comprehensive data from a NOAA station"""
|
65 |
station_id = self.default_stations.get(station_name)
|
|
|
45 |
}
|
46 |
|
47 |
try:
|
48 |
+
print(f"π‘ Requesting {product} data for station {station_id}")
|
49 |
+
print("π Date range:", start_date.strftime('%Y-%m-%d'), "to", end_date.strftime('%Y-%m-%d'))
|
50 |
response = requests.get(self.noaa_base_url, params=params, timeout=30)
|
51 |
+
|
52 |
+
print(f"π Status code: {response.status_code}")
|
53 |
+
|
54 |
if response.status_code == 200:
|
55 |
data = response.json()
|
56 |
if 'data' in data:
|
57 |
+
print(f"β
Data received: {len(data['data'])} records for {product}")
|
58 |
return pd.DataFrame(data['data'])
|
59 |
+
elif 'error' in data:
|
60 |
+
print(f"β NOAA error: {data['error'].get('message')}")
|
61 |
else:
|
62 |
+
print(f"β Unknown response structure: {data}")
|
|
|
63 |
else:
|
64 |
+
print(f"β API HTTP error {response.status_code}: {response.text}")
|
65 |
+
|
|
|
|
|
66 |
return None
|
67 |
+
|
68 |
def get_comprehensive_station_data(self, station_name, days_back=30):
|
69 |
"""Get comprehensive data from a NOAA station"""
|
70 |
station_id = self.default_stations.get(station_name)
|