From 51876d68fbe749a6fa06d24a774ed7f6b2684991 Mon Sep 17 00:00:00 2001 From: Claudio Satriano Date: Fri, 19 Jul 2024 12:25:35 +0200 Subject: [PATCH] Command line option to parse ASDF file for event and picks information Note: the option will allow also reading traces and metadata from the ASDF file (to be implemented in the next commits). Also, renamed asdf.py to asdf_event.py --- sourcespec2/input/event_and_picks.py | 6 +++++- sourcespec2/input/event_parsers/__init__.py | 2 +- sourcespec2/input/event_parsers/{asdf.py => asdf_event.py} | 0 sourcespec2/ssp_parse_arguments.py | 7 +++++++ 4 files changed, 13 insertions(+), 2 deletions(-) rename sourcespec2/input/event_parsers/{asdf.py => asdf_event.py} (100%) diff --git a/sourcespec2/input/event_and_picks.py b/sourcespec2/input/event_and_picks.py index 6c073716..c32d20ea 100644 --- a/sourcespec2/input/event_and_picks.py +++ b/sourcespec2/input/event_and_picks.py @@ -19,8 +19,9 @@ import logging from ..setup import config, ssp_exit from .event_parsers import ( + parse_source_spec_event_file, parse_hypo71_hypocenter, parse_hypo71_picks, parse_hypo2000_file, - parse_qml_file, parse_source_spec_event_file + parse_qml_file, parse_asdf_event_picks ) logger = logging.getLogger(__name__.rsplit('.', maxsplit=1)[-1]) @@ -102,6 +103,9 @@ def read_event_and_picks(trace1=None): # parse QML file if config.options.qml_file is not None: ssp_event, picks = parse_qml_file() + # parse ASDF file + if config.options.asdf_file is not None: + ssp_event, picks = parse_asdf_event_picks(config.options.asdf_file) if ssp_event is not None: _log_event_info(ssp_event) diff --git a/sourcespec2/input/event_parsers/__init__.py b/sourcespec2/input/event_parsers/__init__.py index c50957e4..a3e3b588 100644 --- a/sourcespec2/input/event_parsers/__init__.py +++ b/sourcespec2/input/event_parsers/__init__.py @@ -9,7 +9,7 @@ CeCILL Free Software License Agreement v2.1 (http://www.cecill.info/licences.en.html) """ -from .asdf import parse_asdf_event_picks # noqa +from .asdf_event import parse_asdf_event_picks # noqa 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 diff --git a/sourcespec2/input/event_parsers/asdf.py b/sourcespec2/input/event_parsers/asdf_event.py similarity index 100% rename from sourcespec2/input/event_parsers/asdf.py rename to sourcespec2/input/event_parsers/asdf_event.py diff --git a/sourcespec2/ssp_parse_arguments.py b/sourcespec2/ssp_parse_arguments.py index dda63df7..3ef87a7e 100644 --- a/sourcespec2/ssp_parse_arguments.py +++ b/sourcespec2/ssp_parse_arguments.py @@ -118,6 +118,13 @@ def _init_parser(description, epilog, nargs): help='get picks and hypocenter information from QuakeML FILE', metavar='FILE' ) + parser.add_argument( + '-a', '--asdffile', dest='asdf_file', + action='store', default=None, + help='get picks, hypocenter information, traces and metadata from\n' + 'ASDF FILE', + metavar='FILE' + ) parser.add_argument( '-H', '--hypocenter', dest='hypo_file', action='store', default=None,