From e9a0be347cff520b3d1384020023975ec75f27d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Fri, 11 Aug 2017 12:48:43 +0200 Subject: [PATCH 1/4] [Bugfix] Take into account different formats of input argument iplot. --- pylot/core/analysis/magnitude.py | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/pylot/core/analysis/magnitude.py b/pylot/core/analysis/magnitude.py index 89c4ff11..51093aab 100644 --- a/pylot/core/analysis/magnitude.py +++ b/pylot/core/analysis/magnitude.py @@ -192,6 +192,14 @@ class LocalMagnitude(Magnitude): def peak_to_peak(self, st, t0): + try: + iplot = int(self.plot_flag) + except: + if self.plot_flag == True or self.plot_flag == 'True': + iplot = 2 + else: + iplot = 0 + # simulate Wood-Anderson response st.simulate(paz_remove=None, paz_simulate=self._paz) @@ -224,7 +232,7 @@ class LocalMagnitude(Magnitude): # check for plot flag (for debugging only) fig = None - if self.plot_flag > 1: + if iplot > 1: st.plot() fig = plt.figure() ax = fig.add_subplot(111) @@ -455,6 +463,14 @@ def calcsourcespec(wfstream, onset, vp, delta, azimuth, incidence, if verbosity: print("Calculating source spectrum for station %s ...." % wfstream[0].stats.station) + try: + iplot = int(iplot) + except: + if iplot == True or iplot == 'True': + iplot = 2 + else: + iplot = 0 + # get Q value Q, A = qp @@ -651,6 +667,14 @@ def fitSourceModel(f, S, fc0, iplot, verbosity=False): :type: float ''' + try: + iplot = int(iplot) + except: + if iplot == True or iplot == 'True': + iplot = 2 + else: + iplot = 0 + w0 = [] stdw0 = [] fc = [] From fe2957f76dc19fad4aba3c460409adc945da2915 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Fri, 11 Aug 2017 15:02:47 +0200 Subject: [PATCH 2/4] Cosmetics --- QtPyLoT.py | 30 +++++++++++++----------------- pylot/core/io/phases.py | 4 ++-- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/QtPyLoT.py b/QtPyLoT.py index a8ccdfb5..2e9474c6 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -73,7 +73,7 @@ from pylot.core.util.errors import FormatError, DatastructureError, \ 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 + full_range, readFilterInformation 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, \ @@ -1365,10 +1365,6 @@ class MainWindow(QMainWindow): # ans = False self.fnames = self.getWFFnames_from_eventbox() self.data.setWFData(self.fnames) - wfdat = self.data.getWFData() # all available streams - check4gaps(wfdat) - # trim station components to same start value - trim_station_components(wfdat, trim_start=True, trim_end=False) self._stime = full_range(self.get_data().getWFData())[0] def connectWFplotEvents(self): @@ -1798,18 +1794,18 @@ class MainWindow(QMainWindow): fig = Figure() self.fig_dict[key] = fig - #if not self.tap: - # init TuneAutopicker object - self.tap = TuneAutopicker(self) - # first call of update to init tabs with empty canvas - self.update_autopicker() - # connect update signal of TuneAutopicker with update function - # creating and filling figure canvas - self.tap.update.connect(self.update_autopicker) - self.tap.figure_tabs.setCurrentIndex(0) - #else: - # self.update_autopicker() - # self.tap.fill_eventbox() + if not self.tap: + # init TuneAutopicker object + self.tap = TuneAutopicker(self) + # first call of update to init tabs with empty canvas + self.update_autopicker() + # connect update signal of TuneAutopicker with update function + # creating and filling figure canvas + self.tap.update.connect(self.update_autopicker) + self.tap.figure_tabs.setCurrentIndex(0) + else: + self.update_autopicker() + self.tap.fill_eventbox() self.tap.show() def update_autopicker(self): diff --git a/pylot/core/io/phases.py b/pylot/core/io/phases.py index a3c48d39..c85d2727 100644 --- a/pylot/core/io/phases.py +++ b/pylot/core/io/phases.py @@ -205,6 +205,8 @@ def picksdict_from_picks(evt): station = pick.waveform_id.station_code channel = pick.waveform_id.channel_code network = pick.waveform_id.network_code + mpp = pick.time + spe = pick.time_errors.uncertainty try: picker = str(pick.method_id) if picker.startswith('smi:local/'): @@ -216,8 +218,6 @@ def picksdict_from_picks(evt): except KeyError as e: # print(e) onsets = {} - mpp = pick.time - spe = pick.time_errors.uncertainty try: lpp = mpp + pick.time_errors.upper_uncertainty epp = mpp - pick.time_errors.lower_uncertainty From bd37b60dcba5cf110e1375c3c9f6ecfd5dac469d Mon Sep 17 00:00:00 2001 From: Marcel Paffrath Date: Fri, 11 Aug 2017 15:15:58 +0200 Subject: [PATCH 3/4] [reset] changes in QtPyLoT --- QtPyLoT.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/QtPyLoT.py b/QtPyLoT.py index 2e9474c6..a8ccdfb5 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -73,7 +73,7 @@ from pylot.core.util.errors import FormatError, DatastructureError, \ 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 + full_range, readFilterInformation, trim_station_components, check4gaps 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, \ @@ -1365,6 +1365,10 @@ class MainWindow(QMainWindow): # ans = False self.fnames = self.getWFFnames_from_eventbox() self.data.setWFData(self.fnames) + wfdat = self.data.getWFData() # all available streams + check4gaps(wfdat) + # trim station components to same start value + trim_station_components(wfdat, trim_start=True, trim_end=False) self._stime = full_range(self.get_data().getWFData())[0] def connectWFplotEvents(self): @@ -1794,18 +1798,18 @@ class MainWindow(QMainWindow): fig = Figure() self.fig_dict[key] = fig - if not self.tap: - # init TuneAutopicker object - self.tap = TuneAutopicker(self) - # first call of update to init tabs with empty canvas - self.update_autopicker() - # connect update signal of TuneAutopicker with update function - # creating and filling figure canvas - self.tap.update.connect(self.update_autopicker) - self.tap.figure_tabs.setCurrentIndex(0) - else: - self.update_autopicker() - self.tap.fill_eventbox() + #if not self.tap: + # init TuneAutopicker object + self.tap = TuneAutopicker(self) + # first call of update to init tabs with empty canvas + self.update_autopicker() + # connect update signal of TuneAutopicker with update function + # creating and filling figure canvas + self.tap.update.connect(self.update_autopicker) + self.tap.figure_tabs.setCurrentIndex(0) + #else: + # self.update_autopicker() + # self.tap.fill_eventbox() self.tap.show() def update_autopicker(self): From f393585831d1e4c4baed6090a0c6691d6a9a1c86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Fri, 11 Aug 2017 16:04:18 +0200 Subject: [PATCH 4/4] New function to get quality classes from uncertainties, plot only automatic picks, if pick qualities are less than 4. --- QtPyLoT.py | 20 ++++++++++++++------ pylot/core/pick/utils.py | 25 +++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 6 deletions(-) diff --git a/QtPyLoT.py b/QtPyLoT.py index a8ccdfb5..2cf0e6bb 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 +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 @@ -1951,13 +1951,19 @@ class MainWindow(QMainWindow): } stat_picks = self.getPicks(type=picktype)[station] - stime = self.getStime() for phase in stat_picks: picks = stat_picks[phase] if type(stat_picks[phase]) is not dict and type(stat_picks[phase]) is not AttribDict: return + + # get quality classes + if phase[0] == 'P': + quality = getQualityfromUncertainty(picks['spe'], self._inputs['timeerrorsP']) + elif phase[0] == 'S': + quality = getQualityfromUncertainty(picks['spe'], self._inputs['timeerrorsS']) + colors = phase_col[phase[0].upper()] mpp = picks['mpp'] - stime @@ -1994,7 +2000,8 @@ class MainWindow(QMainWindow): else: pw.plot([mpp, mpp], ylims, pen=colors[0], name='{}-Pick (NO PICKERROR)'.format(phase)) elif picktype == 'auto': - pw.plot([mpp, mpp], ylims, pen=colors[3]) + if quality < 4: + pw.plot([mpp, mpp], ylims, pen=colors[3]) else: raise TypeError('Unknown picktype {0}'.format(picktype)) else: @@ -2009,9 +2016,10 @@ class MainWindow(QMainWindow): else: ax.plot([mpp, mpp], ylims, colors[6], label='{}-Pick (NO PICKERROR)'.format(phase)) elif picktype == 'auto': - ax.plot(mpp, ylims[1], colors[3], - mpp, ylims[0], colors[4]) - ax.vlines(mpp, ylims[0], ylims[1], colors[5], linestyles='dotted') + if quality < 4: + ax.plot(mpp, ylims[1], colors[3], + mpp, ylims[0], colors[4]) + ax.vlines(mpp, ylims[0], ylims[1], colors[5], linestyles='dotted') else: raise TypeError('Unknown picktype {0}'.format(picktype)) diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index 41a5509a..5f1a8d43 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -1069,6 +1069,31 @@ def checkZ4S(X, pick, zfac, checkwin, iplot, fig=None): ax.set_xlabel('Time [s] since %s' % zdat[0].stats.starttime) return returnflag +def getQualityfromUncertainty(uncertainty, Errors): + '''Script to transform uncertainty into quality classes 0-4 + regarding adjusted time errors Errors. + ''' + + if uncertainty == None or uncertainty == 'None': + quality = 4 + else: + if uncertainty <= Errors[0]: + quality = 0 + elif (uncertainty > Errors[0]) and \ + (uncertainty < Errors[1]): + quality = 1 + elif (uncertainty > Errors[1]) and \ + (uncertainty < Errors[2]): + quality = 2 + elif (uncertainty > Errors[2]) and \ + (uncertainty < Errors[3]): + quality = 3 + elif uncertainty > Errors[3]: + quality = 4 + else: + pass + + return quality if __name__ == '__main__': import doctest