update data
Browse files- quakeflow_demo.py +14 -3
quakeflow_demo.py
CHANGED
@@ -91,6 +91,9 @@ class QuakeFlow_NC(datasets.GeneratorBasedBuilder):
|
|
91 |
"data": datasets.Array2D(shape=(3, self.nt), dtype="float32"),
|
92 |
"event_id": datasets.Value("string"),
|
93 |
"station_id": datasets.Value("string"),
|
|
|
|
|
|
|
94 |
}
|
95 |
)
|
96 |
|
@@ -100,6 +103,8 @@ class QuakeFlow_NC(datasets.GeneratorBasedBuilder):
|
|
100 |
"data": datasets.Array3D(shape=(None, 3, self.nt), dtype="float32"),
|
101 |
"event_id": datasets.Value("string"),
|
102 |
"station_ids": datasets.Sequence(datasets.Value("string")),
|
|
|
|
|
103 |
}
|
104 |
)
|
105 |
|
@@ -164,15 +169,18 @@ class QuakeFlow_NC(datasets.GeneratorBasedBuilder):
|
|
164 |
or (self.config.name == "station_test")
|
165 |
):
|
166 |
waveforms = np.zeros([3, self.nt], dtype="float32")
|
167 |
-
station_attrs = event.attrs
|
168 |
|
169 |
for i, station_id in enumerate(station_ids):
|
|
|
170 |
waveforms[:, : self.nt] = event[station_id][:, : self.nt]
|
171 |
|
172 |
yield f"{event_id}/{station_id}", {
|
173 |
"data": waveforms,
|
174 |
"event_id": event_id,
|
175 |
"station_id": station_id,
|
|
|
|
|
|
|
176 |
}
|
177 |
|
178 |
elif (
|
@@ -180,13 +188,16 @@ class QuakeFlow_NC(datasets.GeneratorBasedBuilder):
|
|
180 |
or (self.config.name == "event_train")
|
181 |
or (self.config.name == "event_test")
|
182 |
):
|
|
|
183 |
waveforms = np.zeros([len(station_ids), 3, self.nt], dtype="float32")
|
184 |
|
|
|
|
|
185 |
for i, station_id in enumerate(station_ids):
|
186 |
waveforms[i, :, :] = event[station_id][:, : self.nt]
|
187 |
station_attrs = event[station_id].attrs
|
188 |
-
|
189 |
-
|
190 |
|
191 |
std = np.std(waveforms, axis=1, keepdims=True)
|
192 |
std[std == 0] = 1.0
|
|
|
91 |
"data": datasets.Array2D(shape=(3, self.nt), dtype="float32"),
|
92 |
"event_id": datasets.Value("string"),
|
93 |
"station_id": datasets.Value("string"),
|
94 |
+
"phase_type": datasets.Sequence(datasets.Value("string")),
|
95 |
+
"phase_index": datasets.Sequence(datasets.Value("int32")),
|
96 |
+
"snr": datasets.Sequence(datasets.Value("float32")),
|
97 |
}
|
98 |
)
|
99 |
|
|
|
103 |
"data": datasets.Array3D(shape=(None, 3, self.nt), dtype="float32"),
|
104 |
"event_id": datasets.Value("string"),
|
105 |
"station_ids": datasets.Sequence(datasets.Value("string")),
|
106 |
+
"phase_type": datasets.Sequence(datasets.Sequence(datasets.Value("string"))),
|
107 |
+
"phase_index": datasets.Sequence(datasets.Sequence(datasets.Value("int32"))),
|
108 |
}
|
109 |
)
|
110 |
|
|
|
169 |
or (self.config.name == "station_test")
|
170 |
):
|
171 |
waveforms = np.zeros([3, self.nt], dtype="float32")
|
|
|
172 |
|
173 |
for i, station_id in enumerate(station_ids):
|
174 |
+
station_attrs = event[station_id].attrs
|
175 |
waveforms[:, : self.nt] = event[station_id][:, : self.nt]
|
176 |
|
177 |
yield f"{event_id}/{station_id}", {
|
178 |
"data": waveforms,
|
179 |
"event_id": event_id,
|
180 |
"station_id": station_id,
|
181 |
+
"phase_type": station_attrs["phase_type"],
|
182 |
+
"phase_index": station_attrs["phase_index"],
|
183 |
+
"snr": station_attrs["snr"],
|
184 |
}
|
185 |
|
186 |
elif (
|
|
|
188 |
or (self.config.name == "event_train")
|
189 |
or (self.config.name == "event_test")
|
190 |
):
|
191 |
+
station_attrs = event[station_id].attrs
|
192 |
waveforms = np.zeros([len(station_ids), 3, self.nt], dtype="float32")
|
193 |
|
194 |
+
phase_type = []
|
195 |
+
phase_index = []
|
196 |
for i, station_id in enumerate(station_ids):
|
197 |
waveforms[i, :, :] = event[station_id][:, : self.nt]
|
198 |
station_attrs = event[station_id].attrs
|
199 |
+
phase_type.append(station_attrs["phase_type"])
|
200 |
+
phase_index.append(station_attrs["phase_index"])
|
201 |
|
202 |
std = np.std(waveforms, axis=1, keepdims=True)
|
203 |
std[std == 0] = 1.0
|