Spaces:
Sleeping
Sleeping
Update magnetic.py
Browse files- magnetic.py +20 -7
magnetic.py
CHANGED
@@ -890,16 +890,29 @@ def batch_requests(stations, dataset, lon, lat, date, distance=100):
|
|
890 |
station_distance = new_dataset['Distance']
|
891 |
test_ = get_data(new_dataset.iloc[0]['IagaCode'], str_date_start, str_date_end)
|
892 |
|
893 |
-
if test_:
|
894 |
-
results["station"].append(new_dataset.iloc[0]['IagaCode'])
|
895 |
-
results["data"].append(test_)
|
896 |
plotted = pd.DataFrame({
|
897 |
'datetime': test_['datetime'],
|
898 |
-
'X': test_
|
899 |
-
'Y': test_
|
900 |
-
'Z': test_
|
901 |
-
'S': test_
|
902 |
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
903 |
all_data.append(plotted)
|
904 |
all_event_times.append(pd.to_datetime(date_))
|
905 |
# print(date_)
|
|
|
890 |
station_distance = new_dataset['Distance']
|
891 |
test_ = get_data(new_dataset.iloc[0]['IagaCode'], str_date_start, str_date_end)
|
892 |
|
893 |
+
if test_ and any(test_.get(key) for key in ['X', 'Y', 'Z', 'S']):
|
|
|
|
|
894 |
plotted = pd.DataFrame({
|
895 |
'datetime': test_['datetime'],
|
896 |
+
'X': test_.get('X', []),
|
897 |
+
'Y': test_.get('Y', []),
|
898 |
+
'Z': test_.get('Z', []),
|
899 |
+
'S': test_.get('S', []),
|
900 |
})
|
901 |
+
|
902 |
+
if not plotted[['X', 'Y', 'Z', 'S']].any().any():
|
903 |
+
print(f"No data for X, Y, Z, or S for date: {date_}")
|
904 |
+
return None
|
905 |
+
|
906 |
+
# if test_:
|
907 |
+
# results["station"].append(new_dataset.iloc[0]['IagaCode'])
|
908 |
+
# results["data"].append(test_)
|
909 |
+
# plotted = pd.DataFrame({
|
910 |
+
# 'datetime': test_['datetime'],
|
911 |
+
# 'X': test_['X'],
|
912 |
+
# 'Y': test_['Y'],
|
913 |
+
# 'Z': test_['Z'],
|
914 |
+
# 'S': test_['S'],
|
915 |
+
# })
|
916 |
all_data.append(plotted)
|
917 |
all_event_times.append(pd.to_datetime(date_))
|
918 |
# print(date_)
|