diff --git a/pylot/core/pick/utils.py b/pylot/core/pick/utils.py index 097863ae..166816ad 100644 --- a/pylot/core/pick/utils.py +++ b/pylot/core/pick/utils.py @@ -324,6 +324,9 @@ def getSNR(X, TSNR, t1): print 'getSNR: Empty array isignal, check signal window!' return + # demean over entire snr window + x -= x[inoise[0]:isignal[-1]].mean() + # calculate ratios noiselevel = np.sqrt(np.mean(np.square(x[inoise]))) signallevel = np.sqrt(np.mean(np.square(x[isignal]))) @@ -352,9 +355,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!' @@ -377,9 +379,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!' @@ -395,8 +396,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 @@ -425,15 +426,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 = [] @@ -445,7 +446,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 @@ -461,7 +462,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) @@ -470,7 +471,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!'