Ejemplo n.º 1
0
    def call(self):
        
        self.cleanup()
        currentPile = self.get_pile()
        currentPileViewer = self.get_viewer()
        markers = currentPileViewer.selected_markers()

        tminpick=[]; tmaxpick=[]
        for phase_marker in markers:
            tminpick.append(phase_marker.get_tmin())
            tmaxpick.append(phase_marker.get_tmax())
       
        choppedTraces=currentPile.chopper(tmin=min(tminpick), tmax=min(tmaxpick) )
        
        degrees = range(-180,180,5)
        for traces in choppedTraces:
            AllRotatedTraces = RotateAllTraces(degrees, traces)
            correlationStatVal={}

            for deg in degrees:
                for stationPair in getPairStationTool(AllRotatedTraces[deg]):
                    try:
                        correlationStatVal[stationPair[0].station].append([deg, getTracesCorrelation(stationPair[0], stationPair[1])])
                    except KeyError:
                        correlationStatVal[stationPair[0].station]=[]
            
            
            for trace in traces:
                trace.set_codes(network='rot')

            printFormattedOutput(correlationStatVal)        
        self.add_traces(traces)     
Ejemplo n.º 2
0
    def call(self):
        '''Main work routine of the snuffling.'''
        
        self.cleanup()
        
        swin, ratio = self.swin, self.ratio
        lwin = swin * ratio
        tpad = lwin/2.
        
        pile = self.get_pile()
        tmin, tmax = pile.get_tmin() + tpad, pile.get_tmax() - tpad
        
        if not self.apply_to_all:
            vtmin, vtmax = self.get_viewer().get_time_range()
            tmin = max(vtmin, tmin)
            tmax = min(vtmax, tmax)

        tinc = min(lwin * self.block_factor, tmax-tmin)
        
        show_level_traces = self.show_level_traces
        
       # if show_level_traces and tmax-tmin > lwin * 150:
       #     self.error('Processing time window is longer than 50 x LTA window. Turning off display of level traces.')
       #     show_level_traces = False
        
        markers = []
        for traces in pile.chopper(tmin=tmin, tmax=tmax, tinc=tinc, tpad=tpad, want_incomplete=False):
            sumtrace = None
            isum = 0
            for trace in traces:
                if self.lowpass is not None:
                    trace.lowpass(4, self.lowpass, nyquist_exception=True)

                if self.highpass is not None:
                    trace.highpass(4, self.highpass, nyquist_exception=True)
                
                trace.sta_lta_centered(swin, lwin, scalingmethod=scalingmethod_map[self.scalingmethod])
                trace.chop(trace.wmin, min(trace.wmax,tmax))
                trace.set_codes(location='cg')
                trace.meta = { 'tabu': True }
                
                #print trace.ydata.max()
                if sumtrace is None:
                    sumtrace = trace.copy()
                    sumtrace.set_codes(network='', station='SUM', location='cg', channel='')
                else:
                    sumtrace.add(trace)
                isum += 1
    
            if show_level_traces:
                self.add_traces(traces)
    
            if sumtrace is not None:
                tpeaks, apeaks = sumtrace.peaks(self.level*isum, swin)
    
                for t, a in zip(tpeaks, apeaks):
                    mark = Marker([  ], t, t)
                    print mark, a #'%s.%s.%s.%s' % ('', trace.station, '', trace.channel)
                    markers.append(mark)
                
                if show_level_traces:
                    self.add_trace(sumtrace)
                    
        self.add_markers(markers)