reformat code (fix indentation and python 3.x issues)

This commit is contained in:
Sebastian Wehling-Benatelli 2015-09-28 10:57:48 +02:00
parent 3dc9bb3d06
commit 4bd92565b9

View File

@ -147,7 +147,7 @@ class AICPicker(AutoPicking):
def calcPick(self): def calcPick(self):
print 'AICPicker: Get initial onset time (pick) from AIC-CF ...' print('AICPicker: Get initial onset time (pick) from AIC-CF ...')
self.Pick = None self.Pick = None
self.slope = None self.slope = None
@ -163,7 +163,7 @@ class AICPicker(AutoPicking):
ismooth = int(round(self.Tsmooth / self.dt)) ismooth = int(round(self.Tsmooth / self.dt))
aicsmooth = np.zeros(len(aic)) aicsmooth = np.zeros(len(aic))
if len(aic) < ismooth: if len(aic) < ismooth:
print 'AICPicker: Tsmooth larger than CF!' print('AICPicker: Tsmooth larger than CF!')
return return
else: else:
for i in range(1, len(aic)): for i in range(1, len(aic)):
@ -211,8 +211,8 @@ class AICPicker(AutoPicking):
# get signal window # get signal window
isignal = getsignalwin(self.Tcf, self.Pick, self.TSNR[2]) isignal = getsignalwin(self.Tcf, self.Pick, self.TSNR[2])
# calculate SNR from CF # calculate SNR from CF
self.SNR = max(abs(aic[isignal] - np.mean(aic[isignal]))) / max(abs(aic[inoise] \ self.SNR = max(abs(aic[isignal] - np.mean(aic[isignal]))) / \
- np.mean(aic[inoise]))) max(abs(aic[inoise] - np.mean(aic[inoise])))
# calculate slope from CF after initial pick # calculate slope from CF after initial pick
# get slope window # get slope window
tslope = self.TSNR[3] #slope determination window tslope = self.TSNR[3] #slope determination window
@ -222,8 +222,8 @@ class AICPicker(AutoPicking):
# 'cause slope should be calculated up to first local minimum only! # 'cause slope should be calculated up to first local minimum only!
imax = np.argmax(self.Data[0].data[islope]) imax = np.argmax(self.Data[0].data[islope])
if imax == 0: if imax == 0:
print 'AICPicker: Maximum for slope determination right at the beginning of the window!' print('AICPicker: Maximum for slope determination right at the beginning of the window!')
print 'Choose longer slope determination window!' print('Choose longer slope determination window!')
if self.iplot > 1: if self.iplot > 1:
p = plt.figure(self.iplot) p = plt.figure(self.iplot)
x = self.Data[0].data x = self.Data[0].data
@ -244,7 +244,7 @@ class AICPicker(AutoPicking):
P = np.polyfit(xslope, dataslope, 1) P = np.polyfit(xslope, dataslope, 1)
datafit = np.polyval(P, xslope) datafit = np.polyval(P, xslope)
if datafit[0] >= datafit[len(datafit) - 1]: if datafit[0] >= datafit[len(datafit) - 1]:
print 'AICPicker: Negative slope, bad onset skipped!' print('AICPicker: Negative slope, bad onset skipped!')
return return
self.slope = 1 / tslope * (datafit[len(dataslope) - 1] - datafit[0]) self.slope = 1 / tslope * (datafit[len(dataslope) - 1] - datafit[0])
@ -273,9 +273,9 @@ class AICPicker(AutoPicking):
p13, = plt.plot(self.Tcf[isignal], self.Data[0].data[isignal], 'r') p13, = plt.plot(self.Tcf[isignal], self.Data[0].data[isignal], 'r')
p14, = plt.plot(self.Tcf[islope], dataslope, 'g--') p14, = plt.plot(self.Tcf[islope], dataslope, 'g--')
p15, = plt.plot(self.Tcf[islope], datafit, 'g', linewidth=2) p15, = plt.plot(self.Tcf[islope], datafit, 'g', linewidth=2)
plt.legend([p11, p12, p13, p14, p15], ['Data', 'Noise Window', 'Signal Window', 'Slope Window', 'Slope'], \ plt.legend([p11, p12, p13, p14, p15], ['Data', 'Noise Window', 'Signal Window', 'Slope Window', 'Slope'],
loc='best') loc='best')
plt.title('Station %s, SNR=%7.2f, Slope= %12.2f counts/s' % (self.Data[0].stats.station, \ plt.title('Station %s, SNR=%7.2f, Slope= %12.2f counts/s' % (self.Data[0].stats.station,
self.SNR, self.slope)) self.SNR, self.slope))
plt.xlabel('Time [s] since %s' % self.Data[0].stats.starttime) plt.xlabel('Time [s] since %s' % self.Data[0].stats.starttime)
plt.ylabel('Counts') plt.ylabel('Counts')
@ -286,7 +286,7 @@ class AICPicker(AutoPicking):
plt.close(p) plt.close(p)
if self.Pick == None: if self.Pick == None:
print 'AICPicker: Could not find minimum, picking window too short?' print('AICPicker: Could not find minimum, picking window too short?')
class PragPicker(AutoPicking): class PragPicker(AutoPicking):
@ -297,7 +297,7 @@ class PragPicker(AutoPicking):
def calcPick(self): def calcPick(self):
if self.getpick1() is not None: if self.getpick1() is not None:
print 'PragPicker: Get most likely pick from HOS- or AR-CF using pragmatic picking algorithm ...' print('PragPicker: Get most likely pick from HOS- or AR-CF using pragmatic picking algorithm ...')
self.Pick = None self.Pick = None
self.SNR = None self.SNR = None
@ -307,7 +307,7 @@ class PragPicker(AutoPicking):
ismooth = int(round(self.Tsmooth / self.dt)) ismooth = int(round(self.Tsmooth / self.dt))
cfsmooth = np.zeros(len(self.cf)) cfsmooth = np.zeros(len(self.cf))
if len(self.cf) < ismooth: if len(self.cf) < ismooth:
print 'PragPicker: Tsmooth larger than CF!' print('PragPicker: Tsmooth larger than CF!')
return return
else: else:
for i in range(1, len(self.cf)): for i in range(1, len(self.cf)):
@ -330,11 +330,11 @@ class PragPicker(AutoPicking):
#check trend of CF, i.e. differences of CF and adjust aus regarding this trend #check trend of CF, i.e. differences of CF and adjust aus regarding this trend
#prominent trend: decrease aus #prominent trend: decrease aus
#flat: use given aus #flat: use given aus
cfdiff = np.diff(cfipick); cfdiff = np.diff(cfipick)
i0diff = np.where(cfdiff > 0) i0diff = np.where(cfdiff > 0)
cfdiff = cfdiff[i0diff] cfdiff = cfdiff[i0diff]
minaus = min(cfdiff * (1 + self.aus)); minaus = min(cfdiff * (1 + self.aus))
aus1 = max([minaus, self.aus]); aus1 = max([minaus, self.aus])
#at first we look to the right until the end of the pick window is reached #at first we look to the right until the end of the pick window is reached
flagpick_r = 0 flagpick_r = 0
@ -374,7 +374,7 @@ class PragPicker(AutoPicking):
self.Pick = pick_l self.Pick = pick_l
pickflag = 1 pickflag = 1
else: else:
print 'PragPicker: Could not find reliable onset!' print('PragPicker: Could not find reliable onset!')
self.Pick = None self.Pick = None
pickflag = 0 pickflag = 0
@ -393,6 +393,6 @@ class PragPicker(AutoPicking):
plt.close(p) plt.close(p)
else: else:
print 'PragPicker: No initial onset time given! Check input!' print('PragPicker: No initial onset time given! Check input!')
self.Pick = None self.Pick = None
return return