예제 #1
0
파일: stalta.py 프로젝트: megies/pyrocko
    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)
from cap_utils import make_array, file_mapping, number_map
font = { 'size'   : 7}
rc('font', **font)


def semblance_map(sem):
    sem_min=sem.min()
    sem_max=sem.max()
    sem_range = sem_max-sem_min

# first argument is the filename of CAP output, second argument the filename
# of file containing event markers

#fn = sys.argv[1]
fns = sys.argv[1:]
markers = Marker.load_markers('event_markers_Colm2013.txt')
outer_s = defaultdict(list)
outer_z = []
GMT_string = ''
GMT_string_chopped = ''
for f_i, fn in enumerate(fns):
    flist = fn.split('.')[0]
    print 'filename ',fn

    event_time = file_mapping[flist]
    ev_no = number_map[event_time]
    event_time_seconds = util.str_to_time(event_time)
    print 'event time ', event_time
    for em in markers:
        if em.tmin==util.str_to_time(event_time):
            event = em._event
from pyrocko.gui_util import Marker
import sys

filename = sys.argv[1]
markers = Marker.load_markers(filename)
filtered_markers = filter(lambda m: m._event.magnitude==0., markers)
Marker.save_markers(filtered_markers, filename+".filtered")

예제 #4
0
#!/usr/bin/python

import sys
import matplotlib.pyplot as plt
from matplotlib import rc
import numpy as num
from pyrocko.gui_util import Marker
from pyrocko import util
from pyrocko.gf import seismosizer

# first argument is the filename of CAP output, second argument the filename
# of file containing event markers

fn = sys.argv[1]
markers = Marker.load_markers(sys.argv[2])
f = open(fn, 'r')
flist = fn.split('.')[0]
print 'filename ', fn
event_times = [
    '2013-01-12 08:54:19.000', '2013-01-14 03:34:08.500',
    '2013-03-11 01:26:45.100', '2013-04-22 22:46:00.300',
    '2013-04-23 00:28:30.300', '2013-04-23 02:44:05.100',
    '2013-04-30 19:03:06.800', '2013-07-04 12:29:47.600'
]  #Is there a second event in here??

flists = [
    '2013-01-12', '2013-01-14', '2013-03-11', '2013-04-22', '2013-04-23-00',
    '2013-04-23-02', '2013-04-30', '2013-07-04'
]
mapping = dict(zip(flists, event_times))
import sys
import numpy as num
from cap_utils import make_array, file_mapping
from pyrocko.gui_util import Marker
from pyrocko import util
from pyrocko.gf import seismosizer
from matplotlib import pyplot as plt

files = sys.argv[1:]
marker_fn = 'event_markers_Colm2013.txt'
markers = Marker.load_markers(marker_fn)

center_array_target = seismosizer.Target(lat=50.241611, lon=12.327766)

num_cfreqs = 4

backaz = num.zeros([num_cfreqs, len(files)])
deviat = num.zeros([num_cfreqs, len(files)])
maxsem = num.zeros([num_cfreqs, len(files)])

for i_f, fn in enumerate(files):
    flist = fn.split('.')[0]
    event_time = file_mapping[flist]
    print 'event time ', event_time
    for em in markers:
        if em.tmin==util.str_to_time(event_time):
            event = em._event
            source = seismosizer.Source.from_pyrocko_event(event)
            break
    
    azibazi = center_array_target.azibazi_to(source)
예제 #6
0
#!/usr/bin/python 

import sys
import matplotlib.pyplot as plt
from matplotlib import rc
import numpy as num
from pyrocko.gui_util import Marker
from pyrocko import util
from pyrocko.gf import seismosizer

# first argument is the filename of CAP output, second argument the filename
# of file containing event markers

fn = sys.argv[1]
markers = Marker.load_markers(sys.argv[2])
f = open(fn, 'r')
flist = fn.split('.')[0]
print 'filename ',fn
event_times = ['2013-01-12 08:54:19.000',
'2013-01-14 03:34:08.500',
'2013-03-11 01:26:45.100',
'2013-04-22 22:46:00.300',
'2013-04-23 00:28:30.300',
'2013-04-23 02:44:05.100',
'2013-04-30 19:03:06.800',
'2013-07-04 12:29:47.600'] #Is there a second event in here??

flists = ['2013-01-12',
          '2013-01-14',
          '2013-03-11',
          '2013-04-22',