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 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, getQualityFromUncertainty
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
@ -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.dataprocessing import read_metadata, restitute_data
from pylot.core.util.utils import fnConstructor, getLogin, \ from pylot.core.util.utils import fnConstructor, getLogin, \
full_range, readFilterInformation, trim_station_components, check4gaps, make_pen, pick_color_plt, \ 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.util.event import Event
from pylot.core.io.location import create_creation_info, create_event from pylot.core.io.location import create_creation_info, create_event
from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \ from pylot.core.util.widgets import FilterOptionsDialog, NewEventDlg, \
WaveformWidget, WaveformWidgetPG, PropertiesDlg, HelpForm, createAction, PickDlg, \ 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.map_projection import map_projection
from pylot.core.util.structure import DATASTRUCTURE from pylot.core.util.structure import DATASTRUCTURE
from pylot.core.util.thread import Thread, Worker from pylot.core.util.thread import Thread, Worker
@ -865,7 +865,7 @@ class MainWindow(QMainWindow):
return fnames return fnames
def getPhaseID(self, phase): def getPhaseID(self, phase):
return identifyPhase(loopIdentifyPhase(phase)) return identifyPhaseID(phase)
def get_current_event(self, eventbox=None): def get_current_event(self, eventbox=None):
''' '''
@ -1215,9 +1215,13 @@ class MainWindow(QMainWindow):
def comparePicks(self): def comparePicks(self):
if self.check4Comparison(): if self.check4Comparison():
co = Comparison(auto=self.getPicks('auto'), manu=self.getPicks()) autopicks = excludeQualityClasses(self.getPicks('auto'), [4],
compare_dlg = ComparisonDialog(co, self) self._inputs['timeerrorsP'], self._inputs['timeerrorsS'])
compare_dlg.exec_() 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): def getPlotWidget(self):
return self.dataPlot return self.dataPlot
@ -1998,10 +2002,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 = getQualityFromUncertainty(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 = getQualityFromUncertainty(picks['spe'], self._inputs['timeerrorsS'])
phaseID = 'S' phaseID = 'S'
mpp = picks['mpp'] - stime 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.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 getSNR, fmpicker, checkPonsets, wadaticheck
from pylot.core.util.utils import getPatternLine, gen_Pool, identifyPhase, loopIdentifyPhase, \ from pylot.core.util.utils import getPatternLine, gen_Pool,\
real_Bool real_Bool, identifyPhaseID
from obspy.taup import TauPyModel from obspy.taup import TauPyModel
@ -254,7 +254,7 @@ def autopickstation(wfstream, pickparam, verbose=False,
phases = {'P': [], phases = {'P': [],
'S': []} 'S': []}
for arr in arrivals: 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 # 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]) 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 return returnflag
def getQualityfromUncertainty(uncertainty, Errors): def getQualityFromUncertainty(uncertainty, Errors):
'''Script to transform uncertainty into quality classes 0-4 '''Script to transform uncertainty into quality classes 0-4
regarding adjusted time errors Errors. regarding adjusted time errors Errors.
''' '''

View File

@ -71,6 +71,37 @@ def gen_Pool(ncores=0):
return pool 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): def clims(lim1, lim2):
""" """
takes two pairs of limits and returns one pair of common limts takes two pairs of limits and returns one pair of common limts
@ -806,6 +837,9 @@ def identifyPhase(phase):
return False return False
def identifyPhaseID(phase):
return identifyPhase(loopIdentifyPhase(phase))
if __name__ == "__main__": if __name__ == "__main__":

View File

@ -21,7 +21,8 @@ except:
pg = None pg = None
from matplotlib.figure import Figure 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: try:
from matplotlib.backends.backend_qt4agg import FigureCanvas 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.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, getQualityFromUncertainty
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
@ -118,7 +119,7 @@ def createAction(parent, text, slot=None, shortcut=None, icon=None,
return action return action
class ComparisonDialog(QDialog): class ComparisonWidget(QWidget):
def __init__(self, c, parent=None): def __init__(self, c, parent=None):
self._data = c self._data = c
self._stats = c.stations self._stats = c.stations
@ -128,8 +129,9 @@ class ComparisonDialog(QDialog):
histCheckBox=None) histCheckBox=None)
self._phases = 'PS' self._phases = 'PS'
self._plotprops = dict(station=list(self.stations)[0], phase=list(self.phases)[0]) 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.setupUI()
self.resize(1280, 720)
self.plotcomparison() self.plotcomparison()
def setupUI(self): def setupUI(self):
@ -161,17 +163,12 @@ class ComparisonDialog(QDialog):
_toolbar.addWidget(_phases_combobox) _toolbar.addWidget(_phases_combobox)
_toolbar.addWidget(_hist_checkbox) _toolbar.addWidget(_hist_checkbox)
_buttonbox = QDialogButtonBox(QDialogButtonBox.Close)
_innerlayout.addWidget(self.canvas) _innerlayout.addWidget(self.canvas)
_innerlayout.addWidget(_buttonbox)
_outerlayout.addWidget(_toolbar) _outerlayout.addWidget(_toolbar)
_outerlayout.addLayout(_innerlayout) _outerlayout.addLayout(_innerlayout)
_buttonbox.rejected.connect(self.reject) # finally layout the entire widget
# finally layout the entire dialog
self.setLayout(_outerlayout) self.setLayout(_outerlayout)
@property @property
@ -270,6 +267,10 @@ class ComparisonDialog(QDialog):
# _axes.cla() # _axes.cla()
station = self.plotprops['station'] station = self.plotprops['station']
phase = self.plotprops['phase'] 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] pdf = self.data.comparison[station][phase]
x, y, std, exp = pdf.axis, pdf.data, pdf.standard_deviation(), \ x, y, std, exp = pdf.axis, pdf.data, pdf.standard_deviation(), \
pdf.expectation() pdf.expectation()
@ -1285,7 +1286,7 @@ class PickDlg(QDialog):
self.currentPhase = str(self.s_button.text()) self.currentPhase = str(self.s_button.text())
def getPhaseID(self, phase): def getPhaseID(self, phase):
return identifyPhase(loopIdentifyPhase(phase)) return identifyPhaseID(phase)
def set_button_color(self, button, color=None): def set_button_color(self, button, color=None):
if type(color) == QtGui.QColor: if type(color) == QtGui.QColor:
@ -1714,10 +1715,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 = getQualityFromUncertainty(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 = getQualityFromUncertainty(picks['spe'], self.parameter['timeerrorsS'])
phaseID = 'S' phaseID = 'S'
mpp = picks['mpp'] - self.getStartTime() mpp = picks['mpp'] - self.getStartTime()