reformatting code to avoid indentation inconsistencies

This commit is contained in:
Sebastian Wehling-Benatelli 2015-06-22 11:06:53 +02:00
parent 245a7455ff
commit 30bc8ccd82

View File

@ -13,6 +13,7 @@ import matplotlib.pyplot as plt
from obspy.core import Stream, UTCDateTime from obspy.core import Stream, UTCDateTime
import warnings import warnings
def earllatepicker(X, nfac, TSNR, Pick1, iplot=None): def earllatepicker(X, nfac, TSNR, Pick1, iplot=None):
''' '''
Function to derive earliest and latest possible pick after Diehl & Kissling (2009) Function to derive earliest and latest possible pick after Diehl & Kissling (2009)
@ -84,7 +85,8 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=None):
p2, = plt.plot(t[inoise], x[inoise]) p2, = plt.plot(t[inoise], x[inoise])
p3, = plt.plot(t[isignal], x[isignal], 'r') p3, = plt.plot(t[isignal], x[isignal], 'r')
p4, = plt.plot([t[0], t[int(len(t)) - 1]], [nlevel, nlevel], '--k') p4, = plt.plot([t[0], t[int(len(t)) - 1]], [nlevel, nlevel], '--k')
p5, = plt.plot(t[isignal[0][zc]], np.zeros(len(zc)), '*g', markersize=14) p5, = plt.plot(t[isignal[0][zc]], np.zeros(len(zc)), '*g',
markersize=14)
plt.legend([p1, p2, p3, p4, p5], plt.legend([p1, p2, p3, p4, p5],
['Data', 'Noise Window', 'Signal Window', 'Noise Level', ['Data', 'Noise Window', 'Signal Window', 'Noise Level',
'Zero Crossings'], \ 'Zero Crossings'], \
@ -280,11 +282,13 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=None):
return FM return FM
def crossings_nonzero_all(data): def crossings_nonzero_all(data):
pos = data > 0 pos = data > 0
npos = ~pos npos = ~pos
return ((pos[:-1] & npos[1:]) | (npos[:-1] & pos[1:])).nonzero()[0] return ((pos[:-1] & npos[1:]) | (npos[:-1] & pos[1:])).nonzero()[0]
def getSNR(X, TSNR, t1): def getSNR(X, TSNR, t1):
''' '''
Function to calculate SNR of certain part of seismogram relative to Function to calculate SNR of certain part of seismogram relative to
@ -382,6 +386,7 @@ def getsignalwin(t, t1, tsignal):
return isignal return isignal
def wadaticheck(pickdic, dttolerance, iplot): def wadaticheck(pickdic, dttolerance, iplot):
''' '''
Function to calculate Wadati-diagram from given P and S onsets in order Function to calculate Wadati-diagram from given P and S onsets in order
@ -413,14 +418,19 @@ def wadaticheck(pickdic, dttolerance, iplot):
# add S-P time to dictionary # add S-P time to dictionary
pickdic[key]['SPt'] = spt pickdic[key]['SPt'] = spt
# add P onsets and corresponding S-P times to list # add P onsets and corresponding S-P times to list
UTCPpick = UTCDateTime(pickdic[key]['P']['mpp']) - UTCDateTime(1970,1,1,0,0,0) UTCPpick = UTCDateTime(pickdic[key]['P']['mpp']) - UTCDateTime(1970,
UTCSpick = UTCDateTime(pickdic[key]['S']['mpp']) - UTCDateTime(1970,1,1,0,0,0) 1, 1,
0, 0,
0)
UTCSpick = UTCDateTime(pickdic[key]['S']['mpp']) - UTCDateTime(1970,
1, 1,
0, 0,
0)
Ppicks.append(UTCPpick) Ppicks.append(UTCPpick)
Spicks.append(UTCSpick) Spicks.append(UTCSpick)
SPtimes.append(spt) SPtimes.append(spt)
vpvs.append(UTCPpick / UTCSpick) vpvs.append(UTCPpick / UTCSpick)
if len(SPtimes) >= 3: if len(SPtimes) >= 3:
# calculate slope # calculate slope
p1 = np.polyfit(Ppicks, SPtimes, 1) p1 = np.polyfit(Ppicks, SPtimes, 1)
@ -455,7 +465,8 @@ def wadaticheck(pickdic, dttolerance, iplot):
checkedSpick = UTCDateTime(pickdic[key]['S']['mpp']) - \ checkedSpick = UTCDateTime(pickdic[key]['S']['mpp']) - \
UTCDateTime(1970, 1, 1, 0, 0, 0) UTCDateTime(1970, 1, 1, 0, 0, 0)
checkedSpicks.append(checkedSpick) checkedSpicks.append(checkedSpick)
checkedSPtime = pickdic[key]['S']['mpp'] - pickdic[key]['P']['mpp'] checkedSPtime = pickdic[key]['S']['mpp'] - \
pickdic[key]['P']['mpp']
checkedSPtimes.append(checkedSPtime) checkedSPtimes.append(checkedSPtime)
checkedvpvs.append(checkedPpick / checkedSpick) checkedvpvs.append(checkedPpick / checkedSpick)
@ -487,9 +498,11 @@ def wadaticheck(pickdic, dttolerance, iplot):
f4, = plt.plot(checkedPpicks, wdfit2, 'g') f4, = plt.plot(checkedPpicks, wdfit2, 'g')
plt.ylabel('S-P Times [s]') plt.ylabel('S-P Times [s]')
plt.xlabel('P Times [s]') plt.xlabel('P Times [s]')
plt.title('Wadati-Diagram, %d S-P Times, Vp/Vs(old)=%5.2f, Vp/Vs(checked)=%5.2f' \ plt.title(
'Wadati-Diagram, %d S-P Times, Vp/Vs(old)=%5.2f, Vp/Vs(checked)=%5.2f' \
% (len(SPtimes), vpvsr, cvpvsr)) % (len(SPtimes), vpvsr, cvpvsr))
plt.legend([f1, f2, f3, f4], ['Skipped S-Picks', 'Wadati 1', 'Reliable S-Picks', \ plt.legend([f1, f2, f3, f4],
['Skipped S-Picks', 'Wadati 1', 'Reliable S-Picks', \
'Wadati 2'], loc='best') 'Wadati 2'], loc='best')
plt.show() plt.show()
raw_input() raw_input()