Merge branch 'develop' of ariadne.geophysik.rub.de:/data/git/pylot into develop
Conflicts: pylot/core/pick/utils.py
This commit is contained in:
commit
635ac1686b
@ -66,8 +66,8 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=None):
|
|||||||
|
|
||||||
# get earliest possible pick
|
# get earliest possible pick
|
||||||
|
|
||||||
#determine all zero crossings in signal window
|
# determine all zero crossings in signal window (demeaned)
|
||||||
zc = crossings_nonzero_all(x[isignal])
|
zc = crossings_nonzero_all(x[isignal] - x[isignal].mean())
|
||||||
# calculate mean half period T0 of signal as the average of the
|
# calculate mean half period T0 of signal as the average of the
|
||||||
T0 = np.mean(np.diff(zc)) * X[0].stats.delta # this is half wave length!
|
T0 = np.mean(np.diff(zc)) * X[0].stats.delta # this is half wave length!
|
||||||
# T0/4 is assumed as time difference between most likely and earliest possible pick!
|
# T0/4 is assumed as time difference between most likely and earliest possible pick!
|
||||||
@ -85,7 +85,8 @@ def earllatepicker(X, nfac, TSNR, Pick1, iplot=None):
|
|||||||
p2, = plt.plot(t[inoise], x[inoise])
|
p2, = plt.plot(t[inoise], x[inoise])
|
||||||
p3, = plt.plot(t[isignal], x[isignal], 'r')
|
p3, = plt.plot(t[isignal], x[isignal], 'r')
|
||||||
p4, = plt.plot([t[0], t[int(len(t)) - 1]], [nlevel, nlevel], '--k')
|
p4, = plt.plot([t[0], t[int(len(t)) - 1]], [nlevel, nlevel], '--k')
|
||||||
p5, = plt.plot(t[isignal[0][zc]], np.zeros(len(zc)), '*g', markersize=14)
|
p5, = plt.plot(t[isignal[0][zc]], np.zeros(len(zc)), '*g',
|
||||||
|
markersize=14)
|
||||||
plt.legend([p1, p2, p3, p4, p5],
|
plt.legend([p1, p2, p3, p4, p5],
|
||||||
['Data', 'Noise Window', 'Signal Window', 'Noise Level',
|
['Data', 'Noise Window', 'Signal Window', 'Noise Level',
|
||||||
'Zero Crossings'], \
|
'Zero Crossings'], \
|
||||||
@ -281,11 +282,13 @@ def fmpicker(Xraw, Xfilt, pickwin, Pick, iplot=None):
|
|||||||
|
|
||||||
return FM
|
return FM
|
||||||
|
|
||||||
|
|
||||||
def crossings_nonzero_all(data):
|
def crossings_nonzero_all(data):
|
||||||
pos = data > 0
|
pos = data > 0
|
||||||
npos = ~pos
|
npos = ~pos
|
||||||
return ((pos[:-1] & npos[1:]) | (npos[:-1] & pos[1:])).nonzero()[0]
|
return ((pos[:-1] & npos[1:]) | (npos[:-1] & pos[1:])).nonzero()[0]
|
||||||
|
|
||||||
|
|
||||||
def getSNR(X, TSNR, t1):
|
def getSNR(X, TSNR, t1):
|
||||||
'''
|
'''
|
||||||
Function to calculate SNR of certain part of seismogram relative to
|
Function to calculate SNR of certain part of seismogram relative to
|
||||||
@ -383,6 +386,7 @@ def getsignalwin(t, t1, tsignal):
|
|||||||
|
|
||||||
return isignal
|
return isignal
|
||||||
|
|
||||||
|
|
||||||
def wadaticheck(pickdic, dttolerance, iplot):
|
def wadaticheck(pickdic, dttolerance, iplot):
|
||||||
'''
|
'''
|
||||||
Function to calculate Wadati-diagram from given P and S onsets in order
|
Function to calculate Wadati-diagram from given P and S onsets in order
|
||||||
@ -413,12 +417,18 @@ def wadaticheck(pickdic, dttolerance, iplot):
|
|||||||
# add S-P time to dictionary
|
# add S-P time to dictionary
|
||||||
pickdic[key]['SPt'] = spt
|
pickdic[key]['SPt'] = spt
|
||||||
# add P onsets and corresponding S-P times to list
|
# add P onsets and corresponding S-P times to list
|
||||||
UTCPpick = UTCDateTime(pickdic[key]['P']['mpp'])
|
UTCPpick = UTCDateTime(pickdic[key]['P']['mpp']) - UTCDateTime(1970,
|
||||||
UTCSpick = UTCDateTime(pickdic[key]['S']['mpp'])
|
1, 1,
|
||||||
Ppicks.append(UTCPpick.timestamp)
|
0, 0,
|
||||||
Spicks.append(UTCSpick.timestamp)
|
0)
|
||||||
|
UTCSpick = UTCDateTime(pickdic[key]['S']['mpp']) - UTCDateTime(1970,
|
||||||
|
1, 1,
|
||||||
|
0, 0,
|
||||||
|
0)
|
||||||
|
Ppicks.append(UTCPpick)
|
||||||
|
Spicks.append(UTCSpick)
|
||||||
SPtimes.append(spt)
|
SPtimes.append(spt)
|
||||||
|
vpvs.append(UTCPpick / UTCSpick)
|
||||||
|
|
||||||
if len(SPtimes) >= 3:
|
if len(SPtimes) >= 3:
|
||||||
# calculate slope
|
# calculate slope
|
||||||
@ -447,12 +457,16 @@ def wadaticheck(pickdic, dttolerance, iplot):
|
|||||||
pickdic[key]['S']['weight'] = 9
|
pickdic[key]['S']['weight'] = 9
|
||||||
else:
|
else:
|
||||||
marker = 'goodWadatiCheck'
|
marker = 'goodWadatiCheck'
|
||||||
checkedPpick = UTCDateTime(pickdic[key]['P']['mpp'])
|
checkedPpick = UTCDateTime(pickdic[key]['P']['mpp']) - \
|
||||||
checkedPpicks.append(checkedPpick.timestamp)
|
UTCDateTime(1970, 1, 1, 0, 0, 0)
|
||||||
checkedSpick = UTCDateTime(pickdic[key]['S']['mpp'])
|
checkedPpicks.append(checkedPpick)
|
||||||
checkedSpicks.append(checkedSpick.timestamp)
|
checkedSpick = UTCDateTime(pickdic[key]['S']['mpp']) - \
|
||||||
checkedSPtime = pickdic[key]['S']['mpp'] - pickdic[key]['P']['mpp']
|
UTCDateTime(1970, 1, 1, 0, 0, 0)
|
||||||
|
checkedSpicks.append(checkedSpick)
|
||||||
|
checkedSPtime = pickdic[key]['S']['mpp'] - \
|
||||||
|
pickdic[key]['P']['mpp']
|
||||||
checkedSPtimes.append(checkedSPtime)
|
checkedSPtimes.append(checkedSPtime)
|
||||||
|
checkedvpvs.append(checkedPpick / checkedSpick)
|
||||||
|
|
||||||
pickdic[key]['S']['marked'] = marker
|
pickdic[key]['S']['marked'] = marker
|
||||||
|
|
||||||
@ -482,9 +496,11 @@ def wadaticheck(pickdic, dttolerance, iplot):
|
|||||||
f4, = plt.plot(checkedPpicks, wdfit2, 'g')
|
f4, = plt.plot(checkedPpicks, wdfit2, 'g')
|
||||||
plt.ylabel('S-P Times [s]')
|
plt.ylabel('S-P Times [s]')
|
||||||
plt.xlabel('P Times [s]')
|
plt.xlabel('P Times [s]')
|
||||||
plt.title('Wadati-Diagram, %d S-P Times, Vp/Vs(raw)=%5.2f, Vp/Vs(checked)=%5.2f' \
|
plt.title(
|
||||||
|
'Wadati-Diagram, %d S-P Times, Vp/Vs(old)=%5.2f, Vp/Vs(checked)=%5.2f' \
|
||||||
% (len(SPtimes), vpvsr, cvpvsr))
|
% (len(SPtimes), vpvsr, cvpvsr))
|
||||||
plt.legend([f1, f2, f3, f4], ['Skipped S-Picks', 'Wadati 1', 'Reliable S-Picks', \
|
plt.legend([f1, f2, f3, f4],
|
||||||
|
['Skipped S-Picks', 'Wadati 1', 'Reliable S-Picks', \
|
||||||
'Wadati 2'], loc='best')
|
'Wadati 2'], loc='best')
|
||||||
plt.show()
|
plt.show()
|
||||||
raw_input()
|
raw_input()
|
||||||
|
@ -206,6 +206,19 @@ class FilterOptions(object):
|
|||||||
order=self.getOrder())
|
order=self.getOrder())
|
||||||
return hrs
|
return hrs
|
||||||
|
|
||||||
|
def parseFilterOptions(self):
|
||||||
|
if self.getFilterType():
|
||||||
|
robject = {'type':self.getFilterType()}
|
||||||
|
robject['order'] = self.getOrder()
|
||||||
|
if len(self.getFreq()) > 1:
|
||||||
|
robject['freqmin'] = self.getFreq()[0]
|
||||||
|
robject['freqmax'] = self.getFreq()[1]
|
||||||
|
else:
|
||||||
|
robject['freq'] = self.getFreq() if type(self.getFreq()) is \
|
||||||
|
float else self.getFreq()[0]
|
||||||
|
return robject
|
||||||
|
return None
|
||||||
|
|
||||||
def getFreq(self):
|
def getFreq(self):
|
||||||
return self.__getattribute__('_freq')
|
return self.__getattribute__('_freq')
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import subprocess
|
||||||
import pwd
|
import pwd
|
||||||
import re
|
import re
|
||||||
import hashlib
|
import hashlib
|
||||||
@ -10,6 +11,27 @@ import numpy as np
|
|||||||
from obspy.core import UTCDateTime
|
from obspy.core import UTCDateTime
|
||||||
import obspy.core.event as ope
|
import obspy.core.event as ope
|
||||||
|
|
||||||
|
def runProgram(cmd, parameter=None):
|
||||||
|
"""
|
||||||
|
run an external program specified by cmd with parameters input returning the
|
||||||
|
stdout output
|
||||||
|
|
||||||
|
:param cmd: name of the command to run
|
||||||
|
:type cmd: str
|
||||||
|
:param parameter: filename of parameter file or parameter string
|
||||||
|
:type parameter: str
|
||||||
|
:return: stdout output
|
||||||
|
:rtype: str
|
||||||
|
"""
|
||||||
|
|
||||||
|
if parameter:
|
||||||
|
cmd.strip()
|
||||||
|
cmd += ' %s 2>&1' % parameter
|
||||||
|
|
||||||
|
output = subprocess.check_output('{} | tee /dev/stderr'.format(cmd),
|
||||||
|
shell = True)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def fnConstructor(s):
|
def fnConstructor(s):
|
||||||
if type(s) is str:
|
if type(s) is str:
|
||||||
|
Loading…
Reference in New Issue
Block a user