[bugfix] pickDlg takes into account timeshift of trace.starttime for different components
[add] initial pick displayed in pickDlg
This commit is contained in:
parent
04304d3db8
commit
0fb6e5d4df
16
QtPyLoT.py
16
QtPyLoT.py
@ -1616,18 +1616,24 @@ class MainWindow(QMainWindow):
|
|||||||
colors = phase_col[phase[0].upper()]
|
colors = phase_col[phase[0].upper()]
|
||||||
|
|
||||||
mpp = picks['mpp'] - stime
|
mpp = picks['mpp'] - stime
|
||||||
|
if picks['epp'] and picks['lpp']:
|
||||||
epp = picks['epp'] - stime
|
epp = picks['epp'] - stime
|
||||||
lpp = picks['lpp'] - stime
|
lpp = picks['lpp'] - stime
|
||||||
spe = picks['spe']
|
spe = picks['spe']
|
||||||
if not spe:
|
|
||||||
|
if not spe and epp and lpp:
|
||||||
spe = symmetrize_error(mpp - epp, lpp - mpp)
|
spe = symmetrize_error(mpp - epp, lpp - mpp)
|
||||||
|
|
||||||
if picktype == 'manual':
|
if picktype == 'manual':
|
||||||
|
if picks['epp'] and picks['lpp']:
|
||||||
ax.fill_between([epp, lpp], ylims[0], ylims[1],
|
ax.fill_between([epp, lpp], ylims[0], ylims[1],
|
||||||
alpha=.25, color=colors[0])
|
alpha=.25, color=colors[0], label='EPP, LPP')
|
||||||
ax.plot([mpp - spe, mpp - spe], ylims, colors[1],
|
if spe:
|
||||||
[mpp, mpp], ylims, colors[2],
|
ax.plot([mpp - spe, mpp - spe], ylims, colors[1], label='{}-SPE'.format(phase))
|
||||||
[mpp + spe, mpp + spe], ylims, colors[1])
|
ax.plot([mpp + spe, mpp + spe], ylims, colors[1])
|
||||||
|
ax.plot([mpp, mpp], ylims, colors[2], label='{}-Pick'.format(phase))
|
||||||
|
else:
|
||||||
|
ax.plot([mpp, mpp], ylims, colors[6], label='{}-Pick (NO PICKERROR)'.format(phase))
|
||||||
elif picktype == 'auto':
|
elif picktype == 'auto':
|
||||||
ax.plot(mpp, ylims[1], colors[3],
|
ax.plot(mpp, ylims[1], colors[3],
|
||||||
mpp, ylims[0], colors[4])
|
mpp, ylims[0], colors[4])
|
||||||
|
@ -1 +1 @@
|
|||||||
eaa4-dirty
|
0430-dirty
|
||||||
|
@ -358,7 +358,7 @@ def reassess_pilot_event(root_dir, db_dir, event_id, out_dir=None, fn_param=None
|
|||||||
default.get('tsnrz' if phase == 'P' else 'tsnrh'),
|
default.get('tsnrz' if phase == 'P' else 'tsnrh'),
|
||||||
Pick1=rel_pick,
|
Pick1=rel_pick,
|
||||||
iplot=None,
|
iplot=None,
|
||||||
stealth_mode=True)
|
verbosity=0)
|
||||||
if epp is None or lpp is None:
|
if epp is None or lpp is None:
|
||||||
continue
|
continue
|
||||||
epp = stime + epp
|
epp = stime + epp
|
||||||
|
@ -14,7 +14,7 @@ import numpy as np
|
|||||||
from obspy.core import Stream, UTCDateTime
|
from obspy.core import Stream, UTCDateTime
|
||||||
|
|
||||||
|
|
||||||
def earllatepicker(X, nfac, TSNR, Pick1, iplot=None, stealth_mode=False, fig=None):
|
def earllatepicker(X, nfac, TSNR, Pick1, iplot=None, verbosity=1, fig=None):
|
||||||
'''
|
'''
|
||||||
Function to derive earliest and latest possible pick after Diehl & Kissling (2009)
|
Function to derive earliest and latest possible pick after Diehl & Kissling (2009)
|
||||||
as reasonable uncertainties. Latest possible pick is based on noise level,
|
as reasonable uncertainties. Latest possible pick is based on noise level,
|
||||||
@ -40,10 +40,16 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=None, stealth_mode=False, fig=Non
|
|||||||
|
|
||||||
assert isinstance(X, Stream), "%s is not a stream object" % str(X)
|
assert isinstance(X, Stream), "%s is not a stream object" % str(X)
|
||||||
|
|
||||||
|
if verbosity == 2:
|
||||||
|
print('earllatepicker:')
|
||||||
|
print('nfac:', nfac)
|
||||||
|
print('Init pick:', Pick1)
|
||||||
|
print('TSNR (T_noise, T_gap, T_signal):', TSNR)
|
||||||
|
|
||||||
LPick = None
|
LPick = None
|
||||||
EPick = None
|
EPick = None
|
||||||
PickError = None
|
PickError = None
|
||||||
if stealth_mode is False:
|
if verbosity:
|
||||||
print('earllatepicker: Get earliest and latest possible pick'
|
print('earllatepicker: Get earliest and latest possible pick'
|
||||||
' relative to most likely pick ...')
|
' relative to most likely pick ...')
|
||||||
|
|
||||||
@ -57,11 +63,18 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=None, stealth_mode=False, fig=Non
|
|||||||
x = x - np.mean(x[inoise])
|
x = x - np.mean(x[inoise])
|
||||||
# calculate noise level
|
# calculate noise level
|
||||||
nlevel = np.sqrt(np.mean(np.square(x[inoise]))) * nfac
|
nlevel = np.sqrt(np.mean(np.square(x[inoise]))) * nfac
|
||||||
|
if verbosity == 2:
|
||||||
|
print('x:', x)
|
||||||
|
print('t:', t)
|
||||||
|
print('x_inoise:', x[inoise])
|
||||||
|
print('x_isignal:', x[isignal])
|
||||||
|
print('nlevel:', nlevel)
|
||||||
|
|
||||||
# get time where signal exceeds nlevel
|
# get time where signal exceeds nlevel
|
||||||
ilup, = np.where(x[isignal] > nlevel)
|
ilup, = np.where(x[isignal] > nlevel)
|
||||||
ildown, = np.where(x[isignal] < -nlevel)
|
ildown, = np.where(x[isignal] < -nlevel)
|
||||||
if not ilup.size and not ildown.size:
|
if not ilup.size and not ildown.size:
|
||||||
if stealth_mode is False:
|
if verbosity:
|
||||||
print ("earllatepicker: Signal lower than noise level!\n"
|
print ("earllatepicker: Signal lower than noise level!\n"
|
||||||
"Skip this trace!")
|
"Skip this trace!")
|
||||||
return LPick, EPick, PickError
|
return LPick, EPick, PickError
|
||||||
@ -78,7 +91,7 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=None, stealth_mode=False, fig=Non
|
|||||||
# if EPick stays NaN the signal window size will be doubled
|
# if EPick stays NaN the signal window size will be doubled
|
||||||
while np.isnan(EPick):
|
while np.isnan(EPick):
|
||||||
if count > 0:
|
if count > 0:
|
||||||
if stealth_mode is False:
|
if verbosity:
|
||||||
print("\nearllatepicker: Doubled signal window size %s time(s) "
|
print("\nearllatepicker: Doubled signal window size %s time(s) "
|
||||||
"because of NaN for earliest pick." % count)
|
"because of NaN for earliest pick." % count)
|
||||||
isigDoubleWinStart = pis[-1] + 1
|
isigDoubleWinStart = pis[-1] + 1
|
||||||
@ -87,7 +100,7 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=None, stealth_mode=False, fig=Non
|
|||||||
if (isigDoubleWinStart + len(pis)) < X[0].data.size:
|
if (isigDoubleWinStart + len(pis)) < X[0].data.size:
|
||||||
pis = np.concatenate((pis, isignalDoubleWin))
|
pis = np.concatenate((pis, isignalDoubleWin))
|
||||||
else:
|
else:
|
||||||
if stealth_mode is False:
|
if verbosity:
|
||||||
print("Could not double signal window. Index out of bounds.")
|
print("Could not double signal window. Index out of bounds.")
|
||||||
break
|
break
|
||||||
count += 1
|
count += 1
|
||||||
|
@ -169,7 +169,8 @@ def read_metadata(path_to_inventory):
|
|||||||
dlfile = list()
|
dlfile = list()
|
||||||
invfile = list()
|
invfile = list()
|
||||||
respfile = list()
|
respfile = list()
|
||||||
inv = dict(dless=dlfile, xml=invfile, resp=respfile)
|
# possible file extensions specified here:
|
||||||
|
inv = dict(dless=dlfile, xml=invfile, resp=respfile, dseed=dlfile)
|
||||||
if os.path.isfile(path_to_inventory):
|
if os.path.isfile(path_to_inventory):
|
||||||
ext = os.path.splitext(path_to_inventory)[1].split('.')[1]
|
ext = os.path.splitext(path_to_inventory)[1].split('.')[1]
|
||||||
inv[ext] += [path_to_inventory]
|
inv[ext] += [path_to_inventory]
|
||||||
|
@ -431,7 +431,7 @@ class WaveformWidget(FigureCanvas):
|
|||||||
|
|
||||||
def plotWFData(self, wfdata, title=None, zoomx=None, zoomy=None,
|
def plotWFData(self, wfdata, title=None, zoomx=None, zoomy=None,
|
||||||
noiselevel=None, scaleddata=False, mapping=True,
|
noiselevel=None, scaleddata=False, mapping=True,
|
||||||
component='*', nth_sample=1):
|
component='*', nth_sample=1, iniPick=None):
|
||||||
self.getAxes().cla()
|
self.getAxes().cla()
|
||||||
self.clearPlotDict()
|
self.clearPlotDict()
|
||||||
wfstart, wfend = full_range(wfdata)
|
wfstart, wfend = full_range(wfdata)
|
||||||
@ -477,6 +477,11 @@ class WaveformWidget(FigureCanvas):
|
|||||||
for level in noiselevel:
|
for level in noiselevel:
|
||||||
self.getAxes().plot([time_ax[0], time_ax[-1]],
|
self.getAxes().plot([time_ax[0], time_ax[-1]],
|
||||||
[level, level], '--k')
|
[level, level], '--k')
|
||||||
|
if iniPick:
|
||||||
|
ax = self.getAxes()
|
||||||
|
ax.vlines(iniPick, ax.get_ylim()[0], ax.get_ylim()[1],
|
||||||
|
colors='green', linestyles='dashed',
|
||||||
|
linewidth=2)
|
||||||
self.setPlotDict(n, (station, channel, network))
|
self.setPlotDict(n, (station, channel, network))
|
||||||
xlabel = 'seconds since {0}'.format(wfstart)
|
xlabel = 'seconds since {0}'.format(wfstart)
|
||||||
ylabel = ''
|
ylabel = ''
|
||||||
@ -965,6 +970,9 @@ class PickDlg(QDialog):
|
|||||||
while itrace > len(wfdata) - 1:
|
while itrace > len(wfdata) - 1:
|
||||||
itrace -= 1
|
itrace -= 1
|
||||||
|
|
||||||
|
stime = self.getStartTime()
|
||||||
|
stime_diff = wfdata[itrace].stats.starttime-stime
|
||||||
|
|
||||||
# copy data for plotting
|
# copy data for plotting
|
||||||
data = self.getWFData().copy()
|
data = self.getWFData().copy()
|
||||||
|
|
||||||
@ -975,7 +983,7 @@ class PickDlg(QDialog):
|
|||||||
data.filter(**filteroptions)
|
data.filter(**filteroptions)
|
||||||
wfdata.filter(**filteroptions)
|
wfdata.filter(**filteroptions)
|
||||||
|
|
||||||
result = getSNR(wfdata, (noise_win, gap_win, signal_win), ini_pick, itrace)
|
result = getSNR(wfdata, (noise_win, gap_win, signal_win), ini_pick-stime_diff, itrace)
|
||||||
|
|
||||||
snr = result[0]
|
snr = result[0]
|
||||||
noiselevel = result[2]
|
noiselevel = result[2]
|
||||||
@ -988,8 +996,8 @@ class PickDlg(QDialog):
|
|||||||
|
|
||||||
# remove mean noise level from waveforms
|
# remove mean noise level from waveforms
|
||||||
for trace in data:
|
for trace in data:
|
||||||
t = prepTimeAxis(trace.stats.starttime - self.getStartTime(), trace)
|
t = prepTimeAxis(trace.stats.starttime - stime, trace)
|
||||||
inoise = getnoisewin(t, ini_pick, noise_win, gap_win)
|
inoise = getnoisewin(t, ini_pick-stime_diff, noise_win, gap_win)
|
||||||
trace = demeanTrace(trace=trace, window=inoise)
|
trace = demeanTrace(trace=trace, window=inoise)
|
||||||
|
|
||||||
self.setXLims([ini_pick - x_res, ini_pick + x_res])
|
self.setXLims([ini_pick - x_res, ini_pick + x_res])
|
||||||
@ -1001,7 +1009,8 @@ class PickDlg(QDialog):
|
|||||||
zoomx=self.getXLims(),
|
zoomx=self.getXLims(),
|
||||||
zoomy=self.getYLims(),
|
zoomy=self.getYLims(),
|
||||||
noiselevel=(trace_number + noiselevel,
|
noiselevel=(trace_number + noiselevel,
|
||||||
trace_number - noiselevel))
|
trace_number - noiselevel),
|
||||||
|
iniPick=ini_pick)
|
||||||
|
|
||||||
def setIniPickS(self, gui_event, wfdata):
|
def setIniPickS(self, gui_event, wfdata):
|
||||||
|
|
||||||
@ -1014,6 +1023,9 @@ class PickDlg(QDialog):
|
|||||||
gap_win = twins[1]
|
gap_win = twins[1]
|
||||||
signal_win = twins[2]
|
signal_win = twins[2]
|
||||||
|
|
||||||
|
stime = self.getStartTime()
|
||||||
|
stime_diff = wfdata[0].stats.starttime-stime
|
||||||
|
|
||||||
# copy data for plotting
|
# copy data for plotting
|
||||||
data = self.getWFData().copy()
|
data = self.getWFData().copy()
|
||||||
|
|
||||||
@ -1025,7 +1037,7 @@ class PickDlg(QDialog):
|
|||||||
wfdata.filter(**filteroptions)
|
wfdata.filter(**filteroptions)
|
||||||
|
|
||||||
# determine SNR and noiselevel
|
# determine SNR and noiselevel
|
||||||
result = getSNR(wfdata, (noise_win, gap_win, signal_win), ini_pick)
|
result = getSNR(wfdata, (noise_win, gap_win, signal_win), ini_pick-stime_diff)
|
||||||
snr = result[0]
|
snr = result[0]
|
||||||
noiselevel = result[2]
|
noiselevel = result[2]
|
||||||
|
|
||||||
@ -1036,8 +1048,8 @@ class PickDlg(QDialog):
|
|||||||
|
|
||||||
# prepare plotting of data
|
# prepare plotting of data
|
||||||
for trace in data:
|
for trace in data:
|
||||||
t = prepTimeAxis(trace.stats.starttime - self.getStartTime(), trace)
|
t = prepTimeAxis(trace.stats.starttime - stime, trace)
|
||||||
inoise = getnoisewin(t, ini_pick, noise_win, gap_win)
|
inoise = getnoisewin(t, ini_pick-stime_diff, noise_win, gap_win)
|
||||||
trace = demeanTrace(trace, inoise)
|
trace = demeanTrace(trace, inoise)
|
||||||
|
|
||||||
# scale waveform for plotting
|
# scale waveform for plotting
|
||||||
@ -1060,7 +1072,8 @@ class PickDlg(QDialog):
|
|||||||
zoomx=self.getXLims(),
|
zoomx=self.getXLims(),
|
||||||
zoomy=self.getYLims(),
|
zoomy=self.getYLims(),
|
||||||
noiselevel=noiselevels,
|
noiselevel=noiselevels,
|
||||||
scaleddata=True)
|
scaleddata=True,
|
||||||
|
iniPick=ini_pick)
|
||||||
|
|
||||||
def setPick(self, gui_event):
|
def setPick(self, gui_event):
|
||||||
|
|
||||||
@ -1092,13 +1105,17 @@ class PickDlg(QDialog):
|
|||||||
nfac = parameter.get('nfacS')
|
nfac = parameter.get('nfacS')
|
||||||
TSNR = parameter.get('tsnrh')
|
TSNR = parameter.get('tsnrh')
|
||||||
|
|
||||||
[epp, lpp, spe] = earllatepicker(wfdata, nfac, (TSNR[0], TSNR[1], TSNR[2]), pick)
|
|
||||||
|
|
||||||
# return absolute time values for phases
|
# return absolute time values for phases
|
||||||
stime = self.getStartTime()
|
stime = self.getStartTime()
|
||||||
epp = stime + epp
|
stime_diff = wfdata[0].stats.starttime-stime
|
||||||
|
|
||||||
|
[epp, lpp, spe] = earllatepicker(wfdata, nfac, (TSNR[0], TSNR[1], TSNR[2]), pick-stime_diff, verbosity=2)
|
||||||
|
|
||||||
mpp = stime + pick
|
mpp = stime + pick
|
||||||
lpp = stime + lpp
|
if epp:
|
||||||
|
epp = stime + epp + stime_diff
|
||||||
|
if lpp:
|
||||||
|
lpp = stime + lpp + stime_diff
|
||||||
|
|
||||||
# save pick times for actual phase
|
# save pick times for actual phase
|
||||||
phasepicks = dict(epp=epp, lpp=lpp, mpp=mpp, spe=spe,
|
phasepicks = dict(epp=epp, lpp=lpp, mpp=mpp, spe=spe,
|
||||||
@ -1147,8 +1164,8 @@ class PickDlg(QDialog):
|
|||||||
ax = self.getPlotWidget().axes
|
ax = self.getPlotWidget().axes
|
||||||
ylims = self.getGlobalLimits('y')
|
ylims = self.getGlobalLimits('y')
|
||||||
phase_col = {
|
phase_col = {
|
||||||
'P': ('c', 'c--', 'b-', 'bv', 'b^', 'b'),
|
'P': ('c', 'c--', 'b-', 'bv', 'b^', 'b', 'c:'),
|
||||||
'S': ('m', 'm--', 'r-', 'rv', 'r^', 'r')
|
'S': ('m', 'm--', 'r-', 'rv', 'r^', 'r', 'm:')
|
||||||
}
|
}
|
||||||
if self.getPicks(picktype):
|
if self.getPicks(picktype):
|
||||||
if phase is not None and type(self.getPicks(picktype)[phase]) is dict:
|
if phase is not None and type(self.getPicks(picktype)[phase]) is dict:
|
||||||
@ -1164,23 +1181,29 @@ class PickDlg(QDialog):
|
|||||||
return
|
return
|
||||||
|
|
||||||
mpp = picks['mpp'] - self.getStartTime()
|
mpp = picks['mpp'] - self.getStartTime()
|
||||||
|
if picks['epp'] and picks['lpp']:
|
||||||
epp = picks['epp'] - self.getStartTime()
|
epp = picks['epp'] - self.getStartTime()
|
||||||
lpp = picks['lpp'] - self.getStartTime()
|
lpp = picks['lpp'] - self.getStartTime()
|
||||||
spe = picks['spe']
|
spe = picks['spe']
|
||||||
|
|
||||||
if picktype == 'manual':
|
if picktype == 'manual':
|
||||||
|
if picks['epp'] and picks['lpp']:
|
||||||
ax.fill_between([epp, lpp], ylims[0], ylims[1],
|
ax.fill_between([epp, lpp], ylims[0], ylims[1],
|
||||||
alpha=.25, color=colors[0])
|
alpha=.25, color=colors[0], label='EPP, LPP')
|
||||||
if spe:
|
if spe:
|
||||||
ax.plot([mpp - spe, mpp - spe], ylims, colors[1],
|
ax.plot([mpp - spe, mpp - spe], ylims, colors[1], label='{}-SPE'.format(phase))
|
||||||
[mpp, mpp], ylims, colors[2],
|
ax.plot([mpp + spe, mpp + spe], ylims, colors[1])
|
||||||
[mpp + spe, mpp + spe], ylims, colors[1])
|
ax.plot([mpp, mpp], ylims, colors[2], label='{}-Pick'.format(phase))
|
||||||
|
else:
|
||||||
|
ax.plot([mpp, mpp], ylims, colors[6], label='{}-Pick (NO PICKERROR)'.format(phase))
|
||||||
|
|
||||||
elif picktype == 'auto':
|
elif picktype == 'auto':
|
||||||
ax.plot(mpp, ylims[1], colors[3],
|
ax.plot(mpp, ylims[1], colors[3],
|
||||||
mpp, ylims[0], colors[4])
|
mpp, ylims[0], colors[4])
|
||||||
ax.vlines(mpp, ylims[0], ylims[1], colors[5], linestyles='dotted')
|
ax.vlines(mpp, ylims[0], ylims[1], colors[5], linestyles='dotted')
|
||||||
else:
|
else:
|
||||||
raise TypeError('Unknown picktype {0}'.format(picktype))
|
raise TypeError('Unknown picktype {0}'.format(picktype))
|
||||||
|
ax.legend()
|
||||||
|
|
||||||
|
|
||||||
def panPress(self, gui_event):
|
def panPress(self, gui_event):
|
||||||
|
Loading…
Reference in New Issue
Block a user