Skip to content

Commit

Permalink
Make parse_qml_event_picks() behave like parse_asdf_event_picks()
Browse files Browse the repository at this point in the history
The function was previously named parse_qml_file()
  • Loading branch information
claudiodsf committed Jul 19, 2024
1 parent b1fd02a commit 3d98b25
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions sourcespec2/input/event_and_picks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from .event_parsers import (
parse_source_spec_event_file,
parse_hypo71_hypocenter, parse_hypo71_picks, parse_hypo2000_file,
parse_qml_file, parse_asdf_event_picks
parse_qml_event_picks, parse_asdf_event_picks
)
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])

Expand Down Expand Up @@ -102,7 +102,7 @@ def read_event_and_picks(trace1=None):
picks = parse_hypo71_picks()
# parse QML file
if config.options.qml_file is not None:
ssp_event, picks = parse_qml_file()
ssp_event, picks = parse_qml_event_picks(config.options.qml_file)
# parse ASDF file
if config.options.asdf_file is not None:
ssp_event, picks = parse_asdf_event_picks(config.options.asdf_file)
Expand Down
2 changes: 1 addition & 1 deletion sourcespec2/input/event_parsers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
from .hypo71 import parse_hypo71_hypocenter, parse_hypo71_picks # noqa
from .hypo2000 import parse_hypo2000_file # noqa
from .obspy_catalog import parse_obspy_catalog # noqa
from .quakeml import parse_qml_file # noqa
from .quakeml import parse_qml_event_picks # noqa
from .source_spec_event import parse_source_spec_event_file # noqa
12 changes: 8 additions & 4 deletions sourcespec2/input/event_parsers/quakeml.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,30 @@
"""
import logging
from obspy import read_events
from ...setup import config, ssp_exit
from ...setup import ssp_exit
from .obspy_catalog import parse_obspy_catalog
logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1])


def parse_qml_file():
def parse_qml_event_picks(qml_file, event_id=None):
"""
Parse event metadata and picks from a QuakeML file.
:param qml_file: Path to the QuakeML file.
:type qml_file: str
:param event_id: event id
:type event_id: str
:return: a tuple of (SSPEvent, picks)
:rtype: tuple
"""
qml_file = config.options.qml_file
if qml_file is None:
ssp_event = None
picks = []
return ssp_event, picks
try:
obspy_catalog = read_events(qml_file)
return parse_obspy_catalog(obspy_catalog, file_name=qml_file)
return parse_obspy_catalog(obspy_catalog, event_id, qml_file)
except Exception as err:
logger.error(err)
ssp_exit(1)

0 comments on commit 3d98b25

Please sign in to comment.