Included AICPicker of class Picker

This commit is contained in:
Ludger Küperkoch 2014-12-05 16:32:55 +01:00
parent ca809c4673
commit 479058a41e

View File

@ -10,8 +10,10 @@ from obspy.core import read
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import numpy as np import numpy as np
from CharFuns import * from CharFuns 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
@ -32,6 +34,9 @@ def run_makeCF(project, database, event, iplot, station=None):
dpz = '/DATA/%s/EVENT_DATA/LOCAL/%s/%s/%s*EHZ.msd' % (project, database, event, station) dpz = '/DATA/%s/EVENT_DATA/LOCAL/%s/%s/%s*EHZ.msd' % (project, database, event, station)
dpe = '/DATA/%s/EVENT_DATA/LOCAL/%s/%s/%s*EHE.msd' % (project, database, event, station) dpe = '/DATA/%s/EVENT_DATA/LOCAL/%s/%s/%s*EHE.msd' % (project, database, event, station)
dpn = '/DATA/%s/EVENT_DATA/LOCAL/%s/%s/%s*EHN.msd' % (project, database, event, station) dpn = '/DATA/%s/EVENT_DATA/LOCAL/%s/%s/%s*EHN.msd' % (project, database, event, station)
#dpz = '/DATA/%s/EVENT_DATA/LOCAL/%s/%s/%s*_z.gse' % (project, database, event, station)
#dpe = '/DATA/%s/EVENT_DATA/LOCAL/%s/%s/%s*_e.gse' % (project, database, event, station)
#dpn = '/DATA/%s/EVENT_DATA/LOCAL/%s/%s/%s*_n.gse' % (project, database, event, station)
else: else:
dpz = '/DATA/%s/EVENT_DATA/LOCAL/%s/%s/*EHZ.msd' % (project, database, event) dpz = '/DATA/%s/EVENT_DATA/LOCAL/%s/%s/*EHZ.msd' % (project, database, event)
dpe = '/DATA/%s/EVENT_DATA/LOCAL/%s/%s/*EHE.msd' % (project, database, event) dpe = '/DATA/%s/EVENT_DATA/LOCAL/%s/%s/*EHE.msd' % (project, database, event)
@ -53,6 +58,12 @@ def run_makeCF(project, database, event, iplot, station=None):
############################################################## ##############################################################
#calculate HOS-CF using subclass HOScf of class CharacteristicFunction #calculate HOS-CF using subclass HOScf of class CharacteristicFunction
hoscf = HOScf(st_copy, cuttimes, t2, p) #instance of HOScf hoscf = HOScf(st_copy, cuttimes, t2, p) #instance of HOScf
#get corresponding time array
thoscf = np.arange(0, len(hoscf.getCF()) / tr_filt.stats.sampling_rate, tr_filt.stats.delta) + cuttimes[0]
##############################################################
#get onset time from HOS-CF using class Picker
#hospick = PragPicker(hoscf.getCF(), thoscf, 2, 70, [1, 0.5, 0.2], 2, 0.001, 0.2)
#pdb.set_trace()
############################################################## ##############################################################
#calculate AIC-HOS-CF using subclass AICcf of class CharacteristicFunction #calculate AIC-HOS-CF using subclass AICcf of class CharacteristicFunction
#class needs stream object => build it #class needs stream object => build it
@ -60,6 +71,11 @@ def run_makeCF(project, database, event, iplot, station=None):
tr_aic.data = hoscf.getCF() tr_aic.data = hoscf.getCF()
st_copy[0].data = tr_aic.data st_copy[0].data = tr_aic.data
aiccf = AICcf(st_copy, cuttimes, t2, p) #instance of AICcf aiccf = AICcf(st_copy, cuttimes, t2, p) #instance of AICcf
#get corresponding time array
taiccf = np.arange(0, len(aiccf.getCF()) / tr_filt.stats.sampling_rate, tr_filt.stats.delta) + cuttimes[0]
##############################################################
#get onset time from AIC-HOS-CF using subclass AICPicker of class AutoPicking
aicpick = AICPicker(aiccf.getCF(), taiccf, tr_filt.stats.delta, 2, 70, [1, 0.5, 0.2], 2, 0.001, 2.5)
############################################################## ##############################################################
#calculate ARZ-CF using subclass ARZcf of class CharcteristicFunction #calculate ARZ-CF using subclass ARZcf of class CharcteristicFunction
#get stream object of filtered data #get stream object of filtered data
@ -124,8 +140,6 @@ def run_makeCF(project, database, event, iplot, station=None):
tr = st[0] tr = st[0]
tstepz = tpredz / 16 tstepz = tpredz / 16
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)
thoscf = np.arange(0, len(hoscf.getCF()) / tr.stats.sampling_rate, tr.stats.delta) + cuttimes[0]
taiccf = np.arange(0, len(aiccf.getCF()) / tr.stats.sampling_rate, tr.stats.delta) + cuttimes[0]
tarzcf = np.arange(0, len(arzcf.getCF()) * tstepz, tstepz) + cuttimes[0] + tdetz +tpredz tarzcf = np.arange(0, len(arzcf.getCF()) * tstepz, tstepz) + cuttimes[0] + tdetz +tpredz
taraiccf = np.arange(0, len(araiccf.getCF()) * tstepz, tstepz) + cuttimes[0] +tdetz + tpredz taraiccf = np.arange(0, len(araiccf.getCF()) * tstepz, tstepz) + cuttimes[0] +tdetz + tpredz
p1 = plt.plot(tdata, tr_filt.data/max(tr_filt.data), 'k') p1 = plt.plot(tdata, tr_filt.data/max(tr_filt.data), 'k')
@ -133,6 +147,9 @@ def run_makeCF(project, database, event, iplot, station=None):
p3 = plt.plot(taiccf, aiccf.getCF()/max(aiccf.getCF()), 'b') p3 = plt.plot(taiccf, aiccf.getCF()/max(aiccf.getCF()), 'b')
p4 = plt.plot(tarzcf, arzcf.getCF()/max(arzcf.getCF()), 'g') p4 = plt.plot(tarzcf, arzcf.getCF()/max(arzcf.getCF()), 'g')
p5 = plt.plot(taraiccf, araiccf.getCF()/max(araiccf.getCF()), 'y') p5 = plt.plot(taraiccf, araiccf.getCF()/max(araiccf.getCF()), 'y')
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.yticks([]) plt.yticks([])
plt.xlabel('Time [s]') plt.xlabel('Time [s]')
plt.ylabel('Normalized Counts') plt.ylabel('Normalized Counts')
@ -188,6 +205,7 @@ def run_makeCF(project, database, event, iplot, station=None):
plt.show() plt.show()
raw_input() raw_input()
plt.close() plt.close()
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument('--project', type=str, help='project name (e.g. Insheim)') parser.add_argument('--project', type=str, help='project name (e.g. Insheim)')
parser.add_argument('--database', type=str, help='event data base (e.g. 2014.09_Insheim)') parser.add_argument('--database', type=str, help='event data base (e.g. 2014.09_Insheim)')