From c760ea394ca2ba9a0543975ec1730b2cf80827c4 Mon Sep 17 00:00:00 2001 From: Darius Arnold <Darius.Arnold@ruhr-uni-bochum.de> Date: Sat, 26 Aug 2017 01:53:38 +0200 Subject: [PATCH] [add] remove picks with weight > 3 from pickdictionary after autopicking --- QtPyLoT.py | 3 ++- pylot/core/pick/utils.py | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/QtPyLoT.py b/QtPyLoT.py index 424c9264..4cfdeee2 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -64,7 +64,7 @@ from pylot.core.io.data import Data from pylot.core.io.inputs import FilterOptions, PylotParameter from autoPyLoT import autoPyLoT from pylot.core.pick.compare import Comparison -from pylot.core.pick.utils import symmetrize_error, getQualityFromUncertainty +from pylot.core.pick.utils import symmetrize_error, getQualityFromUncertainty, removePicksAbove from pylot.core.io.phases import picksdict_from_picks import pylot.core.loc.nll as nll from pylot.core.util.defaults import FILTERDEFAULTS, SetChannelComponents @@ -1999,6 +1999,7 @@ class MainWindow(QMainWindow): def finalizeAutoPick(self, result): self.apw.enable(True) if result: + result = removePicksAbove(result, 3) self.init_canvas_dict_wadatijack() for eventID in result.keys(): event = self.get_event_from_id(eventID) diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index 6a214b2e..1ebfdbd5 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -1146,6 +1146,30 @@ def getQualityFromUncertainty(uncertainty, Errors): return quality +def removePicksAbove(pickDic, minWeight): + '''remove picks from pick dicitonary with a weight > minweight''' + newdic = {} + for event in pickDic.keys(): + newdic[event] = {} + + for eventKey, eventDic in pickDic.items(): + for station, phases in eventDic.items(): + if phases['P']['weight'] < minWeight or phases['S']['weight'] < minWeight: + # dont append stations that will be empty to output dict + newdic[eventKey][station] = {} + if len(phases) > 2: + # copy over other values beside P/S information + additional_info = phases.copy() + if 'P' in phases.keys(): + additional_info.pop('P') + if 'S' in phases.keys(): + additional_info.pop('S') + newdic[eventKey][station].update(additional_info) + for phasename, phaseinfo in phases.items(): + if phasename in ('P', 'S') and phaseinfo['weight'] < minWeight: + newdic[eventKey][station].update({phasename: phaseinfo}) + return newdic + if __name__ == '__main__': import doctest