From 5c3ce04868b6c25613d22cba8aaeba243f358ab3 Mon Sep 17 00:00:00 2001 From: jakubkokowski Date: Thu, 28 Mar 2024 12:29:29 +0100 Subject: [PATCH] Fix. Merge traces from the same station after loading waveforms, use real channel names (i.e. not only EHZ, EHN, EHE) and stop trying to use zero length streams. --- scripts/mseeds_to_seisbench.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/mseeds_to_seisbench.py b/scripts/mseeds_to_seisbench.py index b8cf4c5..e36d2a3 100644 --- a/scripts/mseeds_to_seisbench.py +++ b/scripts/mseeds_to_seisbench.py @@ -132,9 +132,10 @@ def get_three_channels_trace_paths(input_path, trace_params): day_of_year = pd.Timestamp(str(trace_params["time"])).day_of_year net = trace_params["station_network_code"] station = trace_params["station_code"] - + channel_base = trace_params["trace_channel"] paths = [] - for channel in ["EHE", "EHN", "EHZ"]: + for ch in ["E", "N", "Z"]: + channel = channel_base[:-1] + ch paths.append( f"{input_path}/{year}/{net}/{station}/{channel}.D/{net}.{station}..{channel}.D.{year}.{day_of_year:03}") return paths @@ -178,6 +179,7 @@ def load_stream(input_path, trace_params, time_before=60, time_after=60): print(f"no data in: {trace_path}") else: sampling_rate = stream.traces[0].stats.sampling_rate + stream.merge() return sampling_rate, stream @@ -224,7 +226,7 @@ def convert_mseed_to_seisbench_format(input_path, catalog_path, output_path): trace_params = get_trace_params(picks[0]) sampling_rate, stream = load_stream(input_path, trace_params) - if stream is None: + if stream is None or len(stream.traces) == 0: continue actual_t_start, data, _ = sbu.stream_to_array(