diff --git a/sourcespec2/input/event_and_picks.py b/sourcespec2/input/event_and_picks.py index c32d20ea..7c1434a7 100644 --- a/sourcespec2/input/event_and_picks.py +++ b/sourcespec2/input/event_and_picks.py @@ -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]) @@ -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) diff --git a/sourcespec2/input/event_parsers/__init__.py b/sourcespec2/input/event_parsers/__init__.py index a3e3b588..e3769c37 100644 --- a/sourcespec2/input/event_parsers/__init__.py +++ b/sourcespec2/input/event_parsers/__init__.py @@ -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 diff --git a/sourcespec2/input/event_parsers/quakeml.py b/sourcespec2/input/event_parsers/quakeml.py index d9244d57..624b7ee9 100644 --- a/sourcespec2/input/event_parsers/quakeml.py +++ b/sourcespec2/input/event_parsers/quakeml.py @@ -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)