Spaces:
Runtime error
Runtime error
Added description
Browse files
app.py
CHANGED
@@ -5,7 +5,8 @@ import numpy as np
|
|
5 |
from phasehunter.model import Onset_picker, Updated_onset_picker
|
6 |
from phasehunter.data_preparation import prepare_waveform
|
7 |
import torch
|
8 |
-
|
|
|
9 |
|
10 |
import obspy
|
11 |
from obspy.clients.fdsn import Client
|
@@ -77,6 +78,8 @@ def mark_phases(waveform):
|
|
77 |
plt.close(fig)
|
78 |
return image
|
79 |
|
|
|
|
|
80 |
def download_data(timestamp, eq_lat, eq_lon, client_name, radius_km):
|
81 |
client = Client(client_name)
|
82 |
window = radius_km / 111.2
|
@@ -84,8 +87,21 @@ def download_data(timestamp, eq_lat, eq_lon, client_name, radius_km):
|
|
84 |
assert eq_lat - window > -90 and eq_lat + window < 90, "Latitude out of bounds"
|
85 |
assert eq_lon - window > -180 and eq_lon + window < 180, "Longitude out of bounds"
|
86 |
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
|
90 |
return 0
|
91 |
|
@@ -159,6 +175,7 @@ with gr.Blocks() as demo:
|
|
159 |
interactive=True)
|
160 |
|
161 |
button = gr.Button("Predict phases")
|
|
|
162 |
|
163 |
with gr.Tab("Predict on your own waveform"):
|
164 |
gr.Markdown("""
|
@@ -166,6 +183,6 @@ with gr.Blocks() as demo:
|
|
166 |
Your waveform should be sampled at 100 sps and have 3 (Z, N, E) or 1 (Z) channels.
|
167 |
""")
|
168 |
|
169 |
-
button.click(
|
170 |
|
171 |
demo.launch()
|
|
|
5 |
from phasehunter.model import Onset_picker, Updated_onset_picker
|
6 |
from phasehunter.data_preparation import prepare_waveform
|
7 |
import torch
|
8 |
+
|
9 |
+
from scipy.stats import gaussian_kde
|
10 |
|
11 |
import obspy
|
12 |
from obspy.clients.fdsn import Client
|
|
|
78 |
plt.close(fig)
|
79 |
return image
|
80 |
|
81 |
+
#??
|
82 |
+
|
83 |
def download_data(timestamp, eq_lat, eq_lon, client_name, radius_km):
|
84 |
client = Client(client_name)
|
85 |
window = radius_km / 111.2
|
|
|
87 |
assert eq_lat - window > -90 and eq_lat + window < 90, "Latitude out of bounds"
|
88 |
assert eq_lon - window > -180 and eq_lon + window < 180, "Longitude out of bounds"
|
89 |
|
90 |
+
starttime = obspy.UTCDateTime(timestamp)
|
91 |
+
endtime = startime + 120
|
92 |
+
|
93 |
+
inv = client.get_stations(network="*", station="*", location="*", channel="*H*",
|
94 |
+
starttime=obspy.UTCDateTime(starttime), endtime=endtime,
|
95 |
+
minlatitude=eq_lat-window, maxlatitude=eq_lat+window,
|
96 |
+
minlongitude=eq_lon-window, maxlongitude=eq_lon+window,
|
97 |
+
level='channel')
|
98 |
+
|
99 |
+
for network in inv:
|
100 |
+
for station in network:
|
101 |
+
print(station)
|
102 |
+
|
103 |
+
# waveform = client.get_waveforms(network=network.code, station=station.code, location="*", channel="*",
|
104 |
+
# starttime=obspy.UTCDateTime(start_date), endtime=obspy.UTCDateTime(end_date))
|
105 |
|
106 |
return 0
|
107 |
|
|
|
175 |
interactive=True)
|
176 |
|
177 |
button = gr.Button("Predict phases")
|
178 |
+
button.click(mark_phases, inputs=inputs, outputs=outputs)
|
179 |
|
180 |
with gr.Tab("Predict on your own waveform"):
|
181 |
gr.Markdown("""
|
|
|
183 |
Your waveform should be sampled at 100 sps and have 3 (Z, N, E) or 1 (Z) channels.
|
184 |
""")
|
185 |
|
186 |
+
button.click(download_data, inputs=[timestamp_inputs, eq_lat_inputs,eq_lo_inputs, radius_inputs], outputs=outputs)
|
187 |
|
188 |
demo.launch()
|