Merge branch 'develop'

This commit is contained in:
Sebastian Wehling-Benatelli 2015-01-27 05:01:45 +01:00
commit 1accc92421
3 changed files with 24 additions and 27 deletions

View File

@ -155,7 +155,7 @@ class CharacteristicFunction(object):
stop = self.cut[1] / self.dt stop = self.cut[1] / self.dt
zz = self.orig_data.copy() zz = self.orig_data.copy()
z1 = zz[0].copy() z1 = zz[0].copy()
zz[0].data = z1.data[start:stop] zz[0].data = z1.data[int(start):int(stop)]
data = zz data = zz
return data return data
elif len(self.orig_data) == 2: elif len(self.orig_data) == 2:
@ -171,8 +171,8 @@ class CharacteristicFunction(object):
hh = self.orig_data.copy() hh = self.orig_data.copy()
h1 = hh[0].copy() h1 = hh[0].copy()
h2 = hh[1].copy() h2 = hh[1].copy()
hh[0].data = h1.data[start:stop] hh[0].data = h1.data[int(start):int(stop)]
hh[1].data = h2.data[start:stop] hh[1].data = h2.data[int(start):int(stop)]
data = hh data = hh
return data return data
elif len(self.orig_data) == 3: elif len(self.orig_data) == 3:
@ -189,9 +189,9 @@ class CharacteristicFunction(object):
h1 = hh[0].copy() h1 = hh[0].copy()
h2 = hh[1].copy() h2 = hh[1].copy()
h3 = hh[2].copy() h3 = hh[2].copy()
hh[0].data = h1.data[start:stop] hh[0].data = h1.data[int(start):int(stop)]
hh[1].data = h2.data[start:stop] hh[1].data = h2.data[int(start):int(stop)]
hh[2].data = h3.data[start:stop] hh[2].data = h3.data[int(start):int(stop)]
data = hh data = hh
return data return data
else: else:
@ -263,10 +263,9 @@ class HOScf(CharacteristicFunction):
#Initialisation #Initialisation
#t2: long term moving window #t2: long term moving window
ilta = round(self.getTime2() / self.getIncrement()) ilta = int(round(self.getTime2() / self.getIncrement()))
lta = y[0] lta = y[0]
lta1 = y1[0] lta1 = y1[0]
#moving windows #moving windows
LTA = np.zeros(len(xnp)) LTA = np.zeros(len(xnp))
for j in range(0, len(xnp)): for j in range(0, len(xnp)):

View File

@ -17,7 +17,6 @@ autoregressive prediction: application ot local and regional distances, Geophys.
import numpy as np import numpy as np
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
from pylot.core.pick.CharFuns import CharacteristicFunction from pylot.core.pick.CharFuns import CharacteristicFunction
import pdb
class AutoPicking(object): class AutoPicking(object):
''' '''
@ -173,7 +172,7 @@ class PragPicker(AutoPicking):
self.Pick = -1 self.Pick = -1
#smooth CF #smooth CF
ismooth = round(self.Tsmooth / self.dt); ismooth = int(round(self.Tsmooth / self.dt))
cfsmooth = np.zeros(len(self.cf)) cfsmooth = np.zeros(len(self.cf))
if len(self.cf) < ismooth: if len(self.cf) < ismooth:
print 'PragPicker: Tsmooth larger than CF!' print 'PragPicker: Tsmooth larger than CF!'

View File

@ -13,13 +13,12 @@ from CharFuns import *
from Picker import * from Picker import *
import glob import glob
import argparse import argparse
import pdb
def run_makeCF(project, database, event, iplot, station=None): def run_makeCF(project, database, event, iplot, station=None):
#parameters for CF calculation #parameters for CF calculation
t2 = 7 #length of moving window for HOS calculation [sec] t2 = 7 #length of moving window for HOS calculation [sec]
p = 4 #order of statistics p = 4 #order of statistics
cuttimes = [5, 40] #start and end time for CF calculation cuttimes = [10, 40] #start and end time for CF calculation
bpz = [2, 30] #corner frequencies of bandpass filter, vertical component bpz = [2, 30] #corner frequencies of bandpass filter, vertical component
bph = [2, 15] #corner frequencies of bandpass filter, horizontal components bph = [2, 15] #corner frequencies of bandpass filter, horizontal components
tdetz= 1.2 #length of AR-determination window [sec], vertical component tdetz= 1.2 #length of AR-determination window [sec], vertical component
@ -151,11 +150,11 @@ def run_makeCF(project, database, event, iplot, station=None):
plt.figure() plt.figure()
tr = st[0] tr = st[0]
tdata = np.arange(0, tr.stats.npts / tr.stats.sampling_rate, tr.stats.delta) tdata = np.arange(0, tr.stats.npts / tr.stats.sampling_rate, tr.stats.delta)
p1 = plt.plot(tdata, tr_filt.data/max(tr_filt.data), 'k') p1, = plt.plot(tdata, tr_filt.data/max(tr_filt.data), 'k')
p2 = plt.plot(hoscf.getTimeArray(), hoscf.getCF() / max(hoscf.getCF()), 'r') p2, = plt.plot(hoscf.getTimeArray(), hoscf.getCF() / max(hoscf.getCF()), 'r')
p3 = plt.plot(aiccf.getTimeArray(), aiccf.getCF()/max(aiccf.getCF()), 'b') p3, = plt.plot(aiccf.getTimeArray(), aiccf.getCF()/max(aiccf.getCF()), 'b')
p4 = plt.plot(arzcf.getTimeArray(), arzcf.getCF()/max(arzcf.getCF()), 'g') p4, = plt.plot(arzcf.getTimeArray(), arzcf.getCF()/max(arzcf.getCF()), 'g')
p5 = plt.plot(araiccf.getTimeArray(), araiccf.getCF()/max(araiccf.getCF()), 'y') p5, = plt.plot(araiccf.getTimeArray(), araiccf.getCF()/max(araiccf.getCF()), 'y')
plt.plot([aicpick.getpick(), aicpick.getpick()], [-1, 1], 'b--') plt.plot([aicpick.getpick(), aicpick.getpick()], [-1, 1], 'b--')
plt.plot([aicpick.getpick()-0.5, aicpick.getpick()+0.5], [1, 1], 'b') plt.plot([aicpick.getpick()-0.5, aicpick.getpick()+0.5], [1, 1], 'b')
plt.plot([aicpick.getpick()-0.5, aicpick.getpick()+0.5], [-1, -1], 'b') plt.plot([aicpick.getpick()-0.5, aicpick.getpick()+0.5], [-1, -1], 'b')
@ -176,14 +175,14 @@ def run_makeCF(project, database, event, iplot, station=None):
plt.legend([p1, p2, p3, p4, p5], ['Data', 'HOS-CF', 'HOSAIC-CF', 'ARZ-CF', 'ARZAIC-CF']) plt.legend([p1, p2, p3, p4, p5], ['Data', 'HOS-CF', 'HOSAIC-CF', 'ARZ-CF', 'ARZAIC-CF'])
#plot horizontal traces #plot horizontal traces
plt.figure(2) plt.figure(2)
plt.subplot(211) plt.subplot(2,1,1)
tsteph = tpredh / 4 tsteph = tpredh / 4
th1data = np.arange(0, trH1_filt.stats.npts / trH1_filt.stats.sampling_rate, trH1_filt.stats.delta) th1data = np.arange(0, trH1_filt.stats.npts / trH1_filt.stats.sampling_rate, trH1_filt.stats.delta)
th2data = np.arange(0, trH2_filt.stats.npts / trH2_filt.stats.sampling_rate, trH2_filt.stats.delta) th2data = np.arange(0, trH2_filt.stats.npts / trH2_filt.stats.sampling_rate, trH2_filt.stats.delta)
tarhcf = np.arange(0, len(arhcf.getCF()) * tsteph, tsteph) + cuttimes[0] + tdeth +tpredh tarhcf = np.arange(0, len(arhcf.getCF()) * tsteph, tsteph) + cuttimes[0] + tdeth +tpredh
p21 = plt.plot(th1data, trH1_filt.data/max(trH1_filt.data), 'k') p21, = plt.plot(th1data, trH1_filt.data/max(trH1_filt.data), 'k')
p22 = plt.plot(arhcf.getTimeArray(), arhcf.getCF()/max(arhcf.getCF()), 'r') p22, = plt.plot(arhcf.getTimeArray(), arhcf.getCF()/max(arhcf.getCF()), 'r')
p23 = plt.plot(arhaiccf.getTimeArray(), arhaiccf.getCF()/max(arhaiccf.getCF())) p23, = plt.plot(arhaiccf.getTimeArray(), arhaiccf.getCF()/max(arhaiccf.getCF()))
plt.plot([aicarhpick.getpick(), aicarhpick.getpick()], [-1, 1], 'b--') plt.plot([aicarhpick.getpick(), aicarhpick.getpick()], [-1, 1], 'b--')
plt.plot([aicarhpick.getpick()-0.5, aicarhpick.getpick()+0.5], [1, 1], 'b') plt.plot([aicarhpick.getpick()-0.5, aicarhpick.getpick()+0.5], [1, 1], 'b')
plt.plot([aicarhpick.getpick()-0.5, aicarhpick.getpick()+0.5], [-1, -1], 'b') plt.plot([aicarhpick.getpick()-0.5, aicarhpick.getpick()+0.5], [-1, -1], 'b')
@ -192,7 +191,7 @@ def run_makeCF(project, database, event, iplot, station=None):
plt.title([trH1_filt.stats.station, trH1_filt.stats.channel]) plt.title([trH1_filt.stats.station, trH1_filt.stats.channel])
plt.suptitle(trH1_filt.stats.starttime) plt.suptitle(trH1_filt.stats.starttime)
plt.legend([p21, p22, p23], ['Data', 'ARH-CF', 'ARHAIC-CF']) plt.legend([p21, p22, p23], ['Data', 'ARH-CF', 'ARHAIC-CF'])
plt.subplot(212) plt.subplot(2,1,2)
plt.plot(th2data, trH2_filt.data/max(trH2_filt.data), 'k') plt.plot(th2data, trH2_filt.data/max(trH2_filt.data), 'k')
plt.plot(arhaiccf.getTimeArray(), arhaiccf.getCF()/max(arhaiccf.getCF())) plt.plot(arhaiccf.getTimeArray(), arhaiccf.getCF()/max(arhaiccf.getCF()))
plt.plot([aicarhpick.getpick(), aicarhpick.getpick()], [-1, 1], 'b--') plt.plot([aicarhpick.getpick(), aicarhpick.getpick()], [-1, 1], 'b--')
@ -205,22 +204,22 @@ def run_makeCF(project, database, event, iplot, station=None):
#plot 3-component window #plot 3-component window
plt.figure(3) plt.figure(3)
tar3ccf = np.arange(0, len(ar3ccf.getCF()) * tsteph, tsteph) + cuttimes[0] + tdetz +tpredz tar3ccf = np.arange(0, len(ar3ccf.getCF()) * tsteph, tsteph) + cuttimes[0] + tdetz +tpredz
plt.subplot(311) plt.subplot(3,1,1)
p31 = plt.plot(tdata, tr_filt.data/max(tr_filt.data), 'k') p31, = plt.plot(tdata, tr_filt.data/max(tr_filt.data), 'k')
p32 = plt.plot(tar3ccf, ar3ccf.getCF()/max(ar3ccf.getCF()), 'r') p32, = plt.plot(tar3ccf, ar3ccf.getCF()/max(ar3ccf.getCF()), 'r')
plt.yticks([]) plt.yticks([])
plt.xticks([]) plt.xticks([])
plt.ylabel('Normalized Counts') plt.ylabel('Normalized Counts')
plt.title([tr.stats.station, tr.stats.channel]) plt.title([tr.stats.station, tr.stats.channel])
plt.legend([p31, p32], ['Data', 'AR3C-CF']) plt.legend([p31, p32], ['Data', 'AR3C-CF'])
plt.subplot(312) plt.subplot(3,1,2)
plt.plot(th1data, trH1_filt.data/max(trH1_filt.data), 'k') plt.plot(th1data, trH1_filt.data/max(trH1_filt.data), 'k')
plt.plot(tar3ccf, ar3ccf.getCF()/max(ar3ccf.getCF()), 'r') plt.plot(tar3ccf, ar3ccf.getCF()/max(ar3ccf.getCF()), 'r')
plt.yticks([]) plt.yticks([])
plt.xticks([]) plt.xticks([])
plt.ylabel('Normalized Counts') plt.ylabel('Normalized Counts')
plt.title([trH1_filt.stats.station, trH1_filt.stats.channel]) plt.title([trH1_filt.stats.station, trH1_filt.stats.channel])
plt.subplot(313) plt.subplot(3,1,3)
plt.plot(th2data, trH2_filt.data/max(trH2_filt.data), 'k') plt.plot(th2data, trH2_filt.data/max(trH2_filt.data), 'k')
plt.plot(tar3ccf, ar3ccf.getCF()/max(ar3ccf.getCF()), 'r') plt.plot(tar3ccf, ar3ccf.getCF()/max(ar3ccf.getCF()), 'r')
plt.yticks([]) plt.yticks([])