SkillAgentSearch skills...

EQTransformer

EQTransformer, a python package for earthquake signal detection and phase picking using AI.

Install / Use

/learn @smousavi05/EQTransformer

README

event

An AI-Based Earthquake Signal Detector and Phase Picker

PyPI Conda Read the Docs PyPI - License Conda GitHub last commit Twitter Follow GitHub followers GitHub stars GitHub forks


Description

EQTransformer is an AI-based earthquake signal detector and phase (P&S) picker based on a deep neural network with an attention mechanism. It has a hierarchical architecture specifically designed for earthquake signals. EQTransformer has been trained on global seismic data and can perform detection and arrival time picking simultaneously and efficiently. In addition to the prediction probabilities, it can also provide estimated model uncertainties.

The EQTransformer python 3 package includes modules for downloading continuous seismic data, preprocessing, performing earthquake signal detection, and phase (P & S) picking using pre-trained models, building and testing new models, and performing a simple phase association.

Developer: S. Mostafa Mousavi (smousavi05@gmail.com)


Links

  • Documentation: https://rebrand.ly/EQT-documentations

  • Paper: https://rdcu.be/b58li


Installation

EQTransformer supports a variety of platforms, including macOS, Windows, and Linux operating systems. Note that you will need to have Python 3.x (3.6 or 3.7) installed. The EQTransformer Python package can be installed using the following options:

Via Anaconda (recommended):

conda create -n eqt python=3.7

conda activate eqt

conda install conda-forge::obspy

conda install -c smousavi05 eqtransformer 
Note: sometimes you need to keep repeating executing the last line multiple time to succeed.

Via PyPI:

If you already have Obspy installed on your machine, you can get EQTransformer through PyPI:

pip install EQTransformer

From source:

The sources for EQTransformer can be downloaded from the GitHub repo.

Note: the GitHub version has been modified for Tensorflow 2.5.0

You can either clone the public repository:

git clone https://github.com/smousavi05/EQTransformer.git

or (if you are working on Colab)

pip install git+https://github.com/smousavi05/EQTransformer

Once you have a copy of the source, you can cd to EQTransformer directory and install it with:

python setup.py install

If you have installed EQTransformer Python package before and want to upgrade to the latest version, you can use the following command:

pip install EQTransformer -U
To install EqT on M1 laptop with python>=3.9 from the source (GitHub) code by changing tensorflow to tensorflow-maco in the setup.py and follow these steps:
  conda create -n eqt python=3.10
  conda activate eqt
  conda install -c apple tensorflow-deps
  conda install obspy jupyter pandas
  pip install tensorflow-macos
  python3 setup.py install

Tutorials

See either:

https://rebrand.ly/EQT-documentations

and/or

https://rebrand.ly/EQT-examples

Important Notes:

There is not much difference between the two models (i.e. original and conservative models) regarding the network architecture (only 1 or 2 layers). The main difference comes from the training procedure and the hyperparameters used for data augmentation during the training.

Original model (the one in the paper) has been optimized to minimize the false negative rate (maximize the number of detected events). This is a good choice when high false positive rates is not an issue in your application. For instance, in event location workflow most of the false positives will automatically be removed during the association, location, and - especially - relocation procedure. You can use the original model with higher threshold values (~ 0.3 for P and S and 0.5 for detection).

Conservative Model, on the other hand, has been optimized to minimize the false positive rate (maximum number of valid detections). This model is useful when your application can not tolerate a high false positive rate. For example, in travel time tomography or using the detected events by EqT as the templates for template matching. You should use this model with a much lower threshold levels (0.03 for P and S).

Suggestions for Optimal Catalog Building:

  1. use the original model for detection and picking and have a cross-correlation-based event relocation at the end to clean up false positives.
  2. use detected events by the conservative model as template events and then perform a complementary template-matching to detect the rest of events. See this paper (https://academic.oup.com/gji/advance-article-abstract/doi/10.1093/gji/ggac487/6881721) as an example.

If you feel some larger events are missed while smaller ones are detected: Use larger overlapping value (e.g. 0.9) for moving windows.

Note: to run the notebook examples, you may need to reinstall the jupyter on the same environment that EQTransformer has been installed.


Related Software Packages:

QuakePhase (https://github.com/speedshi/quakephase) the quakephase can be used to largely enhance the results of pre-trained EQT model for picking phases on traces recorded in epicentral distances > 100 km, different types of instruments, larger events, etc.

Blocky Earthquake Transformer (https://github.com/maihao14/BlocklyEQTransformer) is a user-interface no-code-based platform that makes it easy to fine-tune EqT for specific data/regions. It also provides a user-friendly interface to create your own EqT model and train it without dealing with coding or knowing in-depth ML.

Siamese Earthquake Transformer (https://github.com/MrXiaoXiao/SiameseEarthquakeTransformer) performs a secondary template-matching-type post-processing step (by using the learned features in EqT layers as the templates and measure the similarities using a Siamese neural network instead of cross-correlation) to reduce the false-negative rate of the EqT retrieving previously missed phase picks in low SNR seismograms.

EdgePhase (https://github.com/lovelytt0/EdgePhase) Graph-based EQTransformer for picking phases using multi-station data.

OBSTransformer (https://github.com/alirezaniki/OBSTransformer)) is a transfer-learned seismic phase picker for Ocean Bottom Seismometer (OBS) data adopted from the EqTransformer model. OBSTransformer has been trained on an auto-labeled tectonically inclusive OBS dataset comprising ~36k earthquake and 25k noise samples.

QuakeLabeler (https://maihao14.github.io/QuakeLabeler/) is a software package that can be used to create labeled training dataset for EQTransformer (i.e. STEAD format).

SeisBench (https://github.com/seisbench/seisbench/) is an open source benchmarking package with PyTorch implementation of EgT that makes it easy to either apply pre-trained EqT model, retrain it, or compare it with other models.

MALMI (https://github.com/speedshi/MALMI/) is an earthquake monitoring pipline, i.e. picking and event location determination, that uses EqT for event detection and phase picking.

easyQuake (https://github.com/jakewalter/easyQuake) is an earthquake monitoring pipline, i.e. detection, picking, association, location, and magnitude determination, that includes EqT and other DL-pickers for event detection and phase picking.


A Quick Example


    from EQTransformer.core.mseed_predictor import mseed_predictor
    
    mseed_predictor(input_dir='downloads_mseeds',   
                    input_model='ModelsAndSampleData/EqT_model.h5',
                    stations_json='station_list.json',
                    output_dir='detection_results',
                    detection_threshold=0.2,                
                    P_threshold=0.1,
                    S_threshold=0.1, 
                    number_of_plots=10,
                    plot_mode='time_frequency',
                    batch_size=500,
                    overlap=0.3)

Reference

Mousavi, S.M., Ellsworth, W.L., Zhu, W., Chuang, L, Y., and Beroza, G, C. Earthquake transformer—an attentive deep-learning model for simultaneous earthquake detection and phase picking. Nat Commun 11, 3952 (2020). https://doi.org/10.1038/s41467-020-17591-w

BibTeX:

@article{mousavi2020earthquake,
    title={Earthquake transformer—an attentive deep-learning model for simultaneous earthquake detection and phase picking},
    author={Mousavi, S Mostafa and Ellsworth, William L and Zhu, Weiqiang and Chuang, Lindsay Y and Beroza, Gregory C},
    journal={Nature Communications},
    volume={11},
    number={1},
    pages={1--12},
    year={2

Related Skills

View on GitHub
GitHub Stars401
CategoryEducation
Updated1d ago
Forks168

Languages

Python

Security Score

100/100

Audited on Mar 22, 2026

No findings