Datasets:

ArXiv:
DOI:
License:
zhuwq0 commited on
Commit
19ad17e
·
1 Parent(s): 32aa588

add README

Browse files
Files changed (2) hide show
  1. .gitattributes +55 -0
  2. README.md +160 -0
.gitattributes ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.lz4 filter=lfs diff=lfs merge=lfs -text
12
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
13
+ *.model filter=lfs diff=lfs merge=lfs -text
14
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
15
+ *.npy filter=lfs diff=lfs merge=lfs -text
16
+ *.npz filter=lfs diff=lfs merge=lfs -text
17
+ *.onnx filter=lfs diff=lfs merge=lfs -text
18
+ *.ot filter=lfs diff=lfs merge=lfs -text
19
+ *.parquet filter=lfs diff=lfs merge=lfs -text
20
+ *.pb filter=lfs diff=lfs merge=lfs -text
21
+ *.pickle filter=lfs diff=lfs merge=lfs -text
22
+ *.pkl filter=lfs diff=lfs merge=lfs -text
23
+ *.pt filter=lfs diff=lfs merge=lfs -text
24
+ *.pth filter=lfs diff=lfs merge=lfs -text
25
+ *.rar filter=lfs diff=lfs merge=lfs -text
26
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
27
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
28
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
29
+ *.tflite filter=lfs diff=lfs merge=lfs -text
30
+ *.tgz filter=lfs diff=lfs merge=lfs -text
31
+ *.wasm filter=lfs diff=lfs merge=lfs -text
32
+ *.xz filter=lfs diff=lfs merge=lfs -text
33
+ *.zip filter=lfs diff=lfs merge=lfs -text
34
+ *.zst filter=lfs diff=lfs merge=lfs -text
35
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ # Audio files - uncompressed
37
+ *.pcm filter=lfs diff=lfs merge=lfs -text
38
+ *.sam filter=lfs diff=lfs merge=lfs -text
39
+ *.raw filter=lfs diff=lfs merge=lfs -text
40
+ # Audio files - compressed
41
+ *.aac filter=lfs diff=lfs merge=lfs -text
42
+ *.flac filter=lfs diff=lfs merge=lfs -text
43
+ *.mp3 filter=lfs diff=lfs merge=lfs -text
44
+ *.ogg filter=lfs diff=lfs merge=lfs -text
45
+ *.wav filter=lfs diff=lfs merge=lfs -text
46
+ # Image files - uncompressed
47
+ *.bmp filter=lfs diff=lfs merge=lfs -text
48
+ *.gif filter=lfs diff=lfs merge=lfs -text
49
+ *.png filter=lfs diff=lfs merge=lfs -text
50
+ *.tiff filter=lfs diff=lfs merge=lfs -text
51
+ # Image files - compressed
52
+ *.jpg filter=lfs diff=lfs merge=lfs -text
53
+ *.jpeg filter=lfs diff=lfs merge=lfs -text
54
+ *.webp filter=lfs diff=lfs merge=lfs -text
55
+ *.csv filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+
5
+ # Quakeflow_NC
6
+
7
+ ## Introduction
8
+ This dataset is part of the data (1970-2020) from [NCEDC (Northern California Earthquake Data Center)](https://ncedc.org/index.html) and is organized as several HDF5 files. The dataset structure is shown below, and you can find more information about the format at [AI4EPS](https://ai4eps.github.io/homepage/ml4earth/seismic_event_format1/))
9
+
10
+ Cite the NCEDC and PhaseNet:
11
+
12
+ Zhu, W., & Beroza, G. C. (2018). PhaseNet: A Deep-Neural-Network-Based Seismic Arrival Time Picking Method. arXiv preprint arXiv:1803.03211.
13
+
14
+ NCEDC (2014), Northern California Earthquake Data Center. UC Berkeley Seismological Laboratory. Dataset. doi:10.7932/NCEDC.
15
+
16
+ Acknowledge the NCEDC:
17
+
18
+ Waveform data, metadata, or data products for this study were accessed through the Northern California Earthquake Data Center (NCEDC), doi:10.7932/NCEDC.
19
+
20
+ ```
21
+ Group: / len:16227
22
+ |- Group: /nc71111584 len:2
23
+ | |-* begin_time = 2020-01-02T07:01:19.620
24
+ | |-* depth_km = 3.69
25
+ | |-* end_time = 2020-01-02T07:03:19.620
26
+ | |-* event_id = nc71111584
27
+ | |-* event_time = 2020-01-02T07:01:48.240
28
+ | |-* event_time_index = 2862
29
+ | |-* latitude = 37.6545
30
+ | |-* longitude = -118.8798
31
+ | |-* magnitude = -0.15
32
+ | |-* magnitude_type = D
33
+ | |-* num_stations = 2
34
+ | |- Dataset: /nc71111584/NC.MCB..HH (shape:(3, 12000))
35
+ | | |- (dtype=float32)
36
+ | | | |-* azimuth = 233.0
37
+ | | | |-* component = ['E' 'N' 'Z']
38
+ | | | |-* distance_km = 1.9
39
+ | | | |-* dt_s = 0.01
40
+ | | | |-* elevation_m = 2391.0
41
+ | | | |-* emergence_angle = 159.0
42
+ | | | |-* event_id = ['nc71111584' 'nc71111584']
43
+ | | | |-* latitude = 37.6444
44
+ | | | |-* location =
45
+ | | | |-* longitude = -118.8968
46
+ | | | |-* network = NC
47
+ | | | |-* phase_index = [3000 3101]
48
+ | | | |-* phase_polarity = ['U' 'N']
49
+ | | | |-* phase_remark = ['IP' 'ES']
50
+ | | | |-* phase_score = [1 2]
51
+ | | | |-* phase_time = ['2020-01-02T07:01:49.620' '2020-01-02T07:01:50.630']
52
+ | | | |-* phase_type = ['P' 'S']
53
+ | | | |-* snr = [2.82143 3.055604 1.8412642]
54
+ | | | |-* station = MCB
55
+ | | | |-* unit = 1e-6m/s
56
+ | |- Dataset: /nc71111584/NC.MCB..HN (shape:(3, 12000))
57
+ | | |- (dtype=float32)
58
+ | | | |-* azimuth = 233.0
59
+ | | | |-* component = ['E' 'N' 'Z']
60
+ ......
61
+ ```
62
+
63
+ ## How to use
64
+
65
+ ### Requirements
66
+ - datasets
67
+ - h5py
68
+ - fsspec
69
+ - pytorch
70
+
71
+ ### Usage
72
+ Import the necessary packages:
73
+ ```python
74
+ import h5py
75
+ import numpy as np
76
+ import torch
77
+ from datasets import load_dataset
78
+ ```
79
+ We have 6 configurations for the dataset:
80
+ - "station"
81
+ - "event"
82
+ - "station_train"
83
+ - "event_train"
84
+ - "station_test"
85
+ - "event_test"
86
+
87
+ "station" yields station-based samples one by one, while "event" yields event-based samples one by one. The configurations with no suffix are the full dataset, while the configurations with suffix "_train" and "_test" only have corresponding split of the full dataset. Train split contains data from 1970 to 2019, while test split contains data in 2020.
88
+
89
+ The sample of `station` is a dictionary with the following keys:
90
+ - `data`: the waveform with shape `(3, nt)`, the default time length is 8192
91
+ - `begin_time`: the begin time of the waveform data
92
+ - `end_time`: the end time of the waveform data
93
+ - `phase_time`: the phase arrival time
94
+ - `phase_index`: the time point index of the phase arrival time
95
+ - `phase_type`: the phase type
96
+ - `phase_polarity`: the phase polarity in ('U', 'D', 'N')
97
+ - `event_time`: the event time
98
+ - `event_time_index`: the time point index of the event time
99
+ - `event_location`: the event location with shape `(3,)`, including latitude, longitude, depth
100
+ - `station_location`: the station location with shape `(3,)`, including latitude, longitude and depth
101
+
102
+ The sample of `event` is a dictionary with the following keys:
103
+ - `data`: the waveform with shape `(n_station, 3, nt)`, the default time length is 8192
104
+ - `begin_time`: the begin time of the waveform data
105
+ - `end_time`: the end time of the waveform data
106
+ - `phase_time`: the phase arrival time with shape `(n_station,)`
107
+ - `phase_index`: the time point index of the phase arrival time with shape `(n_station,)`
108
+ - `phase_type`: the phase type with shape `(n_station,)`
109
+ - `phase_polarity`: the phase polarity in ('U', 'D', 'N') with shape `(n_station,)`
110
+ - `event_time`: the event time
111
+ - `event_time_index`: the time point index of the event time
112
+ - `event_location`: the space-time coordinates of the event with shape `(n_staion, 3)`
113
+ - `station_location`: the space coordinates of the station with shape `(n_station, 3)`, including latitude, longitude and depth
114
+
115
+ The default configuration is `station_test`. You can specify the configuration by argument `name`. For example:
116
+ ```python
117
+ # load dataset
118
+ # ATTENTION: Streaming(Iterable Dataset) is difficult to support because of the feature of HDF5
119
+ # So we recommend to directly load the dataset and convert it into iterable later
120
+ # The dataset is very large, so you need to wait for some time at the first time
121
+
122
+ # to load "station_test" with test split
123
+ quakeflow_nc = load_dataset("AI4EPS/quakeflow_nc", split="test")
124
+ # or
125
+ quakeflow_nc = load_dataset("AI4EPS/quakeflow_nc", name="station_test", split="test")
126
+
127
+ # to load "event" with train split
128
+ quakeflow_nc = load_dataset("AI4EPS/quakeflow_nc", name="event", split="train")
129
+ ```
130
+
131
+ #### Example loading the dataset
132
+ ```python
133
+ quakeflow_nc = load_dataset("AI4EPS/quakeflow_nc", name="station_test", split="test")
134
+
135
+ # print the first sample of the iterable dataset
136
+ for example in quakeflow_nc:
137
+ print("\nIterable test\n")
138
+ print(example.keys())
139
+ for key in example.keys():
140
+ if key == "data":
141
+ print(key, np.array(example[key]).shape)
142
+ else:
143
+ print(key, example[key])
144
+ break
145
+
146
+ # %%
147
+ quakeflow_nc = quakeflow_nc.with_format("torch")
148
+ dataloader = DataLoader(quakeflow_nc, batch_size=8, num_workers=0, collate_fn=lambda x: x)
149
+
150
+ for batch in dataloader:
151
+ print("\nDataloader test\n")
152
+ print(f"Batch size: {len(batch)}")
153
+ print(batch[0].keys())
154
+ for key in batch[0].keys():
155
+ if key == "data":
156
+ print(key, np.array(batch[0][key]).shape)
157
+ else:
158
+ print(key, batch[0][key])
159
+ break
160
+ ```