Spaces:
Runtime error
Runtime error
Fixed imports
Browse files- phasehunter/app.py +18 -1
phasehunter/app.py
CHANGED
@@ -17,6 +17,8 @@ from obspy.taup.helper_classes import SlownessModelError
|
|
17 |
|
18 |
from obspy.clients.fdsn.header import URL_MAPPINGS
|
19 |
|
|
|
|
|
20 |
def make_prediction(waveform):
|
21 |
waveform = np.load(waveform)
|
22 |
processed_input = prepare_waveform(waveform)
|
@@ -83,7 +85,21 @@ def download_data(timestamp, eq_lat, eq_lon, client_name, radius_km):
|
|
83 |
assert eq_lat - window > -90 and eq_lat + window < 90, "Latitude out of bounds"
|
84 |
assert eq_lon - window > -180 and eq_lon + window < 180, "Longitude out of bounds"
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
|
88 |
return 0
|
89 |
|
@@ -152,6 +168,7 @@ with gr.Blocks() as demo:
|
|
152 |
interactive=True)
|
153 |
|
154 |
button = gr.Button("Predict phases")
|
|
|
155 |
|
156 |
with gr.Tab("Predict on your own waveform"):
|
157 |
gr.Markdown("""
|
@@ -159,6 +176,6 @@ with gr.Blocks() as demo:
|
|
159 |
Your waveform should be sampled at 100 sps and have 3 (Z, N, E) or 1 (Z) channels.
|
160 |
""")
|
161 |
|
162 |
-
button.click(
|
163 |
|
164 |
demo.launch()
|
|
|
17 |
|
18 |
from obspy.clients.fdsn.header import URL_MAPPINGS
|
19 |
|
20 |
+
import matplotlib.pyplot as plt
|
21 |
+
|
22 |
def make_prediction(waveform):
|
23 |
waveform = np.load(waveform)
|
24 |
processed_input = prepare_waveform(waveform)
|
|
|
85 |
assert eq_lat - window > -90 and eq_lat + window < 90, "Latitude out of bounds"
|
86 |
assert eq_lon - window > -180 and eq_lon + window < 180, "Longitude out of bounds"
|
87 |
|
88 |
+
starttime = obspy.UTCDateTime(timestamp)
|
89 |
+
endtime = startime + 120
|
90 |
+
|
91 |
+
inv = client.get_stations(network="*", station="*", location="*", channel="*H*",
|
92 |
+
starttime=obspy.UTCDateTime(starttime), endtime=endtime,
|
93 |
+
minlatitude=eq_lat-window, maxlatitude=eq_lat+window,
|
94 |
+
minlongitude=eq_lon-window, maxlongitude=eq_lon+window,
|
95 |
+
level='channel')
|
96 |
|
97 |
+
for network in inv:
|
98 |
+
for station in network:
|
99 |
+
print(station)
|
100 |
+
|
101 |
+
# waveform = client.get_waveforms(network=network.code, station=station.code, location="*", channel="*",
|
102 |
+
# starttime=obspy.UTCDateTime(start_date), endtime=obspy.UTCDateTime(end_date))
|
103 |
|
104 |
return 0
|
105 |
|
|
|
168 |
interactive=True)
|
169 |
|
170 |
button = gr.Button("Predict phases")
|
171 |
+
button.click(mark_phases, inputs=inputs, outputs=outputs)
|
172 |
|
173 |
with gr.Tab("Predict on your own waveform"):
|
174 |
gr.Markdown("""
|
|
|
176 |
Your waveform should be sampled at 100 sps and have 3 (Z, N, E) or 1 (Z) channels.
|
177 |
""")
|
178 |
|
179 |
+
button.click(download_data, inputs=[timestamp_inputs, eq_lat_inputs,eq_lo_inputs, radius_inputs], outputs=outputs)
|
180 |
|
181 |
demo.launch()
|