示例#1
0
def RMS(st, plot): 
    """return quadradic sum with all signal multiplied by their signs
    * input: 
        - st : stream with the 3 components RTZ or NTZ idem !!
        - plot : if True, plots of filtered and none filtered will be shown
    * output : 
        - tSumtrace : type : trace;  trace signal non decomposed in components
    *exemple
        tSumtrace =  RMS(st, plot)
        ==>  tSumtrace gets all the attributes as a trace"""
        
    trR, trT, trZ = SelectTracesRTZ(st)
    SignR = np.sign(trR.data)
    SignT = np.sign(trT.data)
    SignZ = np.sign(trZ.data)

    SommeQsigne = trR.data**2 + trT.data**2 +trZ.data**2 
   
    SommeSigne = np.sqrt(SommeQsigne) 
    tSumtrace = Trace(SommeSigne,trT.stats)
    tSumtrace.stats.channel = "Sum_quadratic"
    if plot == True :
        fig=plt.figure()
        tSumtrace.plot(fig=fig)
    return tSumtrace
示例#2
0
def RealafterrottrH(st,plot):
    """return quadradic average of the horizontal components 
    * input: 
        - st : stream with the 3 components RTZ !!
        - plot : if True, plots of filtered and none filtered will be shown
    * output : 
        - tSumtrace : type : trace;  trace signal non decomposed in components
    *exemple
        trH =  horizontal quadratic average 
        trZabs = abs average 
        ==> trH gets all the attributes as a trace """
        
    trR,trT,trZ = SelectTracesRTZ(st)
    trZabs=np.abs(trZ.data)
    trZabs=Trace(trZabs,trZ.stats)
    trH  = np.sqrt(trR.data**2 + trT.data**2)/np.sqrt(2)
    trH= Trace(trH,trR.stats)
    trH.stats.channel = "Horizontal"
    if plot == True :
        fig=plt.figure()
        trH.plot(fig=fig)    
    return trH, trZabs
示例#3
0
def RealtrH(st,plot):
    """return quadradic sum of the horizontal components with all signal multiplied by their signs
    * input: 
        - st : stream with the 3 components RTZ or NTZ idem !!
        - plot : if True, plots of filtered and none filtered will be shown
    * output : 
        - tSumtrace : type : trace;  trace signal non decomposed in components
    *exemple
        trH =  RMS(st, plot)
        ==> trH gets all the attributes as a trace """
        
    trN,trE,trZ = SelectTracesNEZ(st)
  
    trH  = np.sqrt(trN.data**2 + trE.data**2)/np.sqrt(2)
    trH= Trace(trH,trN.stats)
    trH.stats.channel = "Horizontal"
    trZabs=np.abs(trZ.data)
    trZabs=Trace(trZabs,trZ.stats)
    trZabs.stats.channel = 'Vertical absolute' 
    if plot == True :
        fig=plt.figure()
        trH.plot(fig=fig)    
    return trH,trZabs
示例#4
0
import numpy as np
from obspy.core import Trace, UTCDateTime

x = np.zeros(200)
x[100] = 1
tr = Trace(x)
tr.stats.network = "XX"
tr.stats.station = "SDFD1"
print tr
print "showing original trace"
tr.plot()
tr.stats.sampling_rate = 20
tr.stats.starttime = UTCDateTime(2011, 2, 21, 8)
print tr
tr.plot()

tr.filter("lowpass", freq=1)
print "showing filtered trace"
tr.plot()
tr.trim(tr.stats.starttime + 4.5, tr.stats.endtime - 2)
print "showing trimmed trace"
tr.plot()

tr.data = tr.data * 500
tr2 = tr.copy()
tr2.data = tr2.data + np.random.randn(len(tr2))
tr2.stats.station = "SDFD2"
print tr2
print "showing trace with gaussian noise added"
tr2.plot()