Modified internal function getTimeArray for calculating correct time stamps even for AR prediction, where CF time array is different to data time array. Implemented getARdetStep and setARdetStep where ARdetStep is the recalculation step of AR coefficients.
This commit is contained in:
parent
223c992f20
commit
112e0bc7fa
@ -22,7 +22,7 @@ class CharacteristicFunction(object):
|
|||||||
'''
|
'''
|
||||||
SuperClass for different types of characteristic functions.
|
SuperClass for different types of characteristic functions.
|
||||||
'''
|
'''
|
||||||
def __init__(self, data, cut, t2, order, t1=None, fnoise=0.001):
|
def __init__(self, data, cut, t2=None, order=None, t1=None, fnoise=0.001):
|
||||||
'''
|
'''
|
||||||
Initialize data type object with information from the original
|
Initialize data type object with information from the original
|
||||||
Seismogram.
|
Seismogram.
|
||||||
@ -55,6 +55,7 @@ class CharacteristicFunction(object):
|
|||||||
self.setTime2(t2)
|
self.setTime2(t2)
|
||||||
self.setOrder(order)
|
self.setOrder(order)
|
||||||
self.setFnoise(fnoise)
|
self.setFnoise(fnoise)
|
||||||
|
self.setARdetStep(t2)
|
||||||
self.calcCF(self.getDataArray())
|
self.calcCF(self.getDataArray())
|
||||||
self.arpara = np.array([])
|
self.arpara = np.array([])
|
||||||
self.xpred = np.array([])
|
self.xpred = np.array([])
|
||||||
@ -66,12 +67,14 @@ class CharacteristicFunction(object):
|
|||||||
t2:\t{t2}\n
|
t2:\t{t2}\n
|
||||||
Order:\t\t{order}\n
|
Order:\t\t{order}\n
|
||||||
Fnoise:\t{fnoise}\n
|
Fnoise:\t{fnoise}\n
|
||||||
|
ARdetStep:\t{ardetstep}\n
|
||||||
'''.format(name=type(self).__name__,
|
'''.format(name=type(self).__name__,
|
||||||
cut=self.getCut(),
|
cut=self.getCut(),
|
||||||
t1=self.getTime1(),
|
t1=self.getTime1(),
|
||||||
t2=self.getTime2(),
|
t2=self.getTime2(),
|
||||||
order=self.getOrder(),
|
order=self.getOrder(),
|
||||||
fnoise=self.getFnoise())
|
fnoise=self.getFnoise(),
|
||||||
|
ardetstep=self.getARdetStep())
|
||||||
|
|
||||||
def getCut(self):
|
def getCut(self):
|
||||||
return self.cut
|
return self.cut
|
||||||
@ -91,11 +94,13 @@ class CharacteristicFunction(object):
|
|||||||
def setTime2(self, t2):
|
def setTime2(self, t2):
|
||||||
self.t2 = t2
|
self.t2 = t2
|
||||||
|
|
||||||
def getTimeArray(self):
|
def getARdetStep(self):
|
||||||
incr = self.getIncrement()
|
return self.ARdetStep
|
||||||
timeArray = np.arange(0, len(self.getCF()) / incr**-1,
|
|
||||||
incr) + self.getCut()[0]
|
def setARdetStep(self, t1):
|
||||||
return timeArray
|
if t1:
|
||||||
|
self.ARdetStep = t1 / 4
|
||||||
|
return self.ARdetStep
|
||||||
|
|
||||||
def getOrder(self):
|
def getOrder(self):
|
||||||
return self.order
|
return self.order
|
||||||
@ -109,6 +114,29 @@ class CharacteristicFunction(object):
|
|||||||
"""
|
"""
|
||||||
return self.dt
|
return self.dt
|
||||||
|
|
||||||
|
def getTimeArray(self):
|
||||||
|
if self.getTime1() == None and self.getTime2() and self.getOrder():
|
||||||
|
#for HOS
|
||||||
|
incr = self.getIncrement()
|
||||||
|
timeArray = np.arange(0, len(self.getCF()) * incr,
|
||||||
|
incr) + self.getCut()[0]
|
||||||
|
elif self.getTime1() == None and self.getTime2() and self.getOrder() == None:
|
||||||
|
#for AIC-HOS
|
||||||
|
incr = self.getIncrement()
|
||||||
|
timeArray = np.arange(0, len(self.getCF()) * incr,
|
||||||
|
incr) + self.getCut()[0]
|
||||||
|
elif self.getTime1() and self.getTime2() and self.getOrder() == 0:
|
||||||
|
#for AIC-AR
|
||||||
|
incr = self.getARdetStep()
|
||||||
|
timeArray = np.arange(0, len(self.getCF()) * incr,
|
||||||
|
incr) + self.getCut()[0] + self.getTime1() + self.getTime2()
|
||||||
|
elif self.getTime1() and self.getTime2() and self.getOrder():
|
||||||
|
#for AR
|
||||||
|
incr = self.getARdetStep()
|
||||||
|
timeArray = np.arange(0, len(self.getCF()) * incr,
|
||||||
|
incr) + self.getCut()[0] + self.getTime1() + self.getTime2()
|
||||||
|
return timeArray
|
||||||
|
|
||||||
def getFnoise(self):
|
def getFnoise(self):
|
||||||
return self.fnoise
|
return self.fnoise
|
||||||
|
|
||||||
@ -190,7 +218,7 @@ class AICcf(CharacteristicFunction):
|
|||||||
cumsumcf[k - 1]) / (datlen - k + 1)))
|
cumsumcf[k - 1]) / (datlen - k + 1)))
|
||||||
cf[0] = cf[1]
|
cf[0] = cf[1]
|
||||||
inf = np.isinf(cf)
|
inf = np.isinf(cf)
|
||||||
ff = np.where(inf == 'True')
|
ff = np.where(inf == True)
|
||||||
if len(ff) >= 1:
|
if len(ff) >= 1:
|
||||||
cf[ff] = 0
|
cf[ff] = 0
|
||||||
|
|
||||||
@ -260,7 +288,7 @@ class ARZcf(CharacteristicFunction):
|
|||||||
lpred = int(np.ceil(self.getTime2() / self.getIncrement())) #length of AR-prediction window [samples]
|
lpred = int(np.ceil(self.getTime2() / self.getIncrement())) #length of AR-prediction window [samples]
|
||||||
|
|
||||||
cf = []
|
cf = []
|
||||||
for i in range(ldet + self.getOrder() - 1, tend - lpred + 1, lpred / 16):
|
for i in range(ldet + self.getOrder() - 1, tend - lpred + 1, lpred / 4):
|
||||||
#determination of AR coefficients
|
#determination of AR coefficients
|
||||||
self.arDetZ(xnoise, self.getOrder(), i-ldet, i)
|
self.arDetZ(xnoise, self.getOrder(), i-ldet, i)
|
||||||
#AR prediction of waveform using calculated AR coefficients
|
#AR prediction of waveform using calculated AR coefficients
|
||||||
|
Loading…
Reference in New Issue
Block a user