Merge branch 'develop' of ariadne.geophysik.rub.de:/data/git/pylot into develop

This commit is contained in:
Ludger Küperkoch 2017-08-21 16:11:41 +02:00
commit dabd7f463c
5 changed files with 65 additions and 26 deletions

View File

@ -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
from pylot.core.io.phases import picksdict_from_picks
import pylot.core.loc.nll as nll
from pylot.core.util.defaults import FILTERDEFAULTS, SetChannelComponents
@ -74,12 +74,12 @@ from pylot.core.util.connection import checkurl
from pylot.core.util.dataprocessing import read_metadata, restitute_data
from pylot.core.util.utils import fnConstructor, getLogin, \
full_range, readFilterInformation, trim_station_components, check4gaps, make_pen, pick_color_plt, \
pick_linestyle_plt, identifyPhase, loopIdentifyPhase, remove_underscores, check4doubled
pick_linestyle_plt, remove_underscores, check4doubled, identifyPhaseID, excludeQualityClasses
from pylot.core.util.event import Event
from pylot.core.io.location import create_creation_info, create_event
from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \
WaveformWidget, WaveformWidgetPG, PropertiesDlg, HelpForm, createAction, PickDlg, \
getDataType, ComparisonDialog, TuneAutopicker, PylotParaBox, AutoPickDlg
getDataType, ComparisonWidget, TuneAutopicker, PylotParaBox, AutoPickDlg
from pylot.core.util.map_projection import map_projection
from pylot.core.util.structure import DATASTRUCTURE
from pylot.core.util.thread import Thread, Worker
@ -865,7 +865,7 @@ class MainWindow(QMainWindow):
return fnames
def getPhaseID(self, phase):
return identifyPhase(loopIdentifyPhase(phase))
return identifyPhaseID(phase)
def get_current_event(self, eventbox=None):
'''
@ -1215,9 +1215,13 @@ class MainWindow(QMainWindow):
def comparePicks(self):
if self.check4Comparison():
co = Comparison(auto=self.getPicks('auto'), manu=self.getPicks())
compare_dlg = ComparisonDialog(co, self)
compare_dlg.exec_()
autopicks = excludeQualityClasses(self.getPicks('auto'), [4],
self._inputs['timeerrorsP'], self._inputs['timeerrorsS'])
manupicks = excludeQualityClasses(self.getPicks('manual'), [4],
self._inputs['timeerrorsP'], self._inputs['timeerrorsS'])
co = Comparison(auto=autopicks, manu=manupicks)
compare_dlg = ComparisonWidget(co, self)
compare_dlg.show()
def getPlotWidget(self):
return self.dataPlot
@ -1998,10 +2002,10 @@ class MainWindow(QMainWindow):
# get quality classes
if self.getPhaseID(phase) == 'P':
quality = getQualityfromUncertainty(picks['spe'], self._inputs['timeerrorsP'])
quality = getQualityFromUncertainty(picks['spe'], self._inputs['timeerrorsP'])
phaseID = 'P'
elif self.getPhaseID(phase) == 'S':
quality = getQualityfromUncertainty(picks['spe'], self._inputs['timeerrorsS'])
quality = getQualityFromUncertainty(picks['spe'], self._inputs['timeerrorsS'])
phaseID = 'S'
mpp = picks['mpp'] - stime

View File

@ -18,8 +18,8 @@ from pylot.core.pick.charfuns import HOScf, AICcf, ARZcf, ARHcf, AR3Ccf
from pylot.core.pick.picker import AICPicker, PragPicker
from pylot.core.pick.utils import checksignallength, checkZ4S, earllatepicker, \
getSNR, fmpicker, checkPonsets, wadaticheck
from pylot.core.util.utils import getPatternLine, gen_Pool, identifyPhase, loopIdentifyPhase, \
real_Bool
from pylot.core.util.utils import getPatternLine, gen_Pool,\
real_Bool, identifyPhaseID
from obspy.taup import TauPyModel
@ -254,7 +254,7 @@ def autopickstation(wfstream, pickparam, verbose=False,
phases = {'P': [],
'S': []}
for arr in arrivals:
phases[identifyPhase(loopIdentifyPhase(arr.phase.name))].append(arr)
phases[identifyPhaseID(arr.phase.name)].append(arr)
# get first P and S onsets from arrivals list
arrP, estFirstP = min([(arr, arr.time) for arr in phases['P']], key = lambda t: t[1])

View File

@ -1098,7 +1098,7 @@ def checkZ4S(X, pick, zfac, checkwin, iplot, fig=None):
return returnflag
def getQualityfromUncertainty(uncertainty, Errors):
def getQualityFromUncertainty(uncertainty, Errors):
'''Script to transform uncertainty into quality classes 0-4
regarding adjusted time errors Errors.
'''

View File

@ -71,6 +71,37 @@ def gen_Pool(ncores=0):
return pool
def excludeQualityClasses(picks, qClasses, timeerrorsP, timeerrorsS):
'''
takes PyLoT picks dictionary and returns a new dictionary with certain classes excluded.
:param picks: PyLoT picks dictionary
:param qClasses: list (or int) of quality classes (0-4) to exclude
:param timeerrorsP: time errors for classes (0-4) for P
:param timeerrorsS: time errors for classes (0-4) for S
:return: new picks dictionary
'''
from pylot.core.pick.utils import getQualityFromUncertainty
if type(qClasses) in [int, float]:
qClasses = [qClasses]
picksdict_new = {}
phaseError = {'P': timeerrorsP,
'S': timeerrorsS}
for station, phases in picks.items():
for phase, pick in phases.items():
pickerror = phaseError[identifyPhaseID(phase)]
quality = getQualityFromUncertainty(pick['spe'], pickerror)
if not quality in qClasses:
if not station in picksdict_new:
picksdict_new[station] = {}
picksdict_new[station][phase] = pick
return picksdict_new
def clims(lim1, lim2):
"""
takes two pairs of limits and returns one pair of common limts
@ -806,6 +837,9 @@ def identifyPhase(phase):
return False
def identifyPhaseID(phase):
return identifyPhase(loopIdentifyPhase(phase))
if __name__ == "__main__":

View File

@ -21,7 +21,8 @@ except:
pg = None
from matplotlib.figure import Figure
from pylot.core.util.utils import find_horizontals, identifyPhase, loopIdentifyPhase, trim_station_components
from pylot.core.util.utils import find_horizontals, identifyPhase, loopIdentifyPhase, trim_station_components, \
identifyPhaseID
try:
from matplotlib.backends.backend_qt4agg import FigureCanvas
@ -44,7 +45,7 @@ from obspy.taup.utils import get_phase_names
from pylot.core.io.data import Data
from pylot.core.io.inputs import FilterOptions, PylotParameter
from pylot.core.pick.utils import getSNR, earllatepicker, getnoisewin, \
getResolutionWindow, getQualityfromUncertainty
getResolutionWindow, getQualityFromUncertainty
from pylot.core.pick.compare import Comparison
from pylot.core.util.defaults import OUTPUTFORMATS, FILTERDEFAULTS, \
SetChannelComponents
@ -118,7 +119,7 @@ def createAction(parent, text, slot=None, shortcut=None, icon=None,
return action
class ComparisonDialog(QDialog):
class ComparisonWidget(QWidget):
def __init__(self, c, parent=None):
self._data = c
self._stats = c.stations
@ -128,8 +129,9 @@ class ComparisonDialog(QDialog):
histCheckBox=None)
self._phases = 'PS'
self._plotprops = dict(station=list(self.stations)[0], phase=list(self.phases)[0])
super(ComparisonDialog, self).__init__(parent)
super(ComparisonWidget, self).__init__(parent, 1)
self.setupUI()
self.resize(1280, 720)
self.plotcomparison()
def setupUI(self):
@ -161,17 +163,12 @@ class ComparisonDialog(QDialog):
_toolbar.addWidget(_phases_combobox)
_toolbar.addWidget(_hist_checkbox)
_buttonbox = QDialogButtonBox(QDialogButtonBox.Close)
_innerlayout.addWidget(self.canvas)
_innerlayout.addWidget(_buttonbox)
_outerlayout.addWidget(_toolbar)
_outerlayout.addLayout(_innerlayout)
_buttonbox.rejected.connect(self.reject)
# finally layout the entire dialog
# finally layout the entire widget
self.setLayout(_outerlayout)
@property
@ -270,6 +267,10 @@ class ComparisonDialog(QDialog):
# _axes.cla()
station = self.plotprops['station']
phase = self.plotprops['phase']
if not phase in self.data.comparison[station]:
_axes.set_title('No pick found for phase {}.'.format(phase))
self.canvas.draw()
return
pdf = self.data.comparison[station][phase]
x, y, std, exp = pdf.axis, pdf.data, pdf.standard_deviation(), \
pdf.expectation()
@ -1285,7 +1286,7 @@ class PickDlg(QDialog):
self.currentPhase = str(self.s_button.text())
def getPhaseID(self, phase):
return identifyPhase(loopIdentifyPhase(phase))
return identifyPhaseID(phase)
def set_button_color(self, button, color=None):
if type(color) == QtGui.QColor:
@ -1714,10 +1715,10 @@ class PickDlg(QDialog):
# get quality classes
if self.getPhaseID(phase) == 'P':
quality = getQualityfromUncertainty(picks['spe'], self.parameter['timeerrorsP'])
quality = getQualityFromUncertainty(picks['spe'], self.parameter['timeerrorsP'])
phaseID = 'P'
elif self.getPhaseID(phase) == 'S':
quality = getQualityfromUncertainty(picks['spe'], self.parameter['timeerrorsS'])
quality = getQualityFromUncertainty(picks['spe'], self.parameter['timeerrorsS'])
phaseID = 'S'
mpp = picks['mpp'] - self.getStartTime()