Datasets:

ArXiv:
License:
File size: 18,904 Bytes
0f141f9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "train files: [['1987.h5', '1988.h5', '1989.h5', '1990.h5', '1991.h5', '1992.h5', '1993.h5', '1994.h5', '1995.h5', '1996.h5', '1997.h5', '1998.h5', '1999.h5', '2000.h5', '2001.h5', '2002.h5', '2003.h5', '2004.h5', '2005.h5', '2006.h5', '2007.h5', '2008.h5', '2009.h5', '2010.h5', '2011.h5', '2012.h5', '2013.h5', '2014.h5', '2015.h5', '2016.h5', '2017.h5', '2018.h5', '2019.h5', '2020.h5', '2021.h5', '2022.h5'], ['1999.h5', '2000.h5', '2001.h5', '2002.h5', '2003.h5', '2004.h5', '2005.h5', '2006.h5', '2007.h5', '2008.h5', '2009.h5', '2010.h5', '2011.h5', '2012.h5', '2013.h5', '2014.h5', '2015.h5', '2016.h5', '2017.h5', '2018.h5', '2019.h5', '2020.h5', '2021.h5', '2022.h5']]\n",
      "test files: [['2023.h5'], ['2023.h5']]\n"
     ]
    }
   ],
   "source": [
    "# %%\n",
    "import os\n",
    "\n",
    "import h5py\n",
    "import matplotlib.pyplot as plt\n",
    "from tqdm import tqdm\n",
    "\n",
    "# %%\n",
    "h5_dirs = [\"NC/waveform_h5\", \"SC/waveform_h5\"]\n",
    "h5_out = \"waveform.h5\"\n",
    "h5_train = \"waveform_train.h5\"\n",
    "h5_test = \"waveform_test.h5\"\n",
    "\n",
    "# # %%\n",
    "# h5_dir = \"waveform_h5\"\n",
    "# h5_out = \"waveform.h5\"\n",
    "# h5_train = \"waveform_train.h5\"\n",
    "# h5_test = \"waveform_test.h5\"\n",
    "\n",
    "h5_file_lists = [sorted(os.listdir(h5_dir)) for h5_dir in h5_dirs]\n",
    "train_file_lists = [x[:-1] for x in h5_file_lists]\n",
    "test_file_lists = [x[-1:] for x in h5_file_lists]\n",
    "# train_files = h5_files\n",
    "# train_files = [x for x in train_files if (x != \"2014.h5\") and (x not in [])]\n",
    "# test_files = []\n",
    "print(f\"train files: {train_file_lists}\")\n",
    "print(f\"test files: {test_file_lists}\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "1987.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 21/21 [00:00<00:00, 13205.45it/s]\n",
      "1988.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 122/122 [00:00<00:00, 44093.50it/s]\n",
      "1989.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 145/145 [00:00<00:00, 48487.13it/s]\n",
      "1990.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 149/149 [00:00<00:00, 47098.60it/s]\n",
      "1991.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 161/161 [00:00<00:00, 42155.12it/s]\n",
      "1992.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 158/158 [00:00<00:00, 47980.02it/s]\n",
      "1993.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1647/1647 [00:00<00:00, 49726.60it/s]\n",
      "1994.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1625/1625 [00:00<00:00, 49557.51it/s]\n",
      "1995.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4595/4595 [00:00<00:00, 48027.90it/s]\n",
      "1996.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4287/4287 [00:00<00:00, 49844.30it/s]\n",
      "1997.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 6260/6260 [00:00<00:00, 57234.54it/s]\n",
      "1998.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4568/4568 [00:00<00:00, 57102.95it/s]\n",
      "1999.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 6024/6024 [00:00<00:00, 57112.18it/s]\n",
      "2000.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1105/1105 [00:00<00:00, 53676.60it/s]\n",
      "2001.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2679/2679 [00:00<00:00, 63035.62it/s]\n",
      "2002.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 7506/7506 [00:00<00:00, 60202.90it/s]\n",
      "2003.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 8420/8420 [00:00<00:00, 47666.41it/s]\n",
      "2004.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15232/15232 [00:00<00:00, 47821.13it/s]\n",
      "2005.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 8465/8465 [00:00<00:00, 52576.08it/s]\n",
      "2006.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 7269/7269 [00:00<00:00, 47932.45it/s]\n",
      "2007.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 12722/12722 [00:00<00:00, 52216.50it/s]\n",
      "2008.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 11822/11822 [00:00<00:00, 43993.57it/s]\n",
      "2009.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 11412/11412 [00:00<00:00, 42015.39it/s]\n",
      "2010.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 11973/11973 [00:00<00:00, 45174.53it/s]\n",
      "2011.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 13848/13848 [00:00<00:00, 47253.07it/s]\n",
      "2012.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15738/15738 [00:00<00:00, 40880.02it/s]\n",
      "2013.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 16020/16020 [00:00<00:00, 38879.41it/s]\n",
      "2014.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 21804/21804 [00:00<00:00, 44580.12it/s]\n",
      "2015.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 14230/14230 [00:00<00:00, 41559.02it/s]\n",
      "2016.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 13977/13977 [00:00<00:00, 39143.14it/s]\n",
      "2017.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 18099/18099 [00:00<00:00, 38739.83it/s]\n",
      "2018.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 14036/14036 [00:00<00:00, 41671.15it/s]\n",
      "2019.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15064/15064 [00:00<00:00, 43094.97it/s]\n",
      "2020.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 16155/16155 [00:00<00:00, 36563.74it/s]\n",
      "2021.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15581/15581 [00:00<00:00, 38802.18it/s]\n",
      "2022.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 10898/10898 [00:00<00:00, 40756.44it/s]\n",
      "2023.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 11085/11085 [00:00<00:00, 39294.58it/s]\n",
      "1999.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 24/24 [00:00<00:00, 30849.92it/s]\n",
      "2000.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 27/27 [00:00<00:00, 26226.54it/s]\n",
      "2001.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 29/29 [00:00<00:00, 30715.86it/s]\n",
      "2002.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 34/34 [00:00<00:00, 34091.88it/s]\n",
      "2003.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 73/73 [00:00<00:00, 28934.44it/s]\n",
      "2004.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 740/740 [00:00<00:00, 33500.47it/s]\n",
      "2005.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1249/1249 [00:00<00:00, 35171.48it/s]\n",
      "2006.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 657/657 [00:00<00:00, 34450.03it/s]\n",
      "2007.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1743/1743 [00:00<00:00, 35092.29it/s]\n",
      "2008.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 12570/12570 [00:00<00:00, 35370.94it/s]\n",
      "2009.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 14282/14282 [00:00<00:00, 40763.96it/s]\n",
      "2010.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 34818/34818 [00:00<00:00, 40016.59it/s]\n",
      "2011.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 13427/13427 [00:00<00:00, 36651.35it/s]\n",
      "2012.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15416/15416 [00:00<00:00, 38639.99it/s]\n",
      "2013.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 17056/17056 [00:00<00:00, 40840.94it/s]\n",
      "2014.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 13937/13937 [00:00<00:00, 39126.77it/s]\n",
      "2015.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15311/15311 [00:00<00:00, 37447.81it/s]\n",
      "2016.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15470/15470 [00:00<00:00, 36607.05it/s]\n",
      "2017.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15771/15771 [00:00<00:00, 36313.59it/s]\n",
      "2018.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 20344/20344 [00:00<00:00, 35744.70it/s]\n",
      "2019.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 60424/60424 [00:01<00:00, 36248.55it/s]\n",
      "2020.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 33621/33621 [00:00<00:00, 36729.94it/s]\n",
      "2021.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15206/15206 [00:00<00:00, 35751.59it/s]\n",
      "2022.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 12532/12532 [00:00<00:00, 34850.17it/s]\n",
      "2023.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 13410/13410 [00:00<00:00, 34365.93it/s]\n",
      "1987.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 21/21 [00:00<00:00, 42184.09it/s]\n",
      "1988.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 122/122 [00:00<00:00, 54774.68it/s]\n",
      "1989.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 145/145 [00:00<00:00, 53522.32it/s]\n",
      "1990.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 149/149 [00:00<00:00, 55506.82it/s]\n",
      "1991.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 161/161 [00:00<00:00, 51115.20it/s]\n",
      "1992.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 158/158 [00:00<00:00, 51384.05it/s]\n",
      "1993.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1647/1647 [00:00<00:00, 54106.28it/s]\n",
      "1994.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1625/1625 [00:00<00:00, 55482.02it/s]\n",
      "1995.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4595/4595 [00:00<00:00, 58728.18it/s]\n",
      "1996.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4287/4287 [00:00<00:00, 55312.14it/s]\n",
      "1997.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 6260/6260 [00:00<00:00, 52698.71it/s]\n",
      "1998.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 4568/4568 [00:00<00:00, 53222.39it/s]\n",
      "1999.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 6024/6024 [00:00<00:00, 52687.69it/s]\n",
      "2000.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1105/1105 [00:00<00:00, 58423.12it/s]\n",
      "2001.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 2679/2679 [00:00<00:00, 57428.62it/s]\n",
      "2002.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 7506/7506 [00:00<00:00, 58583.76it/s]\n",
      "2003.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 8420/8420 [00:00<00:00, 54412.15it/s]\n",
      "2004.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15232/15232 [00:00<00:00, 57007.87it/s]\n",
      "2005.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 8465/8465 [00:00<00:00, 54145.10it/s]\n",
      "2006.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 7269/7269 [00:00<00:00, 51191.79it/s]\n",
      "2007.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 12722/12722 [00:00<00:00, 47122.06it/s]\n",
      "2008.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 11822/11822 [00:00<00:00, 44205.48it/s]\n",
      "2009.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 11412/11412 [00:00<00:00, 43242.28it/s]\n",
      "2010.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 11973/11973 [00:00<00:00, 42805.26it/s]\n",
      "2011.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 13848/13848 [00:00<00:00, 42280.57it/s]\n",
      "2012.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15738/15738 [00:00<00:00, 41685.79it/s]\n",
      "2013.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 16020/16020 [00:00<00:00, 43329.98it/s]\n",
      "2014.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 21804/21804 [00:00<00:00, 44983.11it/s]\n",
      "2015.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 14230/14230 [00:00<00:00, 44135.09it/s]\n",
      "2016.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 13977/13977 [00:00<00:00, 44137.57it/s]\n",
      "2017.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 18099/18099 [00:00<00:00, 42492.87it/s]\n",
      "2018.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 14036/14036 [00:00<00:00, 39025.89it/s]\n",
      "2019.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15064/15064 [00:00<00:00, 38635.81it/s]\n",
      "2020.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 16155/16155 [00:00<00:00, 38816.08it/s]\n",
      "2021.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15581/15581 [00:00<00:00, 39043.39it/s]\n",
      "2022.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 10898/10898 [00:00<00:00, 39888.76it/s]\n",
      "1999.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 24/24 [00:00<00:00, 34532.86it/s]\n",
      "2000.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 27/27 [00:00<00:00, 26690.13it/s]\n",
      "2001.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 29/29 [00:00<00:00, 30700.36it/s]\n",
      "2002.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 34/34 [00:00<00:00, 35029.80it/s]\n",
      "2003.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 73/73 [00:00<00:00, 35970.89it/s]\n",
      "2004.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 740/740 [00:00<00:00, 36212.21it/s]\n",
      "2005.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1249/1249 [00:00<00:00, 40190.00it/s]\n",
      "2006.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 657/657 [00:00<00:00, 38375.36it/s]\n",
      "2007.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 1743/1743 [00:00<00:00, 37327.53it/s]\n",
      "2008.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 12570/12570 [00:00<00:00, 41988.87it/s]\n",
      "2009.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 14282/14282 [00:00<00:00, 42669.64it/s]\n",
      "2010.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 34818/34818 [00:00<00:00, 42444.23it/s]\n",
      "2011.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 13427/13427 [00:00<00:00, 37659.90it/s]\n",
      "2012.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15416/15416 [00:00<00:00, 37632.25it/s]\n",
      "2013.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 17056/17056 [00:00<00:00, 37530.78it/s]\n",
      "2014.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 13937/13937 [00:00<00:00, 37437.27it/s]\n",
      "2015.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15311/15311 [00:00<00:00, 39536.43it/s]\n",
      "2016.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15470/15470 [00:00<00:00, 38313.60it/s]\n",
      "2017.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15771/15771 [00:00<00:00, 40890.63it/s]\n",
      "2018.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 20344/20344 [00:00<00:00, 38624.25it/s]\n",
      "2019.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 60424/60424 [00:01<00:00, 35660.70it/s]\n",
      "2020.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 33621/33621 [00:00<00:00, 36877.49it/s]\n",
      "2021.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 15206/15206 [00:00<00:00, 36150.85it/s]\n",
      "2022.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 12532/12532 [00:00<00:00, 37151.34it/s]\n",
      "2023.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 11085/11085 [00:00<00:00, 55073.48it/s]\n",
      "2023.h5: 100%|β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ| 13410/13410 [00:00<00:00, 55802.88it/s]\n"
     ]
    }
   ],
   "source": [
    "# %%\n",
    "with h5py.File(h5_out, \"w\") as fp:\n",
    "    # external linked file\n",
    "    for h5_dir, h5_files in zip(h5_dirs, h5_file_lists):\n",
    "        for h5_file in h5_files:\n",
    "            with h5py.File(os.path.join(h5_dir, h5_file), \"r\") as f:\n",
    "                for event in tqdm(f.keys(), desc=h5_file, total=len(f.keys())):\n",
    "                    if event not in fp:\n",
    "                        fp[event] = h5py.ExternalLink(os.path.join(h5_dir, h5_file), event)\n",
    "                    else:\n",
    "                        print(f\"{event} already exists\")\n",
    "                        continue\n",
    "\n",
    "# %%\n",
    "with h5py.File(h5_train, \"w\") as fp:\n",
    "    # external linked file\n",
    "    for h5_dir, h5_files in zip(h5_dirs, train_file_lists):\n",
    "        for h5_file in h5_files:\n",
    "            with h5py.File(os.path.join(h5_dir, h5_file), \"r\") as f:\n",
    "                for event in tqdm(f.keys(), desc=h5_file, total=len(f.keys())):\n",
    "                    if event not in fp:\n",
    "                        fp[event] = h5py.ExternalLink(os.path.join(h5_dir, h5_file), event)\n",
    "                    else:\n",
    "                        print(f\"{event} already exists\")\n",
    "                        continue\n",
    "\n",
    "# %%\n",
    "with h5py.File(h5_test, \"w\") as fp:\n",
    "    # external linked file\n",
    "    for h5_dir, h5_files in zip(h5_dirs, test_file_lists):\n",
    "        for h5_file in h5_files:\n",
    "            with h5py.File(os.path.join(h5_dir, h5_file), \"r\") as f:\n",
    "                for event in tqdm(f.keys(), desc=h5_file, total=len(f.keys())):\n",
    "                    if event not in fp:\n",
    "                        fp[event] = h5py.ExternalLink(os.path.join(h5_dir, h5_file), event)\n",
    "                    else:\n",
    "                        print(f\"{event} already exists\")\n",
    "                        continue\n",
    "\n",
    "# %%\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "import h5py"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "653073"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "h5_fp = h5py.File(\"waveform.h5\", \"r\")\n",
    "len(list(h5_fp.keys()))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/tmp/ipykernel_3422288/108058564.py:9: DtypeWarning: Columns (11) have mixed types. Specify dtype option on import or set low_memory=False.\n",
      "  df = pd.read_csv(f\"{dir}/{csv_file}\")\n",
      "/tmp/ipykernel_3422288/108058564.py:9: DtypeWarning: Columns (11) have mixed types. Specify dtype option on import or set low_memory=False.\n",
      "  df = pd.read_csv(f\"{dir}/{csv_file}\")\n",
      "/tmp/ipykernel_3422288/108058564.py:9: DtypeWarning: Columns (11) have mixed types. Specify dtype option on import or set low_memory=False.\n",
      "  df = pd.read_csv(f\"{dir}/{csv_file}\")\n"
     ]
    }
   ],
   "source": [
    "import pandas as pd\n",
    "\n",
    "dirs = [\"NC\", \"SC\"]\n",
    "csv_files = ['events.csv', 'events_test.csv', 'events_train.csv', 'picks.csv', 'picks_test.csv', 'picks_train.csv']\n",
    "\n",
    "for csv_file in csv_files:\n",
    "    dfs = []\n",
    "    for dir in dirs:\n",
    "        df = pd.read_csv(f\"{dir}/{csv_file}\")\n",
    "        dfs.append(df)\n",
    "    df = pd.concat(dfs)\n",
    "    df.to_csv(csv_file, index=False, na_rep='')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "scp [email protected]:/data/wanghy/events_test.csv ./\n",
    "scp [email protected]:/data/wanghy/picks.csv ./\n",
    "scp [email protected]:/data/wanghy/picks_train.csv ./\n",
    "scp [email protected]:/data/wanghy/picks_test.csv ./\n",
    "scp [email protected]:/data/wanghy/waveform.h5 ./\n",
    "scp [email protected]:/data/wanghy/waveform_test.h5 ./\n",
    "scp [email protected]:/data/wanghy/waveform_train.h5 ./"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "obspy",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}