Exemple #1
0
def filterWaveform(Config, waveform, station):

    cfg = FilterCfg(self.Config)
    switch = cfg.filterswitch()  # 'filterswitch'

    if switch == 1:
        which = 'bandpass'
        waveform.filter(
            which,
            freqmin=cfg.flo(),  # ['flo']
            freqmax=cfg.fhi(),  # ['fhi']
            corners=cfg.ns(),  # ['ns']
            zerophase=bool(Config['zph']))
    elif switch == 2:
        waveform.filter(
            which,
            freqmin=cfg.flo2(),  # ['flo']
            freqmax=cfg.fhi2(),  # ['fhi']
            corners=cfg.ns2(),  # ['ns']
            zerophase=bool(Config['zph2']))
    elif switch == 3:
        which = 'highpass'
        waveform.filter(
            which,
            freq=cfg.h_fc(),  # ['h_fc']
            corners=cfg.h_ns(),  # ['h_ns']
            zerophase=bool(Config['h_zph']))
    else:
        return None

    Logfile.add('%s filtered stream for station %s ' % (which, i))
    return waveform
Exemple #2
0
    def filterWaveform(self, Waveform):

        Logfile.red('Filter Waveform: ')
        cfg = FilterCfg(self.Config)

        new_frequence = (cfg.newFrequency())

        st = Stream()
        for i in Waveform:
            Logfile.red('Downsampling to %s: from %d' %
                        (new_frequence, i.stats.sampling_rate))
            j = i.resample(new_frequence)
            switch = cfg.filterswitch()

            if switch == 1:
                Logfile.add('bandpass filtered \
                        stream for station %s ' % (i))

                j.filter('bandpass',
                         freqmin=cfg.flo(),
                         freqmax=cfg.fhi(),
                         corners=cfg.ns(),
                         zerophase=bool(self.Config['zph']))

            elif switch == 2:
                Logfile.add('bandpass filtered \
                        stream for station %s ' % (i))

                j.filter('bandpass',
                         freqmin=cfg.flo2(),
                         freqmax=cfg.fhi2(),
                         corners=cfg.ns2(),
                         zerophase=bool(self.Config['zph']))
            st.append(j)

        return st
Exemple #3
0
def processWaveforms(WaveformDict, Config, Folder, network, MetaDict, Event,
                     switch, Xcorr):

    Logfile.red('Start Processing')

    cfg = FilterCfg(Config)
    new_frequence = cfg.newFrequency()

    for index, i in enumerate(WaveformDict):
        Logfile.add('%s:%s ---------------------' % (index, i))

        if Config['export_unfiltered'].capitalize() is 'True':
            writeWaveform(Folder, i, WaveformDict[i], 'U', network)

        station = getStation(i, MetaDict)

        if cfg.Int('fm') == 1:
            azi = ttt.bearing(Event, station)
            bazi = ttt.backazi(station, Event)

            msg = 'Takeoff ' + str(station.takeoff) + ' Azi ' + str(azi) +\
                  'Bazi ' + str(bazi)

            Logfile.add(msg)

        gain = float(station.gain)

        if gain == 0.0 or gain == -1.0:
            gain = 1

        WaveformDict[i][0].data * (1.0 / gain)

        if switch is 0:
            Logfile.add('bandpass filtered stream for station %s ' % (i))

            WaveformDict[i].filter('bandpass',
                                   freqmin=cfg.flo(),
                                   freqmax=cfg.fhi(),
                                   corners=cfg.ns(),
                                   zerophase=bool(Config['zph']))

        elif switch is 1:
            Logfile.add('bandpass filtered stream for station %s ' % (i))

            WaveformDict[i].filter('bandpass',
                                   freqmin=cfg.flo2(),
                                   freqmax=cfg.fhi2(),
                                   corners=cfg.ns2(),
                                   zerophase=bool(Config['zph2']))

        else:
            Logfile.add('no filter set for station %s ' % (i))

        if Config['export_filtered'].capitalize() is 'True':
            writeWaveform(Folder, i, WaveformDict[i], 'F', network)

        j = resampleWaveform(WaveformDict[i][0], new_frequence)
        WaveformDict[i] = j

        if Config['export_resampled'].capitalize() is 'True':
            writeWaveform(Folder, i, WaveformDict[i], 'R', network)

    return WaveformDict
Exemple #4
0
def processWaveforms(WaveformDict, Config, Folder, network, MetaDict, Event,
                     switch, Xcorr):

    Logfile.red('Start Processing')

    cfg = FilterCfg(Config)
    new_frequence = cfg.newFrequency()  #  ['new_frequence']

    vp, vs, rho = ttt.calcak135parameter(Event)

    for index, i in enumerate(WaveformDict):
        Logfile.add(
            '%s:%s -------------------------------------------------------------'
            % (index, i))

        if Config['export_unfiltered'].capitalize() == 'True':
            writeWaveform(Folder, i, WaveformDict[i], 'U', network)

        station = getStation(i, MetaDict)

        psign = 1

        if cfg.Int('fm') == 1:
            azi = ttt.bearing(Event, station)
            bazi = ttt.backazi(station, Event)
            psign = ttt.dubcup(rho, vp, vs, Event.strike, Event.dip,
                               Event.rake, azi, station.takeoff)

            msg = 'Takeoff ' + str(
                station.takeoff) + ' Azi ' + str(azi) + ' Bazi ' + str(bazi)
            msg += (' vp ' + str(vp) + ' vs ' + str(vs) + ' rho ' + str(rho) +
                    ' Psign ' + str(psign))
            Logfile.add(msg)

        try:
            Logfile.add(station.getName() + ' ' + station.lat + ' ' +
                        station.lon + ' ' + station.gain + ' PSIGN: ' +
                        str(psign))
        except:
            try:
                print psign, station.getName(
                ), station.lat, station.lon, station.gain
            except:
                pass
        if psign == -1:
            Logfile.add('correcting polarisation for station %s ' % (i))
            -1. * WaveformDict[i][0].data
        #gain correctur
        gain = float(station.gain)

        if gain == 0.0 or gain == -1.0:
            gain = 1  #hs : gain missing in metafile

        WaveformDict[i][0].data * (1.0 / gain)

        if switch == 0:
            Logfile.add('bandpass filtered stream for station %s ' % (i))

            WaveformDict[i].filter(
                'bandpass',
                freqmin=cfg.flo(),  # ['flo']
                freqmax=cfg.fhi(),  # ['fhi']
                corners=cfg.ns(),  # ['ns']
                zerophase=bool(Config['zph']))

        elif switch == 1:
            Logfile.add('bandpass filtered stream for station %s ' % (i))

            WaveformDict[i].filter(
                'bandpass',
                freqmin=cfg.flo2(),  # ['flo']
                freqmax=cfg.fhi2(),  # ['fhi']
                corners=cfg.ns2(),  # ['ns']
                zerophase=bool(Config['zph2']))

        else:
            Logfile.add('no filter set for station %s ' % (i))

        if Config['export_filtered'].capitalize() == 'True':
            writeWaveform(Folder, i, WaveformDict[i], 'F', network)

        #resampling
        j = resampleWaveform(WaveformDict[i][0], new_frequence)
        WaveformDict[i] = j

        if Config['export_resampled'].capitalize() == 'True':
            writeWaveform(Folder, i, WaveformDict[i], 'R', network)

    return WaveformDict