Merge branch 'develop' of ariadne:/data/git/pylot into develop
This commit is contained in:
commit
4ed8e54822
@ -6,6 +6,7 @@ Revised/extended summer 2017.
|
|||||||
|
|
||||||
:author: Ludger Küperkoch / MAGS2 EP3 working group
|
:author: Ludger Küperkoch / MAGS2 EP3 working group
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import obspy.core.event as ope
|
import obspy.core.event as ope
|
||||||
@ -219,7 +220,7 @@ class LocalMagnitude(Magnitude):
|
|||||||
sqH = np.sqrt(power_sum)
|
sqH = np.sqrt(power_sum)
|
||||||
|
|
||||||
# get time array
|
# get time array
|
||||||
th = np.arange(0, len(sqH) * dt, dt)
|
th=np.arange(0, st[0].stats.npts/st[0].stats.sampling_rate, st[0].stats.delta)
|
||||||
# get maximum peak within pick window
|
# get maximum peak within pick window
|
||||||
iwin = getsignalwin(th, t0 - stime, self.calc_win)
|
iwin = getsignalwin(th, t0 - stime, self.calc_win)
|
||||||
ii = min([iwin[len(iwin) - 1], len(th)])
|
ii = min([iwin[len(iwin) - 1], len(th)])
|
||||||
|
@ -100,9 +100,9 @@ def autopickevent(data, param, iplot=0, fig_dict=None, fig_dict_wadatijack=None,
|
|||||||
|
|
||||||
# quality control
|
# quality control
|
||||||
# median check and jackknife on P-onset times
|
# median check and jackknife on P-onset times
|
||||||
jk_checked_onsets = checkPonsets(all_onsets, mdttolerance, jackfactor, 1, fig_dict_wadatijack)
|
jk_checked_onsets = checkPonsets(all_onsets, mdttolerance, jackfactor, iplot, fig_dict_wadatijack)
|
||||||
# check S-P times (Wadati)
|
# check S-P times (Wadati)
|
||||||
wadationsets = wadaticheck(jk_checked_onsets, wdttolerance, 1, fig_dict_wadatijack)
|
wadationsets = wadaticheck(jk_checked_onsets, wdttolerance, iplot, fig_dict_wadatijack)
|
||||||
return wadationsets
|
return wadationsets
|
||||||
|
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ def autopickstation(wfstream, pickparam, verbose=False,
|
|||||||
return
|
return
|
||||||
|
|
||||||
Ldiff = Lwf - abs(Lc)
|
Ldiff = Lwf - abs(Lc)
|
||||||
if Ldiff < 0 or pstop <= pstart:
|
if Ldiff <= 0 or pstop <= pstart or pstop - pstart <= thosmw:
|
||||||
msg = 'autopickstation: Cutting times are too large for actual ' \
|
msg = 'autopickstation: Cutting times are too large for actual ' \
|
||||||
'waveform!\nUsing entire waveform instead!'
|
'waveform!\nUsing entire waveform instead!'
|
||||||
if verbose: print(msg)
|
if verbose: print(msg)
|
||||||
@ -564,7 +564,8 @@ def autopickstation(wfstream, pickparam, verbose=False,
|
|||||||
SNRPdB,
|
SNRPdB,
|
||||||
FM)
|
FM)
|
||||||
print(msg)
|
print(msg)
|
||||||
msg = 'autopickstation: Refined P-Pick: {} s | P-Error: {} s'.format(mpickP, Perror)
|
msg = 'autopickstation: Refind P-Pick: {} s | P-Error: {} s'.format(zdat[0].stats.starttime \
|
||||||
|
+ mpickP, Perror)
|
||||||
print(msg)
|
print(msg)
|
||||||
Sflag = 1
|
Sflag = 1
|
||||||
|
|
||||||
@ -843,7 +844,8 @@ def autopickstation(wfstream, pickparam, verbose=False,
|
|||||||
lpickS = lpick[ipick]
|
lpickS = lpick[ipick]
|
||||||
Serror = pickerr[ipick]
|
Serror = pickerr[ipick]
|
||||||
|
|
||||||
msg = 'autopickstation: Refined S-Pick: {} s | S-Error: {} s'.format(mpickS, Serror)
|
msg = 'autopickstation: Refined S-Pick: {} s | S-Error: {} s'.format(hdat[0].stats.starttime \
|
||||||
|
+ mpickS, Serror)
|
||||||
print(msg)
|
print(msg)
|
||||||
|
|
||||||
# get SNR
|
# get SNR
|
||||||
|
@ -239,7 +239,7 @@ class AICPicker(AutoPicker):
|
|||||||
print(msg)
|
print(msg)
|
||||||
return
|
return
|
||||||
# calculate SNR from CF
|
# calculate SNR from CF
|
||||||
self.SNR = max(abs(self.Data[0].data[isignal] - np.mean(self.Data[0].data[isignal]))) / \
|
self.SNR = max(abs(self.Data[0].data[isignal])) / \
|
||||||
max(abs(self.Data[0].data[inoise] - np.mean(self.Data[0].data[inoise])))
|
max(abs(self.Data[0].data[inoise] - np.mean(self.Data[0].data[inoise])))
|
||||||
# calculate slope from CF after initial pick
|
# calculate slope from CF after initial pick
|
||||||
# get slope window
|
# get slope window
|
||||||
@ -253,13 +253,15 @@ class AICPicker(AutoPicker):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
print("Slope Calculation: empty array islope, check signal window")
|
print("Slope Calculation: empty array islope, check signal window")
|
||||||
return
|
return
|
||||||
if len(dataslope) <= 1:
|
if len(dataslope) < 2:
|
||||||
print('No or not enough data in slope window found!')
|
print('No or not enough data in slope window found!')
|
||||||
return
|
return
|
||||||
imaxs, = argrelmax(dataslope)
|
try:
|
||||||
if imaxs.size:
|
imaxs, = argrelmax(dataslope)
|
||||||
|
imaxs.size
|
||||||
imax = imaxs[0]
|
imax = imaxs[0]
|
||||||
else:
|
except ValueError as e:
|
||||||
|
print(e, 'picker: argrelmax not working!')
|
||||||
imax = np.argmax(dataslope)
|
imax = np.argmax(dataslope)
|
||||||
iislope = islope[0][0:imax + 1]
|
iislope = islope[0][0:imax + 1]
|
||||||
if len(iislope) < 2:
|
if len(iislope) < 2:
|
||||||
@ -298,8 +300,8 @@ class AICPicker(AutoPicker):
|
|||||||
datafit = np.polyval(P, xslope)
|
datafit = np.polyval(P, xslope)
|
||||||
if datafit[0] >= datafit[-1]:
|
if datafit[0] >= datafit[-1]:
|
||||||
print('AICPicker: Negative slope, bad onset skipped!')
|
print('AICPicker: Negative slope, bad onset skipped!')
|
||||||
return
|
else:
|
||||||
self.slope = 1 / (len(dataslope) * self.Data[0].stats.delta) * (datafit[-1] - datafit[0])
|
self.slope = 1 / (len(dataslope) * self.Data[0].stats.delta) * (datafit[-1] - datafit[0])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.SNR = None
|
self.SNR = None
|
||||||
@ -340,8 +342,11 @@ class AICPicker(AutoPicker):
|
|||||||
label='Slope Window')
|
label='Slope Window')
|
||||||
ax2.plot(self.Tcf[iislope], datafit, 'g', linewidth=2, label='Slope')
|
ax2.plot(self.Tcf[iislope], datafit, 'g', linewidth=2, label='Slope')
|
||||||
|
|
||||||
ax1.set_title('Station %s, SNR=%7.2f, Slope= %12.2f counts/s' % (self.Data[0].stats.station,
|
if self.slope is not None:
|
||||||
self.SNR, self.slope))
|
ax1.set_title('Station %s, SNR=%7.2f, Slope= %12.2f counts/s' % (self.Data[0].stats.station,
|
||||||
|
self.SNR, self.slope))
|
||||||
|
else:
|
||||||
|
ax1.set_title('Station %s, SNR=%7.2f' % (self.Data[0].stats.station, self.SNR))
|
||||||
ax2.set_xlabel('Time [s] since %s' % self.Data[0].stats.starttime)
|
ax2.set_xlabel('Time [s] since %s' % self.Data[0].stats.starttime)
|
||||||
ax2.set_ylabel('Counts')
|
ax2.set_ylabel('Counts')
|
||||||
ax2.set_yticks([])
|
ax2.set_yticks([])
|
||||||
|
Loading…
Reference in New Issue
Block a user