Skip to main content

Simplified machine-learning driven earthquake detection, location, and analysis

Project description

easyQuake

Simplified machine-learning driven earthquake detection, location, and analysis in one easy-to-implement python package.

On most systems you should be able to simply:

pip install easyQuake

To stay on the bleeding edge of updates:

pip install easyQuake --upgrade

Or if you need to tweak something, like the number of GPUs in gpd_predict, you could:

git clone https://github.com/jakewalter/easyQuake.git
cd easyQuake
pip install .

If you find this useful, please cite:

Walter, J. I., P. Ogwari, A. Thiel, F. Ferrer, and I. Woelfel (2021), easyQuake: Putting machine 
learning to work for your regional seismic network or local earthquake study, Seismological Research 
Letters, 92(1): 555–563, https://doi.org/10.1785/0220200226

Requirements

This code leverages machine-learning for earthquake detection with the choice of either the GPD (https://github.com/interseismic/generalized-phase-detection) or EQTransformer (https://github.com/smousavi05/EQTransformer) pickers. You should have suitable hardware to run CUDA/Tensorflow, which usually means some sort of GPU. This has been tested on servers with nvidia compute cards and modest multi-core desktop with consumer gaming nvidia card (e.g. Geforce 1050 Ti). The event-mode can be run efficiently enough on a laptop.

  • Requires nvidia-cuda-toolkit, obspy, keras==2.3.1, tensorflow-gpu==2.1 (if using multiple GPUs only tensorflow 1.15 is tested), basemap
  • I've found that the the easiest way to install cuda, tensorflow, and keras is through installing Anaconda python and running conda install tensorflow-gpu==2.1
  • Because tensorflow-gpu 2.1 requires python 3.7 (not the latest version), you might find an easier road creating a new environment:
conda create -n easyquake python=3.7 anaconda
conda activate easyquake
conda install tensorflow-gpu==2.1
conda install keras
conda install obspy -c conda-forge
pip install easyQuake

Running easyQuake

The example runs easyQuake for a recent M6.5 earthquake in Idaho for the 2 days around the earthquake (foreshocks and aftershocks). The catalog from running the example is in the examples folder: https://github.com/jakewalter/easyQuake/blob/master/examples/catalog_idaho_2days.xml

from easyQuake import download_mseed
from easyQuake import daterange
from datetime import date
from easyQuake import combine_associated
from easyQuake import detection_continuous
from easyQuake import association_continuous

from easyQuake import magnitude_quakeml
from easyQuake import simple_cat_df

import matplotlib.pyplot as plt
maxkm = 300
maxdist=300
lat_a = 42
lat_b = 47.5
lon_a = -118
lon_b = -111


start_date = date(2020, 3, 31)
end_date = date(2020, 4, 2)

project_code = 'idaho'
project_folder = '/data/id'
for single_date in daterange(start_date, end_date):
    print(single_date.strftime("%Y-%m-%d"))
    dirname = single_date.strftime("%Y%m%d")
    download_mseed(dirname=dirname, project_folder=project_folder, single_date=single_date, minlat=lat_a, maxlat=lat_b, minlon=lon_a, maxlon=lon_b)
    detection_continuous(dirname=dirname, project_folder=project_folder, project_code=project_code, single_date=single_date, machine=True,local=True)
    association_continuous(dirname=dirname, project_folder=project_folder, project_code=project_code, maxdist=maxdist, maxkm=maxkm, single_date=single_date, local=True)

cat, dfs = combine_associated(project_folder=project_folder, project_code=project_code)
cat = magnitude_quakeml(cat=cat, project_folder=project_folder,plot_event=True)
cat.write('catalog_idaho.xml',format='QUAKEML')


catdf = simple_cat_df(cat)
plt.figure()
plt.plot(catdf.index,catdf.magnitude,'.')

Tips for successful outputs

Within your systems, consider running driver scripts as nohup background processes nohup python ~/work_dir/okla_daily.py &. In this way, one could cat nohup.out | grep Traceback to understand python errors or grep nohup.out | Killed to understand when the system runs out of memory.

Video intros to easyQuake

Most recent updates, recorded for the 2021 SSA Annual meeting: https://www.youtube.com/watch?v=bjBqPL9pD5w

Recorded for the fall 2020 Virtual SSA Eastern Section meeting: https://www.youtube.com/watch?v=coS2OwTWO3Y

Running easyQuake with SLURM

If you have access to shared computing resources that utilize SLURM, you can drive easyQuake by making a bash script to run the example code or any code (thanks to Xiaowei Chen at OU). Save the following to a drive_easyQuake.sh and then run it

#!/bin/bash
#
#SBATCH --partition=gpu_cluster
#SBATCH --ntasks=1
#SBATCH --mem=1024
#SBATCH --output=easyquake_%J_stdout.txt
#SBATCH --error=easyquake_%J_stderr.txt
#SBATCH --time=24:00:00
#SBATCH --job-name=easyquake
#SBATCH --mail-user=user@school.edu
#SBATCH --mail-type=ALL
#SBATCH --chdir=/drive/group/user/folder
conda init bash
bash
conda activate easyquake
python idaho_example.py

Version brief notes

Verson 0.6 (2/24/2021) - Implemented choice of GPD or EQTransformer pickers for the picking stage

Version 0.5 (2/10/2021) - includes embedded hypoinverse location functionality, rather than the simple location with the associator.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

easyQuake-0.6.7.tar.gz (28.0 MB view details)

Uploaded Source

Built Distribution

easyQuake-0.6.7-py3-none-any.whl (28.0 MB view details)

Uploaded Python 3

File details

Details for the file easyQuake-0.6.7.tar.gz.

File metadata

  • Download URL: easyQuake-0.6.7.tar.gz
  • Upload date:
  • Size: 28.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.3

File hashes

Hashes for easyQuake-0.6.7.tar.gz
Algorithm Hash digest
SHA256 78f4a3587dfbd27d670f6a9418ec1c47fe564b802b24ed4e6f803e1df2192d75
MD5 640f30b1554b2a0e5358ac1be948389c
BLAKE2b-256 16685216db7d6fb3208b0e027ec3243c1a7b438706530aa69ae99a7de1b3ae89

See more details on using hashes here.

File details

Details for the file easyQuake-0.6.7-py3-none-any.whl.

File metadata

  • Download URL: easyQuake-0.6.7-py3-none-any.whl
  • Upload date:
  • Size: 28.0 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.1 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.7.3

File hashes

Hashes for easyQuake-0.6.7-py3-none-any.whl
Algorithm Hash digest
SHA256 fd44a955aac031a58c027b2226ce8c91f9052cc13d75443abfa539a4093492e0
MD5 1e0a274f4a3641c3b040a68dc8667aa1
BLAKE2b-256 cfcde36fb8d5c73770f8fea8c63b7f6e9b112127a165424133758cff8f32b238

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page