PhaseAssociator/qml2picks.py

19 lines
800 B
Python

from obspy import read_events
from seisbench.util import Pick as SBPick
def qml2picks(path_to_qml_picks, p_hint, s_hint):
c = read_events(path_to_qml_picks, format="QUAKEML")
picks = list()
for p in c.events[0].picks:
# PyOcto requires one character "P" and "S" hints.
if p.phase_hint == p_hint:
picks.append(
SBPick(trace_id=f"{p.waveform_id.network_code}.{p.waveform_id.station_code}.", start_time=p.time,
peak_time=p.time, end_time=p.time, phase="P"))
elif p.phase_hint == s_hint:
picks.append(
SBPick(trace_id=f"{p.waveform_id.network_code}.{p.waveform_id.station_code}.", start_time=p.time,
peak_time=p.time, end_time=p.time, phase="S"))
return picks