From a9cd53886b8d7336adcb12c1c215264ed5566020 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Mon, 11 Apr 2016 05:47:38 +0200 Subject: [PATCH] [enhancement, task] there was no routine to read obs pick files available; default values for autopicking should be the same for all parts of PyLoT, thus defaults should be defined only once --- QtPyLoT.py | 6 +++--- pylot/core/read/io.py | 20 +++++++++++++++++++- pylot/core/util/defaults.py | 4 ++++ 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/QtPyLoT.py b/QtPyLoT.py index 08a67127..285e2ffb 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -45,7 +45,8 @@ from pylot.core.read.inputs import FilterOptions, AutoPickParameter from pylot.core.pick.autopick import autopickevent from pylot.core.read.io import picks_from_evt from pylot.core.loc.nll import locate as locateNll -from pylot.core.util.defaults import FILTERDEFAULTS, COMPNAME_MAP +from pylot.core.util.defaults import FILTERDEFAULTS, COMPNAME_MAP,\ + AUTOMATIC_DEFAULTS from pylot.core.util.errors import FormatError, DatastructureError, \ OverwriteError from pylot.core.util.connection import checkurl @@ -689,8 +690,7 @@ class MainWindow(QMainWindow): self.logDockWidget.setWidget(self.listWidget) self.addDockWidget(Qt.LeftDockWidgetArea, self.logDockWidget) self.addListItem('loading default values for local data ...') - home = os.path.expanduser("~") - autopick_parameter = AutoPickParameter('%s/.pylot/autoPyLoT_local.in' % home) + autopick_parameter = AutoPickParameter(AUTOMATIC_DEFAULTS) self.addListItem(str(autopick_parameter)) # Create the worker thread and run it diff --git a/pylot/core/read/io.py b/pylot/core/read/io.py index b499d911..f34a7616 100644 --- a/pylot/core/read/io.py +++ b/pylot/core/read/io.py @@ -135,6 +135,24 @@ def readPILOTEvent(phasfn=None, locfn=None, authority_id=None, **kwargs): raise AttributeError('{0} - Matlab LOC files {1} and {2} contains \ insufficient data!'.format(e, phasfn, locfn)) +def picks_from_obs(fn): + picks = dict() + station_name = str() + for line in open(fn, 'r'): + if line.startswith('#'): + continue + else: + phase_line = line.split() + if not station_name == phase_line[0]: + phase = dict() + station_name = phase_line[0] + phase_name = phase_line[4].upper() + pick = UTCDateTime(phase_line[6] + phase_line[7] + phase_line[8]) + phase[phase_name] = dict(mpp=pick, fm=phase_line[5]) + picks[station_name] = phase + return picks + + def picks_from_evt(evt): ''' Takes an Event object and return the pick dictionary commonly used within @@ -170,4 +188,4 @@ def picks_from_evt(evt): onsets[pick.phase_hint] = phase.copy() picks[station] = onsets.copy() - return picks \ No newline at end of file + return picks diff --git a/pylot/core/util/defaults.py b/pylot/core/util/defaults.py index c74b1332..d42a0786 100644 --- a/pylot/core/util/defaults.py +++ b/pylot/core/util/defaults.py @@ -43,6 +43,10 @@ FILTERDEFAULTS = readFilterInformation(os.path.join(os.path.expanduser('~'), '.pylot', 'filter.in')) +AUTOMATIC_DEFAULTS = os.path.join(os.path.expanduser('~'), + '.pylot', + 'autoPyLoT.in') + OUTPUTFORMATS = {'.xml': 'QUAKEML', '.cnv': 'CNV', '.obs': 'NLLOC_OBS'}