Switched off warnings.
This commit is contained in:
parent
4a911a4ac9
commit
f2510ff400
@ -3,18 +3,18 @@
|
|||||||
Created Dec 2014 to Feb 2015
|
Created Dec 2014 to Feb 2015
|
||||||
Implementation of the automated picking algorithms published and described in:
|
Implementation of the automated picking algorithms published and described in:
|
||||||
|
|
||||||
Kueperkoch, L., Meier, T., Lee, J., Friederich, W., & Egelados Working Group,
|
Kueperkoch, L., Meier, T., Lee, J., Friederich, W., & Egelados Working Group, 2010:
|
||||||
2010: Automated determination of P-phase arrival times at regional and local
|
Automated determination of P-phase arrival times at regional and local distances
|
||||||
distances using higher order statistics, Geophys. J. Int., 181, 1159-1170
|
using higher order statistics, Geophys. J. Int., 181, 1159-1170
|
||||||
|
|
||||||
Kueperkoch, L., Meier, T., Bruestle, A., Lee, J., Friederich, W., & Egelados
|
Kueperkoch, L., Meier, T., Bruestle, A., Lee, J., Friederich, W., & Egelados
|
||||||
Working Group, 2012: Automated determination of S-phase arrival times using
|
Working Group, 2012: Automated determination of S-phase arrival times using
|
||||||
autoregressive prediction: application ot local and regional distances,
|
autoregressive prediction: application ot local and regional distances, Geophys. J. Int.,
|
||||||
Geophys. J. Int., 188, 687-702.
|
188, 687-702.
|
||||||
|
|
||||||
The picks with the above described algorithms are assumed to be the most likely
|
The picks with the above described algorithms are assumed to be the most likely picks.
|
||||||
picks. For each most likely pick the corresponding earliest and latest possible
|
For each most likely pick the corresponding earliest and latest possible picks are
|
||||||
picks are calculated after Diehl & Kissling (2009).
|
calculated after Diehl & Kissling (2009).
|
||||||
|
|
||||||
:author: MAGS2 EP3 working group / Ludger Kueperkoch
|
:author: MAGS2 EP3 working group / Ludger Kueperkoch
|
||||||
"""
|
"""
|
||||||
@ -22,46 +22,43 @@ import numpy as np
|
|||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
from pylot.core.pick.utils import *
|
from pylot.core.pick.utils import *
|
||||||
from pylot.core.pick.CharFuns import CharacteristicFunction
|
from pylot.core.pick.CharFuns import CharacteristicFunction
|
||||||
|
import warnings
|
||||||
|
|
||||||
class AutoPicking(object):
|
class AutoPicking(object):
|
||||||
'''
|
'''
|
||||||
Superclass of different, automated picking algorithms applied on a CF
|
Superclass of different, automated picking algorithms applied on a CF determined
|
||||||
determined using AIC, HOS, or AR prediction.
|
using AIC, HOS, or AR prediction.
|
||||||
'''
|
'''
|
||||||
|
|
||||||
def __init__(self, cf, TSNR, PickWindow, iplot=None, aus=None, Tsmooth=None,
|
warnings.simplefilter('ignore')
|
||||||
Pick1=None):
|
|
||||||
|
def __init__(self, cf, TSNR, PickWindow, iplot=None, aus=None, Tsmooth=None, Pick1=None):
|
||||||
'''
|
'''
|
||||||
:param cf: characteristic function, on which the picking algorithm is
|
:param: cf, characteristic function, on which the picking algorithm is applied
|
||||||
applied
|
:type: `~pylot.core.pick.CharFuns.CharacteristicFunction` object
|
||||||
:type cf: `~pylot.core.pick.CharFuns.CharacteristicFunction` object
|
|
||||||
|
|
||||||
:param TSNR: length of time windows for SNR determination - [s]
|
:param: TSNR, length of time windows around pick used to determine SNR [s]
|
||||||
:type TSNR: tuple (T_noise, T_gap, T_signal)
|
:type: tuple (T_noise, T_gap, T_signal)
|
||||||
|
|
||||||
:param PickWindow: length of pick window - [s]
|
:param: PickWindow, length of pick window [s]
|
||||||
:type PickWindow: float
|
:type: float
|
||||||
|
|
||||||
:param iplot: no. of figure window for plotting interims results
|
:param: iplot, no. of figure window for plotting interims results
|
||||||
:type iplot: integer
|
:type: integer
|
||||||
|
|
||||||
:param aus: aus ("artificial uplift of samples"), find local minimum at
|
:param: aus ("artificial uplift of samples"), find local minimum at i if aic(i-1)*(1+aus) >= aic(i)
|
||||||
i if aic(i-1)*(1+aus) >= aic(i)
|
:type: float
|
||||||
:type aus: float
|
|
||||||
|
|
||||||
:param Tsmooth: length of moving window to calculate smoothed CF - [s]
|
:param: Tsmooth, length of moving smoothing window to calculate smoothed CF [s]
|
||||||
:type Tsmooth: float
|
:type: float
|
||||||
|
|
||||||
:param Pick1: initial (prelimenary) onset time, starting point for
|
:param: Pick1, initial (prelimenary) onset time, starting point for PragPicker and
|
||||||
PragPicker
|
EarlLatePicker
|
||||||
:type Pick1: float
|
:type: float
|
||||||
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
assert isinstance(cf,
|
assert isinstance(cf, CharacteristicFunction), "%s is not a CharacteristicFunction object" % str(cf)
|
||||||
CharacteristicFunction), "%s is of wrong type" % str(
|
|
||||||
cf)
|
|
||||||
|
|
||||||
self.cf = cf.getCF()
|
self.cf = cf.getCF()
|
||||||
self.Tcf = cf.getTimeArray()
|
self.Tcf = cf.getTimeArray()
|
||||||
@ -89,6 +86,7 @@ class AutoPicking(object):
|
|||||||
Tsmooth=self.getTsmooth(),
|
Tsmooth=self.getTsmooth(),
|
||||||
Pick1=self.getpick1())
|
Pick1=self.getpick1())
|
||||||
|
|
||||||
|
|
||||||
def getTSNR(self):
|
def getTSNR(self):
|
||||||
return self.TSNR
|
return self.TSNR
|
||||||
|
|
||||||
@ -170,15 +168,13 @@ class AICPicker(AutoPicking):
|
|||||||
for i in range(1, len(aic)):
|
for i in range(1, len(aic)):
|
||||||
if i > ismooth:
|
if i > ismooth:
|
||||||
ii1 = i - ismooth
|
ii1 = i - ismooth
|
||||||
aicsmooth[i] = aicsmooth[i - 1] + (aic[i] - aic[
|
aicsmooth[i] = aicsmooth[i - 1] + (aic[i] - aic[ii1]) / ismooth
|
||||||
ii1]) / ismooth
|
|
||||||
else:
|
else:
|
||||||
aicsmooth[i] = np.mean(aic[1 : i])
|
aicsmooth[i] = np.mean(aic[1 : i])
|
||||||
#remove offset
|
#remove offset
|
||||||
offset = abs(min(aic) - min(aicsmooth))
|
offset = abs(min(aic) - min(aicsmooth))
|
||||||
aicsmooth = aicsmooth - offset
|
aicsmooth = aicsmooth - offset
|
||||||
# get maximum of 1st derivative of AIC-CF (more stable!) as starting
|
#get maximum of 1st derivative of AIC-CF (more stable!) as starting point
|
||||||
# point
|
|
||||||
diffcf = np.diff(aicsmooth)
|
diffcf = np.diff(aicsmooth)
|
||||||
#find NaN's
|
#find NaN's
|
||||||
nn = np.isnan(diffcf)
|
nn = np.isnan(diffcf)
|
||||||
@ -206,29 +202,26 @@ class AICPicker(AutoPicking):
|
|||||||
# quality assessment using SNR and slope from CF
|
# quality assessment using SNR and slope from CF
|
||||||
if self.Pick is not None:
|
if self.Pick is not None:
|
||||||
# get noise window
|
# get noise window
|
||||||
inoise = getnoisewin(self.Tcf, self.Pick, self.TSNR[0],
|
inoise = getnoisewin(self.Tcf, self.Pick, self.TSNR[0], self.TSNR[1])
|
||||||
self.TSNR[1])
|
|
||||||
# check, if these are counts or m/s, important for slope estimation!
|
# check, if these are counts or m/s, important for slope estimation!
|
||||||
# this is quick and dirty, better solution?
|
# this is quick and dirty, better solution?
|
||||||
if max(self.Data[0].data < 1e-3):
|
if max(self.Data[0].data < 1e-3):
|
||||||
self.Data[0].data *= 1000000
|
self.Data[0].data = self.Data[0].data * 1000000
|
||||||
# get signal window
|
# get signal window
|
||||||
isignal = getsignalwin(self.Tcf, self.Pick, self.TSNR[2])
|
isignal = getsignalwin(self.Tcf, self.Pick, self.TSNR[2])
|
||||||
# calculate SNR from CF
|
# calculate SNR from CF
|
||||||
self.SNR = max(abs(aic[isignal] - np.mean(aic[isignal]))) / \
|
self.SNR = max(abs(aic[isignal] - np.mean(aic[isignal]))) / max(abs(aic[inoise] \
|
||||||
max(abs(aic[inoise] - np.mean(aic[inoise])))
|
- np.mean(aic[inoise])))
|
||||||
# calculate slope from CF after initial pick
|
# calculate slope from CF after initial pick
|
||||||
# get slope window
|
# get slope window
|
||||||
tslope = self.TSNR[3] #slope determination window
|
tslope = self.TSNR[3] #slope determination window
|
||||||
islope = np.where(
|
islope = np.where((self.Tcf <= min([self.Pick + tslope, len(self.Data[0].data)])) \
|
||||||
(self.Tcf <= min([self.Pick + tslope, len(self.Data[0].data)]))
|
& (self.Tcf >= self.Pick))
|
||||||
and (self.Tcf >= self.Pick))
|
|
||||||
# find maximum within slope determination window
|
# find maximum within slope determination window
|
||||||
# 'cause slope should be calculated up to first local minimum only!
|
# 'cause slope should be calculated up to first local minimum only!
|
||||||
imax = np.argmax(self.Data[0].data[islope])
|
imax = np.argmax(self.Data[0].data[islope])
|
||||||
if imax == 0:
|
if imax == 0:
|
||||||
print 'AICPicker: Maximum for slope determination right at ' \
|
print 'AICPicker: Maximum for slope determination right at the beginning of the window!'
|
||||||
'the beginning of the window!'
|
|
||||||
print 'Choose longer slope determination window!'
|
print 'Choose longer slope determination window!'
|
||||||
return
|
return
|
||||||
islope = islope[0][0 :imax]
|
islope = islope[0][0 :imax]
|
||||||
@ -253,10 +246,8 @@ class AICPicker(AutoPicking):
|
|||||||
p1, = plt.plot(self.Tcf, x / max(x), 'k')
|
p1, = plt.plot(self.Tcf, x / max(x), 'k')
|
||||||
p2, = plt.plot(self.Tcf, aicsmooth / max(aicsmooth), 'r')
|
p2, = plt.plot(self.Tcf, aicsmooth / max(aicsmooth), 'r')
|
||||||
if self.Pick is not None:
|
if self.Pick is not None:
|
||||||
p3, = plt.plot([self.Pick, self.Pick], [-0.1, 0.5], 'b',
|
p3, = plt.plot([self.Pick, self.Pick], [-0.1 , 0.5], 'b', linewidth=2)
|
||||||
linewidth=2)
|
plt.legend([p1, p2, p3], ['(HOS-/AR-) Data', 'Smoothed AIC-CF', 'AIC-Pick'])
|
||||||
plt.legend([p1, p2, p3],
|
|
||||||
['(HOS-/AR-) Data', 'Smoothed AIC-CF', 'AIC-Pick'])
|
|
||||||
else:
|
else:
|
||||||
plt.legend([p1, p2], ['(HOS-/AR-) Data', 'Smoothed AIC-CF'])
|
plt.legend([p1, p2], ['(HOS-/AR-) Data', 'Smoothed AIC-CF'])
|
||||||
plt.xlabel('Time [s] since %s' % self.Data[0].stats.starttime)
|
plt.xlabel('Time [s] since %s' % self.Data[0].stats.starttime)
|
||||||
@ -267,29 +258,24 @@ class AICPicker(AutoPicking):
|
|||||||
plt.figure(self.iplot + 1)
|
plt.figure(self.iplot + 1)
|
||||||
p11, = plt.plot(self.Tcf, x, 'k')
|
p11, = plt.plot(self.Tcf, x, 'k')
|
||||||
p12, = plt.plot(self.Tcf[inoise], self.Data[0].data[inoise])
|
p12, = plt.plot(self.Tcf[inoise], self.Data[0].data[inoise])
|
||||||
p13, = plt.plot(self.Tcf[isignal], self.Data[0].data[isignal],
|
p13, = plt.plot(self.Tcf[isignal], self.Data[0].data[isignal], 'r')
|
||||||
'r')
|
|
||||||
p14, = plt.plot(self.Tcf[islope], dataslope, 'g--')
|
p14, = plt.plot(self.Tcf[islope], dataslope, 'g--')
|
||||||
p15, = plt.plot(self.Tcf[islope], datafit, 'g', linewidth=2)
|
p15, = plt.plot(self.Tcf[islope], datafit, 'g', linewidth=2)
|
||||||
plt.legend([p11, p12, p13, p14, p15],
|
plt.legend([p11, p12, p13, p14, p15], ['Data', 'Noise Window', 'Signal Window', 'Slope Window', 'Slope'], \
|
||||||
['Data', 'Noise Window', 'Signal Window',
|
|
||||||
'Slope Window', 'Slope'],
|
|
||||||
loc='best')
|
loc='best')
|
||||||
plt.title('Station %s, SNR=%7.2f, Slope= %12.2f counts/s' % (
|
plt.title('Station %s, SNR=%7.2f, Slope= %12.2f counts/s' % (self.Data[0].stats.station, \
|
||||||
self.Data[0].stats.station,
|
|
||||||
self.SNR, self.slope))
|
self.SNR, self.slope))
|
||||||
plt.xlabel('Time [s] since %s' % self.Data[0].stats.starttime)
|
plt.xlabel('Time [s] since %s' % self.Data[0].stats.starttime)
|
||||||
plt.ylabel('Counts')
|
plt.ylabel('Counts')
|
||||||
ax = plt.gca()
|
ax = plt.gca()
|
||||||
plt.yticks([])
|
plt.yticks([])
|
||||||
ax.set_xlim([self.Tcf[inoise[0][0]] - 5,
|
ax.set_xlim([self.Tcf[inoise[0][0]] - 5, self.Tcf[isignal[0][len(isignal) - 1]] + 5])
|
||||||
self.Tcf[isignal[0][len(isignal) - 1]] + 5])
|
|
||||||
|
|
||||||
plt.show()
|
plt.show()
|
||||||
raw_input()
|
raw_input()
|
||||||
plt.close(p)
|
plt.close(p)
|
||||||
|
|
||||||
if self.Pick is None:
|
if self.Pick == None:
|
||||||
print 'AICPicker: Could not find minimum, picking window too short?'
|
print 'AICPicker: Could not find minimum, picking window too short?'
|
||||||
|
|
||||||
|
|
||||||
@ -301,8 +287,7 @@ class PragPicker(AutoPicking):
|
|||||||
def calcPick(self):
|
def calcPick(self):
|
||||||
|
|
||||||
if self.getpick1() is not None:
|
if self.getpick1() is not None:
|
||||||
print 'PragPicker: Get most likely pick from HOS- or AR-CF using ' \
|
print 'PragPicker: Get most likely pick from HOS- or AR-CF using pragmatic picking algorithm ...'
|
||||||
'pragmatic picking algorithm ...'
|
|
||||||
|
|
||||||
self.Pick = None
|
self.Pick = None
|
||||||
self.SNR = None
|
self.SNR = None
|
||||||
@ -316,18 +301,15 @@ class PragPicker(AutoPicking):
|
|||||||
else:
|
else:
|
||||||
for i in range(1, len(self.cf)):
|
for i in range(1, len(self.cf)):
|
||||||
if i > ismooth:
|
if i > ismooth:
|
||||||
ii1 = i - ismooth
|
ii1 = i - ismooth;
|
||||||
cfsmooth[i] = cfsmooth[i - 1] + (self.cf[i] - self.cf[
|
cfsmooth[i] = cfsmooth[i - 1] + (self.cf[i] - self.cf[ii1]) / ismooth
|
||||||
ii1]) / ismooth
|
|
||||||
else:
|
else:
|
||||||
cfsmooth[i] = np.mean(self.cf[1 : i])
|
cfsmooth[i] = np.mean(self.cf[1 : i])
|
||||||
|
|
||||||
#select picking window
|
#select picking window
|
||||||
#which is centered around tpick1
|
#which is centered around tpick1
|
||||||
ipick = np.where((self.Tcf >=
|
ipick = np.where((self.Tcf >= self.getpick1() - self.PickWindow / 2) \
|
||||||
(self.getpick1() - self.PickWindow / 2)) and
|
& (self.Tcf <= self.getpick1() + self.PickWindow / 2))
|
||||||
(self.Tcf <=
|
|
||||||
(self.getpick1() + self.PickWindow / 2)))
|
|
||||||
cfipick = self.cf[ipick] - np.mean(self.cf[ipick])
|
cfipick = self.cf[ipick] - np.mean(self.cf[ipick])
|
||||||
Tcfpick = self.Tcf[ipick]
|
Tcfpick = self.Tcf[ipick]
|
||||||
cfsmoothipick = cfsmooth[ipick]- np.mean(self.cf[ipick])
|
cfsmoothipick = cfsmooth[ipick]- np.mean(self.cf[ipick])
|
||||||
@ -337,19 +319,18 @@ class PragPicker(AutoPicking):
|
|||||||
#check trend of CF, i.e. differences of CF and adjust aus regarding this trend
|
#check trend of CF, i.e. differences of CF and adjust aus regarding this trend
|
||||||
#prominent trend: decrease aus
|
#prominent trend: decrease aus
|
||||||
#flat: use given aus
|
#flat: use given aus
|
||||||
cfdiff = np.diff(cfipick)
|
cfdiff = np.diff(cfipick);
|
||||||
i0diff = np.where(cfdiff > 0)
|
i0diff = np.where(cfdiff > 0)
|
||||||
cfdiff = cfdiff[i0diff]
|
cfdiff = cfdiff[i0diff]
|
||||||
minaus = min(cfdiff * (1 + self.aus))
|
minaus = min(cfdiff * (1 + self.aus));
|
||||||
aus1 = max([minaus, self.aus])
|
aus1 = max([minaus, self.aus]);
|
||||||
|
|
||||||
#at first we look to the right until the end of the pick window is reached
|
#at first we look to the right until the end of the pick window is reached
|
||||||
flagpick_r = 0
|
flagpick_r = 0
|
||||||
flagpick_l = 0
|
flagpick_l = 0
|
||||||
flagpick = 0
|
flagpick = 0
|
||||||
lpickwindow = int(round(self.PickWindow / self.dt))
|
lpickwindow = int(round(self.PickWindow / self.dt))
|
||||||
for i in range(max(np.insert(ipick, 0, 2)),
|
for i in range(max(np.insert(ipick, 0, 2)), min([ipick1 + lpickwindow + 1, len(self.cf) - 1])):
|
||||||
min([ipick1 + lpickwindow + 1, len(self.cf) - 1])):
|
|
||||||
if self.cf[i + 1] > self.cf[i] and self.cf[i - 1] >= self.cf[i]:
|
if self.cf[i + 1] > self.cf[i] and self.cf[i - 1] >= self.cf[i]:
|
||||||
if cfsmooth[i - 1] * (1 + aus1) >= cfsmooth[i]:
|
if cfsmooth[i - 1] * (1 + aus1) >= cfsmooth[i]:
|
||||||
if cfpick1 >= self.cf[i]:
|
if cfpick1 >= self.cf[i]:
|
||||||
@ -380,8 +361,7 @@ class PragPicker(AutoPicking):
|
|||||||
p = plt.figure(self.getiplot())
|
p = plt.figure(self.getiplot())
|
||||||
p1, = plt.plot(Tcfpick,cfipick, 'k')
|
p1, = plt.plot(Tcfpick,cfipick, 'k')
|
||||||
p2, = plt.plot(Tcfpick,cfsmoothipick, 'r')
|
p2, = plt.plot(Tcfpick,cfsmoothipick, 'r')
|
||||||
p3, = plt.plot([self.Pick, self.Pick],
|
p3, = plt.plot([self.Pick, self.Pick], [min(cfipick), max(cfipick)], 'b', linewidth=2)
|
||||||
[min(cfipick), max(cfipick)], 'b', linewidth=2)
|
|
||||||
plt.legend([p1, p2, p3], ['CF', 'Smoothed CF', 'Pick'])
|
plt.legend([p1, p2, p3], ['CF', 'Smoothed CF', 'Pick'])
|
||||||
plt.xlabel('Time [s] since %s' % self.Data[0].stats.starttime)
|
plt.xlabel('Time [s] since %s' % self.Data[0].stats.starttime)
|
||||||
plt.yticks([])
|
plt.yticks([])
|
||||||
@ -393,3 +373,4 @@ class PragPicker(AutoPicking):
|
|||||||
else:
|
else:
|
||||||
self.Pick = None
|
self.Pick = None
|
||||||
print 'PragPicker: No initial onset time given! Check input!'
|
print 'PragPicker: No initial onset time given! Check input!'
|
||||||
|
return
|
||||||
|
Loading…
Reference in New Issue
Block a user