general clean-up 2.0 even more checks made and issues resolved

This commit is contained in:
Sebastian Wehling-Benatelli 2015-10-19 11:25:15 +02:00
parent 0fa701a878
commit 0a7b02c04a
9 changed files with 76 additions and 76 deletions

View File

@ -273,8 +273,7 @@ class MainWindow(QMainWindow):
slot=self.autoPick, shortcut='Alt+Ctrl+A', slot=self.autoPick, shortcut='Alt+Ctrl+A',
icon=auto_icon, tip='Automatically pick' icon=auto_icon, tip='Automatically pick'
' the entire dataset' ' the entire dataset'
' displayed!', ' displayed!')
checkable=False)
autoPickToolBar = self.addToolBar("autoPyLoT") autoPickToolBar = self.addToolBar("autoPyLoT")
autoPickActions = (auto_pick,) autoPickActions = (auto_pick,)

View File

@ -437,7 +437,7 @@ class SeismicShot(object):
if self.getDistance(traceID) == distance: if self.getDistance(traceID) == distance:
traceID_list.append(traceID) traceID_list.append(traceID)
if distancebin[0] >= 0 and distancebin[1] > 0: if distancebin[0] >= 0 and distancebin[1] > 0:
if self.getDistance(traceID) > distancebin[0] and self.getDistance(traceID) < distancebin[1]: if distancebin[0] < self.getDistance(traceID) < distancebin[1]:
traceID_list.append(traceID) traceID_list.append(traceID)
if len(traceID_list) > 0: if len(traceID_list) > 0:

View File

@ -185,7 +185,7 @@ class DCfc(Magnitude):
[optspecfit, pcov] = curve_fit(synthsourcespec, F, YY.real, [DCin, Fcin]) [optspecfit, pcov] = curve_fit(synthsourcespec, F, YY.real, [DCin, Fcin])
self.w0 = optspecfit[0] self.w0 = optspecfit[0]
self.fc = optspecfit[1] self.fc = optspecfit[1]
print ("DCfc: Determined DC-value: %e m/Hz, \n" \ print ("DCfc: Determined DC-value: %e m/Hz, \n"
"Determined corner frequency: %f Hz" % (self.w0, self.fc)) "Determined corner frequency: %f Hz" % (self.w0, self.fc))

View File

@ -165,12 +165,12 @@ class CharacteristicFunction(object):
stop = min([len(self.orig_data[0]), len(self.orig_data[1])]) stop = min([len(self.orig_data[0]), len(self.orig_data[1])])
elif self.cut[0] == 0 and self.cut[1] is not 0: elif self.cut[0] == 0 and self.cut[1] is not 0:
start = 0 start = 0
stop = min([self.cut[1] / self.dt, len(self.orig_data[0]), \ stop = min([self.cut[1] / self.dt, len(self.orig_data[0]),
len(self.orig_data[1])]) len(self.orig_data[1])])
else: else:
start = max([0, self.cut[0] / self.dt]) start = max([0, self.cut[0] / self.dt])
stop = min([self.cut[1] / self.dt, len(self.orig_data[0]), \ stop = min([self.cut[1] / self.dt, len(self.orig_data[0]),
len(self.orig_data[1])]) len(self.orig_data[1])])
hh = self.orig_data.copy() hh = self.orig_data.copy()
h1 = hh[0].copy() h1 = hh[0].copy()
h2 = hh[1].copy() h2 = hh[1].copy()
@ -181,15 +181,15 @@ class CharacteristicFunction(object):
elif len(self.orig_data) == 3: elif len(self.orig_data) == 3:
if self.cut[0] == 0 and self.cut[1] == 0: if self.cut[0] == 0 and self.cut[1] == 0:
start = 0 start = 0
stop = min([self.cut[1] / self.dt, len(self.orig_data[0]), \ stop = min([self.cut[1] / self.dt, len(self.orig_data[0]),
len(self.orig_data[1]), len(self.orig_data[2])]) len(self.orig_data[1]), len(self.orig_data[2])])
elif self.cut[0] == 0 and self.cut[1] is not 0: elif self.cut[0] == 0 and self.cut[1] is not 0:
start = 0 start = 0
stop = self.cut[1] / self.dt stop = self.cut[1] / self.dt
else: else:
start = max([0, self.cut[0] / self.dt]) start = max([0, self.cut[0] / self.dt])
stop = min([self.cut[1] / self.dt, len(self.orig_data[0]), \ stop = min([self.cut[1] / self.dt, len(self.orig_data[0]),
len(self.orig_data[1]), len(self.orig_data[2])]) len(self.orig_data[1]), len(self.orig_data[2])])
hh = self.orig_data.copy() hh = self.orig_data.copy()
h1 = hh[0].copy() h1 = hh[0].copy()
h2 = hh[1].copy() h2 = hh[1].copy()
@ -231,7 +231,7 @@ class AICcf(CharacteristicFunction):
cumsumcf = np.cumsum(np.power(xnp, 2)) cumsumcf = np.cumsum(np.power(xnp, 2))
i = np.where(cumsumcf == 0) i = np.where(cumsumcf == 0)
cumsumcf[i] = np.finfo(np.float64).eps cumsumcf[i] = np.finfo(np.float64).eps
cf[k] = ((k - 1) * np.log(cumsumcf[k] / k) + (datlen - k + 1) * \ cf[k] = ((k - 1) * np.log(cumsumcf[k] / k) + (datlen - k + 1) *
np.log((cumsumcf[datlen - 1] - cumsumcf[k - 1]) / (datlen - k + 1))) np.log((cumsumcf[datlen - 1] - cumsumcf[k - 1]) / (datlen - k + 1)))
cf[0] = cf[1] cf[0] = cf[1]
inf = np.isinf(cf) inf = np.isinf(cf)

View File

@ -204,27 +204,27 @@ def autopickstation(wfstream, pickparam):
if len(ndat) == 0 or len(edat) == 0: if len(ndat) == 0 or len(edat) == 0:
print ("One or more horizontal components missing!") print ("One or more horizontal components missing!")
print ("Signal length only checked on vertical component!") print ("Signal length only checked on vertical component!")
print ("Decreasing minsiglengh from %f to %f" \ print ("Decreasing minsiglengh from %f to %f"
% (minsiglength, minsiglength / 2)) % (minsiglength, minsiglength / 2))
Pflag = checksignallength(zne, aicpick.getpick(), tsnrz, Pflag = checksignallength(zne, aicpick.getpick(), tsnrz,
minsiglength / 2, \ minsiglength / 2,
nfacsl, minpercent, iplot) nfacsl, minpercent, iplot)
else: else:
# filter and taper horizontal traces # filter and taper horizontal traces
trH1_filt = edat.copy() trH1_filt = edat.copy()
trH2_filt = ndat.copy() trH2_filt = ndat.copy()
trH1_filt.filter('bandpass', freqmin=bph1[0], trH1_filt.filter('bandpass', freqmin=bph1[0],
freqmax=bph1[1], \ freqmax=bph1[1],
zerophase=False) zerophase=False)
trH2_filt.filter('bandpass', freqmin=bph1[0], trH2_filt.filter('bandpass', freqmin=bph1[0],
freqmax=bph1[1], \ freqmax=bph1[1],
zerophase=False) zerophase=False)
trH1_filt.taper(max_percentage=0.05, type='hann') trH1_filt.taper(max_percentage=0.05, type='hann')
trH2_filt.taper(max_percentage=0.05, type='hann') trH2_filt.taper(max_percentage=0.05, type='hann')
zne += trH1_filt zne += trH1_filt
zne += trH2_filt zne += trH2_filt
Pflag = checksignallength(zne, aicpick.getpick(), tsnrz, Pflag = checksignallength(zne, aicpick.getpick(), tsnrz,
minsiglength, \ minsiglength,
nfacsl, minpercent, iplot) nfacsl, minpercent, iplot)
if Pflag == 1: if Pflag == 1:
@ -234,7 +234,7 @@ def autopickstation(wfstream, pickparam):
print 'One or more horizontal components missing!' print 'One or more horizontal components missing!'
print 'Skipping control function checkZ4S.' print 'Skipping control function checkZ4S.'
else: else:
Pflag = checkZ4S(zne, aicpick.getpick(), zfac, \ Pflag = checkZ4S(zne, aicpick.getpick(), zfac,
tsnrz[3], iplot) tsnrz[3], iplot)
if Pflag == 0: if Pflag == 0:
Pmarker = 'SinsteadP' Pmarker = 'SinsteadP'
@ -331,7 +331,7 @@ def autopickstation(wfstream, pickparam):
# waveform after P onset! # waveform after P onset!
zc = crossings_nonzero_all(wfzc) zc = crossings_nonzero_all(wfzc)
if np.size(zc) == 0: if np.size(zc) == 0:
print ("Something is wrong with the waveform, " \ print ("Something is wrong with the waveform, "
"no zero crossings derived!") "no zero crossings derived!")
print ("Cannot calculate source spectrum!") print ("Cannot calculate source spectrum!")
else: else:
@ -341,7 +341,7 @@ def autopickstation(wfstream, pickparam):
w0 = specpara.getw0() w0 = specpara.getw0()
fc = specpara.getfc() fc = specpara.getfc()
print ("autopickstation: P-weight: %d, SNR: %f, SNR[dB]: %f, " \ print ("autopickstation: P-weight: %d, SNR: %f, SNR[dB]: %f, "
"Polarity: %s" % (Pweight, SNRP, SNRPdB, FM)) "Polarity: %s" % (Pweight, SNRP, SNRPdB, FM))
Sflag = 1 Sflag = 1
@ -352,7 +352,7 @@ def autopickstation(wfstream, pickparam):
Sflag = 0 Sflag = 0
else: else:
print ("autopickstation: No vertical component data available!, " \ print ("autopickstation: No vertical component data available!, "
"Skipping station!") "Skipping station!")
if edat is not None and ndat is not None and len(edat) > 0 and len( if edat is not None and ndat is not None and len(edat) > 0 and len(
@ -593,8 +593,8 @@ def autopickstation(wfstream, pickparam):
if restflag == 1: if restflag == 1:
# calculate WA-peak-to-peak amplitude # calculate WA-peak-to-peak amplitude
# using subclass WApp of superclass Magnitude # using subclass WApp of superclass Magnitude
wapp = WApp(cordat, mpickP, mpickP + sstop + (0.5 * (mpickP \ wapp = WApp(cordat, mpickP, mpickP + sstop + (0.5 * (mpickP
+ sstop)), iplot) + sstop)), iplot)
Ao = wapp.getwapp() Ao = wapp.getwapp()
else: else:
@ -771,14 +771,14 @@ def autopickstation(wfstream, pickparam):
# create dictionary # create dictionary
# for P phase # for P phase
phase = 'P' phase = 'P'
phasepick = {'lpp': lpickP, 'epp': epickP, 'mpp': mpickP, 'spe': Perror, \ phasepick = {'lpp': lpickP, 'epp': epickP, 'mpp': mpickP, 'spe': Perror,
'snr': SNRP, 'snrdb': SNRPdB, 'weight': Pweight, 'fm': FM} 'snr': SNRP, 'snrdb': SNRPdB, 'weight': Pweight, 'fm': FM}
picks = {phase: phasepick} picks = {phase: phasepick}
# add P marker # add P marker
picks[phase]['marked'] = Pmarker picks[phase]['marked'] = Pmarker
# add S phase # add S phase
phase = 'S' phase = 'S'
phasepick = {'lpp': lpickS, 'epp': epickS, 'mpp': mpickS, 'spe': Serror, \ phasepick = {'lpp': lpickS, 'epp': epickS, 'mpp': mpickS, 'spe': Serror,
'snr': SNRS, 'snrdb': SNRSdB, 'weight': Sweight, 'fm': None} 'snr': SNRS, 'snrdb': SNRSdB, 'weight': Sweight, 'fm': None}
picks[phase] = phasepick picks[phase] = phasepick
# add Wood-Anderson amplitude # add Wood-Anderson amplitude

View File

@ -6,8 +6,8 @@
Only for test purposes! Only for test purposes!
""" """
from obspy.core import read from obspy.core import read
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
from pylot.core.pick.CharFuns import CharacteristicFunction from pylot.core.pick.CharFuns import CharacteristicFunction
from pylot.core.pick.Picker import AutoPicking from pylot.core.pick.Picker import AutoPicking
@ -56,7 +56,7 @@ def run_makeCF(project, database, event, iplot, station=None):
st_copy = st.copy() st_copy = st.copy()
#filter and taper data #filter and taper data
tr_filt = st[0].copy() tr_filt = st[0].copy()
tr_filt.filter('bandpass', freqmin=bpz[0], freqmax=bpz[1], zerophase=False) tr_filt.filter('bandpass', freqmin=bpz[0], freqmax=bpz[1], zerophase=False)
tr_filt.taper(max_percentage=0.05, type='hann') tr_filt.taper(max_percentage=0.05, type='hann')
st_copy[0].data = tr_filt.data st_copy[0].data = tr_filt.data
############################################################## ##############################################################
@ -120,8 +120,8 @@ def run_makeCF(project, database, event, iplot, station=None):
#filter and taper data #filter and taper data
trH1_filt = H[0].copy() trH1_filt = H[0].copy()
trH2_filt = H[1].copy() trH2_filt = H[1].copy()
trH1_filt.filter('bandpass', freqmin=bph[0], freqmax=bph[1], zerophase=False) trH1_filt.filter('bandpass', freqmin=bph[0], freqmax=bph[1], zerophase=False)
trH2_filt.filter('bandpass', freqmin=bph[0], freqmax=bph[1], zerophase=False) trH2_filt.filter('bandpass', freqmin=bph[0], freqmax=bph[1], zerophase=False)
trH1_filt.taper(max_percentage=0.05, type='hann') trH1_filt.taper(max_percentage=0.05, type='hann')
trH2_filt.taper(max_percentage=0.05, type='hann') trH2_filt.taper(max_percentage=0.05, type='hann')
H_copy[0].data = trH1_filt.data H_copy[0].data = trH1_filt.data
@ -167,9 +167,9 @@ def run_makeCF(project, database, event, iplot, station=None):
All1_filt = AllC[0].copy() All1_filt = AllC[0].copy()
All2_filt = AllC[1].copy() All2_filt = AllC[1].copy()
All3_filt = AllC[2].copy() All3_filt = AllC[2].copy()
All1_filt.filter('bandpass', freqmin=bph[0], freqmax=bph[1], zerophase=False) All1_filt.filter('bandpass', freqmin=bph[0], freqmax=bph[1], zerophase=False)
All2_filt.filter('bandpass', freqmin=bph[0], freqmax=bph[1], zerophase=False) All2_filt.filter('bandpass', freqmin=bph[0], freqmax=bph[1], zerophase=False)
All3_filt.filter('bandpass', freqmin=bpz[0], freqmax=bpz[1], zerophase=False) All3_filt.filter('bandpass', freqmin=bpz[0], freqmax=bpz[1], zerophase=False)
All1_filt.taper(max_percentage=0.05, type='hann') All1_filt.taper(max_percentage=0.05, type='hann')
All2_filt.taper(max_percentage=0.05, type='hann') All2_filt.taper(max_percentage=0.05, type='hann')
All3_filt.taper(max_percentage=0.05, type='hann') All3_filt.taper(max_percentage=0.05, type='hann')
@ -209,19 +209,19 @@ def run_makeCF(project, database, event, iplot, station=None):
plt.ylim([-1.5, 1.5]) plt.ylim([-1.5, 1.5])
plt.xlabel('Time [s]') plt.xlabel('Time [s]')
plt.ylabel('Normalized Counts') plt.ylabel('Normalized Counts')
plt.title('%s, %s, CF-SNR=%7.2f, CF-Slope=%12.2f' % (tr.stats.station, \ plt.title('%s, %s, CF-SNR=%7.2f, CF-Slope=%12.2f' % (tr.stats.station,
tr.stats.channel, aicpick.getSNR(), aicpick.getSlope())) tr.stats.channel, aicpick.getSNR(), aicpick.getSlope()))
plt.suptitle(tr.stats.starttime) plt.suptitle(tr.stats.starttime)
plt.legend([p1, p2, p3, p4, p5], ['Data', 'HOS-CF', 'HOSAIC-CF', 'ARZ-CF', 'ARZAIC-CF']) plt.legend([p1, p2, p3, p4, p5], ['Data', 'HOS-CF', 'HOSAIC-CF', 'ARZ-CF', 'ARZAIC-CF'])
#plot horizontal traces #plot horizontal traces
plt.figure(2) plt.figure(2)
plt.subplot(2,1,1) plt.subplot(2,1,1)
tsteph = tpredh / 4 tsteph = tpredh / 4
th1data = np.arange(0, trH1_filt.stats.npts / trH1_filt.stats.sampling_rate, trH1_filt.stats.delta) th1data = np.arange(0, trH1_filt.stats.npts / trH1_filt.stats.sampling_rate, trH1_filt.stats.delta)
th2data = np.arange(0, trH2_filt.stats.npts / trH2_filt.stats.sampling_rate, trH2_filt.stats.delta) th2data = np.arange(0, trH2_filt.stats.npts / trH2_filt.stats.sampling_rate, trH2_filt.stats.delta)
tarhcf = np.arange(0, len(arhcf.getCF()) * tsteph, tsteph) + cuttimes[0] + tdeth +tpredh tarhcf = np.arange(0, len(arhcf.getCF()) * tsteph, tsteph) + cuttimes[0] + tdeth +tpredh
p21, = plt.plot(th1data, trH1_filt.data/max(trH1_filt.data), 'k') p21, = plt.plot(th1data, trH1_filt.data/max(trH1_filt.data), 'k')
p22, = plt.plot(arhcf.getTimeArray(), arhcf.getCF()/max(arhcf.getCF()), 'r') p22, = plt.plot(arhcf.getTimeArray(), arhcf.getCF()/max(arhcf.getCF()), 'r')
p23, = plt.plot(arhaiccf.getTimeArray(), arhaiccf.getCF()/max(arhaiccf.getCF())) p23, = plt.plot(arhaiccf.getTimeArray(), arhaiccf.getCF()/max(arhaiccf.getCF()))
plt.plot([aicarhpick.getpick(), aicarhpick.getpick()], [-1, 1], 'b') plt.plot([aicarhpick.getpick(), aicarhpick.getpick()], [-1, 1], 'b')
plt.plot([aicarhpick.getpick()-0.5, aicarhpick.getpick()+0.5], [1, 1], 'b') plt.plot([aicarhpick.getpick()-0.5, aicarhpick.getpick()+0.5], [1, 1], 'b')
@ -238,10 +238,10 @@ def run_makeCF(project, database, event, iplot, station=None):
plt.ylabel('Normalized Counts') plt.ylabel('Normalized Counts')
plt.title([trH1_filt.stats.station, trH1_filt.stats.channel]) plt.title([trH1_filt.stats.station, trH1_filt.stats.channel])
plt.suptitle(trH1_filt.stats.starttime) plt.suptitle(trH1_filt.stats.starttime)
plt.legend([p21, p22, p23], ['Data', 'ARH-CF', 'ARHAIC-CF']) plt.legend([p21, p22, p23], ['Data', 'ARH-CF', 'ARHAIC-CF'])
plt.subplot(2,1,2) plt.subplot(2,1,2)
plt.plot(th2data, trH2_filt.data/max(trH2_filt.data), 'k') plt.plot(th2data, trH2_filt.data/max(trH2_filt.data), 'k')
plt.plot(arhcf.getTimeArray(), arhcf.getCF()/max(arhcf.getCF()), 'r') plt.plot(arhcf.getTimeArray(), arhcf.getCF()/max(arhcf.getCF()), 'r')
plt.plot(arhaiccf.getTimeArray(), arhaiccf.getCF()/max(arhaiccf.getCF())) plt.plot(arhaiccf.getTimeArray(), arhaiccf.getCF()/max(arhaiccf.getCF()))
plt.plot([aicarhpick.getpick(), aicarhpick.getpick()], [-1, 1], 'b') plt.plot([aicarhpick.getpick(), aicarhpick.getpick()], [-1, 1], 'b')
plt.plot([aicarhpick.getpick()-0.5, aicarhpick.getpick()+0.5], [1, 1], 'b') plt.plot([aicarhpick.getpick()-0.5, aicarhpick.getpick()+0.5], [1, 1], 'b')
@ -271,7 +271,7 @@ def run_makeCF(project, database, event, iplot, station=None):
plt.ylabel('Normalized Counts') plt.ylabel('Normalized Counts')
plt.title([tr.stats.station, tr.stats.channel]) plt.title([tr.stats.station, tr.stats.channel])
plt.suptitle(trH1_filt.stats.starttime) plt.suptitle(trH1_filt.stats.starttime)
plt.legend([p31, p32], ['Data', 'AR3C-CF']) plt.legend([p31, p32], ['Data', 'AR3C-CF'])
plt.subplot(3,1,2) plt.subplot(3,1,2)
plt.plot(th1data, trH1_filt.data/max(trH1_filt.data), 'k') plt.plot(th1data, trH1_filt.data/max(trH1_filt.data), 'k')
plt.plot(ar3ccf.getTimeArray(), ar3ccf.getCF()/max(ar3ccf.getCF()), 'r') plt.plot(ar3ccf.getTimeArray(), ar3ccf.getCF()/max(ar3ccf.getCF()), 'r')

View File

@ -110,7 +110,7 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=None):
markersize=14) 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'],
loc='best') loc='best')
plt.plot([t[0], t[int(len(t)) - 1]], [-nlevel, -nlevel], '--k') plt.plot([t[0], t[int(len(t)) - 1]], [-nlevel, -nlevel], '--k')
plt.plot([Pick1, Pick1], [max(x), -max(x)], 'b', linewidth=2) plt.plot([Pick1, Pick1], [max(x), -max(x)], 'b', linewidth=2)
@ -183,10 +183,10 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=None):
i = 0 i = 0
for j in range(ipick[0][1], ipick[0][len(t[ipick]) - 1]): for j in range(ipick[0][1], ipick[0][len(t[ipick]) - 1]):
i = i + 1 i = i + 1
if xraw[j - 1] <= 0 and xraw[j] >= 0: if xraw[j - 1] <= 0 <= xraw[j]:
zc1.append(t[ipick][i]) zc1.append(t[ipick][i])
index1.append(i) index1.append(i)
elif xraw[j - 1] > 0 and xraw[j] <= 0: elif xraw[j - 1] > 0 >= xraw[j]:
zc1.append(t[ipick][i]) zc1.append(t[ipick][i])
index1.append(i) index1.append(i)
if len(zc1) == 3: if len(zc1) == 3:
@ -225,10 +225,10 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=None):
i = 0 i = 0
for j in range(ipick[0][1], ipick[0][len(t[ipick]) - 1]): for j in range(ipick[0][1], ipick[0][len(t[ipick]) - 1]):
i = i + 1 i = i + 1
if xfilt[j - 1] <= 0 and xfilt[j] >= 0: if xfilt[j - 1] <= 0 <= xfilt[j]:
zc2.append(t[ipick][i]) zc2.append(t[ipick][i])
index2.append(i) index2.append(i)
elif xfilt[j - 1] > 0 and xfilt[j] <= 0: elif xfilt[j - 1] > 0 >= xfilt[j]:
zc2.append(t[ipick][i]) zc2.append(t[ipick][i])
index2.append(i) index2.append(i)
if len(zc2) == 3: if len(zc2) == 3:
@ -263,15 +263,15 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=None):
if P1 is not None and P2 is not None: if P1 is not None and P2 is not None:
if P1[0] < 0 and P2[0] < 0: if P1[0] < 0 and P2[0] < 0:
FM = 'D' FM = 'D'
elif P1[0] >= 0 and P2[0] < 0: elif P1[0] >= 0 > P2[0]:
FM = '-' FM = '-'
elif P1[0] < 0 and P2[0] >= 0: elif P1[0] < 0 <= P2[0]:
FM = '-' FM = '-'
elif P1[0] > 0 and P2[0] > 0: elif P1[0] > 0 and P2[0] > 0:
FM = 'U' FM = 'U'
elif P1[0] <= 0 and P2[0] > 0: elif P1[0] <= 0 < P2[0]:
FM = '+' FM = '+'
elif P1[0] > 0 and P2[0] <= 0: elif P1[0] > 0 >= P2[0]:
FM = '+' FM = '+'
print ("fmpicker: Found polarity %s" % FM) print ("fmpicker: Found polarity %s" % FM)
@ -286,7 +286,7 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=None):
p3, = plt.plot(zc1, np.zeros(len(zc1)), '*g', markersize=14) p3, = plt.plot(zc1, np.zeros(len(zc1)), '*g', markersize=14)
p4, = plt.plot(t[islope1], datafit1, '--g', linewidth=2) p4, = plt.plot(t[islope1], datafit1, '--g', linewidth=2)
plt.legend([p1, p2, p3, p4], plt.legend([p1, p2, p3, p4],
['Pick', 'Slope Window', 'Zero Crossings', 'Slope'], \ ['Pick', 'Slope Window', 'Zero Crossings', 'Slope'],
loc='best') loc='best')
plt.text(Pick + 0.02, max(xraw) / 2, '%s' % FM, fontsize=14) plt.text(Pick + 0.02, max(xraw) / 2, '%s' % FM, fontsize=14)
ax = plt.gca() ax = plt.gca()
@ -563,8 +563,8 @@ def wadaticheck(pickdic, dttolerance, iplot):
f4, = plt.plot(checkedPpicks, wdfit2, 'g') f4, = plt.plot(checkedPpicks, wdfit2, 'g')
plt.title('Wadati-Diagram, %d S-P Times, Vp/Vs(raw)=%5.2f,' \ plt.title('Wadati-Diagram, %d S-P Times, Vp/Vs(raw)=%5.2f,' \
'Vp/Vs(checked)=%5.2f' % (len(SPtimes), vpvsr, cvpvsr)) 'Vp/Vs(checked)=%5.2f' % (len(SPtimes), vpvsr, cvpvsr))
plt.legend([f1, f2, f3, f4], ['Skipped S-Picks', 'Wadati 1', \ plt.legend([f1, f2, f3, f4], ['Skipped S-Picks', 'Wadati 1',
'Reliable S-Picks', 'Wadati 2'], loc='best') 'Reliable S-Picks', 'Wadati 2'], loc='best')
else: else:
plt.title('Wadati-Diagram, %d S-P Times' % len(SPtimes)) plt.title('Wadati-Diagram, %d S-P Times' % len(SPtimes))
@ -653,12 +653,12 @@ def checksignallength(X, pick, TSNR, minsiglength, nfac, minpercent, iplot):
p1, = plt.plot(t,rms, 'k') p1, = plt.plot(t,rms, 'k')
p2, = plt.plot(t[inoise], rms[inoise], 'c') p2, = plt.plot(t[inoise], rms[inoise], 'c')
p3, = plt.plot(t[isignal],rms[isignal], 'r') p3, = plt.plot(t[isignal],rms[isignal], 'r')
p4, = plt.plot([t[isignal[0]], t[isignal[len(isignal)-1]]], \ p4, = plt.plot([t[isignal[0]], t[isignal[len(isignal)-1]]],
[minsiglevel, minsiglevel], 'g', linewidth=2) [minsiglevel, minsiglevel], 'g', linewidth=2)
p5, = plt.plot([pick, pick], [min(rms), max(rms)], 'b', linewidth=2) p5, = plt.plot([pick, pick], [min(rms), max(rms)], 'b', linewidth=2)
plt.legend([p1, p2, p3, p4, p5], ['RMS Data', 'RMS Noise Window', \ plt.legend([p1, p2, p3, p4, p5], ['RMS Data', 'RMS Noise Window',
'RMS Signal Window', 'Minimum Signal Level', \ 'RMS Signal Window', 'Minimum Signal Level',
'Onset'], loc='best') 'Onset'], loc='best')
plt.xlabel('Time [s] since %s' % X[0].stats.starttime) plt.xlabel('Time [s] since %s' % X[0].stats.starttime)
plt.ylabel('Counts') plt.ylabel('Counts')
plt.title('Check for Signal Length, Station %s' % X[0].stats.station) plt.title('Check for Signal Length, Station %s' % X[0].stats.station)
@ -747,15 +747,15 @@ def checkPonsets(pickdic, dttolerance, iplot):
if iplot > 1: if iplot > 1:
p1, = plt.plot(np.arange(0, len(Ppicks)), Ppicks, 'r+', markersize=14) p1, = plt.plot(np.arange(0, len(Ppicks)), Ppicks, 'r+', markersize=14)
p2, = plt.plot(igood, np.array(Ppicks)[igood], 'g*', markersize=14) p2, = plt.plot(igood, np.array(Ppicks)[igood], 'g*', markersize=14)
p3, = plt.plot([0, len(Ppicks) - 1], [pmedian, pmedian], 'g', \ p3, = plt.plot([0, len(Ppicks) - 1], [pmedian, pmedian], 'g',
linewidth=2) linewidth=2)
for i in range(0, len(Ppicks)): for i in range(0, len(Ppicks)):
plt.text(i, Ppicks[i] + 0.2, stations[i]) plt.text(i, Ppicks[i] + 0.2, stations[i])
plt.xlabel('Number of P Picks') plt.xlabel('Number of P Picks')
plt.ylabel('Onset Time [s] from 1.1.1970') plt.ylabel('Onset Time [s] from 1.1.1970')
plt.legend([p1, p2, p3], ['Skipped P Picks', 'Good P Picks', 'Median'], \ plt.legend([p1, p2, p3], ['Skipped P Picks', 'Good P Picks', 'Median'],
loc='best') loc='best')
plt.title('Check P Onsets') plt.title('Check P Onsets')
plt.show() plt.show()
raw_input() raw_input()
@ -916,13 +916,13 @@ def checkZ4S(X, pick, zfac, checkwin, iplot):
plt.plot(te[isignal], edat[0].data[isignal] / max(edat[0].data) + 1, 'r') plt.plot(te[isignal], edat[0].data[isignal] / max(edat[0].data) + 1, 'r')
plt.plot(tn, ndat[0].data / max(ndat[0].data) + 2, 'k') plt.plot(tn, ndat[0].data / max(ndat[0].data) + 2, 'k')
plt.plot(tn[isignal], ndat[0].data[isignal] / max(ndat[0].data) + 2, 'r') plt.plot(tn[isignal], ndat[0].data[isignal] / max(ndat[0].data) + 2, 'r')
plt.plot([tz[isignal[0]], tz[isignal[len(isignal) - 1]]], \ plt.plot([tz[isignal[0]], tz[isignal[len(isignal) - 1]]],
[minsiglevel / max(z), minsiglevel / max(z)], 'g', \ [minsiglevel / max(z), minsiglevel / max(z)], 'g',
linewidth=2) linewidth=2)
plt.xlabel('Time [s] since %s' % zdat[0].stats.starttime) plt.xlabel('Time [s] since %s' % zdat[0].stats.starttime)
plt.ylabel('Normalized Counts') plt.ylabel('Normalized Counts')
plt.yticks([0, 1, 2], [zdat[0].stats.channel, edat[0].stats.channel, \ plt.yticks([0, 1, 2], [zdat[0].stats.channel, edat[0].stats.channel,
ndat[0].stats.channel]) ndat[0].stats.channel])
plt.title('CheckZ4S, Station %s' % zdat[0].stats.station) plt.title('CheckZ4S, Station %s' % zdat[0].stats.station)
plt.show() plt.show()
raw_input() raw_input()

View File

@ -73,8 +73,8 @@ def readPILOTEvent(phasfn=None, locfn=None, authority_id=None, **kwargs):
stations = [stat for stat in phases['stat'][0:-1:3]] stations = [stat for stat in phases['stat'][0:-1:3]]
event = createEvent(eventDate, loccinfo, None, 'earthquake', eventNum, event = createEvent(eventDate, loccinfo, etype='earthquake', resID=eventNum,
authority_id) authority_id=authority_id)
lat = float(loc['LAT']) lat = float(loc['LAT'])
lon = float(loc['LON']) lon = float(loc['LON'])
@ -130,7 +130,7 @@ def readPILOTEvent(phasfn=None, locfn=None, authority_id=None, **kwargs):
event.magnitudes.append(magnitude) event.magnitudes.append(magnitude)
return event return event
except AttributeError, e: except AttributeError as e:
raise AttributeError('{0} - Matlab LOC files {1} and {2} contains \ raise AttributeError('{0} - Matlab LOC files {1} and {2} contains \
insufficient data!'.format(e, phasfn, locfn)) insufficient data!'.format(e, phasfn, locfn))

View File

@ -814,9 +814,10 @@ class PropertiesDlg(QDialog):
if values is not None: if values is not None:
self.setValues(values) self.setValues(values)
def setValues(self, tabValues): @staticmethod
def setValues(tabValues):
settings = QSettings() settings = QSettings()
for setting, value in tabValues.iteritems(): for setting, value in tabValues.items():
settings.setValue(setting, value) settings.setValue(setting, value)
settings.sync() settings.sync()