[refactor] rename getQualityFromUncertainty function to be more pythonic

This commit is contained in:
Darius Arnold 2018-05-29 18:53:38 +02:00
parent 7910df3cc9
commit c38e3eb07a
7 changed files with 18 additions and 18 deletions

View File

@ -67,7 +67,7 @@ from pylot.core.io.data import Data
from pylot.core.io.inputs import FilterOptions, PylotParameter from pylot.core.io.inputs import FilterOptions, PylotParameter
from autoPyLoT import autoPyLoT from autoPyLoT import autoPyLoT
from pylot.core.pick.compare import Comparison from pylot.core.pick.compare import Comparison
from pylot.core.pick.utils import symmetrize_error, getQualityFromUncertainty from pylot.core.pick.utils import symmetrize_error, get_quality_class
from pylot.core.io.phases import picksdict_from_picks from pylot.core.io.phases import picksdict_from_picks
import pylot.core.loc.nll as nll import pylot.core.loc.nll as nll
from pylot.core.util.defaults import FILTERDEFAULTS, SetChannelComponents from pylot.core.util.defaults import FILTERDEFAULTS, SetChannelComponents
@ -1243,7 +1243,7 @@ class MainWindow(QMainWindow):
for phasename, pick in picks.items(): for phasename, pick in picks.items():
if not type(pick) in [dict, AttribDict]: if not type(pick) in [dict, AttribDict]:
continue continue
if getQualityFromUncertainty(has_spe(pick), phaseErrors[self.getPhaseID(phasename)]) < 4: if get_quality_class(has_spe(pick), phaseErrors[self.getPhaseID(phasename)]) < 4:
ma_count[ma] += 1 ma_count[ma] += 1
event_ref = event.isRefEvent() event_ref = event.isRefEvent()
@ -2519,10 +2519,10 @@ class MainWindow(QMainWindow):
# get quality classes # get quality classes
if self.getPhaseID(phase) == 'P': if self.getPhaseID(phase) == 'P':
quality = getQualityFromUncertainty(picks['spe'], self._inputs['timeerrorsP']) quality = get_quality_class(picks['spe'], self._inputs['timeerrorsP'])
phaseID = 'P' phaseID = 'P'
elif self.getPhaseID(phase) == 'S': elif self.getPhaseID(phase) == 'S':
quality = getQualityFromUncertainty(picks['spe'], self._inputs['timeerrorsS']) quality = get_quality_class(picks['spe'], self._inputs['timeerrorsS'])
phaseID = 'S' phaseID = 'S'
mpp = picks['mpp'] - stime mpp = picks['mpp'] - stime
@ -2870,7 +2870,7 @@ class MainWindow(QMainWindow):
for phasename, pick in picks.items(): for phasename, pick in picks.items():
if not type(pick) in [dict, AttribDict]: if not type(pick) in [dict, AttribDict]:
continue continue
if getQualityFromUncertainty(has_spe(pick), phaseErrors[self.getPhaseID(phasename)]) < 4: if get_quality_class(has_spe(pick), phaseErrors[self.getPhaseID(phasename)]) < 4:
ma_count[ma] += 1 ma_count[ma] += 1
# init table items for current row # init table items for current row

View File

@ -943,7 +943,7 @@ def getQualitiesfromxml(xmlnames, ErrorsP, ErrorsS, plotflag=1):
:rtype: :rtype:
""" """
from pylot.core.pick.utils import getQualityFromUncertainty from pylot.core.pick.utils import get_quality_class
from pylot.core.util.utils import loopIdentifyPhase, identifyPhase from pylot.core.util.utils import loopIdentifyPhase, identifyPhase
# read all onset weights # read all onset weights
@ -991,7 +991,7 @@ def getQualitiesfromxml(xmlnames, ErrorsP, ErrorsS, plotflag=1):
for Pick in arrivals_copy: for Pick in arrivals_copy:
phase = identifyPhase(loopIdentifyPhase(Pick.phase_hint)) phase = identifyPhase(loopIdentifyPhase(Pick.phase_hint))
if phase == 'P': if phase == 'P':
Pqual = getQualityFromUncertainty(Pick.time_errors.uncertainty, ErrorsP) Pqual = get_quality_class(Pick.time_errors.uncertainty, ErrorsP)
if Pqual == 0: if Pqual == 0:
Pw0.append(Pick.time_errors.uncertainty) Pw0.append(Pick.time_errors.uncertainty)
elif Pqual == 1: elif Pqual == 1:
@ -1003,7 +1003,7 @@ def getQualitiesfromxml(xmlnames, ErrorsP, ErrorsS, plotflag=1):
elif Pqual == 4: elif Pqual == 4:
Pw4.append(Pick.time_errors.uncertainty) Pw4.append(Pick.time_errors.uncertainty)
elif phase == 'S': elif phase == 'S':
Squal = getQualityFromUncertainty(Pick.time_errors.uncertainty, ErrorsS) Squal = get_quality_class(Pick.time_errors.uncertainty, ErrorsS)
if Squal == 0: if Squal == 0:
Sw0.append(Pick.time_errors.uncertainty) Sw0.append(Pick.time_errors.uncertainty)
elif Squal == 1: elif Squal == 1:

View File

@ -15,7 +15,7 @@ from pylot.core.pick.charfuns import CharacteristicFunction
from pylot.core.pick.charfuns import HOScf, AICcf, ARZcf, ARHcf, AR3Ccf from pylot.core.pick.charfuns import HOScf, AICcf, ARZcf, ARHcf, AR3Ccf
from pylot.core.pick.picker import AICPicker, PragPicker from pylot.core.pick.picker import AICPicker, PragPicker
from pylot.core.pick.utils import checksignallength, checkZ4S, earllatepicker, \ from pylot.core.pick.utils import checksignallength, checkZ4S, earllatepicker, \
getSNR, fmpicker, checkPonsets, wadaticheck, get_pickparams getSNR, fmpicker, checkPonsets, wadaticheck, get_pickparams, get_quality_class
from pylot.core.util.utils import getPatternLine, gen_Pool,\ from pylot.core.util.utils import getPatternLine, gen_Pool,\
real_Bool, identifyPhaseID real_Bool, identifyPhaseID

View File

@ -1194,7 +1194,7 @@ def checkZ4S(X, pick, zfac, checkwin, iplot, fig=None, linecolor='k'):
return returnflag return returnflag
def getQualityFromUncertainty(uncertainty, Errors): def get_quality_class(uncertainty, weight_classes):
""" """
Script to transform uncertainty into quality classes 0-4 regarding adjusted time errors Script to transform uncertainty into quality classes 0-4 regarding adjusted time errors
:param uncertainty: symmetric picking error of picks :param uncertainty: symmetric picking error of picks

View File

@ -141,7 +141,7 @@ def excludeQualityClasses(picks, qClasses, timeerrorsP, timeerrorsS):
:return: dictionary containing only picks above the excluded quality class(es) :return: dictionary containing only picks above the excluded quality class(es)
:rtype: dict :rtype: dict
""" """
from pylot.core.pick.utils import getQualityFromUncertainty from pylot.core.pick.utils import get_quality_class
if type(qClasses) in [int, float]: if type(qClasses) in [int, float]:
qClasses = [qClasses] qClasses = [qClasses]
@ -156,7 +156,7 @@ def excludeQualityClasses(picks, qClasses, timeerrorsP, timeerrorsS):
if not type(pick) in [AttribDict, dict]: if not type(pick) in [AttribDict, dict]:
continue continue
pickerror = phaseError[identifyPhaseID(phase)] pickerror = phaseError[identifyPhaseID(phase)]
quality = getQualityFromUncertainty(pick['spe'], pickerror) quality = get_quality_class(pick['spe'], pickerror)
if not quality in qClasses: if not quality in qClasses:
if not station in picksdict_new: if not station in picksdict_new:
picksdict_new[station] = {} picksdict_new[station] = {}

View File

@ -42,7 +42,7 @@ from obspy.taup.utils import get_phase_names
from pylot.core.io.data import Data from pylot.core.io.data import Data
from pylot.core.io.inputs import FilterOptions, PylotParameter from pylot.core.io.inputs import FilterOptions, PylotParameter
from pylot.core.pick.utils import getSNR, earllatepicker, getnoisewin, \ from pylot.core.pick.utils import getSNR, earllatepicker, getnoisewin, \
getResolutionWindow, getQualityFromUncertainty getResolutionWindow, get_quality_class
from pylot.core.pick.compare import Comparison from pylot.core.pick.compare import Comparison
from pylot.core.util.defaults import OUTPUTFORMATS, FILTERDEFAULTS, \ from pylot.core.util.defaults import OUTPUTFORMATS, FILTERDEFAULTS, \
SetChannelComponents SetChannelComponents
@ -2259,10 +2259,10 @@ class PickDlg(QDialog):
# get quality classes # get quality classes
if self.getPhaseID(phase) == 'P': if self.getPhaseID(phase) == 'P':
quality = getQualityFromUncertainty(picks['spe'], self.parameter['timeerrorsP']) quality = get_quality_class(picks['spe'], self.parameter['timeerrorsP'])
phaseID = 'P' phaseID = 'P'
elif self.getPhaseID(phase) == 'S': elif self.getPhaseID(phase) == 'S':
quality = getQualityFromUncertainty(picks['spe'], self.parameter['timeerrorsS']) quality = get_quality_class(picks['spe'], self.parameter['timeerrorsS'])
phaseID = 'S' phaseID = 'S'
mpp = picks['mpp'] - self.getStartTime() mpp = picks['mpp'] - self.getStartTime()
@ -3180,8 +3180,8 @@ class TuneAutopicker(QWidget):
('refSpick', 0), ('refSpick', 0),
('el_S1pick', 0), ('el_S1pick', 0),
('el_S2pick', 0)] ('el_S2pick', 0)]
qualityPpick = getQualityFromUncertainty(picks['P']['spe'], self.parameter['timeerrorsP']) qualityPpick = get_quality_class(picks['P']['spe'], self.parameter['timeerrorsP'])
qualitySpick = getQualityFromUncertainty(picks['S']['spe'], self.parameter['timeerrorsS']) qualitySpick = get_quality_class(picks['S']['spe'], self.parameter['timeerrorsS'])
for p_ax in p_axes: for p_ax in p_axes:
axes = self.parent().fig_dict[p_ax[0]].axes axes = self.parent().fig_dict[p_ax[0]].axes
if not axes: if not axes:

View File

@ -1,5 +1,5 @@
import unittest import unittest
from pylot.core.pick.utils import getQualityFromUncertainty as get_quality_class from pylot.core.pick.utils import get_quality_class
class TestQualityClassFromUncertainty(unittest.TestCase): class TestQualityClassFromUncertainty(unittest.TestCase):