From a7fd239574b97e923d914acdca52ee2dc3a4b424 Mon Sep 17 00:00:00 2001 From: Darius Arnold Date: Fri, 15 Sep 2017 16:28:27 +0200 Subject: [PATCH 1/8] [bugfix] improvements to removal of NaNs during Cf calculation --- pylot/core/pick/charfuns.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/pylot/core/pick/charfuns.py b/pylot/core/pick/charfuns.py index a6fb5841..7ee59092 100644 --- a/pylot/core/pick/charfuns.py +++ b/pylot/core/pick/charfuns.py @@ -228,9 +228,9 @@ class AICcf(CharacteristicFunction): # print 'Calculating AIC ...' x = self.getDataArray() xnp = x[0].data - nn = np.isnan(xnp) - if len(nn) > 1: - xnp[nn] = 0 + ind = np.where(~np.isnan(xnp))[0] + if ind.size: + xnp[:ind[0]] = xnp[ind[0]] datlen = len(xnp) k = np.arange(1, datlen) cf = np.zeros(datlen) @@ -345,7 +345,8 @@ class ARZcf(CharacteristicFunction): cf = tap * cf io = np.where(cf == 0) ino = np.where(cf > 0) - cf[io] = cf[ino[0][0]] + if np.size(ino): + cf[io] = cf[ino[0][0]] self.cf = cf self.xcf = x @@ -477,7 +478,8 @@ class ARHcf(CharacteristicFunction): cf = tap * cf io = np.where(cf == 0) ino = np.where(cf > 0) - cf[io] = cf[ino[0][0]] + if np.size(ino): + cf[io] = cf[ino[0][0]] self.cf = cf self.xcf = xnp @@ -619,7 +621,8 @@ class AR3Ccf(CharacteristicFunction): cf = tap * cf io = np.where(cf == 0) ino = np.where(cf > 0) - cf[io] = cf[ino[0][0]] + if np.size(ino): + cf[io] = cf[ino[0][0]] self.cf = cf self.xcf = xnp From 8dc5be8e493ccb50fcbfd403f57b843abcb76d64 Mon Sep 17 00:00:00 2001 From: Darius Arnold Date: Fri, 15 Sep 2017 16:47:12 +0200 Subject: [PATCH 2/8] [bugfix] removed unneccessary command added during tight layout change --- pylot/core/pick/autopick.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pylot/core/pick/autopick.py b/pylot/core/pick/autopick.py index e558b124..d84496c0 100644 --- a/pylot/core/pick/autopick.py +++ b/pylot/core/pick/autopick.py @@ -727,7 +727,6 @@ def autopickstation(wfstream, pickparam, verbose=False, else: fig = None linecolor = 'k' - fig._tight = True refSpick = PragPicker(arhcf2, tsnrh, pickwinS, iplot, ausS, tsmoothS, aicarhpick.getpick(), fig, linecolor) mpickS = refSpick.getpick() From 7c528a4bfdf71a4be50df8ba1e86d3433dac2186 Mon Sep 17 00:00:00 2001 From: Darius Arnold Date: Fri, 15 Sep 2017 16:48:08 +0200 Subject: [PATCH 3/8] [change] jackknife and wadati plot show one instead of two points in legend --- pylot/core/pick/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index 3cafc490..ff67055f 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -690,7 +690,7 @@ def wadaticheck(pickdic, dttolerance, iplot=0, fig_dict=None): ax.plot(checkedPpicks, wdfit2, 'g', label='Wadati 2') ax.set_title('Wadati-Diagram, %d S-P Times, Vp/Vs(raw)=%5.2f,' \ 'Vp/Vs(checked)=%5.2f' % (len(SPtimes), vpvsr, cvpvsr)) - ax.legend(loc=1) + ax.legend(loc=1, numpoints=1) else: ax.set_title('Wadati-Diagram, %d S-P Times' % len(SPtimes)) @@ -921,7 +921,7 @@ def checkPonsets(pickdic, dttolerance, jackfactor=5, iplot=0, fig_dict=None): ax.set_xlabel('Number of P Picks') ax.set_ylabel('Onset Time [s] from 1.1.1970') - ax.legend(loc=1) + ax.legend(loc=1, numpoints=1) ax.set_title('Jackknifing and Median Tests on P Onsets') if plt_flag: fig.show() From 62625d6941b3d92693c1758b79eff45384fd1b51 Mon Sep 17 00:00:00 2001 From: Darius Arnold Date: Fri, 15 Sep 2017 18:28:33 +0200 Subject: [PATCH 4/8] improved wadati plot added names of stations, added lines indicating wadati tolerance --- pylot/core/pick/utils.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index ff67055f..a5e72cd8 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -589,6 +589,7 @@ def wadaticheck(pickdic, dttolerance, iplot=0, fig_dict=None): Ppicks = [] Spicks = [] SPtimes = [] + stations = [] for key in list(pickdic.keys()): if pickdic[key]['P']['weight'] < 4 and pickdic[key]['S']['weight'] < 4: # calculate S-P time @@ -622,6 +623,7 @@ def wadaticheck(pickdic, dttolerance, iplot=0, fig_dict=None): ibad = 0 for key in list(pickdic.keys()): if 'SPt' in pickdic[key]: + stations.append(key) wddiff = abs(pickdic[key]['SPt'] - wdfit[ii]) ii += 1 # check, if deviation is larger than adjusted @@ -682,12 +684,18 @@ def wadaticheck(pickdic, dttolerance, iplot=0, fig_dict=None): linecolor = 'k' plt_flag = 1 ax = fig.add_subplot(111) - ax.plot(Ppicks, SPtimes, 'ro', label='Skipped S-Picks') + if ibad > 0: + ax.plot(Ppicks, SPtimes, 'ro', label='Skipped S-Picks') if wfitflag == 0: ax.plot(Ppicks, wdfit, color=linecolor, linewidth=0.7, label='Wadati 1') + ax.plot(Ppicks, wdfit+dttolerance, color='0.9', linewidth=0.5, label='Wadati 1 Tolerance') + ax.plot(Ppicks, wdfit-dttolerance, color='0.9', linewidth=0.5) + ax.plot(checkedPpicks, wdfit2, 'g', label='Wadati 2') ax.plot(checkedPpicks, checkedSPtimes, color=linecolor, linewidth=0, marker='o', label='Reliable S-Picks') - ax.plot(checkedPpicks, wdfit2, 'g', label='Wadati 2') + for Ppick, SPtime, station in zip(Ppicks, SPtimes, stations): + ax.text(Ppick, SPtime + 0.01, '{0}'.format(station)) + ax.set_title('Wadati-Diagram, %d S-P Times, Vp/Vs(raw)=%5.2f,' \ 'Vp/Vs(checked)=%5.2f' % (len(SPtimes), vpvsr, cvpvsr)) ax.legend(loc=1, numpoints=1) From 27a6af663661ae81f5a44499a41beb91a9482546 Mon Sep 17 00:00:00 2001 From: Darius Arnold Date: Fri, 15 Sep 2017 18:31:20 +0200 Subject: [PATCH 5/8] improved jackknife/median plot added different colors to markers for accepted picks, jackknife reject picks and median rejected picks, added lines indicating median tolerance --- pylot/core/pick/utils.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index a5e72cd8..359059ac 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -917,16 +917,19 @@ def checkPonsets(pickdic, dttolerance, jackfactor=5, iplot=0, fig_dict=None): plt_flag = 1 ax = fig.add_subplot(111) - ax.plot(np.arange(0, len(Ppicks)), Ppicks, 'ro', markersize=14) - if len(badstations) < 1 and len(badjkstations) < 1: - ax.plot(np.arange(0, len(Ppicks)), Ppicks, 'go', markersize=14, label='Skipped P Picks') - else: - ax.plot(igood, np.array(Ppicks)[igood], 'go', markersize=14, label='Good P Picks') - ax.plot([0, len(Ppicks) - 1], [pmedian, pmedian], 'g', - linewidth=2, label='Median') - for i in range(0, len(Ppicks)): - ax.text(i, Ppicks[i] + 0.01, '{0}'.format(stations[i])) - + if len(badstations) > 0: + ax.plot(ibad, np.array(Ppicks)[ibad], marker ='o', markerfacecolor='orange', markersize=14, + linestyle='None', label='Median Skipped P Picks') + if len(badjkstations) > 0: + ax.plot(badjk[0], np.array(Ppicks)[badjk], 'ro', markersize=14, label='Jackknife Skipped P Picks') + ax.plot(igood, np.array(Ppicks)[igood], 'go', markersize=14, label='Good P Picks') + ax.plot([0, len(Ppicks) - 1], [pmedian, pmedian], 'g', linewidth=2, label='Median') + ax.plot([0, len(Ppicks) - 1], [pmedian + dttolerance, pmedian + dttolerance], 'g--', linewidth=1.2, + dashes=[25, 25], label='Median Tolerance') + ax.plot([0, len(Ppicks) - 1], [pmedian - dttolerance, pmedian - dttolerance], 'g--', linewidth=1.2, + dashes=[25, 25]) + for index, pick in enumerate(Ppicks): + ax.text(index, pick + 0.01, '{0}'.format(stations[i])) ax.set_xlabel('Number of P Picks') ax.set_ylabel('Onset Time [s] from 1.1.1970') ax.legend(loc=1, numpoints=1) From 2e6c33de452c3d4dacaab4d3399f754ce81d0dd7 Mon Sep 17 00:00:00 2001 From: Darius Arnold Date: Fri, 15 Sep 2017 18:56:04 +0200 Subject: [PATCH 6/8] [bugfix] allow picking of S phase in lower area of waveform plot Fixes bug report #211 --- pylot/core/util/widgets.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index e12d6680..54772bc3 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -1601,6 +1601,7 @@ class PickDlg(QDialog): return self.station def getChannelID(self, key): + if key < 0: key = 0 return self.multicompfig.getPlotDict()[int(key)][1] def getTraceID(self, channels): From 2ee3c9a3042b52af7366814838c7cde0df218a17 Mon Sep 17 00:00:00 2001 From: Darius Arnold Date: Sun, 27 Aug 2017 16:34:00 +0200 Subject: [PATCH 7/8] [change] show more stations in stationbox of tune autopicker dialog --- pylot/core/util/widgets.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 54772bc3..4c1a1356 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -2494,6 +2494,7 @@ class TuneAutopicker(QWidget): def init_stationlist(self): self.stationBox = QtGui.QComboBox() + self.stationBox.setMaxVisibleItems(42) self.trace_layout.addWidget(self.stationBox) self.fill_stationbox() self.figure_tabs.setCurrentIndex(0) From 586abea8748ec2e74b932bb6dd23e2caad7d7a41 Mon Sep 17 00:00:00 2001 From: Darius Arnold Date: Fri, 15 Sep 2017 20:48:22 +0200 Subject: [PATCH 8/8] [bugfix] same treatment of waveform data in tune autopicker and load waveform fixes #217. While generating the station list for the tune autopicker dialog, waveform data was loaded and some traces were removed (gaps, doubled, rotated). However, not all the functions were called on wfdat, so some stations would be unavailable in the general waveform overview for the event, but could be selected in the tune autopicker. --- pylot/core/util/widgets.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pylot/core/util/widgets.py b/pylot/core/util/widgets.py index 4c1a1356..5f0201e3 100644 --- a/pylot/core/util/widgets.py +++ b/pylot/core/util/widgets.py @@ -48,7 +48,8 @@ from pylot.core.pick.compare import Comparison from pylot.core.util.defaults import OUTPUTFORMATS, FILTERDEFAULTS, \ SetChannelComponents from pylot.core.util.utils import prepTimeAxis, full_range, scaleWFData, \ - demeanTrace, isSorted, findComboBoxIndex, clims, pick_linestyle_plt, pick_color_plt + demeanTrace, isSorted, findComboBoxIndex, clims, pick_linestyle_plt, pick_color_plt, \ + check4rotated, check4doubled, check4gaps, remove_underscores from autoPyLoT import autoPyLoT from pylot.core.util.thread import Thread @@ -2509,10 +2510,15 @@ class TuneAutopicker(QWidget): fnames = self.parent().getWFFnames_from_eventbox(eventbox=self.eventBox) self.data.setWFData(fnames) wfdat = self.data.getWFData() # all available streams + # remove possible underscores in station names + wfdat = remove_underscores(wfdat) + # rotate misaligned stations to ZNE + # check for gaps and doubled channels + check4gaps(wfdat) + check4doubled(wfdat) + wfdat = check4rotated(wfdat, self.parent().metadata, verbosity=0) # trim station components to same start value trim_station_components(wfdat, trim_start=True, trim_end=False) - # rotate misaligned stations to ZNE - wfdat = check4rotated(wfdat, self.parent().metadata, verbosity=0) self.stationBox.clear() stations = [] for trace in self.data.getWFData():