From 81b95e6a22bae7b82810e6e9d1df34333c83f579 Mon Sep 17 00:00:00 2001 From: Sebastianw Wehling-Benatelli Date: Thu, 3 Sep 2015 09:15:31 +0200 Subject: [PATCH 1/8] [addresses #167] started fixing the multiple phase saving issue --- pylot/RELEASE-VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index 41931e59..586b7cb0 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -c940-dirty +0.0.0-gbf11 From cc0b1e0a5bca14d2b703601ea64268039fa7a899 Mon Sep 17 00:00:00 2001 From: Sebastianw Wehling-Benatelli Date: Thu, 3 Sep 2015 13:21:46 +0200 Subject: [PATCH 2/8] 176 open event failure --- QtPyLoT.py | 44 +++++++++++++++++++++----------------- pylot/RELEASE-VERSION | 2 +- pylot/core/read/data.py | 5 ++++- pylot/core/util/widgets.py | 6 +++--- 4 files changed, 32 insertions(+), 25 deletions(-) diff --git a/QtPyLoT.py b/QtPyLoT.py index 38cab8b1..6726306a 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -36,7 +36,7 @@ from PySide.QtGui import QMainWindow, QInputDialog, QIcon, QFileDialog, \ QDialog, QErrorMessage, QApplication, QPixmap, QMessageBox, QSplashScreen, \ QActionGroup, QListWidget, QDockWidget import numpy as np -from obspy.core import UTCDateTime +from obspy import UTCDateTime, readEvents from pylot.core.read.data import Data from pylot.core.read.inputs import FilterOptions, AutoPickParameter @@ -339,26 +339,25 @@ class MainWindow(QMainWindow): return settings.value("data/dataRoot") def loadData(self, fname=None): + if not self.okToContinue(): + return if fname is None: - try: - self.data = Data(self, evtdata=self.fname) - except AttributeError: - action = self.sender() - if isinstance(action, QAction): - if action.data() is None: - filt = "Supported event formats (*.mat *.qml *.xml *.kor *.evt)" - caption = "Open an event file" - fname = QFileDialog().getOpenFileName(self, - caption=caption, - filter=filt) - self.fname = fname[0] - else: - self.fname = unicode(action.data().toString()) - if not self.okToContinue(): - return - else: - self.fname = fname - self.data = Data(self, evtdata=self.fname) + action = self.sender() + if isinstance(action, QAction): + if action.data() is None: + filt = "Supported event formats (*.mat *.qml *.xml *.kor *.evt)" + caption = "Open an event file" + fname = QFileDialog().getOpenFileName(self, + caption=caption, + filter=filt) + fname = fname[0] + else: + fname = unicode(action.data().toString()) + event = readEvents(fname)[0] + self.setFileName(fname) + self.getData().applyEVTData(event, type='event') + self.convertPicks4PyLoT() + self.drawPicks() def getLastEvent(self): return self.recentEvents[0] @@ -694,6 +693,11 @@ class MainWindow(QMainWindow): raise Exception('FATAL: Should never occur!') self.getPicks()[station] = stat_picks + def convertPicks4PyLoT(self): + evt = self.getData().getEvtData() + for pick in evt.picks: + station = pick.waveform_id.getSEEDstring() + def drawPicks(self, station=None): # if picks to draw not specified, draw all picks available if not station: diff --git a/pylot/RELEASE-VERSION b/pylot/RELEASE-VERSION index 586b7cb0..835782c8 100644 --- a/pylot/RELEASE-VERSION +++ b/pylot/RELEASE-VERSION @@ -1 +1 @@ -0.0.0-gbf11 +81b9-dirty diff --git a/pylot/core/read/data.py b/pylot/core/read/data.py index 30f82c36..945d7dd6 100644 --- a/pylot/core/read/data.py +++ b/pylot/core/read/data.py @@ -417,7 +417,10 @@ class Data(object): :param event: """ - pass + if not self.evtdata: + self.evtdata = event + else: + raise OverwriteError('Acutal event would be overwritten!') applydata = {'pick': applyPicks, 'arrival': applyArrivals, diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 08ef0779..0afe5b7d 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -105,10 +105,10 @@ class MPLWidget(FigureCanvas): for level in noiselevel: self.getAxes().plot([time_ax[0], time_ax[-1]], [level, level], '--k') - xlabel = 'seconds since {0}'.format(wfstart) - ylabel = '' - self.updateWidget(xlabel, ylabel, title) self.setPlotDict(n, (station, channel)) + xlabel = 'seconds since {0}'.format(wfstart) + ylabel = '' + self.updateWidget(xlabel, ylabel, title) self.setXLims([0, wfend - wfstart]) self.setYLims([-0.5, n + 0.5]) if zoomx is not None: From 4eef4d238b168e8697165ba159359969290644ef Mon Sep 17 00:00:00 2001 From: Sebastianw Wehling-Benatelli Date: Fri, 4 Sep 2015 15:01:59 +0200 Subject: [PATCH 3/8] 176 open event failure --- QtPyLoT.py | 16 +++++++++++++++- pylot/core/read/data.py | 14 +++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/QtPyLoT.py b/QtPyLoT.py index 6726306a..70bf2496 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -695,8 +695,22 @@ class MainWindow(QMainWindow): def convertPicks4PyLoT(self): evt = self.getData().getEvtData() + picks = {} + onsets = {} for pick in evt.picks: - station = pick.waveform_id.getSEEDstring() + phase = {} + station = pick.waveform_id.station_code + mpp = pick.time + lpp = mpp + pick.time.upper_uncertainty + epp = mpp - pick.time.lower_uncertainty + spe = pick.time.uncertainty + phase['mpp'] = mpp + phase['epp'] = epp + phase['lpp'] = lpp + phase['spe'] = spe + + onsets[pick.phase_hint] = phase + picks[station] = onsets def drawPicks(self, station=None): # if picks to draw not specified, draw all picks available diff --git a/pylot/core/read/data.py b/pylot/core/read/data.py index 945d7dd6..e942619c 100644 --- a/pylot/core/read/data.py +++ b/pylot/core/read/data.py @@ -33,7 +33,7 @@ class Data(object): else: self.comp = 'Z' self.wfdata = Stream() - self.newevent = False + self._new = False if evtdata is not None and isinstance(evtdata, Event): self.evtdata = evtdata elif evtdata is not None and not isinstance(evtdata, dict): @@ -41,8 +41,9 @@ class Data(object): self.evtdata = cat[0] elif evtdata is not None: cat = readPILOTEvent(**evtdata) + self.evtdata = cat[0] else: # create an empty Event object - self.newevent = True + self._new = True self.evtdata = Event() self.getEvtData().picks = [] self.wforiginal = None @@ -73,7 +74,7 @@ class Data(object): :return: """ - return self.newevent + return self._new def getCutTimes(self): """ @@ -356,6 +357,9 @@ class Data(object): """ return self.evtdata + def setEvtData(self, event): + self.evtdata = event + def applyEVTData(self, data, type='pick', authority_id='rub'): """ @@ -417,8 +421,8 @@ class Data(object): :param event: """ - if not self.evtdata: - self.evtdata = event + if not self.isNew(): + self.setEvtData(event) else: raise OverwriteError('Acutal event would be overwritten!') From cfca52e576025c5cd5dfeb9f4468304eaccd555d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Fri, 4 Sep 2015 15:28:37 +0200 Subject: [PATCH 4/8] Debuged slope determination [counts/s] within AICPicker. --- pylot/core/pick/Picker.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylot/core/pick/Picker.py b/pylot/core/pick/Picker.py index d8a224e6..61eade5e 100644 --- a/pylot/core/pick/Picker.py +++ b/pylot/core/pick/Picker.py @@ -18,6 +18,7 @@ calculated after Diehl & Kissling (2009). :author: MAGS2 EP3 working group / Ludger Kueperkoch """ + import numpy as np import matplotlib.pyplot as plt from pylot.core.pick.utils import getnoisewin, getsignalwin @@ -245,8 +246,7 @@ class AICPicker(AutoPicking): if datafit[0] >= datafit[len(datafit) - 1]: print 'AICPicker: Negative slope, bad onset skipped!' return - - self.slope = 1 / tslope * datafit[len(dataslope) - 1] - datafit[0] + self.slope = 1 / tslope * (datafit[len(dataslope) - 1] - datafit[0]) else: self.SNR = None From 5d8346b1caebb4613ab3359e066305fb79ae89ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Fri, 4 Sep 2015 15:28:57 +0200 Subject: [PATCH 5/8] Optimized some parameters. --- autoPyLoT_local.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoPyLoT_local.in b/autoPyLoT_local.in index c2ee8508..84ae2137 100644 --- a/autoPyLoT_local.in +++ b/autoPyLoT_local.in @@ -7,8 +7,8 @@ #main settings# /DATA/Insheim #rootpath# %project path EVENT_DATA/LOCAL #datapath# %data path -2015.08_Insheim #database# %name of data base -e0013.241.15 #eventID# %event ID for single event processing +2013.02_Insheim #database# %name of data base +e0019.048.13 #eventID# %event ID for single event processing /DATA/Insheim/STAT_INFO #invdir# %full path to inventory or dataless-seed file PILOT #datastructure# %choose data structure 0 #iplot# %flag for plotting: 0 none, 1, partly, >1 everything From 70b3f031f8026fed3544c109ec22c71202088948 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludger=20K=C3=BCperkoch?= Date: Fri, 4 Sep 2015 15:29:04 +0200 Subject: [PATCH 6/8] Optimized some parameters. --- autoPyLoT_regional.in | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/autoPyLoT_regional.in b/autoPyLoT_regional.in index 23cdce87..52f5c465 100644 --- a/autoPyLoT_regional.in +++ b/autoPyLoT_regional.in @@ -32,7 +32,7 @@ HYPOSAT #locrt# %location routine used ("HYPO #common settings picker# 20 #pstart# %start time [s] for calculating CF for P-picking 100 #pstop# %end time [s] for calculating CF for P-picking -3.0 #sstart# %start time [s] after or before(-) P-onset for calculating CF for S-picking +1.0 #sstart# %start time [s] after or before(-) P-onset for calculating CF for S-picking 100 #sstop# %end time [s] after P-onset for calculating CF for S-picking 3 10 #bpz1# %lower/upper corner freq. of first band pass filter Z-comp. [Hz] 3 12 #bpz2# %lower/upper corner freq. of second band pass filter Z-comp. [Hz] @@ -65,11 +65,11 @@ ARH #algoS# %choose algorithm for S-onset 0.3 #tpred2h# %for HOS/AR, length of AR-prediction window [s], H-components, 2nd pick 4 #Sarorder# %for AR-picker, order of AR process of H-components 10 #Srecalcwin# %for AR-picker, window length [s] for recalculation of CF (2nd pick) (H) -6 #pickwinS# %for initial AIC and refined pick, length of S-pick window [s] +25 #pickwinS# %for initial AIC and refined pick, length of S-pick window [s] 5 0.2 3.0 3.0 #tsnrh# %for ARH/AR3, window lengths for SNR-and slope estimation [tnoise,tsafetey,tsignal,tslope] [s] -3.0 #aictsmoothS# %for AIC-picker, take average of samples for smoothing of AIC-function [s] +3.5 #aictsmoothS# %for AIC-picker, take average of samples for smoothing of AIC-function [s] 1.0 #tsmoothS# %for AR-picker, take average of samples for smoothing CF [s] (S) -0.4 #ausS# %for HOS/AR, artificial uplift of samples (aus) of CF (S) +0.2 #ausS# %for HOS/AR, artificial uplift of samples (aus) of CF (S) 1.5 #nfacS# %for AR-picker, noise factor for noise level determination (S) %first-motion picker% 1 #minfmweight# %minimum required p weight for first-motion determination @@ -81,16 +81,16 @@ ARH #algoS# %choose algorithm for S-onset 0.04 0.08 0.16 0.32 #timeerrorsS# %discrete time errors [s] corresponding to picking weights [0 1 2 3] for S 3 #minAICPslope# %below this slope [counts/s] the initial P pick is rejected 1.2 #minAICPSNR# %below this SNR the initial P pick is rejected -3 #minAICSslope# %below this slope [counts/s] the initial S pick is rejected -1.5 #minAICSSNR# %below this SNR the initial S pick is rejected +5 #minAICSslope# %below this slope [counts/s] the initial S pick is rejected +2.5 #minAICSSNR# %below this SNR the initial S pick is rejected #check duration of signal using envelope function# 30 #minsiglength# %minimum required length of signal [s] 2.5 #noisefactor# %noiselevel*noisefactor=threshold 60 #minpercent# %required percentage of samples higher than threshold #check for spuriously picked S-onsets# -1.5 #zfac# %P-amplitude must exceed at least zfac times RMS-S amplitude +1.0 #zfac# %P-amplitude must exceed at least zfac times RMS-S amplitude #check statistics of P onsets# -35 #mdttolerance# %maximum allowed deviation of P picks from median [s] +45 #mdttolerance# %maximum allowed deviation of P picks from median [s] #wadati check# -2.0 #wdttolerance# %maximum allowed deviation from Wadati-diagram +3.0 #wdttolerance# %maximum allowed deviation from Wadati-diagram From f5fa4f4fafa45b89b13f6cb0e21dffbe908635b7 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Mon, 7 Sep 2015 10:03:12 +0200 Subject: [PATCH 7/8] Python 3 compatibility --- QtPyLoT.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/QtPyLoT.py b/QtPyLoT.py index 70bf2496..123d9991 100755 --- a/QtPyLoT.py +++ b/QtPyLoT.py @@ -389,8 +389,8 @@ class MainWindow(QMainWindow): else: raise DatastructureError('not specified') return self.fnames - except DatastructureError, e: - print e + except DatastructureError as e: + print(e) props = PropertiesDlg(self) if props.exec_() == QDialog.Accepted: return self.getWFFnames() From 57a9444478c10afd9416b7b5a5a18dc65dce4593 Mon Sep 17 00:00:00 2001 From: Marcel Paffrath Date: Mon, 14 Sep 2015 11:01:23 +0200 Subject: [PATCH 8/8] commiting changes to suppress output; necessary for fast calculation in active mode --- pylot/core/pick/CharFuns.py | 4 ++-- pylot/core/pick/utils.py | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pylot/core/pick/CharFuns.py b/pylot/core/pick/CharFuns.py index b3ad1f07..2f6e8cd8 100644 --- a/pylot/core/pick/CharFuns.py +++ b/pylot/core/pick/CharFuns.py @@ -218,7 +218,7 @@ class AICcf(CharacteristicFunction): def calcCF(self, data): - print 'Calculating AIC ...' + #print 'Calculating AIC ...' ## MP MP output suppressed x = self.getDataArray() xnp = x[0].data nn = np.isnan(xnp) @@ -260,7 +260,7 @@ class HOScf(CharacteristicFunction): y = np.power(xnp, 3) y1 = np.power(xnp, 2) elif self.getOrder() == 4: # this is kurtosis - print 'Calculating kurtosis ...' + #print 'Calculating kurtosis ...' ## MP MP output suppressed y = np.power(xnp, 4) y1 = np.power(xnp, 2) diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index 052c2870..80277623 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -43,7 +43,13 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=None): LPick = None EPick = None PickError = None +<<<<<<< Updated upstream print ("earllatepicker: Get earliest and latest possible pick relative to most likely pick ...") +======= + # MP MP ++ output suppressed + #print 'earllatepicker: Get earliest and latest possible pick relative to most likely pick ...' + # MP MP -- +>>>>>>> Stashed changes x = X[0].data t = np.arange(0, X[0].stats.npts / X[0].stats.sampling_rate,