예제 #1
0
파일: syngine.py 프로젝트: junxie01/mtuq
    def get_greens_tensor(self, station, origin):
        # download and unizp data
        dirname = unzip(download_greens_tensor(self.model, station, origin))

        # read data
        stream = Stream()
        stream.id = station.id
        for filename in GREENS_TENSOR_FILENAMES:
            stream += obspy.read(dirname + '/' + filename, format='sac')

        # what are the start and end times of the data?
        t1_new = float(station.starttime)
        t2_new = float(station.endtime)
        dt_new = float(station.delta)

        # what are the start and end times of the Green's function?
        t1_old = float(stream[0].stats.starttime)
        t2_old = float(stream[0].stats.endtime)
        dt_old = float(stream[0].stats.delta)

        for trace in stream:
            # resample Green's functions
            data_old = trace.data
            data_new = resample(data_old, t1_old, t2_old, dt_old, t1_new,
                                t2_new, dt_new)
            trace.data = data_new
            trace.stats.starttime = t1_new
            trace.stats.delta = dt_new
            trace.stats.npts = len(data_new)

        traces = [trace for trace in stream]
        return GreensTensor(traces, station, origin)
예제 #2
0
    def get_greens_tensor(self, station, origin):
        """ 
        Reads a Greens tensor from a directory tree organized by model, event
        depth, and event distance
        """
        stream = Stream()

        # what are the start and end times of the data?
        t1_new = float(station.starttime)
        t2_new = float(station.endtime)
        dt_new = float(station.delta)

        dep = str(int(round(origin.depth / 1000.)))
        #dst = str(int(round(station.distance)))
        dst = str(int(ceil(station.distance)))

        # See cap/fk documentation for indexing scheme details;
        # here we try to follow as closely as possible the cap way of
        # doing things
        channels = [
            'TSS',
            'TDS',
            'REP',
            'RSS',
            'RDS',
            'RDD',
            'ZEP',
            'ZSS',
            'ZDS',
            'ZDD',
        ]

        extensions = [
            '8',
            '5',  # t
            'b',
            '7',
            '4',
            '1',  # r
            'a',
            '6',
            '3',
            '0',  # z
        ]

        for _i, ext in enumerate(extensions):
            trace = obspy.read('%s/%s_%s/%s.grn.%s' %
                               (self.path, self.model, dep, dst, ext),
                               format='sac')[0]

            trace.stats.channel = channels[_i]

            # what are the start and end times of the Green's function?
            t1_old = float(origin.time) + float(trace.stats.starttime)
            t2_old = float(origin.time) + float(trace.stats.endtime)

            dt_old = float(trace.stats.delta)

            # resample Green's function
            data_old = trace.data
            data_new = resample(data_old, t1_old, t2_old, dt_old, t1_new,
                                t2_new, dt_new)
            trace.data = data_new
            # convert from 10^-20 dyne to N^-1
            trace.data *= 1.e-15
            trace.stats.starttime = t1_new
            trace.stats.delta = dt_new

            stream += trace

        stream.id = station.id

        traces = [trace for trace in stream]
        return GreensTensor(traces, station, origin)