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