Change whitespace, add comments/documentation
This commit is contained in:
parent
6d26338f2e
commit
775d3de46c
@ -148,6 +148,7 @@ def get_source_coords(parser, station_id):
|
|||||||
print('Could not get source coordinates for station {}: {}'.format(station_id, e))
|
print('Could not get source coordinates for station {}: {}'.format(station_id, e))
|
||||||
return station_coords
|
return station_coords
|
||||||
|
|
||||||
|
|
||||||
class PickingParameters(object):
|
class PickingParameters(object):
|
||||||
"""
|
"""
|
||||||
Stores parameters used for picking a single station.
|
Stores parameters used for picking a single station.
|
||||||
@ -218,21 +219,42 @@ class PickingResults(dict):
|
|||||||
def __getattr__(self, key):
|
def __getattr__(self, key):
|
||||||
return self[key]
|
return self[key]
|
||||||
|
|
||||||
|
|
||||||
class MissingTraceException(ValueError):
|
class MissingTraceException(ValueError):
|
||||||
"""
|
"""
|
||||||
Used to indicate missing traces in a obspy.core.stream.Stream object
|
Used to indicate missing traces in a obspy.core.stream.Stream object
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class PickingFailedException(Exception):
|
class PickingFailedException(Exception):
|
||||||
"""
|
"""
|
||||||
Raised when picking fails due to missing values etc.
|
Raised when picking fails due to missing values etc.
|
||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class AutopickStation(object):
|
class AutopickStation(object):
|
||||||
|
|
||||||
def __init__(self, wfstream, pickparam, verbose, iplot, fig_dict, metadata, origin):
|
def __init__(self, wfstream, pickparam, verbose, iplot, fig_dict, metadata, origin):
|
||||||
|
"""
|
||||||
|
:param wfstream: stream object containing waveform of all traces
|
||||||
|
:type wfstream: ~obspy.core.stream.Stream
|
||||||
|
:param pickparam: container of picking parameters from input file, usually pylot.in
|
||||||
|
:type pickparam: pylot.core.io.inputs.PylotParameter
|
||||||
|
:param verbose: used to control output to log during picking. True = more information printed
|
||||||
|
:type verbose: bool
|
||||||
|
:param iplot: logical variable for plotting: 0=none, 1=partial, 2=all
|
||||||
|
:type iplot: int, (Boolean or String)
|
||||||
|
:param fig_dict: dictionary containing Matplotlib figures used for plotting picking results during tuning
|
||||||
|
:type fig_dict: dict
|
||||||
|
:param metadata: tuple containing metadata type string and Parser object read from inventory file
|
||||||
|
:type metadata: tuple (str, ~obspy.io.xseed.parser.Parser)
|
||||||
|
:param origin: list containing origin objects representing origins for all events
|
||||||
|
:type origin: list(~obspy.core.event.origin)
|
||||||
|
:return: dictionary-like object containing P pick, S pick and station name
|
||||||
|
:rtype:
|
||||||
|
"""
|
||||||
# save given parameters
|
# save given parameters
|
||||||
self.wfstream = wfstream
|
self.wfstream = wfstream
|
||||||
self.pickparam = pickparam
|
self.pickparam = pickparam
|
||||||
@ -322,7 +344,6 @@ class AutopickStation(object):
|
|||||||
:return: Tuple containing (z waveform, n waveform, e waveform) selected by the given channels
|
:return: Tuple containing (z waveform, n waveform, e waveform) selected by the given channels
|
||||||
:rtype: (obspy.core.stream.Stream, obspy.core.stream.Stream, obspy.core.stream.Stream)
|
:rtype: (obspy.core.stream.Stream, obspy.core.stream.Stream, obspy.core.stream.Stream)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
waveform_data = {}
|
waveform_data = {}
|
||||||
for key in self.channelorder:
|
for key in self.channelorder:
|
||||||
waveform_data[key] = self.wfstream.select(component=key) # try ZNE first
|
waveform_data[key] = self.wfstream.select(component=key) # try ZNE first
|
||||||
@ -739,10 +760,8 @@ class AutopickStation(object):
|
|||||||
cf1 = None
|
cf1 = None
|
||||||
# save cf1 for plotting
|
# save cf1 for plotting
|
||||||
self.cf1 = cf1
|
self.cf1 = cf1
|
||||||
assert isinstance(cf1, CharacteristicFunction), 'cf1 is not set ' \
|
assert isinstance(cf1, CharacteristicFunction), 'cf1 is not set correctly: maybe the algorithm name ({}) is ' \
|
||||||
'correctly: maybe the algorithm name ({algoP}) is ' \
|
'corrupted'.format(self.p_params.algoP)
|
||||||
'corrupted'.format(algoP=self.p_params.algoP)
|
|
||||||
|
|
||||||
# calculate AIC cf from first cf (either HOS or ARZ)
|
# calculate AIC cf from first cf (either HOS or ARZ)
|
||||||
z_copy[0].data = cf1.getCF()
|
z_copy[0].data = cf1.getCF()
|
||||||
aiccf = AICcf(z_copy, cuttimes)
|
aiccf = AICcf(z_copy, cuttimes)
|
||||||
@ -775,15 +794,14 @@ class AutopickStation(object):
|
|||||||
raise PickingFailedException(error_msg)
|
raise PickingFailedException(error_msg)
|
||||||
|
|
||||||
self.p_results.aicPflag = 1
|
self.p_results.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' \
|
'autopickstation: re-filtering vertical trace...'.format(aicpick.getSlope(), aicpick.getSNR())
|
||||||
'autopickstation: re-filtering vertical trace ' \
|
|
||||||
'...'.format(aicpick.getSlope(), aicpick.getSNR())
|
|
||||||
self.vprint(msg)
|
self.vprint(msg)
|
||||||
# refilter waveform with larger bandpass
|
# refilter waveform with larger bandpass
|
||||||
tr_filt, z_copy = self.prepare_wfstream(self.zstream, freqmin=self.p_params.bpz2[0], freqmax=self.p_params.bpz2[1])
|
tr_filt, z_copy = self.prepare_wfstream(self.zstream, freqmin=self.p_params.bpz2[0], freqmax=self.p_params.bpz2[1])
|
||||||
# save filtered trace in instance for later plotting
|
# save filtered trace in instance for later plotting
|
||||||
self.tr_filt_z_bpz2 = tr_filt
|
self.tr_filt_z_bpz2 = tr_filt
|
||||||
|
# determine new times around initial onset
|
||||||
starttime2 = round(max(aicpick.getpick() - self.p_params.Precalcwin, 0))
|
starttime2 = round(max(aicpick.getpick() - self.p_params.Precalcwin, 0))
|
||||||
endtime2 = round(min(len(self.ztrace.data) * self.ztrace.stats.delta, aicpick.getpick() + self.p_params.Precalcwin))
|
endtime2 = round(min(len(self.ztrace.data) * self.ztrace.stats.delta, aicpick.getpick() + self.p_params.Precalcwin))
|
||||||
cuttimes2 = [starttime2, endtime2]
|
cuttimes2 = [starttime2, endtime2]
|
||||||
@ -795,10 +813,10 @@ class AutopickStation(object):
|
|||||||
cf2 = None
|
cf2 = None
|
||||||
# save cf2 for plotting
|
# save cf2 for plotting
|
||||||
self.cf2 = cf2
|
self.cf2 = cf2
|
||||||
# get refined onset time from CF2
|
|
||||||
assert isinstance(cf2, CharacteristicFunction), 'cf2 is not set correctly: maybe the algorithm name () is ' \
|
assert isinstance(cf2, CharacteristicFunction), 'cf2 is not set correctly: maybe the algorithm name () is ' \
|
||||||
'corrupted'.format(self.p_params.algoP)
|
'corrupted'.format(self.p_params.algoP)
|
||||||
fig, linecolor = get_fig_from_figdict(self.fig_dict, 'refPpick')
|
fig, linecolor = get_fig_from_figdict(self.fig_dict, 'refPpick')
|
||||||
|
# get refined onset time from CF2
|
||||||
refPpick = PragPicker(cf2, self.p_params.tsnrz, self.p_params.pickwinP, self.iplot, self.p_params.ausP,
|
refPpick = PragPicker(cf2, self.p_params.tsnrz, self.p_params.pickwinP, self.iplot, self.p_params.ausP,
|
||||||
self.p_params.tsmoothP, aicpick.getpick(), fig, linecolor)
|
self.p_params.tsmoothP, aicpick.getpick(), fig, linecolor)
|
||||||
# save PragPicker result for plotting
|
# save PragPicker result for plotting
|
||||||
@ -833,7 +851,6 @@ class AutopickStation(object):
|
|||||||
print(msg)
|
print(msg)
|
||||||
self.s_results.Sflag = 1
|
self.s_results.Sflag = 1
|
||||||
|
|
||||||
|
|
||||||
def pick_s_phase(self):
|
def pick_s_phase(self):
|
||||||
|
|
||||||
def check_existence_ne_traces():
|
def check_existence_ne_traces():
|
||||||
|
Loading…
Reference in New Issue
Block a user