Spaces:
Sleeping
Sleeping
Update magnetic.py
Browse files- magnetic.py +23 -13
magnetic.py
CHANGED
|
@@ -899,9 +899,19 @@ def batch_requests(stations, dataset, lon, lat, date, distance=100):
|
|
| 899 |
'S': test_.get('S', []),
|
| 900 |
})
|
| 901 |
|
| 902 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 903 |
print(f"No data for X, Y, Z, or S for date: {date_}")
|
| 904 |
-
|
|
|
|
|
|
|
| 905 |
|
| 906 |
# if test_:
|
| 907 |
# results["station"].append(new_dataset.iloc[0]['IagaCode'])
|
|
@@ -913,17 +923,17 @@ def batch_requests(stations, dataset, lon, lat, date, distance=100):
|
|
| 913 |
# 'Z': test_['Z'],
|
| 914 |
# 'S': test_['S'],
|
| 915 |
# })
|
| 916 |
-
|
| 917 |
-
|
| 918 |
-
|
| 919 |
-
|
| 920 |
-
|
| 921 |
-
|
| 922 |
-
|
| 923 |
-
|
| 924 |
-
except Exception as e:
|
| 925 |
-
|
| 926 |
-
|
| 927 |
|
| 928 |
if all_data:
|
| 929 |
fig_overlapped = plot_overlapped_timeseries(all_data, all_event_times)
|
|
|
|
| 899 |
'S': test_.get('S', []),
|
| 900 |
})
|
| 901 |
|
| 902 |
+
if plotted[['X', 'Y', 'Z', 'S']].any().any():
|
| 903 |
+
all_data.append(plotted)
|
| 904 |
+
all_event_times.append(pd.to_datetime(date_))
|
| 905 |
+
additional_data = f"Date: {date_}\nLat/Lon: {lat_}, {lon_}\nClosest station: {station_name.values[0]}\nDistance: {round(station_distance.values[0], 2)} km"
|
| 906 |
+
fig = plot_data_custom(plotted, date=pd.to_datetime(date_), save_path=None, subtitle=additional_data)
|
| 907 |
+
with st.status(f'Magnetic Data: {date_}', expanded=False) as status:
|
| 908 |
+
st.pyplot(fig)
|
| 909 |
+
status.update(f'Magnetic Data: {date_} - Finished!')
|
| 910 |
+
else:
|
| 911 |
print(f"No data for X, Y, Z, or S for date: {date_}")
|
| 912 |
+
except Exception as e:
|
| 913 |
+
#print(f"An error occurred: {e}")
|
| 914 |
+
pass
|
| 915 |
|
| 916 |
# if test_:
|
| 917 |
# results["station"].append(new_dataset.iloc[0]['IagaCode'])
|
|
|
|
| 923 |
# 'Z': test_['Z'],
|
| 924 |
# 'S': test_['S'],
|
| 925 |
# })
|
| 926 |
+
# all_data.append(plotted)
|
| 927 |
+
# all_event_times.append(pd.to_datetime(date_))
|
| 928 |
+
# # print(date_)
|
| 929 |
+
# additional_data = f"Date: {date_}\nLat/Lon: {lat_}, {lon_}\nClosest station: {station_name.values[0]}\n Distance:{round(station_distance.values[0],2)} km"
|
| 930 |
+
# fig = plot_data_custom(plotted, date=pd.to_datetime(date_), save_path=None, subtitle =additional_data)
|
| 931 |
+
# with st.status(f'Magnetic Data: {date_}', expanded=False) as status:
|
| 932 |
+
# st.pyplot(fig)
|
| 933 |
+
# status.update(f'Magnetic Data: {date_} - Finished!')
|
| 934 |
+
# except Exception as e:
|
| 935 |
+
# #print(f"An error occurred: {e}")
|
| 936 |
+
# pass
|
| 937 |
|
| 938 |
if all_data:
|
| 939 |
fig_overlapped = plot_overlapped_timeseries(all_data, all_event_times)
|