Ejemplo n.º 1
0
def semblancestalta(sembmaxvaluevector, sembmaxlatvector, sembmaxlonvector):

    data = np.array(sembmaxvaluevector, dtype=np.float64)

    tr = Trace(data, header=None)

    sta = 0.5
    lta = 4
    cft = recursive_sta_lta(tr, int(sta * tr.stats.sampling_rate),
                            int(lta * tr.stats.sampling_rate))

    thrOn = 0.5
    thrOff = 1.5
    plotTrigger(tr, cft, thrOn, thrOff)
Ejemplo n.º 2
0
def semblancestalta(sembmaxvaluevector, sembmaxlatvector, sembmaxlonvector):

    data = np.array(sembmaxvaluevector, dtype=np.float64)

    #stats = Stats()                  #hs
    #stats.network    = 'BW'          #hs
    #stats['station'] = 'MANZ'        #hs

    tr = Trace(data, header=None)

    sta = 0.5
    lta = 4
    cft = recSTALTA(tr, int(sta * tr.stats.sampling_rate),
                    int(lta * tr.stats.sampling_rate))

    #print cft

    thrOn = 0.5
    thrOff = 1.5
    plotTrigger(tr, cft, thrOn, thrOff)
Ejemplo n.º 3
0
def LTASTAtr(tr,thres1, thres2,STA, LTA,plotSTA):
    """ return the cut on and off of the LTA/STA list [[cuton, cutoff], [cuton, cutoff]]
    * input : 
        - tr : type : trace , stream to filnd STA, LTA
        - thres1 : type; float : cut on limit of STA/LTA values :  after tjis value  the cut on is defined
        - thres2 : type, float : cut off limit of STA/LTA values : after this value the cut off is defined
        - STA : type int :  size of the LTA windows in second : STA = the trace average on this time windows
        - LTA : type int :  size of the LTA windows in second : LTA = the trace average on this time windows
        - plotSTA: type, bool; it true, the trace and it's characteristic function are plotted
        
        RQ: AFTER TESTING IT'S SEEEMS GOOD TO HAVE A RATIO WSTA/WLTA > 1/4 AND A CUT OFF HIGHER THAN CUT ON
    * outputs
        - L_onoff: type np, array : 2D  array of cut on and cut_off time  in number of sample ie time* df where df is the sampling rate [[cuton,cutoff], [cuton1, cutoff1]]
    
    exemple: 
        st = Read_event('15','206','15','1', '1', True)
        stcorrec = Stream_Correction(st,  '1', False)
        stfiltered= Stream_PBfilter(stcorrec,0.5, 20,False)
        LTASTA(stfiltered,2, 2.5,300,1400,True)
    """
    #0. sampling rate ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    df = tr.stats.sampling_rate
    #1. characteristic function of the trace following classical LTA ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    #cft = classicSTALTA(tr.data, int(STA * df), int(LTA* df))
     #2. characteristic function of the trace following recursive LTA
    cft2 =recursive_sta_lta(tr.data, int(STA * df), int(LTA* df))
    #3. list of [cuton, cutoff] time in number of samples~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
    #max_len = maximum lenght of the triggered event in sample, 
    #max_len_delete = Do not write events longer than max_len into report file.
    L_onoff = trigger_onset(cft2, thres1, thres2, max_len=9e+99, max_len_delete=False)
    #4. plot~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    if plotSTA==True : 
        
        ##plotTrigger(tr[0], cft, thres1,thres2)
     
        plotTrigger(tr[0], cft2, thres1,thres2)
        plt.title('recursive')
    return np.array(L_onoff)
    def refTrigger(self, RefWaveform, phase, cfg_yaml):
        Config = self.Config
        cfg = ConfigObj(dict=Config)
        name = ('%s.%s.%s.%s') % (RefWaveform[0].stats.network,
                                  RefWaveform[0].stats.station,
                                  RefWaveform[0].stats.location,
                                  RefWaveform[0].stats.channel)

        i = self.searchMeta(name, self.StationMeta)
        de = loc2degrees(self.Origin, i)

        ptime = 0

        Phase = cake.PhaseDef(phase)
        model = cake.load_model()
        if cfg_yaml.config_data.colesseo_input is True:
            arrivals = model.arrivals([de, de], phases=Phase,
                                      zstart=self.Origin.depth, zstop=0.)
        else:
            arrivals = model.arrivals([de, de], phases=Phase,
                                      zstart=self.Origin.depth*km, zstop=0.)
        try:
            ptime = arrivals[0].t
        except Exception:
            arrivals = model.arrivals([de, de], phases=Phase,
                                      zstart=self.Origin.depth*km-0.1)
            ptime = arrivals[0].t

        if ptime == 0:
                raise Exception("\033[31mILLEGAL: phase definition\033[0m")

        tw = self.calculateTimeWindows(ptime)

        if cfg_yaml.config_data.pyrocko_download is True:
            stP = self.readWaveformsPicker_pyrocko(i, tw, self.Origin, ptime,
                                                   cfg_yaml)
        elif cfg_yaml.config_data.colesseo_input is True:
            stP = self.readWaveformsPicker_colos(i, tw, self.Origin, ptime,
                                                 cfg_yaml)
        else:
            stP = self.readWaveformsPicker(i, tw, self.Origin, ptime, cfg_yaml)

        refuntouchname = os.path.basename(self.AF)+'-refstation-raw.mseed'
        stP.write(os.path.join(self.EventPath, refuntouchname), format='MSEED',
                                                                byteorder='>')
        stP.filter("bandpass",
                   freqmin=float(cfg_yaml.config_xcorr.refstationfreqmin),
                   freqmax=float(cfg_yaml.config_xcorr.refstationfreqmax))

        stP.trim(tw['xcorrstart'], tw['xcorrend'])
        trP = stP[0]

        trP.stats.starttime = UTCDateTime(3600)
        refname = os.path.basename(self.AF)+'-refstation-filtered.mseed'
        trP.write(os.path.join(self.EventPath, refname), format='MSEED',
                                                         byteorder='>')

        sta = float(cfg_yaml.config_xcorr.refsta)
        lta = float(cfg_yaml.config_xcorr.reflta)
        cft = recSTALTA(trP.data, int(sta * trP.stats.sampling_rate),
                        int(lta * trP.stats.sampling_rate))

        t = triggerOnset(cft, lta, sta)

        try:
            onset = t[0][0] / trP.stats.sampling_rate

        except Exception:
            onset = self.mintforerun

        trigger = trP.stats.starttime+onset

        tdiff = (trP.stats.starttime + onset)-(UTCDateTime(3600)
                                               + self.mintforerun)

        refp = UTCDateTime(self.Origin.time)+ptime
        reftriggeronset = refp+onset-self.mintforerun

        if cfg_yaml.config_xcorr.autoxcorrcorrectur is True:
                refmarkername = os.path.join(self.EventPath,
                                             ('%s-marker') % (os.path.basename(
                                              self.AF)))
                fobjrefmarkername = open(refmarkername, 'w')
                fobjrefmarkername.write('# Snuffler Markers File Version\
                                         0.2\n')
                fobjrefmarkername.write(('phase: %s 0 %s    None           None         None         XWStart        None False\n') % (tw['xcorrstart'].strftime('%Y-%m-%d %H:%M:%S.%f'), name))
                fobjrefmarkername.write(('phase: %s 0 %s    None           None         None         XWEnd        None False\n') % (tw['xcorrend'].strftime('%Y-%m-%d %H:%M:%S.%f'), name))
                fobjrefmarkername.write(('phase: %s 1 %s    None           None         None         TheoP        None False\n') % (refp.strftime('%Y-%m-%d %H:%M:%S.%f'), name))
                fobjrefmarkername.write(('phase: %s 3 %s    None           None         None         XTrig        None False') % (reftriggeronset.strftime('%Y-%m-%d %H:%M:%S.%f'), name))
                fobjrefmarkername.close()

                cmd = 'snuffler %s --markers=%s&' % (os.path.join(
                                                    self.EventPath,
                                                    refuntouchname),
                                                    refmarkername)
                os.system(cmd)

                thrOn = float(self.Config['reflta'])
                thrOff = float(self.Config['refsta'])
                plotTrigger(trP, cft, thrOn, thrOff)

                selection = float(input('Enter self picked phase in seconds: '))
                tdiff = selection-self.mintforerun
                refname = os.path.basename(self.AF)+'-shift.mseed'
                trP.stats.starttime = trP.stats.starttime - selection
                trP.write(os.path.join(self.EventPath, refname),
                                       format='MSEED')

        '''
        tdiff = 0
        trigger = trP.stats.starttime
        '''
        To = Trigger(name, trigger, os.path.basename(self.AF), tdiff)

        return tdiff, To
Ejemplo n.º 5
0
def stalta_pick(stream,
                stalen,
                ltalen,
                trig_on,
                trig_off,
                freqmin=False,
                freqmax=False,
                debug=0,
                show=False):
    r"""Simple sta-lta (short-term average/long-term average) picker, using \
    obspy's stalta routine to generate the characteristic function.

    Currently very basic quick wrapper, there are many other (better) options \
    in obspy, found \
    (here)[http://docs.obspy.org/packages/autogen/obspy.signal.trigger.html].

    :type stream: obspy.Stream
    :param stream: The stream to pick on, can be any number of channels.
    :type stalen: float
    :param stalen: Length of the short-term average window in seconds.
    :type ltalen: float
    :param ltalen: Length of the long-term average window in seconds.
    :type trig_on: float
    :param trig_on: sta/lta ratio to trigger a detection/pick
    :type trig_off: float
    :param trig_off: sta/lta ratio to turn the trigger off - no further picks\
        will be made between exceeding trig_on until trig_off is reached.
    :type freqmin: float
    :param freqmin: Low-cut frequency in Hz for bandpass filter
    :type freqmax: float
    :param freqmax: High-cut frequency in Hz for bandpass filter
    :type debug: int
    :param debug: Debug output level from 0-5.
    :type show: bool
    :param show: Show picks on waveform.

    :returns: list of pick class.
    """
    from obspy.signal.trigger import classicSTALTA, triggerOnset, plotTrigger
    from sfile_util import PICK
    import EQcorrscan_plotting as plotting
    picks = []
    for tr in stream:
        # We are going to assume, for now, that if the pick is made on the
        # horizontal channel then it is an S, otherwise we will assume it is
        # a P-phase: obviously a bad assumption...
        if tr.stats.channel[-1] == 'Z':
            phase = 'P'
        else:
            phase = 'S'
        if freqmin and freqmax:
            tr.detrend('simple')
            tr.filter('bandpass',
                      freqmin=freqmin,
                      freqmax=freqmax,
                      corners=3,
                      zerophase=True)
        df = tr.stats.sampling_rate
        cft = classicSTALTA(tr.data, int(stalen * df), int(ltalen * df))
        if debug > 3:
            plotTrigger(tr, cft, trig_on, trig_off)
        triggers = triggerOnset(cft, trig_on, trig_off)
        for trigger in triggers:
            on = tr.stats.starttime + (trigger[0] / df)
            # off = tr.stats.starttime + (trigger[1] / df)
            pick = PICK(station=tr.stats.station,
                        channel=tr.stats.channel,
                        time=on,
                        phase=phase)
            if debug > 2:
                print('Pick made:')
                print(pick)
            picks.append(pick)
    # QC picks
    del pick
    pick_stations = list(set([pick.station for pick in picks]))
    for pick_station in pick_stations:
        station_picks = [
            pick for pick in picks if pick.station == pick_station
        ]
        # If P-pick is after S-picks, remove it.
        p_time = [pick.time for pick in station_picks if pick.phase == 'P']
        s_time = [pick.time for pick in station_picks if pick.phase == 'S']
        if p_time > s_time:
            p_pick = [pick for pick in station_picks if pick.phase == 'P']
            for pick in p_pick:
                print('P pick after S pick, removing P pick')
                picks.remove(pick)
    if show:
        plotting.pretty_template_plot(stream,
                                      picks=picks,
                                      title='Autopicks',
                                      size=(8, 9))
    return picks
Ejemplo n.º 6
0
def stalta_pick(stream, stalen, ltalen, trig_on, trig_off, freqmin=False,
                freqmax=False, debug=0, show=False):
    r"""Simple sta-lta (short-term average/long-term average) picker, using \
    obspy's stalta routine to generate the characteristic function.

    Currently very basic quick wrapper, there are many other (better) options \
    in obspy, found \
    (here)[http://docs.obspy.org/packages/autogen/obspy.signal.trigger.html].

    :type stream: obspy.Stream
    :param stream: The stream to pick on, can be any number of channels.
    :type stalen: float
    :param stalen: Length of the short-term average window in seconds.
    :type ltalen: float
    :param ltalen: Length of the long-term average window in seconds.
    :type trig_on: float
    :param trig_on: sta/lta ratio to trigger a detection/pick
    :type trig_off: float
    :param trig_off: sta/lta ratio to turn the trigger off - no further picks\
        will be made between exceeding trig_on until trig_off is reached.
    :type freqmin: float
    :param freqmin: Low-cut frequency in Hz for bandpass filter
    :type freqmax: float
    :param freqmax: High-cut frequency in Hz for bandpass filter
    :type debug: int
    :param debug: Debug output level from 0-5.
    :type show: bool
    :param show: Show picks on waveform.

    :returns: list of pick class.
    """
    from obspy.signal.trigger import classicSTALTA, triggerOnset, plotTrigger
    from Sfile_util import PICK
    import EQcorrscan_plotting as plotting
    picks = []
    for tr in stream:
        # We are going to assume, for now, that if the pick is made on the
        # horizontal channel then it is an S, otherwise we will assume it is
        # a P-phase: obviously a bad assumption...
        if tr.stats.channel[-1] == 'Z':
            phase = 'P'
        else:
            phase = 'S'
        if freqmin and freqmax:
            tr.detrend('simple')
            tr.filter('bandpass', freqmin=freqmin, freqmax=freqmax,
                      corners=3, zerophase=True)
        df = tr.stats.sampling_rate
        cft = classicSTALTA(tr.data, int(stalen * df), int(ltalen * df))
        if debug > 3:
            plotTrigger(tr, cft, trig_on, trig_off)
        triggers = triggerOnset(cft, trig_on, trig_off)
        for trigger in triggers:
            on = tr.stats.starttime + (trigger[0] / df)
            # off = tr.stats.starttime + (trigger[1] / df)
            pick = PICK(station=tr.stats.station, channel=tr.stats.channel,
                        time=on, phase=phase)
            if debug > 2:
                print('Pick made:')
                print(pick)
            picks.append(pick)
    # QC picks
    del pick
    pick_stations = list(set([pick.station for pick in picks]))
    for pick_station in pick_stations:
        station_picks = [pick for pick in picks if
                         pick.station == pick_station]
        # If P-pick is after S-picks, remove it.
        p_time = [pick.time for pick in station_picks if pick.phase == 'P']
        s_time = [pick.time for pick in station_picks if pick.phase == 'S']
        if p_time > s_time:
            p_pick = [pick for pick in station_picks if pick.phase == 'P']
            for pick in p_pick:
                print('P pick after S pick, removing P pick')
                picks.remove(pick)
    if show:
        plotting.pretty_template_plot(stream, picks=picks, title='Autopicks',
                                      size=(8, 9))
    return picks
Ejemplo n.º 7
0
    tmp.stats.network = tr.stats.network
    tmp.stats.station = tr.stats.station
    tmp.stats.channel = 'Z'
    tmp.stats.update(adict={'sac':{'evla':tr.stats.sac.evla,
                                  'evlo':tr.stats.sac.evlo,
                                  'evdp':tr.stats.sac.evdp,
                                  'stla':tr.stats.sac.stla,
                                  'stlo':tr.stats.sac.stlo,
                                  'b':ctime[0],
                                  'gcarc':tr.stats.sac.gcarc}})
    sacname = tr.stats.network+'.'+tr.stats.station+'.z'
    tmp.write(os.path.join(outpath,sacname),format='SAC')

#    st += tmp
    
'''
cft = recSTALTA(data_sum, int(0.5 / dt), int(10 / dt))

trigger = np.where(cft>1.5)[0][0]*dt
tmp = obspy.Trace()
tmp.data = data_sum
tmp.stats.delta = dt
plotTrigger(tmp, cft, 1.5, 0.5)
for tr in st:
#    cef =np.sum(template*tr.data)
#    print(tr.stats.network,tr.stats.station,cef)
#        tr.data = -tr.data
    tr.stats.sac.b = -trigger
    sacname = tr.stats.network+'.'+tr.stats.station+'.z'
    tr.write(os.path.join(outpath,sacname),format='SAC')
'''
Ejemplo n.º 8
0
from obspy.core import read
from obspy.signal.trigger import carlSTATrig, plotTrigger

trace = read("http://examples.obspy.org/ev0_6.a01.gse2")[0]
df = trace.stats.sampling_rate

cft = carlSTATrig(trace.data, int(5 * df), int(10 * df), 0.8, 0.8)
plotTrigger(trace, cft, 20.0, -20.0)
Ejemplo n.º 9
0
from obspy.core import read
from obspy.signal.trigger import classicSTALTA, plotTrigger

trace = read("http://examples.obspy.org/ev0_6.a01.gse2")[0]
df = trace.stats.sampling_rate

cft = classicSTALTA(trace.data, int(5. * df), int(10. * df))
plotTrigger(trace, cft, 1.5, 0.5)
Ejemplo n.º 10
0
    def refTrigger(self, RefWaveform):
        Config = self.Config
        cfg = ConfigObj(dict=Config)
        name = ('%s.%s.%s.%s') % (
            RefWaveform[0].stats.network, RefWaveform[0].stats.station,
            RefWaveform[0].stats.location, RefWaveform[0].stats.channel)

        i = self.searchMeta(name, self.StationMeta)
        de = loc2degrees(self.Origin, i)
        ptime = 0

        Phase = cake.PhaseDef('P')
        model = cake.load_model()
        if cfg.colesseo_input() == True:
            arrivals = model.arrivals([de, de],
                                      phases=Phase,
                                      zstart=self.Origin.depth,
                                      zstop=0.)
        else:
            arrivals = model.arrivals([de, de],
                                      phases=Phase,
                                      zstart=self.Origin.depth * km,
                                      zstop=0.)
        try:
            ptime = arrivals[0].t
        except:
            arrivals = model.arrivals([de, de],
                                      phases=Phase,
                                      zstart=o_depth * km - 0.1)
            ptime = arrivals[0].t
        phasename = ('%sphase') % (os.path.basename(self.AF))

        if ptime == 0:
            print '\033[31mAvailable phases for reference station %s in range %f deegree\033[0m' % (
                i, de)
            print '\033[31m' + '|'.join(
                [str(item['phase_name']) for item in tt]) + '\033[0m'
            print '\033[31myou tried phase %s\033[0m' % (
                self.Config[phasename])
            raise Exception("\033[31mILLEGAL: phase definition\033[0m")

        tw = self.calculateTimeWindows(ptime)

        if cfg.pyrocko_download() == True:
            stP = self.readWaveformsPicker_pyrocko(i, tw, self.Origin, ptime)
        elif cfg.colesseo_input() == True:
            stP = self.readWaveformsPicker_colos(i, tw, self.Origin, ptime)
        else:
            stP = self.readWaveformsPicker(i, tw, self.Origin, ptime)

        refuntouchname = os.path.basename(self.AF) + '-refstation-raw.mseed'
        stP.write(os.path.join(self.EventPath, refuntouchname),
                  format='MSEED',
                  byteorder='>')
        stP.filter("bandpass",
                   freqmin=float(self.Config['refstationfreqmin']),
                   freqmax=float(self.Config['refstationfreqmax']))

        stP.trim(tw['xcorrstart'], tw['xcorrend'])
        trP = stP[0]

        trP.stats.starttime = UTCDateTime(3600)
        refname = os.path.basename(self.AF) + '-refstation-filtered.mseed'
        trP.write(os.path.join(self.EventPath, refname),
                  format='MSEED',
                  byteorder='>')

        sta = float(self.Config['refsta'])
        lta = float(self.Config['reflta'])
        cft = recSTALTA(trP.data, int(sta * trP.stats.sampling_rate),
                        int(lta * trP.stats.sampling_rate))

        t = triggerOnset(cft, lta, sta)

        try:
            onset = t[0][0] / trP.stats.sampling_rate
            print 'ONSET ', onset

        except:
            onset = self.mintforerun

        trigger = trP.stats.starttime + onset

        print 'TRIGGER ', trigger
        print 'THEORETICAL: ', UTCDateTime(3600) + self.mintforerun
        tdiff = (trP.stats.starttime + onset) - (UTCDateTime(3600) +
                                                 self.mintforerun)
        print 'TDIFF: ', tdiff

        refp = UTCDateTime(self.Origin.time) + ptime
        reftriggeronset = refp + onset - self.mintforerun

        if int(self.Config['autoxcorrcorrectur']) == 1:
            try:

                refmarkername = os.path.join(self.EventPath, ('%s-marker') %
                                             (os.path.basename(self.AF)))
                fobjrefmarkername = open(refmarkername, 'w')
                fobjrefmarkername.write(
                    '# Snuffler Markers File Version 0.2\n')
                fobjrefmarkername.write((
                    'phase: %s 0 %s    None           None         None         XWStart        None False\n'
                ) % (tw['xcorrstart'].strftime('%Y-%m-%d %H:%M:%S.%f'), name))
                fobjrefmarkername.write((
                    'phase: %s 0 %s    None           None         None         XWEnd        None False\n'
                ) % (tw['xcorrend'].strftime('%Y-%m-%d %H:%M:%S.%f'), name))
                fobjrefmarkername.write((
                    'phase: %s 1 %s    None           None         None         TheoP        None False\n'
                ) % (refp.strftime('%Y-%m-%d %H:%M:%S.%f'), name))
                fobjrefmarkername.write((
                    'phase: %s 3 %s    None           None         None         XTrig        None False'
                ) % (reftriggeronset.strftime('%Y-%m-%d %H:%M:%S.%f'), name))
                fobjrefmarkername.close()

                cmd = 'snuffler %s --markers=%s&' % (os.path.join(
                    self.EventPath, refuntouchname), refmarkername)
                os.system(cmd)

                thrOn = float(self.Config['reflta'])  # 4
                thrOff = float(self.Config['refsta'])  # 0.7
                plotTrigger(trP, cft, thrOn, thrOff)

                selection = float(
                    raw_input('Enter self picked phase in seconds: '))
                tdiff = selection - self.mintforerun

                refname = os.path.basename(self.AF) + '-shift.mseed'
                trP.stats.starttime = trP.stats.starttime - selection
                trP.write(os.path.join(self.EventPath, refname),
                          format='MSEED')

            except:
                selection = 0.
                refname = os.path.basename(self.AF) + '-shift.mseed'
                trP.stats.starttime = trP.stats.starttime - selection - self.mintforerun
                trP.write(os.path.join(self.EventPath, refname),
                          format='MSEED')
        '''
        tdiff = 0
        trigger = trP.stats.starttime
        '''
        To = Trigger(name, trigger, os.path.basename(self.AF), tdiff)

        return tdiff, To
Ejemplo n.º 11
0
Archivo: mccc.py Proyecto: ymh1997/mccc
        adict={
            'sac': {
                'evla': tr.stats.sac.evla,
                'evlo': tr.stats.sac.evlo,
                'evdp': tr.stats.sac.evdp,
                'stla': tr.stats.sac.stla,
                'stlo': tr.stats.sac.stlo,
                'b': ctime[0],
                'gcarc': tr.stats.sac.gcarc
            }
        })
    sacname = tr.stats.network + '.' + tr.stats.station + '.z'
    tmp.write(os.path.join(outpath, sacname), format='SAC')

#    st += tmp
'''
cft = recSTALTA(data_sum, int(0.5 / dt), int(10 / dt))

trigger = np.where(cft>1.5)[0][0]*dt
tmp = obspy.Trace()
tmp.data = data_sum
tmp.stats.delta = dt
plotTrigger(tmp, cft, 1.5, 0.5)
for tr in st:
#    cef =np.sum(template*tr.data)
#    print(tr.stats.network,tr.stats.station,cef)
#        tr.data = -tr.data
    tr.stats.sac.b = -trigger
    sacname = tr.stats.network+'.'+tr.stats.station+'.z'
    tr.write(os.path.join(outpath,sacname),format='SAC')
'''
Ejemplo n.º 12
0
from obspy.core import read
from obspy.signal.trigger import zDetect, plotTrigger

trace = read("http://examples.obspy.org/ev0_6.a01.gse2")[0]
df = trace.stats.sampling_rate

cft = zDetect(trace.data, int(10. * df))
plotTrigger(trace, cft, -0.4, -0.3)
Ejemplo n.º 13
0
from obspy.core import read
from obspy.signal.trigger import delayedSTALTA, plotTrigger

trace = read("http://examples.obspy.org/ev0_6.a01.gse2")[0]
df = trace.stats.sampling_rate

cft = delayedSTALTA(trace.data, int(5 * df), int(10 * df))
plotTrigger(trace, cft, 5, 10)
Ejemplo n.º 14
0
def plot_trigger(trace, cft, thrOn, thrOff, show=True):
    """
    DEPRECATED. Use :func:`obspy.signal.trigger.plotTrigger` instead.
    """
    from obspy.signal.trigger import plotTrigger
    return plotTrigger(trace, cft, thrOn, thrOff, show=show)
Ejemplo n.º 15
0

# In[33]:

npt = len(trNfil[0].data)
emd = EMD(trNfil[0].data)
imfs = emd.decompose()
time = (np.linspace(1, npt, npt)) * dt
plt.rcParams["figure.figsize"] = (30.0, 50.0)
plot_imfs(trNfil[0].data, time, imfs)


# In[44]:

aa = trNfil[2].copy()
plotTrigger(aa, cft, 2.2, 0.5)
dm = len(cft)
item = [i for i in list(range(dm)) if cft[i] > 2.2]
print(min(item))


ene = [0] * dm
for i in xrange(1, dm):
    # ene[i] = ene[i-1] + envel[i] ** 2
    ene[i] = ene[i - 1] + trNfil[2].data[i] ** 2

    # print(ene[i])
# print(ene/dm)
enen = ene / ene[-1]
enend = np.diff(enen)
item1 = [i for i in list(range(len(ene))) if enen[i] > 0.1]
Ejemplo n.º 16
0
def plot_trigger(trace, cft, thrOn, thrOff, show=True):
    """
    DEPRECATED. Use :func:`obspy.signal.trigger.plotTrigger` instead.
    """
    from obspy.signal.trigger import plotTrigger
    return plotTrigger(trace, cft, thrOn, thrOff, show=show)