[edit] reformatted code
Code indentation and PEP 8 violations automatically reduced with IDE tool
This commit is contained in:
parent
fa6626d62a
commit
7225da87db
@ -11,6 +11,7 @@ function conglomerate utils.
|
|||||||
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
from pylot.core.read.inputs import AutoPickParameter
|
||||||
from pylot.core.pick.picker import AICPicker, PragPicker
|
from pylot.core.pick.picker import AICPicker, PragPicker
|
||||||
from pylot.core.pick.charfuns import CharacteristicFunction
|
from pylot.core.pick.charfuns import CharacteristicFunction
|
||||||
from pylot.core.pick.charfuns import HOScf, AICcf, ARZcf, ARHcf, AR3Ccf
|
from pylot.core.pick.charfuns import HOScf, AICcf, ARZcf, ARHcf, AR3Ccf
|
||||||
@ -20,6 +21,7 @@ from pylot.core.util.utils import getPatternLine
|
|||||||
from pylot.core.read.data import Data
|
from pylot.core.read.data import Data
|
||||||
from pylot.core.analysis.magnitude import WApp
|
from pylot.core.analysis.magnitude import WApp
|
||||||
|
|
||||||
|
|
||||||
def autopickevent(data, param):
|
def autopickevent(data, param):
|
||||||
stations = []
|
stations = []
|
||||||
all_onsets = {}
|
all_onsets = {}
|
||||||
@ -46,14 +48,18 @@ 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, verbose=False):
|
def autopickstation(wfstream, pickparam, verbose=False):
|
||||||
"""
|
"""
|
||||||
:param: wfstream
|
:param wfstream: `~obspy.core.stream.Stream` containing waveform
|
||||||
:type: `~obspy.core.stream.Stream`
|
:type wfstream: obspy.core.stream.Stream
|
||||||
|
|
||||||
:param: pickparam
|
:param pickparam: container of picking parameters from input file,
|
||||||
:type: container of picking parameters from input file,
|
|
||||||
usually autoPyLoT.in
|
usually autoPyLoT.in
|
||||||
|
:type pickparam: AutoPickParameter
|
||||||
|
:param verbose:
|
||||||
|
:type verbose: bool
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# declaring pickparam variables (only for convenience)
|
# declaring pickparam variables (only for convenience)
|
||||||
@ -191,7 +197,8 @@ def autopickstation(wfstream, pickparam, verbose=False):
|
|||||||
# class needs stream object => build it
|
# class needs stream object => build it
|
||||||
assert isinstance(cf1, CharacteristicFunction), 'cf2 is not set ' \
|
assert isinstance(cf1, CharacteristicFunction), 'cf2 is not set ' \
|
||||||
'correctly: maybe the algorithm name ({algoP}) is ' \
|
'correctly: maybe the algorithm name ({algoP}) is ' \
|
||||||
'corrupted'.format(algoP=algoP)
|
'corrupted'.format(
|
||||||
|
algoP=algoP)
|
||||||
tr_aic = tr_filt.copy()
|
tr_aic = tr_filt.copy()
|
||||||
tr_aic.data = cf1.getCF()
|
tr_aic.data = cf1.getCF()
|
||||||
z_copy[0].data = tr_aic.data
|
z_copy[0].data = tr_aic.data
|
||||||
@ -253,8 +260,7 @@ def autopickstation(wfstream, pickparam, verbose=False):
|
|||||||
##############################################################
|
##############################################################
|
||||||
# go on with processing if AIC onset passes quality control
|
# go on with processing if AIC onset passes quality control
|
||||||
if (aicpick.getSlope() >= minAICPslope and
|
if (aicpick.getSlope() >= minAICPslope and
|
||||||
aicpick.getSNR() >= minAICPSNR and
|
aicpick.getSNR() >= minAICPSNR and Pflag == 1):
|
||||||
Pflag == 1):
|
|
||||||
aicPflag = 1
|
aicPflag = 1
|
||||||
msg = 'AIC P-pick passes quality control: Slope: {0} counts/s, ' \
|
msg = 'AIC P-pick passes quality control: Slope: {0} counts/s, ' \
|
||||||
'SNR: {1}\nGo on with refined picking ...\n' \
|
'SNR: {1}\nGo on with refined picking ...\n' \
|
||||||
@ -289,14 +295,15 @@ def autopickstation(wfstream, pickparam, verbose=False):
|
|||||||
# get refined onset time from CF2 using class Picker
|
# get refined onset time from CF2 using class Picker
|
||||||
assert isinstance(cf2, CharacteristicFunction), 'cf2 is not set ' \
|
assert isinstance(cf2, CharacteristicFunction), 'cf2 is not set ' \
|
||||||
'correctly: maybe the algorithm name ({algoP}) is ' \
|
'correctly: maybe the algorithm name ({algoP}) is ' \
|
||||||
'corrupted'.format(algoP=algoP)
|
'corrupted'.format(
|
||||||
|
algoP=algoP)
|
||||||
refPpick = PragPicker(cf2, tsnrz, pickwinP, iplot, ausP, tsmoothP,
|
refPpick = PragPicker(cf2, tsnrz, pickwinP, iplot, ausP, tsmoothP,
|
||||||
aicpick.getpick())
|
aicpick.getpick())
|
||||||
mpickP = refPpick.getpick()
|
mpickP = refPpick.getpick()
|
||||||
#############################################################
|
#############################################################
|
||||||
if mpickP is not None:
|
if mpickP is not None:
|
||||||
# quality assessment
|
# quality assessment
|
||||||
# get earliest and latest possible pick and symmetrized uncertainty
|
# get earliest/latest possible pick and symmetrized uncertainty
|
||||||
[lpickP, epickP, Perror] = earllatepicker(z_copy, nfacP, tsnrz,
|
[lpickP, epickP, Perror] = earllatepicker(z_copy, nfacP, tsnrz,
|
||||||
mpickP, iplot)
|
mpickP, iplot)
|
||||||
|
|
||||||
@ -481,7 +488,7 @@ def autopickstation(wfstream, pickparam, verbose=False):
|
|||||||
#############################################################
|
#############################################################
|
||||||
if mpickS is not None:
|
if mpickS is not None:
|
||||||
# quality assessment
|
# quality assessment
|
||||||
# get earliest and latest possible pick and symmetrized uncertainty
|
# get earliest/latest possible pick and symmetrized uncertainty
|
||||||
h_copy[0].data = trH1_filt.data
|
h_copy[0].data = trH1_filt.data
|
||||||
[lpickS1, epickS1, Serror1] = earllatepicker(h_copy, nfacS,
|
[lpickS1, epickS1, Serror1] = earllatepicker(h_copy, nfacS,
|
||||||
tsnrh,
|
tsnrh,
|
||||||
@ -496,28 +503,30 @@ def autopickstation(wfstream, pickparam, verbose=False):
|
|||||||
epick = [epickS1, epickS2]
|
epick = [epickS1, epickS2]
|
||||||
lpick = [lpickS1, lpickS2]
|
lpick = [lpickS1, lpickS2]
|
||||||
pickerr = [Serror1, Serror2]
|
pickerr = [Serror1, Serror2]
|
||||||
if epickS1 == None and epickS2 is not None:
|
if epickS1 is None and epickS2 is not None:
|
||||||
ipick = 1
|
ipick = 1
|
||||||
elif epickS1 is not None and epickS2 == None:
|
elif epickS1 is not None and epickS2 is None:
|
||||||
ipick = 0
|
ipick = 0
|
||||||
elif epickS1 is not None and epickS2 is not None:
|
elif epickS1 is not None and epickS2 is not None:
|
||||||
ipick = np.argmin([epickS1, epickS2])
|
ipick = np.argmin([epickS1, epickS2])
|
||||||
elif algoS == 'AR3':
|
elif algoS == 'AR3':
|
||||||
[lpickS3, epickS3, Serror3] = earllatepicker(h_copy, nfacS,
|
[lpickS3, epickS3, Serror3] = earllatepicker(h_copy,
|
||||||
|
nfacS,
|
||||||
tsnrh,
|
tsnrh,
|
||||||
mpickS, iplot)
|
mpickS,
|
||||||
|
iplot)
|
||||||
# get earliest pick of all three picks
|
# get earliest pick of all three picks
|
||||||
epick = [epickS1, epickS2, epickS3]
|
epick = [epickS1, epickS2, epickS3]
|
||||||
lpick = [lpickS1, lpickS2, lpickS3]
|
lpick = [lpickS1, lpickS2, lpickS3]
|
||||||
pickerr = [Serror1, Serror2, Serror3]
|
pickerr = [Serror1, Serror2, Serror3]
|
||||||
if epickS1 == None and epickS2 is not None \
|
if epickS1 is None and epickS2 is not None \
|
||||||
and epickS3 is not None:
|
and epickS3 is not None:
|
||||||
ipick = np.argmin([epickS2, epickS3])
|
ipick = np.argmin([epickS2, epickS3])
|
||||||
elif epickS1 is not None and epickS2 == None \
|
elif epickS1 is not None and epickS2 is None \
|
||||||
and epickS3 is not None:
|
and epickS3 is not None:
|
||||||
ipick = np.argmin([epickS2, epickS3])
|
ipick = np.argmin([epickS2, epickS3])
|
||||||
elif epickS1 is not None and epickS2 is not None \
|
elif epickS1 is not None and epickS2 is not None \
|
||||||
and epickS3 == None:
|
and epickS3 is None:
|
||||||
ipick = np.argmin([epickS1, epickS2])
|
ipick = np.argmin([epickS1, epickS2])
|
||||||
elif epickS1 is not None and epickS2 is not None \
|
elif epickS1 is not None and epickS2 is not None \
|
||||||
and epickS3 is not None:
|
and epickS3 is not None:
|
||||||
@ -546,7 +555,7 @@ def autopickstation(wfstream, pickparam, verbose=False):
|
|||||||
'SNR[dB]: {2}\n'
|
'SNR[dB]: {2}\n'
|
||||||
'################################################'
|
'################################################'
|
||||||
''.format(Sweight, SNRS, SNRSdB))
|
''.format(Sweight, SNRS, SNRSdB))
|
||||||
##################################################################
|
################################################################
|
||||||
# get Wood-Anderson peak-to-peak amplitude
|
# get Wood-Anderson peak-to-peak amplitude
|
||||||
# initialize Data object
|
# initialize Data object
|
||||||
data = Data()
|
data = Data()
|
||||||
@ -563,7 +572,7 @@ def autopickstation(wfstream, pickparam, verbose=False):
|
|||||||
else:
|
else:
|
||||||
# use larger window for getting peak-to-peak amplitude
|
# use larger window for getting peak-to-peak amplitude
|
||||||
# as the S pick is quite unsure
|
# as the S pick is quite unsure
|
||||||
wapp = WApp(cordat, mpickP, mpickP + sstop + \
|
wapp = WApp(cordat, mpickP, mpickP + sstop +
|
||||||
(0.5 * (mpickP + sstop)), iplot)
|
(0.5 * (mpickP + sstop)), iplot)
|
||||||
|
|
||||||
Ao = wapp.getwapp()
|
Ao = wapp.getwapp()
|
||||||
@ -593,7 +602,8 @@ def autopickstation(wfstream, pickparam, verbose=False):
|
|||||||
# 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:
|
||||||
@ -801,7 +811,6 @@ def autopickstation(wfstream, pickparam, verbose=False):
|
|||||||
# add Wood-Anderson amplitude
|
# add Wood-Anderson amplitude
|
||||||
picks[phase]['Ao'] = Ao
|
picks[phase]['Ao'] = Ao
|
||||||
|
|
||||||
|
|
||||||
return picks
|
return picks
|
||||||
|
|
||||||
|
|
||||||
@ -852,22 +861,31 @@ def iteratepicker(wf, NLLocfile, picks, badpicks, pickparameter):
|
|||||||
Precalcwin_old = pickparameter.getParam('Precalcwin')
|
Precalcwin_old = pickparameter.getParam('Precalcwin')
|
||||||
noisefactor_old = pickparameter.getParam('noisefactor')
|
noisefactor_old = pickparameter.getParam('noisefactor')
|
||||||
zfac_old = pickparameter.getParam('zfac')
|
zfac_old = pickparameter.getParam('zfac')
|
||||||
pickparameter.setParam(pstart=max([0, badpicks[i][1] - wf2pick[0].stats.starttime \
|
pickparameter.setParam(
|
||||||
|
pstart=max([0, badpicks[i][1] - wf2pick[0].stats.starttime \
|
||||||
- pickparameter.getParam('tlta')]))
|
- pickparameter.getParam('tlta')]))
|
||||||
pickparameter.setParam(pstop=pickparameter.getParam('pstart') + \
|
pickparameter.setParam(pstop=pickparameter.getParam('pstart') + \
|
||||||
(3 * pickparameter.getParam('tlta')))
|
(3 * pickparameter.getParam('tlta')))
|
||||||
pickparameter.setParam(sstop=pickparameter.getParam('sstop') / 2)
|
pickparameter.setParam(sstop=pickparameter.getParam('sstop') / 2)
|
||||||
pickparameter.setParam(pickwinP=pickparameter.getParam('pickwinP') / 2)
|
pickparameter.setParam(pickwinP=pickparameter.getParam('pickwinP') / 2)
|
||||||
pickparameter.setParam(Precalcwin=pickparameter.getParam('Precalcwin') / 2)
|
pickparameter.setParam(
|
||||||
|
Precalcwin=pickparameter.getParam('Precalcwin') / 2)
|
||||||
pickparameter.setParam(noisefactor=1.0)
|
pickparameter.setParam(noisefactor=1.0)
|
||||||
pickparameter.setParam(zfac=1.0)
|
pickparameter.setParam(zfac=1.0)
|
||||||
print("iteratepicker: The following picking parameters have been modified for iterative picking:")
|
print(
|
||||||
print("pstart: %fs => %fs" % (pstart_old, pickparameter.getParam('pstart')))
|
"iteratepicker: The following picking parameters have been modified for iterative picking:")
|
||||||
print("pstop: %fs => %fs" % (pstop_old, pickparameter.getParam('pstop')))
|
print(
|
||||||
print("sstop: %fs => %fs" % (sstop_old, pickparameter.getParam('sstop')))
|
"pstart: %fs => %fs" % (pstart_old, pickparameter.getParam('pstart')))
|
||||||
print("pickwinP: %fs => %fs" % (pickwinP_old, pickparameter.getParam('pickwinP')))
|
print(
|
||||||
print("Precalcwin: %fs => %fs" % (Precalcwin_old, pickparameter.getParam('Precalcwin')))
|
"pstop: %fs => %fs" % (pstop_old, pickparameter.getParam('pstop')))
|
||||||
print("noisefactor: %f => %f" % (noisefactor_old, pickparameter.getParam('noisefactor')))
|
print(
|
||||||
|
"sstop: %fs => %fs" % (sstop_old, pickparameter.getParam('sstop')))
|
||||||
|
print("pickwinP: %fs => %fs" % (
|
||||||
|
pickwinP_old, pickparameter.getParam('pickwinP')))
|
||||||
|
print("Precalcwin: %fs => %fs" % (
|
||||||
|
Precalcwin_old, pickparameter.getParam('Precalcwin')))
|
||||||
|
print("noisefactor: %f => %f" % (
|
||||||
|
noisefactor_old, pickparameter.getParam('noisefactor')))
|
||||||
print("zfac: %f => %f" % (zfac_old, pickparameter.getParam('zfac')))
|
print("zfac: %f => %f" % (zfac_old, pickparameter.getParam('zfac')))
|
||||||
|
|
||||||
# repick station
|
# repick station
|
||||||
@ -887,10 +905,3 @@ def iteratepicker(wf, NLLocfile, picks, badpicks, pickparameter):
|
|||||||
pickparameter.setParam(zfac=zfac_old)
|
pickparameter.setParam(zfac=zfac_old)
|
||||||
|
|
||||||
return picks
|
return picks
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user