Datasets:

ArXiv:
License:
kylewhy commited on
Commit
665e575
·
1 Parent(s): a6afd6d

update doc

Browse files
Files changed (1) hide show
  1. README.md +176 -1
README.md CHANGED
@@ -2,4 +2,179 @@
2
  license: mit
3
  ---
4
 
5
- ## CEED: *C*alifornia *E*arthquak*E* *D*ataset for Machine Learning and Cloud Computing
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  license: mit
3
  ---
4
 
5
+ ## CEED: *C*alifornia *E*arthquak*E* *D*ataset for Machine Learning and Cloud Computing
6
+
7
+ The California EarthquakE Dataset (CEED) is a dataset of earthquake waveforms and metadata for machine learning and cloud computing. 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/)
8
+
9
+ ```
10
+ Group: / len:60424
11
+ |- Group: /ci38457511 len:35
12
+ | |-* begin_time = 2019-07-06T03:19:23.668000
13
+ | |-* depth_km = 8.0
14
+ | |-* end_time = 2019-07-06T03:21:23.668000
15
+ | |-* event_id = ci38457511
16
+ | |-* event_time = 2019-07-06T03:19:53.040000
17
+ | |-* event_time_index = 2937
18
+ | |-* latitude = 35.7695
19
+ | |-* longitude = -117.5993
20
+ | |-* magnitude = 7.1
21
+ | |-* magnitude_type = w
22
+ | |-* nt = 12000
23
+ | |-* nx = 35
24
+ | |-* sampling_rate = 100
25
+ | |-* source = SC
26
+ | |- Dataset: /ci38457511/CI.CCC..HH (shape:(3, 12000))
27
+ | | |- (dtype=float32)
28
+ | | | |-* azimuth = 141.849479
29
+ | | | |-* back_azimuth = 321.986302
30
+ | | | |-* component = ENZ
31
+ | | | |-* depth_km = -0.67
32
+ | | | |-* distance_km = 34.471389
33
+ | | | |-* dt_s = 0.01
34
+ | | | |-* elevation_m = 670.0
35
+ | | | |-* event_id = ['ci38457511' 'ci38457511' 'ci37260300']
36
+ | | | |-* instrument = HH
37
+ | | | |-* latitude = 35.52495
38
+ | | | |-* local_depth_m = 0.0
39
+ | | | |-* location =
40
+ | | | |-* longitude = -117.36453
41
+ | | | |-* network = CI
42
+ | | | |-* p_phase_index = 3575
43
+ | | | |-* p_phase_polarity = U
44
+ | | | |-* p_phase_score = 0.8
45
+ | | | |-* p_phase_status = manual
46
+ | | | |-* p_phase_time = 2019-07-06T03:19:59.422000
47
+ | | | |-* phase_index = [ 3575 4184 11826]
48
+ | | | |-* phase_picking_channel = ['HHZ' 'HNN' 'HHZ']
49
+ | | | |-* phase_polarity = ['U' 'N' 'N']
50
+ | | | |-* phase_remark = ['i' 'e' 'e']
51
+ | | | |-* phase_score = [0.8 0.5 0.5]
52
+ | | | |-* phase_status = manual
53
+ | | | |-* phase_time = ['2019-07-06T03:19:59.422000' '2019-07-06T03:20:05.509000' '2019-07-06T03:21:21.928000']
54
+ | | | |-* phase_type = ['P' 'S' 'P']
55
+ | | | |-* s_phase_index = 4184
56
+ | | | |-* s_phase_polarity = N
57
+ | | | |-* s_phase_score = 0.5
58
+ | | | |-* s_phase_status = manual
59
+ | | | |-* s_phase_time = 2019-07-06T03:20:05.509000
60
+ | | | |-* snr = [ 637.9865898 286.9100766 1433.04052911]
61
+ | | | |-* station = CCC
62
+ | | | |-* unit = 1e-6m/s
63
+ | |- Dataset: /ci38457511/CI.CCC..HN (shape:(3, 12000))
64
+ | | |- (dtype=float32)
65
+ | | | |-* azimuth = 141.849479
66
+ | | | |-* back_azimuth = 321.986302
67
+ | | | |-* component = ENZ
68
+ | | | |-* depth_km = -0.67
69
+ | | | |-* distance_km = 34.471389
70
+ | | | |-* dt_s = 0.01
71
+ | | | |-* elevation_m = 670.0
72
+ | | | |-* event_id = ['ci38457511' 'ci38457511' 'ci37260300']
73
+ ......
74
+ ```
75
+
76
+ ## Getting Started
77
+
78
+ ### Requirements
79
+ - datasets
80
+ - h5py
81
+ - fsspec
82
+ - pytorch
83
+
84
+ ### Usage
85
+ Import the necessary packages:
86
+ ```python
87
+ import h5py
88
+ import numpy as np
89
+ import torch
90
+ from datasets import load_dataset
91
+ ```
92
+ We have 6 configurations for the dataset:
93
+ - "station"
94
+ - "event"
95
+ - "station_train"
96
+ - "event_train"
97
+ - "station_test"
98
+ - "event_test"
99
+
100
+ "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.
101
+
102
+ The sample of `station` is a dictionary with the following keys:
103
+ - `data`: the waveform with shape `(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
107
+ - `phase_index`: the time point index of the phase arrival time
108
+ - `phase_type`: the phase type
109
+ - `phase_polarity`: the phase polarity in ('U', 'D', 'N')
110
+ - `event_time`: the event time
111
+ - `event_time_index`: the time point index of the event time
112
+ - `event_location`: the event location with shape `(3,)`, including latitude, longitude, depth
113
+ - `station_location`: the station location with shape `(3,)`, including latitude, longitude and depth
114
+
115
+ The sample of `event` is a dictionary with the following keys:
116
+ - `data`: the waveform with shape `(n_station, 3, nt)`, the default time length is 8192
117
+ - `begin_time`: the begin time of the waveform data
118
+ - `end_time`: the end time of the waveform data
119
+ - `phase_time`: the phase arrival time with shape `(n_station,)`
120
+ - `phase_index`: the time point index of the phase arrival time with shape `(n_station,)`
121
+ - `phase_type`: the phase type with shape `(n_station,)`
122
+ - `phase_polarity`: the phase polarity in ('U', 'D', 'N') with shape `(n_station,)`
123
+ - `event_time`: the event time
124
+ - `event_time_index`: the time point index of the event time
125
+ - `event_location`: the space-time coordinates of the event with shape `(n_staion, 3)`
126
+ - `station_location`: the space coordinates of the station with shape `(n_station, 3)`, including latitude, longitude and depth
127
+
128
+ The default configuration is `station_test`. You can specify the configuration by argument `name`. For example:
129
+ ```python
130
+ # load dataset
131
+ # ATTENTION: Streaming(Iterable Dataset) is complex to support because of the feature of HDF5
132
+ # So we recommend to directly load the dataset and convert it into iterable later
133
+ # The dataset is very large, so you need to wait for some time at the first time
134
+
135
+ # to load "station_test" with test split
136
+ ceed = load_dataset("AI4EPS/CEED", split="test")
137
+ # or
138
+ ceed = load_dataset("AI4EPS/CEED", name="station_test", split="test")
139
+
140
+ # to load "event" with train split
141
+ ceed = load_dataset("AI4EPS/CEED", name="event", split="train")
142
+ ```
143
+
144
+ #### Example loading the dataset
145
+ ```python
146
+ ceed = load_dataset("AI4EPS/CEED", name="station_test", split="test")
147
+
148
+ # print the first sample of the iterable dataset
149
+ for example in ceed:
150
+ print("\nIterable test\n")
151
+ print(example.keys())
152
+ for key in example.keys():
153
+ if key == "data":
154
+ print(key, np.array(example[key]).shape)
155
+ else:
156
+ print(key, example[key])
157
+ break
158
+
159
+ # %%
160
+ ceed = ceed.with_format("torch")
161
+ dataloader = DataLoader(ceed, batch_size=8, num_workers=0, collate_fn=lambda x: x)
162
+
163
+ for batch in dataloader:
164
+ print("\nDataloader test\n")
165
+ print(f"Batch size: {len(batch)}")
166
+ print(batch[0].keys())
167
+ for key in batch[0].keys():
168
+ if key == "data":
169
+ print(key, np.array(batch[0][key]).shape)
170
+ else:
171
+ print(key, batch[0][key])
172
+ break
173
+ ```
174
+
175
+ #### Extension
176
+
177
+ If you want to introduce new features in to labels, we recommend to make a copy of `CEED.py` and modify the `_generate_examples` method. Check [AI4EPS/EQNet](https://github.com/AI4EPS/EQNet/blob/master/eqnet/data/quakeflow_nc.py) for an example. To load the dataset with your modified script, specify the path to the script in `load_dataset` function:
178
+ ```python
179
+ ceed = load_dataset("path/to/your/CEED.py", name="station_test", split="test", trust_remote_code=True)
180
+ ```