\n",
"
Using PhaseHunter to Analyze Seismic Waveforms
\n",
"
Select an earthquake from the global earthquake catalogue (e.g. USGS) and the app will download the waveform from the FDSN client of your choice. The app will use a velocity model of your choice to select appropriate time windows for each station within a specified radius of the earthquake.
\n",
"
The app will then analyze the waveforms and mark the detected phases on the waveform. Pick data for each waveform is reported in seconds from the start of the waveform.
\n",
"
Velocities are derived from distance and travel time determined by PhaseHunter picks (v = distance/predicted_pick_time). The background of the velocity plot is colored by DEM.
\n",
"
\n",
" \"\"\")\n",
" with gr.Row(): \n",
" with gr.Column(scale=2):\n",
" client_inputs = gr.Dropdown(\n",
" choices = list(URL_MAPPINGS.keys()), \n",
" label=\"FDSN Client\", \n",
" info=\"Select one of the available FDSN clients\",\n",
" value = \"IRIS\",\n",
" interactive=True\n",
" )\n",
"\n",
" velocity_inputs = gr.Dropdown(\n",
" choices = ['1066a', '1066b', 'ak135', \n",
" 'ak135f', 'herrin', 'iasp91', \n",
" 'jb', 'prem', 'pwdk'], \n",
" label=\"1D velocity model\", \n",
" info=\"Velocity model for station selection\",\n",
" value = \"1066a\",\n",
" interactive=True\n",
" )\n",
"\n",
" with gr.Column(scale=2):\n",
" timestamp_inputs = gr.Textbox(value='2019-07-04T17:33:49-00',\n",
" placeholder='YYYY-MM-DDTHH:MM:SS-TZ',\n",
" label=\"Timestamp\",\n",
" info=\"Timestamp of the earthquake\",\n",
" max_lines=1,\n",
" interactive=True)\n",
" \n",
" source_depth_inputs = gr.Number(value=10,\n",
" label=\"Source depth (km)\",\n",
" info=\"Depth of the earthquake\",\n",
" interactive=True)\n",
" \n",
" with gr.Column(scale=2):\n",
" eq_lat_inputs = gr.Number(value=35.766, \n",
" label=\"Latitude\", \n",
" info=\"Latitude of the earthquake\",\n",
" interactive=True)\n",
" \n",
" eq_lon_inputs = gr.Number(value=-117.605,\n",
" label=\"Longitude\",\n",
" info=\"Longitude of the earthquake\",\n",
" interactive=True)\n",
" \n",
" with gr.Column(scale=2):\n",
" radius_inputs = gr.Slider(minimum=1, \n",
" maximum=200, \n",
" value=50, \n",
" label=\"Radius (km)\", \n",
" step=10,\n",
" info=\"\"\"Select the radius around the earthquake to download data from.\\n \n",
" Note that the larger the radius, the longer the app will take to run.\"\"\",\n",
" interactive=True)\n",
" \n",
" max_waveforms_inputs = gr.Slider(minimum=1,\n",
" maximum=100,\n",
" value=10,\n",
" label=\"Max waveforms per section\",\n",
" step=1,\n",
" info=\"Maximum number of waveforms to show per section\\n (to avoid long prediction times)\",\n",
" interactive=True,\n",
" )\n",
" with gr.Column(scale=2):\n",
" P_thres_inputs = gr.Slider(minimum=0.01,\n",
" maximum=1,\n",
" value=0.1,\n",
" label=\"P uncertainty threshold, s\",\n",
" step=0.01,\n",
" info=\"Acceptable uncertainty for P picks expressed in std() seconds\",\n",
" interactive=True,\n",
" )\n",
" S_thres_inputs = gr.Slider(minimum=0.01,\n",
" maximum=1,\n",
" value=0.2,\n",
" label=\"S uncertainty threshold, s\",\n",
" step=0.01,\n",
" info=\"Acceptable uncertainty for S picks expressed in std() seconds\",\n",
" interactive=True,\n",
" )\n",
" \n",
" button = gr.Button(\"Predict phases\")\n",
" output_image = gr.Image(label='Waveforms with Phases Marked', type='numpy', interactive=False)\n",
" \n",
" with gr.Row():\n",
" with gr.Column(scale=2):\n",
" azimuth_input = gr.Slider(minimum=-180, maximum=180, value=0, step=5, label=\"Azimuth\", interactive=True)\n",
" elevation_input = gr.Slider(minimum=-90, maximum=90, value=30, step=5, label=\"Elevation\", interactive=True)\n",
"\n",
" with gr.Row():\n",
" interpolate_input = gr.Checkbox(label=\"Interpolate\", info=\"Interpolate velocity model\")\n",
" n_lat_input = gr.Slider(minimum=5, maximum=100, value=50, step=5, label=\"N lat\", info='Number of Lat grid points', interactive=True)\n",
" n_lon_input = gr.Slider(minimum=5, maximum=100, value=50, step=5, label=\"N lon\", info='Number of Lon grid points', interactive=True)\n",
" n_depth_input = gr.Slider(minimum=5, maximum=100, value=50, step=5, label=\"N depth\", info='Number of Depth grid points', interactive=True)\n",
" \n",
" button = gr.Button(\"Look at 3D Velocities\")\n",
" outputs_vel_model = gr.Image(label=\"3D Velocity Model\")\n",
"\n",
" button.click(compute_velocity_model, \n",
" inputs=[azimuth_input, elevation_input, \n",
" interpolate_input, n_lat_input, \n",
" n_lon_input, n_depth_input], \n",
" outputs=[outputs_vel_model])\n",
" \n",
" with gr.Row():\n",
" output_picks = gr.Dataframe(label='Pick data', \n",
" type='pandas', \n",
" interactive=False)\n",
" output_csv = gr.File(label=\"Output File\", file_types=[\".csv\"])\n",
"\n",
" button.click(predict_on_section, \n",
" inputs=[client_inputs, timestamp_inputs, \n",
" eq_lat_inputs, eq_lon_inputs, \n",
" radius_inputs, source_depth_inputs, \n",
" velocity_inputs, max_waveforms_inputs,\n",
" P_thres_inputs, S_thres_inputs],\n",
" outputs=[output_image, output_picks, output_csv])\n",
"\n",
"demo.launch()"
]
},
{
"cell_type": "code",
"execution_count": 89,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['__class__',\n",
" '__delattr__',\n",
" '__dict__',\n",
" '__dir__',\n",
" '__doc__',\n",
" '__eq__',\n",
" '__format__',\n",
" '__ge__',\n",
" '__getattribute__',\n",
" '__getstate__',\n",
" '__gt__',\n",
" '__hash__',\n",
" '__init__',\n",
" '__init_subclass__',\n",
" '__le__',\n",
" '__lt__',\n",
" '__module__',\n",
" '__ne__',\n",
" '__new__',\n",
" '__reduce__',\n",
" '__reduce_ex__',\n",
" '__repr__',\n",
" '__setattr__',\n",
" '__sizeof__',\n",
" '__str__',\n",
" '__subclasshook__',\n",
" '__weakref__',\n",
" 'azimuth',\n",
" 'distance',\n",
" 'incident_angle',\n",
" 'name',\n",
" 'path',\n",
" 'phase',\n",
" 'pierce',\n",
" 'purist_dist',\n",
" 'purist_distance',\n",
" 'purist_name',\n",
" 'ray_param',\n",
" 'ray_param_index',\n",
" 'ray_param_sec_degree',\n",
" 'receiver_depth',\n",
" 'source_depth',\n",
" 'takeoff_angle',\n",
" 'time']"
]
},
"execution_count": 89,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"dir(ray_path[0])"
]
},
{
"cell_type": "code",
"execution_count": 107,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"