Skip to content

Commit

Permalink
Replace +2 blocks w pack_stream_into_run_group
Browse files Browse the repository at this point in the history
Also, in loop where there is only 1 run in runlist, but
multiple streams from FDSN, cast start,end from times[0],[1]
so that the rest of the logic is same as other cases

[Issue(s): #153]
  • Loading branch information
kkappler committed Jun 17, 2023
1 parent 57da698 commit 01b900c
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions mth5/clients/fdsn.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@ def wrangle_runs_into_containers_v1(
for run_id, times in enumerate(
zip(trace_start_times, trace_end_times), 1
):
start = times[0]
end = times[1]
run_group = m.stations_group.get_station(station_id).add_run(
f"{run_id:03}"
)
run_stream = msstreams.slice(
UTCDateTime(times[0]), UTCDateTime(times[1])
)
run_stream = msstreams.slice(UTCDateTime(start), UTCDateTime(end))
run_group = self.pack_stream_into_run_group(run_group, run_stream)
elif n_times == 1:
run_group = m.stations_group.get_station(station_id).add_run(
Expand Down Expand Up @@ -327,9 +327,9 @@ def wrangle_runs_into_containers_v1(
run_stream = msstreams.slice(
UTCDateTime(start), UTCDateTime(end)
)
run_ts_obj = RunTS()
run_ts_obj.from_obspy_stream(run_stream, run_group.metadata)
run_group.from_runts(run_ts_obj)
run_group = self.pack_stream_into_run_group(
run_group, run_stream
)
else:
continue
else:
Expand Down Expand Up @@ -363,16 +363,16 @@ def wrangle_runs_into_containers_v2(
for run_id, times in enumerate(
zip(trace_start_times, trace_end_times), 1
):
start = times[0]
end = times[1]
run_group = survey_group.stations_group.get_station(
station_id
).add_run(f"{run_id:03}")
run_stream = msstreams.slice(
UTCDateTime(times[0]),
UTCDateTime(times[1]),
UTCDateTime(start),
UTCDateTime(end),
)
run_ts_obj = RunTS()
run_ts_obj.from_obspy_stream(run_stream, run_group.metadata)
run_group.from_runts(run_ts_obj)
run_group = self.pack_stream_into_run_group(run_group, run_stream)
elif n_times == 1:
run_group = survey_group.stations_group.get_station(station_id).add_run(
run_list[0]
Expand Down

0 comments on commit 01b900c

Please sign in to comment.