zhuwq0 commited on
Commit
7b0431f
1 Parent(s): 2c4e20c
Files changed (1) hide show
  1. README.md +153 -0
README.md ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Fastapi Dummy
3
+ emoji: 🐢
4
+ colorFrom: purple
5
+ colorTo: blue
6
+ sdk: docker
7
+ pinned: false
8
+ ---
9
+
10
+ # PhaseNet: A Deep-Neural-Network-Based Seismic Arrival Time Picking Method
11
+
12
+ [![](https://github.com/AI4EPS/PhaseNet/workflows/documentation/badge.svg)](https://ai4eps.github.io/PhaseNet)
13
+
14
+ ## 1. Install [miniconda](https://docs.conda.io/en/latest/miniconda.html) and requirements
15
+ - Download PhaseNet repository
16
+ ```bash
17
+ git clone https://github.com/wayneweiqiang/PhaseNet.git
18
+ cd PhaseNet
19
+ ```
20
+ - Install to default environment
21
+ ```bash
22
+ conda env update -f=env.yml -n base
23
+ ```
24
+ - Install to "phasenet" virtual envirionment
25
+ ```bash
26
+ conda env create -f env.yml
27
+ conda activate phasenet
28
+ ```
29
+
30
+ ## 2. Pre-trained model
31
+ Located in directory: **model/190703-214543**
32
+
33
+ ## 3. Related papers
34
+ - Zhu, Weiqiang, and Gregory C. Beroza. "PhaseNet: A Deep-Neural-Network-Based Seismic Arrival Time Picking Method." arXiv preprint arXiv:1803.03211 (2018).
35
+ - Liu, Min, et al. "Rapid characterization of the July 2019 Ridgecrest, California, earthquake sequence from raw seismic data using machine‐learning phase picker." Geophysical Research Letters 47.4 (2020): e2019GL086189.
36
+ - Park, Yongsoo, et al. "Machine‐learning‐based analysis of the Guy‐Greenbrier, Arkansas earthquakes: A tale of two sequences." Geophysical Research Letters 47.6 (2020): e2020GL087032.
37
+ - Chai, Chengping, et al. "Using a deep neural network and transfer learning to bridge scales for seismic phase picking." Geophysical Research Letters 47.16 (2020): e2020GL088651.
38
+ - Tan, Yen Joe, et al. "Machine‐Learning‐Based High‐Resolution Earthquake Catalog Reveals How Complex Fault Structures Were Activated during the 2016–2017 Central Italy Sequence." The Seismic Record 1.1 (2021): 11-19.
39
+
40
+ ## 4. Batch prediction
41
+ See examples in the [notebook](https://github.com/wayneweiqiang/PhaseNet/blob/master/docs/example_batch_prediction.ipynb): [example_batch_prediction.ipynb](example_batch_prediction.ipynb)
42
+
43
+
44
+ PhaseNet currently supports four data formats: mseed, sac, hdf5, and numpy. The test data can be downloaded here:
45
+ ```
46
+ wget https://github.com/wayneweiqiang/PhaseNet/releases/download/test_data/test_data.zip
47
+ unzip test_data.zip
48
+ ```
49
+
50
+ - For mseed format:
51
+ ```
52
+ python phasenet/predict.py --model=model/190703-214543 --data_list=test_data/mseed.csv --data_dir=test_data/mseed --format=mseed --amplitude --response_xml=test_data/stations.xml --batch_size=1 --sampling_rate=100 --plot_figure
53
+ ```
54
+ ```
55
+ python phasenet/predict.py --model=model/190703-214543 --data_list=test_data/mseed2.csv --data_dir=test_data/mseed --format=mseed --amplitude --response_xml=test_data/stations.xml --batch_size=1 --sampling_rate=100 --plot_figure
56
+ ```
57
+
58
+ - For sac format:
59
+ ```
60
+ python phasenet/predict.py --model=model/190703-214543 --data_list=test_data/sac.csv --data_dir=test_data/sac --format=sac --batch_size=1 --plot_figure
61
+ ```
62
+
63
+ - For numpy format:
64
+ ```
65
+ python phasenet/predict.py --model=model/190703-214543 --data_list=test_data/npz.csv --data_dir=test_data/npz --format=numpy --plot_figure
66
+ ```
67
+
68
+ - For hdf5 format:
69
+ ```
70
+ python phasenet/predict.py --model=model/190703-214543 --hdf5_file=test_data/data.h5 --hdf5_group=data --format=hdf5 --plot_figure
71
+ ```
72
+
73
+ - For a seismic array (used by [QuakeFlow](https://github.com/wayneweiqiang/QuakeFlow)):
74
+ ```
75
+ python phasenet/predict.py --model=model/190703-214543 --data_list=test_data/mseed_array.csv --data_dir=test_data/mseed_array --stations=test_data/stations.json --format=mseed_array --amplitude
76
+ ```
77
+
78
+ Notes:
79
+
80
+ 1. The reason for using "--batch_size=1" is because the mseed or sac files usually are not the same length. If you want to use a larger batch size for a good prediction speed, you need to cut the data to the same length.
81
+
82
+ 2. Remove the "--plot_figure" argument for large datasets, because plotting can be very slow.
83
+
84
+ Optional arguments:
85
+ ```
86
+ usage: predict.py [-h] [--batch_size BATCH_SIZE] [--model_dir MODEL_DIR]
87
+ [--data_dir DATA_DIR] [--data_list DATA_LIST]
88
+ [--hdf5_file HDF5_FILE] [--hdf5_group HDF5_GROUP]
89
+ [--result_dir RESULT_DIR] [--result_fname RESULT_FNAME]
90
+ [--min_p_prob MIN_P_PROB] [--min_s_prob MIN_S_PROB]
91
+ [--mpd MPD] [--amplitude] [--format FORMAT]
92
+ [--s3_url S3_URL] [--stations STATIONS] [--plot_figure]
93
+ [--save_prob]
94
+
95
+ optional arguments:
96
+ -h, --help show this help message and exit
97
+ --batch_size BATCH_SIZE
98
+ batch size
99
+ --model_dir MODEL_DIR
100
+ Checkpoint directory (default: None)
101
+ --data_dir DATA_DIR Input file directory
102
+ --data_list DATA_LIST
103
+ Input csv file
104
+ --hdf5_file HDF5_FILE
105
+ Input hdf5 file
106
+ --hdf5_group HDF5_GROUP
107
+ data group name in hdf5 file
108
+ --result_dir RESULT_DIR
109
+ Output directory
110
+ --result_fname RESULT_FNAME
111
+ Output file
112
+ --min_p_prob MIN_P_PROB
113
+ Probability threshold for P pick
114
+ --min_s_prob MIN_S_PROB
115
+ Probability threshold for S pick
116
+ --mpd MPD Minimum peak distance
117
+ --amplitude if return amplitude value
118
+ --format FORMAT input format
119
+ --stations STATIONS seismic station info
120
+ --plot_figure If plot figure for test
121
+ --save_prob If save result for test
122
+ ```
123
+
124
+ - The output picks are saved to "results/picks.csv" on default
125
+
126
+ |file_name |begin_time |station_id|phase_index|phase_time |phase_score|phase_amp |phase_type|
127
+ |-----------------|-----------------------|----------|-----------|-----------------------|-----------|----------------------|----------|
128
+ |2020-10-01T00:00*|2020-10-01T00:00:00.003|CI.BOM..HH|14734 |2020-10-01T00:02:27.343|0.708 |2.4998866231208325e-14|P |
129
+ |2020-10-01T00:00*|2020-10-01T00:00:00.003|CI.BOM..HH|15487 |2020-10-01T00:02:34.873|0.416 |2.4998866231208325e-14|S |
130
+ |2020-10-01T00:00*|2020-10-01T00:00:00.003|CI.COA..HH|319 |2020-10-01T00:00:03.193|0.762 |3.708662269972206e-14 |P |
131
+
132
+ Notes:
133
+ 1. The *phase_index* means which data point is the pick in the original sequence. So *phase_time* = *begin_time* + *phase_index* / *sampling rate*. The default *sampling_rate* is 100Hz
134
+
135
+
136
+ ## 5. QuakeFlow example
137
+ A complete earthquake detection workflow can be found in the [QuakeFlow](https://wayneweiqiang.github.io/QuakeFlow/) project.
138
+
139
+ ## 6. Interactive example
140
+ See details in the [notebook](https://github.com/wayneweiqiang/PhaseNet/blob/master/docs/example_gradio.ipynb): [example_interactive.ipynb](example_gradio.ipynb)
141
+
142
+ ## 7. Training
143
+ - Download a small sample dataset:
144
+ ```bash
145
+ wget https://github.com/wayneweiqiang/PhaseNet/releases/download/test_data/test_data.zip
146
+ unzip test_data.zip
147
+ ```
148
+ - Start training from the pre-trained model
149
+ ```
150
+ python phasenet/train.py --model_dir=model/190703-214543/ --train_dir=test_data/npz --train_list=test_data/npz.csv --plot_figure --epochs=10 --batch_size=10
151
+ ```
152
+ - Check results in the **log** folder
153
+