From bb6ebc7ee167798bdd580ee9b9b2dcad62ebfedf Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Tue, 23 Jun 2015 08:22:59 +0200 Subject: [PATCH 1/4] reformatting code for reasons of coding conventions --- pylot/core/pick/utils.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index 5bd4c799..97daa194 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -393,8 +393,8 @@ def wadaticheck(pickdic, dttolerance, iplot): : param: pickdic, dictionary containing picks and quality parameters : type: dictionary - - : param: dttolerance, maximum adjusted deviation of S-P time from + + : param: dttolerance, maximum adjusted deviation of S-P time from S-P time regression : type: float @@ -423,15 +423,15 @@ def wadaticheck(pickdic, dttolerance, iplot): if len(SPtimes) >= 3: - # calculate slope + # calculate slope p1 = np.polyfit(Ppicks, SPtimes, 1) wdfit = np.polyval(p1, Ppicks) wfitflag = 0 - + # calculate vp/vs ratio before check vpvsr = p1[0] + 1 print 'wadaticheck: Average Vp/Vs ratio before check:', vpvsr - + checkedPpicks = [] checkedSpicks = [] checkedSPtimes = [] @@ -443,7 +443,7 @@ def wadaticheck(pickdic, dttolerance, iplot): ii += 1 # check, if deviation is larger than adjusted if wddiff >= dttolerance: - # mark onset and downgrade S-weight to 9 + # mark onset and downgrade S-weight to 9 # (not used anymore) marker = 'badWadatiCheck' pickdic[key]['S']['weight'] = 9 @@ -459,7 +459,7 @@ def wadaticheck(pickdic, dttolerance, iplot): pickdic[key]['S']['marked'] = marker - # calculate new slope + # calculate new slope p2 = np.polyfit(checkedPpicks, checkedSPtimes, 1) wdfit2 = np.polyval(p2, checkedPpicks) @@ -468,7 +468,7 @@ def wadaticheck(pickdic, dttolerance, iplot): print 'wadaticheck: Average Vp/Vs ratio after check:', cvpvsr checkedonsets = pickdic - + else: print 'wadaticheck: Not enough S-P times available for reliable regression!' print 'Skip wadati check!' From dc281c6c0e9b3a9611e58324d0f237660bdc8a9f Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Tue, 23 Jun 2015 08:24:21 +0200 Subject: [PATCH 2/4] [bugfix] determine the SNR according to the demeaned waveform between the beginning of the noise window and the end of the signal window --- pylot/core/pick/utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index 97daa194..d74ab2a6 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -322,6 +322,9 @@ def getSNR(X, TSNR, t1): print 'getSNR: Empty array isignal, check signal window!' return + # demean over entire snr window + x -= x[inoise[0][0]:isignal[0][-1]].mean() + # calculate ratios noiselevel = np.sqrt(np.mean(np.square(x[inoise]))) signallevel = np.sqrt(np.mean(np.square(x[isignal]))) From a2ca6fd66fc73eabe954b1f98de31338c801b700 Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Tue, 23 Jun 2015 08:48:14 +0200 Subject: [PATCH 3/4] [bugfix] return value of getnoisewin and getsignalwin should be of expected type numpy.ndarray (was tuple) --- pylot/core/pick/utils.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index d74ab2a6..ce1719a1 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -353,9 +353,8 @@ def getnoisewin(t, t1, tnoise, tgap): :type: float ''' - inoise = None # get noise window - inoise = np.where((t <= max([t1 - tgap, 0])) \ + inoise, = np.where((t <= max([t1 - tgap, 0])) \ & (t >= max([t1 - tnoise - tgap, 0]))) if np.size(inoise) < 1: print 'getnoisewin: Empty array inoise, check noise window!' @@ -378,9 +377,8 @@ def getsignalwin(t, t1, tsignal): :type: float ''' - inoise = None # get signal window - isignal = np.where((t <= min([t1 + tsignal, len(t)])) \ + isignal, = np.where((t <= min([t1 + tsignal, len(t)])) \ & (t >= t1)) if np.size(isignal) < 1: print 'getsignalwin: Empty array isignal, check signal window!' From 8d4aaab92a15093e3698551c88dcddee4c8f0fec Mon Sep 17 00:00:00 2001 From: Sebastian Wehling-Benatelli Date: Tue, 23 Jun 2015 08:48:14 +0200 Subject: [PATCH 4/4] [bugfix] return value of getnoisewin and getsignalwin should be of expected type numpy.ndarray (was tuple) --- pylot/core/pick/utils.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index d74ab2a6..0d3ed952 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -323,7 +323,7 @@ def getSNR(X, TSNR, t1): return # demean over entire snr window - x -= x[inoise[0][0]:isignal[0][-1]].mean() + x -= x[inoise[0]:isignal[-1]].mean() # calculate ratios noiselevel = np.sqrt(np.mean(np.square(x[inoise]))) @@ -353,9 +353,8 @@ def getnoisewin(t, t1, tnoise, tgap): :type: float ''' - inoise = None # get noise window - inoise = np.where((t <= max([t1 - tgap, 0])) \ + inoise, = np.where((t <= max([t1 - tgap, 0])) \ & (t >= max([t1 - tnoise - tgap, 0]))) if np.size(inoise) < 1: print 'getnoisewin: Empty array inoise, check noise window!' @@ -378,9 +377,8 @@ def getsignalwin(t, t1, tsignal): :type: float ''' - inoise = None # get signal window - isignal = np.where((t <= min([t1 + tsignal, len(t)])) \ + isignal, = np.where((t <= min([t1 + tsignal, len(t)])) \ & (t >= t1)) if np.size(isignal) < 1: print 'getsignalwin: Empty array isignal, check signal window!'