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.

This commit is contained in:
jakubkokowski 2024-03-28 12:29:29 +01:00
parent 94054bc391
commit 5c3ce04868
1 changed files with 5 additions and 3 deletions

View File

@ -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(