Skip to content

Commit

Permalink
postprocess codes
Browse files Browse the repository at this point in the history
YijianZhou committed Dec 18, 2024
1 parent 16bd137 commit c95c446
Showing 2 changed files with 2 additions and 17 deletions.
4 changes: 2 additions & 2 deletions preprocess/cut_events.py
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
from torch.utils.data import Dataset, DataLoader
from obspy import read, UTCDateTime
from signal_lib import preprocess, obspy_slice
from reader import read_fpha, get_tk_data, dtime2str
from reader import read_fpha, get_data_dict, dtime2str
shutil.copyfile('../config.py', 'config.py')
import config
import warnings
@@ -19,7 +19,7 @@
# signal process
num_workers = cfg.num_workers
win_len = cfg.win_event
get_data_dict = get_tk_data # modify this if using customized function
get_data_dict = get_data_dict # modify this if using customized function
samp_rate = cfg.samp_rate
freq_band = cfg.freq_band

15 changes: 0 additions & 15 deletions preprocess/reader.py
Original file line number Diff line number Diff line change
@@ -57,18 +57,3 @@ def dtime2str(dtime):

""" Custimized functions
"""
def get_tk_data(date, data_dir):
# get data paths
data_dict = {}
date_code = '{:0>4}{:0>2}{:0>2}'.format(date.year, date.month, date.day)
st_paths = sorted(glob.glob(os.path.join(data_dir, date_code, '*')))
for st_path in st_paths:
fname = os.path.basename(st_path)
net_sta = '.'.join(fname.split('.')[0:2])
if net_sta in data_dict: data_dict[net_sta].append(st_path)
else: data_dict[net_sta] = [st_path]
# drop bad sta
todel = [net_sta for net_sta in data_dict if len(data_dict[net_sta])<3]
for net_sta in todel: data_dict.pop(net_sta)
for net_sta in data_dict: data_dict[net_sta] = data_dict[net_sta][0:3]
return data_dict

0 comments on commit c95c446

Please sign in to comment.