|
|
|
import multiprocessing as mp |
|
import os |
|
from glob import glob |
|
|
|
import h5py |
|
import numpy as np |
|
import pandas as pd |
|
from tqdm import tqdm |
|
|
|
|
|
data_path = "waveform_h5" |
|
result_path = "waveform_h5" |
|
file_list = sorted(glob(f"{data_path}/*.h5")) |
|
|
|
file_size = {file: os.path.getsize(file)/1e9 for file in file_list} |
|
|
|
|
|
MAX_SIZE = 45 |
|
for file, size in file_size.items(): |
|
if size > MAX_SIZE: |
|
|
|
NUM_FILES = int(np.ceil(size / MAX_SIZE)) |
|
with h5py.File(file, "r") as f: |
|
event_ids = list(f.keys()) |
|
for event_id in tqdm(event_ids, desc=f"Processing {file}"): |
|
index = int(event_id[-1]) % NUM_FILES |
|
|
|
with h5py.File(f"{data_path}/{file.split('/')[-1].replace('.h5', '')}_{index}.h5", "a") as g: |
|
|
|
|
|
|
|
|
|
f.copy(event_id, g) |
|
|
|
|
|
|
|
|