[new] introduced verbose flag to suppress to much output during auto picking (slows down especially to GUI triggered auto picking process)
This commit is contained in:
parent
ed7a323c50
commit
f3ba22b235
@ -46,7 +46,7 @@ def autopickevent(data, param):
|
|||||||
# check S-P times (Wadati)
|
# check S-P times (Wadati)
|
||||||
return wadaticheck(jk_checked_onsets, wdttolerance, iplot)
|
return wadaticheck(jk_checked_onsets, wdttolerance, iplot)
|
||||||
|
|
||||||
def autopickstation(wfstream, pickparam):
|
def autopickstation(wfstream, pickparam, verbose=False):
|
||||||
"""
|
"""
|
||||||
:param: wfstream
|
:param: wfstream
|
||||||
:type: `~obspy.core.stream.Stream`
|
:type: `~obspy.core.stream.Stream`
|
||||||
@ -153,11 +153,11 @@ def autopickstation(wfstream, pickparam):
|
|||||||
ndat = wfstream.select(component="1")
|
ndat = wfstream.select(component="1")
|
||||||
|
|
||||||
if algoP == 'HOS' or algoP == 'ARZ' and zdat is not None:
|
if algoP == 'HOS' or algoP == 'ARZ' and zdat is not None:
|
||||||
print '##########################################'
|
msg = '##########################################\nautopickstation:' \
|
||||||
print 'autopickstation: Working on P onset of station %s' % zdat[
|
' Working on P onset of station {station}\nFiltering vertical ' \
|
||||||
0].stats.station
|
'trace ...\n{data}'.format(station=zdat[0].stats.station,
|
||||||
print 'Filtering vertical trace ...'
|
data=str(zdat))
|
||||||
print zdat
|
if verbose: print(msg)
|
||||||
z_copy = zdat.copy()
|
z_copy = zdat.copy()
|
||||||
# filter and taper data
|
# filter and taper data
|
||||||
tr_filt = zdat[0].copy()
|
tr_filt = zdat[0].copy()
|
||||||
@ -171,9 +171,9 @@ def autopickstation(wfstream, pickparam):
|
|||||||
Lwf = zdat[0].stats.endtime - zdat[0].stats.starttime
|
Lwf = zdat[0].stats.endtime - zdat[0].stats.starttime
|
||||||
Ldiff = Lwf - Lc
|
Ldiff = Lwf - Lc
|
||||||
if Ldiff < 0:
|
if Ldiff < 0:
|
||||||
print 'autopickstation: Cutting times are too large for actual ' \
|
msg = 'autopickstation: Cutting times are too large for actual ' \
|
||||||
'waveform!'
|
'waveform!\nUsing entire waveform instead!'
|
||||||
print 'Using entire waveform instead!'
|
if verbose: print(msg)
|
||||||
pstart = 0
|
pstart = 0
|
||||||
pstop = len(zdat[0].data) * zdat[0].stats.delta
|
pstop = len(zdat[0].data) * zdat[0].stats.delta
|
||||||
cuttimes = [pstart, pstop]
|
cuttimes = [pstart, pstop]
|
||||||
@ -206,10 +206,11 @@ def autopickstation(wfstream, pickparam):
|
|||||||
z_copy[0].data = tr_filt.data
|
z_copy[0].data = tr_filt.data
|
||||||
zne = z_copy
|
zne = z_copy
|
||||||
if len(ndat) == 0 or len(edat) == 0:
|
if len(ndat) == 0 or len(edat) == 0:
|
||||||
print ("One or more horizontal components missing!")
|
msg = 'One or more horizontal components missing!\nSignal ' \
|
||||||
print ("Signal length only checked on vertical component!")
|
'length only checked on vertical component!\n' \
|
||||||
print ("Decreasing minsiglengh from %f to %f"
|
'Decreasing minsiglengh from {0} to ' \
|
||||||
% (minsiglength, minsiglength / 2))
|
'{1}'.format(minsiglength, minsiglength / 2)
|
||||||
|
if verbose: print(msg)
|
||||||
Pflag = checksignallength(zne, aicpick.getpick(), tsnrz,
|
Pflag = checksignallength(zne, aicpick.getpick(), tsnrz,
|
||||||
minsiglength / 2,
|
minsiglength / 2,
|
||||||
nfacsl, minpercent, iplot)
|
nfacsl, minpercent, iplot)
|
||||||
@ -235,8 +236,9 @@ def autopickstation(wfstream, pickparam):
|
|||||||
# check for spuriously picked S onset
|
# check for spuriously picked S onset
|
||||||
# both horizontal traces needed
|
# both horizontal traces needed
|
||||||
if len(ndat) == 0 or len(edat) == 0:
|
if len(ndat) == 0 or len(edat) == 0:
|
||||||
print 'One or more horizontal components missing!'
|
msg = 'One or more horizontal components missing!\n' \
|
||||||
print 'Skipping control function checkZ4S.'
|
'Skipping control function checkZ4S.'
|
||||||
|
if verbose: print(msg)
|
||||||
else:
|
else:
|
||||||
Pflag = checkZ4S(zne, aicpick.getpick(), zfac,
|
Pflag = checkZ4S(zne, aicpick.getpick(), zfac,
|
||||||
tsnrz[3], iplot)
|
tsnrz[3], iplot)
|
||||||
@ -252,11 +254,12 @@ def autopickstation(wfstream, pickparam):
|
|||||||
aicpick.getSNR() >= minAICPSNR and
|
aicpick.getSNR() >= minAICPSNR and
|
||||||
Pflag == 1):
|
Pflag == 1):
|
||||||
aicPflag = 1
|
aicPflag = 1
|
||||||
print 'AIC P-pick passes quality control: Slope: %f counts/s, SNR: %f' % \
|
msg = 'AIC P-pick passes quality control: Slope: {0} counts/s, ' \
|
||||||
(aicpick.getSlope(), aicpick.getSNR())
|
'SNR: {1}\nGo on with refined picking ...\n' \
|
||||||
print 'Go on with refined picking ...'
|
'autopickstation: re-filtering vertical trace ' \
|
||||||
|
'...'.format(aicpick.getSlope(), aicpick.getSNR())
|
||||||
|
if verbose: print(msg)
|
||||||
# re-filter waveform with larger bandpass
|
# re-filter waveform with larger bandpass
|
||||||
print 'autopickstation: re-filtering vertical trace ...'
|
|
||||||
z_copy = zdat.copy()
|
z_copy = zdat.copy()
|
||||||
tr_filt = zdat[0].copy()
|
tr_filt = zdat[0].copy()
|
||||||
tr_filt.filter('bandpass', freqmin=bpz2[0], freqmax=bpz2[1],
|
tr_filt.filter('bandpass', freqmin=bpz2[0], freqmax=bpz2[1],
|
||||||
@ -334,9 +337,10 @@ 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 or len(zc) <= 3:
|
if np.size(zc) == 0 or len(zc) <= 3:
|
||||||
print ("Something is wrong with the waveform, "
|
msg = "Something is wrong with the waveform, " \
|
||||||
"no zero crossings derived!")
|
"no zero crossings derived!\nCannot " \
|
||||||
print ("Cannot calculate source spectrum!")
|
"calculate source spectrum!"
|
||||||
|
if verbose: print(msg)
|
||||||
else:
|
else:
|
||||||
index = min([3, len(zc) - 1])
|
index = min([3, len(zc) - 1])
|
||||||
calcwin = (zc[index] - zc[0]) * z_copy[0].stats.delta
|
calcwin = (zc[index] - zc[0]) * z_copy[0].stats.delta
|
||||||
@ -345,33 +349,42 @@ 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, "
|
msg = "autopickstation: P-weight: {0}, " \
|
||||||
"Polarity: %s" % (Pweight, SNRP, SNRPdB, FM))
|
"SNR: {1}, SNR[dB]: {2}, Polarity: {3}".format(Pweight,
|
||||||
|
SNRP,
|
||||||
|
SNRPdB,
|
||||||
|
FM)
|
||||||
|
print(msg)
|
||||||
Sflag = 1
|
Sflag = 1
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print ("Bad initial (AIC) P-pick, skipping this onset!")
|
msg = 'Bad initial (AIC) P-pick, skipping this onset!\n' \
|
||||||
print 'AIC-SNR=', aicpick.getSNR(), 'AIC-Slope=', aicpick.getSlope(), 'counts/s'
|
'AIC-SNR={0}, AIC-Slope={1}counts/s\n' \
|
||||||
print '(min. AIC-SNR=', minAICPSNR, ', min. AIC-Slope=', minAICPslope, 'counts/s)'
|
'(min. AIC-SNR={2}, ' \
|
||||||
|
'min. AIC-Slope={3}counts/s)'.format(aicpick.getSNR(),
|
||||||
|
aicpick.getSlope(),
|
||||||
|
minAICPSNR,
|
||||||
|
minAICPslope)
|
||||||
|
if verbose: print(msg)
|
||||||
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(
|
||||||
ndat) > 0 and Pweight < 4:
|
ndat) > 0 and Pweight < 4:
|
||||||
print ("Go on picking S onset ...")
|
msg = "Go on picking S onset ...\n" \
|
||||||
print ("##################################################")
|
"##################################################\n" \
|
||||||
print ("Working on S onset of station %s" % edat[0].stats.station)
|
"Working on S onset of station {0}\nFiltering horizontal " \
|
||||||
print ("Filtering horizontal traces ...")
|
"traces ...".format(edat[0].stats.station)
|
||||||
|
if verbose: print(msg)
|
||||||
# determine time window for calculating CF after P onset
|
# determine time window for calculating CF after P onset
|
||||||
cuttimesh = [round(max([mpickP + sstart, 0])),
|
cuttimesh = [round(max([mpickP + sstart, 0])),
|
||||||
round(min([mpickP + sstop, Lwf]))]
|
round(min([mpickP + sstop, Lwf]))]
|
||||||
|
|
||||||
if algoS == 'ARH':
|
if algoS == 'ARH':
|
||||||
print edat, ndat
|
if verbose: print(edat, ndat)
|
||||||
# re-create stream object including both horizontal components
|
# re-create stream object including both horizontal components
|
||||||
hdat = edat.copy()
|
hdat = edat.copy()
|
||||||
hdat += ndat
|
hdat += ndat
|
||||||
@ -388,7 +401,7 @@ def autopickstation(wfstream, pickparam):
|
|||||||
h_copy[0].data = trH1_filt.data
|
h_copy[0].data = trH1_filt.data
|
||||||
h_copy[1].data = trH2_filt.data
|
h_copy[1].data = trH2_filt.data
|
||||||
elif algoS == 'AR3':
|
elif algoS == 'AR3':
|
||||||
print zdat, edat, ndat
|
if verbose: print(zdat, edat, ndat)
|
||||||
# re-create stream object including all components
|
# re-create stream object including all components
|
||||||
hdat = zdat.copy()
|
hdat = zdat.copy()
|
||||||
hdat += edat
|
hdat += edat
|
||||||
@ -441,15 +454,15 @@ def autopickstation(wfstream, pickparam):
|
|||||||
aicarhpick.getSNR() >= minAICSSNR and
|
aicarhpick.getSNR() >= minAICSSNR and
|
||||||
aicarhpick.getpick() is not None):
|
aicarhpick.getpick() is not None):
|
||||||
aicSflag = 1
|
aicSflag = 1
|
||||||
print 'AIC S-pick passes quality control: Slope: %f counts/s, SNR: %f' \
|
msg = 'AIC S-pick passes quality control: Slope: {0} counts/s, ' \
|
||||||
% (aicarhpick.getSlope(), aicarhpick.getSNR())
|
'SNR: {1}\nGo on with refined picking ...\n' \
|
||||||
print 'Go on with refined picking ...'
|
'autopickstation: re-filtering horizontal traces ' \
|
||||||
|
'...'.format(aicarhpick.getSlope(), aicarhpick.getSNR())
|
||||||
# re-calculate CF from re-filtered trace in vicinity of initial
|
# re-calculate CF from re-filtered trace in vicinity of initial
|
||||||
# onset
|
# onset
|
||||||
cuttimesh2 = [round(aicarhpick.getpick() - Srecalcwin),
|
cuttimesh2 = [round(aicarhpick.getpick() - Srecalcwin),
|
||||||
round(aicarhpick.getpick() + Srecalcwin)]
|
round(aicarhpick.getpick() + Srecalcwin)]
|
||||||
# re-filter waveform with larger bandpass
|
# re-filter waveform with larger bandpass
|
||||||
print 'autopickstation: re-filtering horizontal traces...'
|
|
||||||
h_copy = hdat.copy()
|
h_copy = hdat.copy()
|
||||||
# filter and taper data
|
# filter and taper data
|
||||||
if algoS == 'ARH':
|
if algoS == 'ARH':
|
||||||
@ -554,11 +567,12 @@ def autopickstation(wfstream, pickparam):
|
|||||||
elif Serror > timeerrorsS[3]:
|
elif Serror > timeerrorsS[3]:
|
||||||
Sweight = 4
|
Sweight = 4
|
||||||
|
|
||||||
print 'autopickstation: S-weight: %d, SNR: %f, SNR[dB]: %f' % (
|
print('autopickstation: S-weight: {0}, SNR: {1}, '
|
||||||
Sweight, SNRS, SNRSdB)
|
'SNR[dB]: {2}\n'
|
||||||
|
'################################################'
|
||||||
|
''.format(Sweight, SNRS, SNRSdB))
|
||||||
##################################################################
|
##################################################################
|
||||||
# get Wood-Anderson peak-to-peak amplitude
|
# get Wood-Anderson peak-to-peak amplitude
|
||||||
print "################################################"
|
|
||||||
# initialize Data object
|
# initialize Data object
|
||||||
data = Data()
|
data = Data()
|
||||||
# re-create stream object including both horizontal components
|
# re-create stream object including both horizontal components
|
||||||
@ -580,15 +594,19 @@ def autopickstation(wfstream, pickparam):
|
|||||||
Ao = wapp.getwapp()
|
Ao = wapp.getwapp()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print 'Bad initial (AIC) S-pick, skipping this onset!'
|
msg = 'Bad initial (AIC) S-pick, skipping this onset!\n' \
|
||||||
print 'AIC-SNR=', aicarhpick.getSNR(), \
|
'AIC-SNR={0}, AIC-Slope={1}counts/s\n' \
|
||||||
'AIC-Slope=', aicarhpick.getSlope(), 'counts/s'
|
'(min. AIC-SNR={2}, ' \
|
||||||
print '(min. AIC-SNR=', minAICSSNR, ', min. AIC-Slope=', \
|
'min. AIC-Slope={3}counts/s)\n' \
|
||||||
minAICSslope, 'counts/s)'
|
'################################################' \
|
||||||
|
''.format(aicarhpick.getSNR(),
|
||||||
|
aicarhpick.getSlope(),
|
||||||
|
minAICSSNR,
|
||||||
|
minAICSslope)
|
||||||
|
if verbose: print(msg)
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# get Wood-Anderson peak-to-peak amplitude
|
# get Wood-Anderson peak-to-peak amplitude
|
||||||
print "################################################"
|
|
||||||
# initialize Data object
|
# initialize Data object
|
||||||
data = Data()
|
data = Data()
|
||||||
# re-create stream object including both horizontal components
|
# re-create stream object including both horizontal components
|
||||||
@ -604,8 +622,8 @@ def autopickstation(wfstream, pickparam):
|
|||||||
Ao = wapp.getwapp()
|
Ao = wapp.getwapp()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print 'autopickstation: No horizontal component data available or ' \
|
print('autopickstation: No horizontal component data available or ' \
|
||||||
'bad P onset, skipping S picking!'
|
'bad P onset, skipping S picking!')
|
||||||
|
|
||||||
##############################################################
|
##############################################################
|
||||||
if iplot > 0:
|
if iplot > 0:
|
||||||
@ -822,9 +840,10 @@ def iteratepicker(wf, NLLocfile, picks, badpicks, pickparameter):
|
|||||||
:param pickparameter: picking parameters from autoPyLoT-input file
|
:param pickparameter: picking parameters from autoPyLoT-input file
|
||||||
'''
|
'''
|
||||||
|
|
||||||
print("#######################################################")
|
msg = '#######################################################\n' \
|
||||||
print("autoPyLoT: Found %d bad onsets at station(s) %s, starting re-picking them ...") \
|
'autoPyLoT: Found {0} bad onsets at station(s) {1}, ' \
|
||||||
% (len(badpicks), badpicks)
|
'starting re-picking them ...'.format(len(badpicks), badpicks)
|
||||||
|
print(msg)
|
||||||
|
|
||||||
newpicks = {}
|
newpicks = {}
|
||||||
for i in range(0, len(badpicks)):
|
for i in range(0, len(badpicks)):
|
||||||
|
Loading…
Reference in New Issue
Block a user