Example #1
0
    def Get_bw_windows(self,
                       stream,
                       UNKNOWN_1,
                       UNKNOWN_2,
                       or_time,
                       Full_P_shift=None,
                       Full_S_shift=None,
                       MANUAL=False):
        ## YOU can do EITHER MANUAL or not:
        """   if MANUAL = False:
                UNKNOWN_1 = EPI
                UNKNOWN_2 = DEPTH
              if MANUAL = True:
                UNKNOWN_1 = tt_P
                UNKNOWN_2 = tt_S

            Full_P_shift = extra shift applied to synthetic, so should be None if Observed
            Full_S_shift = extra shift applied to synthetic, so should be None if Observed

        """

        self.dt = stream.traces[0].stats.delta
        self.original = stream.copy()
        or_time_sec = or_time.timestamp

        if MANUAL == False:
            epi = UNKNOWN_1
            depth = UNKNOWN_2
            tt_P = self.get_P(epi, depth)
            tt_S = self.get_S(epi, depth)
            self.start_P = obspy.UTCDateTime(or_time_sec + tt_P - self.Pre_P)
            self.or_P_len = int(
                (self.start_P - or_time) / stream.traces[0].stats.delta)
            self.start_S = obspy.UTCDateTime(or_time_sec + tt_S - self.Pre_S)
            self.or_S_len = int(
                (self.start_S - or_time) / stream.traces[0].stats.delta)
            # print(self.start_P)
            # print(self.start_S)

            end_P = obspy.UTCDateTime(or_time_sec + tt_P + self.Post_P)
            end_S = obspy.UTCDateTime(or_time_sec + tt_S + self.Post_S)

        else:
            tt_P = UNKNOWN_1
            tt_S = UNKNOWN_2
            self.start_P = obspy.UTCDateTime(tt_P.timestamp - self.Pre_P)
            self.or_P_len = int(
                (self.start_P - or_time) / stream.traces[0].stats.delta)
            self.start_S = obspy.UTCDateTime(tt_S.timestamp - self.Pre_S)
            self.or_S_len = int(
                (self.start_S - or_time) / stream.traces[0].stats.delta)

            end_P = obspy.UTCDateTime(tt_P.timestamp + self.Post_P)
            end_S = obspy.UTCDateTime(tt_S.timestamp + self.Post_S)

        if Full_P_shift == None:
            Full_P_shift = 0
        else:
            Full_P_shift = Full_P_shift * self.dt

        if Full_S_shift == None:
            Full_S_shift = 0
        else:
            Full_S_shift = Full_S_shift * self.dt

        self.S_original = self.original.copy()
        self.P_original = self.original.copy()
        if self.Taper == True:
            self.P_original.taper(
                0.025, 'hann', self.start_P - or_time -
                10)  # Making sure the P and S wave are not effected
            self.S_original.taper(0.025, 'hann', self.start_P - or_time - 10)

            # CHECK IN OBSPY FUNCTION IF TAPER IS GOOD:
            # import matplotlib.pylab as plt
            # plt.close()
            # x = np.arange(len(taper))
            # plt.plot(x, taper, 'r', label='Hann Taper')
            # plt.plot(3606, 1, 'bx', label='P-arrival')
            # plt.plot(6806, 1, 'kx', label='S-arrival')
            # plt.legend()
            # plt.show()

        if self.zero_phase:
            self.P_original.filter('highpass',
                                   freq=1. / (end_P - self.start_P),
                                   zerophase=True,
                                   corners=self.Order)
            self.P_original.filter('highpass',
                                   freq=1. / (end_S - self.start_S),
                                   zerophase=True,
                                   corners=self.Order)
            self.S_original.filter('highpass',
                                   freq=1. / (end_P - self.start_P),
                                   zerophase=True,
                                   corners=self.Order)
            self.S_original.filter('highpass',
                                   freq=1. / (end_S - self.start_S),
                                   zerophase=True,
                                   corners=self.Order)
        else:
            self.P_original.filter('highpass',
                                   freq=1. / (end_P - self.start_P),
                                   corners=self.Order)
            self.P_original.filter('highpass',
                                   freq=1. / (end_S - self.start_S),
                                   corners=self.Order)
            self.S_original.filter('highpass',
                                   freq=1. / (end_P - self.start_P),
                                   corners=self.Order)
            self.S_original.filter('highpass',
                                   freq=1. / (end_S - self.start_S),
                                   corners=self.Order)

        self.P_original = self.Filter(self.P_original,
                                      HP=self.P_HP,
                                      LP=self.P_LP)
        self.S_original = self.Filter(self.S_original,
                                      HP=self.S_HP,
                                      LP=self.S_LP)

        wlen_seconds = self.Taper_Len
        zero_len = self.Zero_len
        # wlen = int(wlen_seconds / self.dt)

        P_stream = Stream()
        S_stream = Stream()
        for i in range(0, len(stream.traces)):
            trace_P = self.P_original.traces[i].copy()
            trace_S = self.S_original.traces[i].copy()
            dt = trace_P.meta.delta

            P_trace = Trace.slice(trace_P,
                                  self.start_P - wlen_seconds + Full_P_shift,
                                  end_P + wlen_seconds + Full_P_shift)
            self.P_len = len(P_trace)
            npts_p = self.P_len + 2 * zero_len
            start_p = dt * zero_len
            S_trace = Trace.slice(trace_S,
                                  self.start_S - wlen_seconds + Full_S_shift,
                                  end_S + wlen_seconds + Full_S_shift)
            self.S_len = len(S_trace)
            npts_s = self.S_len + 2 * zero_len
            start_s = dt * zero_len

            if i == 2:
                total_s_trace = Trace(np.zeros(npts_s),
                                      header={
                                          "starttime":
                                          self.start_S - start_s -
                                          wlen_seconds + Full_S_shift,
                                          'delta':
                                          trace_S.stats.delta,
                                          "station":
                                          trace_S.stats.station,
                                          "network":
                                          trace_S.stats.network,
                                          "location":
                                          trace_S.stats.location,
                                          "channel":
                                          trace_S.stats.channel
                                      }).__add__(S_trace,
                                                 method=0,
                                                 interpolation_samples=0,
                                                 fill_value=S_trace.data,
                                                 sanity_checks=True)

            else:
                total_p_trace = Trace(np.zeros(npts_p),
                                      header={
                                          "starttime":
                                          self.start_P - start_p -
                                          wlen_seconds + Full_P_shift,
                                          'delta':
                                          trace_P.stats.delta,
                                          "station":
                                          trace_P.stats.station,
                                          "network":
                                          trace_P.stats.network,
                                          "location":
                                          trace_P.stats.location,
                                          "channel":
                                          trace_P.stats.channel
                                      }).__add__(P_trace,
                                                 method=0,
                                                 interpolation_samples=0,
                                                 fill_value=P_trace.data,
                                                 sanity_checks=True)
                total_s_trace = Trace(np.zeros(npts_s),
                                      header={
                                          "starttime":
                                          self.start_S - start_s -
                                          wlen_seconds + Full_S_shift,
                                          'delta':
                                          trace_S.stats.delta,
                                          "station":
                                          trace_S.stats.station,
                                          "network":
                                          trace_S.stats.network,
                                          "location":
                                          trace_S.stats.location,
                                          "channel":
                                          trace_S.stats.channel
                                      }).__add__(S_trace,
                                                 method=0,
                                                 interpolation_samples=0,
                                                 fill_value=S_trace.data,
                                                 sanity_checks=True)
                P_stream.append(total_p_trace)
            S_stream.append(total_s_trace)
            self.S_stream = S_stream
            self.P_stream = P_stream
Example #2
0
    def get_window_obspy(self, seis_traces, epi, depth, time, npts):
        tt_P = self.get_P(
            epi, depth
        )  # Estimated P-wave arrival, based on the known velocity model
        tt_S = self.get_S(
            epi, depth
        )  # Estimated S-wave arrival, based on the known velocity model
        sec_per_sample = 1 / (seis_traces[0].meta.sampling_rate)
        #
        total_stream = Stream()
        s_stream = Stream()
        p_stream = Stream()
        p_time = time.timestamp + tt_P
        s_time = time.timestamp + tt_S
        start_time_p = obspy.UTCDateTime(p_time - 5)
        start_time_s = obspy.UTCDateTime(s_time - 15)
        end_time_p = obspy.UTCDateTime(p_time + 20)
        end_time_s = obspy.UTCDateTime(s_time + 35)
        #
        for i, trace in enumerate(seis_traces.traces):
            P_trace = Trace.slice(trace, start_time_p, end_time_p)
            S_trace = Trace.slice(trace, start_time_s, end_time_s)
            #
            #     params = {'legend.fontsize': 'x-large',
            #               'figure.figsize': (15, 15),
            #               'axes.labelsize': 25,
            #               'axes.titlesize': 'x-large',
            #               'xtick.labelsize': 25,
            #               'ytick.labelsize': 25}
            #     pylab.rcParams.update(params)
            #     fig = plt.figure(figsize=(10, 10))
            #     time_array = np.arange(len(trace)) * trace.meta.delta
            #     Axes = plt.subplot()
            #     Axes.plot(time_array, trace, c='k', label = 'Z-component')
            #     ymin, ymax = Axes.get_ylim()
            #     x_cor = [start_time_p.timestamp - trace.meta.starttime.timestamp,
            #              end_time_p.timestamp - trace.meta.starttime.timestamp,
            #              end_time_p.timestamp - trace.meta.starttime.timestamp,
            #              start_time_p.timestamp - trace.meta.starttime.timestamp,
            #              start_time_p.timestamp - trace.meta.starttime.timestamp]
            #     y_cor = [ymax / 10.0, ymax / 10.0, ymin / 10.0, ymin / 10.0, ymax / 10.0]
            #     plt.plot(x_cor,y_cor,c='r')
            #     x_cor_s = [start_time_s.timestamp - trace.meta.starttime.timestamp,
            #              end_time_s.timestamp - trace.meta.starttime.timestamp,
            #              end_time_s.timestamp - trace.meta.starttime.timestamp,
            #              start_time_s.timestamp - trace.meta.starttime.timestamp,
            #              start_time_s.timestamp - trace.meta.starttime.timestamp]
            #     y_cor_s = [ymax / 10.0, ymax / 10.0, ymin / 10.0, ymin / 10.0, ymax / 10.0]
            #     plt.plot(x_cor_s,y_cor_s,c='r')
            #     # Axes.axhline(y=ymin,  color='r')
            #     # Axes.axhline(y=ymax,  color='r')
            #     # plt.vlines(start_time_p,ymin=ymin,ymax=ymax,colors='r',label='P pick')
            #     # plt.vlines(end_time_p,ymin=ymin,ymax=ymax,colors='r')
            #
            #
            #     phases = (dict(starttime=lambda dist, depth: time + dist / 2.8,
            #                    endtime=lambda dist, depth: time + dist / 2.6,
            #                    comp='Z',
            #                    fmin=1. / 20.,
            #                    fmax=1. / 10.,
            #                    dt=5.0,
            #                    name='R1_10_20'))
            #     # trace.detrend(type="demean")
            #     # trace.filter('highpass', freq=phases['fmin'], zerophase=True)
            #     # trace.filter('lowpass', freq=phases['fmax'], zerophase=True)
            #     # trace.detrend()
            #     start = phases['starttime'](2716.72921884, 10000)
            #     end = phases['endtime'](2716.72921884, 10000)
            #     start_vline = int(
            #         (phases['starttime'](2716.72921884, 10000).timestamp- time.timestamp))
            #     end_vline = int(
            #         (phases['endtime'](2716.72921884, 10000).timestamp - time.timestamp))
            #
            #     y_cor_R = [ymin,ymin,ymax,ymax,ymin]
            #     x_cor_R = [start_vline,end_vline,end_vline,start_vline,start_vline]
            #
            #     plt.plot(x_cor_R, y_cor_R, c='g')
            #     Axes.legend()
            #     Axes.ticklabel_format(style="sci", axis='y', scilimits=(-2, 2))
            #     Axes.set_xlabel(trace.meta.starttime.strftime('Time : %Y-%m-%dT%H:%M:%S + [sec]'))
            #     Axes.set_ylabel("Displacement [m]")
            #     plt.tight_layout()
            #     # plt.show()
            #     plt.savefig('/home/nienke/Documents/Applied_geophysics/Thesis/anaconda/Final/check_waveforms' + '/picks.pdf')
            #     plt.close()
            #
            #     # v_p_start = start_time_p

            stream_add = P_trace.__add__(S_trace,
                                         fill_value=0,
                                         sanity_checks=True)
            zero_trace = Trace(np.zeros(npts),
                               header={
                                   "starttime": start_time_p,
                                   'delta': trace.meta.delta,
                                   "station": trace.meta.station,
                                   "network": trace.meta.network,
                                   "location": trace.meta.location,
                                   "channel": trace.meta.channel
                               })
            if 'T' in trace.meta.channel:
                total_trace = zero_trace.__add__(S_trace,
                                                 method=0,
                                                 interpolation_samples=0,
                                                 fill_value=S_trace.data,
                                                 sanity_checks=True)
                total_s_trace = total_trace.copy()
            else:
                total_trace = zero_trace.__add__(stream_add,
                                                 method=0,
                                                 interpolation_samples=0,
                                                 fill_value=stream_add.data,
                                                 sanity_checks=True)
                total_s_trace = zero_trace.__add__(S_trace,
                                                   method=0,
                                                   interpolation_samples=0,
                                                   fill_value=S_trace.data,
                                                   sanity_checks=True)
                total_p_trace = zero_trace.__add__(P_trace,
                                                   method=0,
                                                   interpolation_samples=0,
                                                   fill_value=P_trace.data,
                                                   sanity_checks=True)
                p_stream.append(total_p_trace)
            s_stream.append(total_s_trace)
            total_stream.append(total_trace)
            s_stream = self.BW_filter(s_stream)
            p_stream = self.BW_filter(p_stream)
            total_stream = self.BW_filter(total_stream)
        return total_stream, p_stream, s_stream, start_time_p, start_time_s
Example #3
0
    def get_window_split_syn(self, splitted_syn, epi, depth, time_at_receiver,
                             npts):
        tt_P = self.get_P(
            epi, depth
        )  # Estimated P-wave arrival, based on the known velocity model
        tt_S = self.get_S(
            epi, depth
        )  # Estimated S-wave arrival, based on the known velocity model

        diff = tt_S - tt_P

        P_start = time_at_receiver
        P_end = obspy.UTCDateTime(P_start + 5 + 20)
        S_start = obspy.UTCDateTime(time_at_receiver.timestamp + diff)
        S_end = obspy.UTCDateTime(S_start + 5 + 20)

        p_stream = Stream()
        s_stream = Stream()
        total_stream = Stream()

        for i, trace in enumerate(splitted_syn.traces):
            P_trace = Trace.slice(trace, P_start, P_end)
            S_trace = Trace.slice(trace, S_start, S_end)
            stream_add = P_trace.__add__(S_trace,
                                         fill_value=0,
                                         sanity_checks=True)
            zero_trace = Trace(np.zeros(npts),
                               header={
                                   "starttime": P_start,
                                   'delta': trace.meta.delta,
                                   "station": trace.meta.station,
                                   "network": trace.meta.network,
                                   "location": trace.meta.location,
                                   "channel": trace.meta.channel,
                                   "instaseis": trace.meta.instaseis
                               })
            if 'T' in trace.meta.channel:
                total_trace = zero_trace.__add__(S_trace,
                                                 method=0,
                                                 interpolation_samples=0,
                                                 fill_value=S_trace.data,
                                                 sanity_checks=True)
                total_s_trace = total_trace.copy()
            else:
                total_trace = zero_trace.__add__(stream_add,
                                                 method=0,
                                                 interpolation_samples=0,
                                                 fill_value=stream_add.data,
                                                 sanity_checks=True)
                total_s_trace = zero_trace.__add__(S_trace,
                                                   method=0,
                                                   interpolation_samples=0,
                                                   fill_value=S_trace.data,
                                                   sanity_checks=True)
                total_p_trace = zero_trace.__add__(P_trace,
                                                   method=0,
                                                   interpolation_samples=0,
                                                   fill_value=P_trace.data,
                                                   sanity_checks=True)
                p_stream.append(total_p_trace)
            s_stream.append(total_s_trace)
            total_stream.append(total_trace)
        return total_stream, p_stream, s_stream
    def get_bw(self, time_at_rec, epi, depth, npts_trace):
        gf = self.db.get_greens_function(epicentral_distance_in_degree=epi,
                                         source_depth_in_m=depth,
                                         origin_time=time_at_rec,
                                         kind=self.par['kind'],
                                         kernelwidth=self.par['kernelwidth'],
                                         definition=self.par['definition'])
        tt_P = self.window.get_P(epi, depth)
        tt_S = self.window.get_S(epi, depth)
        p_time = time_at_rec.timestamp + tt_P
        s_time = time_at_rec.timestamp + tt_S
        start_time_p = obspy.UTCDateTime(p_time - 10)
        start_time_s = obspy.UTCDateTime(s_time - 10)
        end_time_p = obspy.UTCDateTime(p_time + 44.2)
        end_time_s = obspy.UTCDateTime(s_time + 44.2)

        format_gf = Stream()
        for i in range(len(gf.traces)):
            if i == 0 or i == 3:
                stream_add = Trace.slice(gf.traces[i], start_time_s,
                                         end_time_s)
            else:
                P_trace = Trace.slice(gf.traces[i], start_time_p, end_time_p)
                S_trace = Trace.slice(gf.traces[i], start_time_s, end_time_s)
                stream_add = P_trace.__add__(S_trace,
                                             fill_value=0,
                                             sanity_checks=True)
            zero_trace = Trace(np.zeros(npts_trace),
                               header={
                                   "starttime": start_time_p,
                                   'delta': gf.traces[0].meta.delta,
                                   'definition': self.par['definition'],
                                   'kernelwidth': self.par['kernelwidth'],
                                   'kind': self.par['kind'],
                                   "instaseis": gf.traces[0].meta.instaseis,
                                   'channel': gf.traces[i].id
                               })
            filled_trace = zero_trace.__add__(stream_add,
                                              method=0,
                                              interpolation_samples=0,
                                              fill_value=stream_add.data,
                                              sanity_checks=False)
            format_gf.append(filled_trace)

        tss = format_gf.traces[0].data
        zss = format_gf.traces[1].data
        rss = format_gf.traces[2].data
        tds = format_gf.traces[3].data
        zds = format_gf.traces[4].data
        rds = format_gf.traces[5].data
        zdd = format_gf.traces[6].data
        rdd = format_gf.traces[7].data
        zep = format_gf.traces[8].data
        rep = format_gf.traces[9].data

        G_z = np.ones((npts_trace, 5))
        G_r = np.ones((npts_trace, 5))
        G_t = np.ones((npts_trace, 5))

        G_z[:, 0] = zss * (0.5) * np.cos(
            2 * np.deg2rad(self.par['az'])) - zdd * 0.5
        G_z[:, 1] = -zdd * 0.5 - zss * (0.5) * np.cos(
            2 * np.deg2rad(self.par['az']))
        # _z G[0:G_z, 1] =  zdd * (1/3) + zep * (1/3)
        G_z[:, 2] = zss * np.sin(2 * np.deg2rad(self.par['az']))
        G_z[:, 3] = -zds * np.cos(np.deg2rad(self.par['az']))
        G_z[:, 4] = -zds * np.sin(np.deg2rad(self.par['az']))

        G_r[:, 0] = rss * (0.5) * np.cos(
            2 * np.deg2rad(self.par['az'])) - rdd * 0.5
        G_r[:, 1] = -0.5 * rdd - rss * (0.5) * np.cos(
            2 * np.deg2rad(self.par['az']))
        # _r G[G_z:G_r, 1] =  rdd * (1/3) + rep * (1/3)
        G_r[:, 2] = rss * np.sin(2 * np.deg2rad(self.par['az']))
        G_r[:, 3] = -rds * np.cos(np.deg2rad(self.par['az']))
        G_r[:, 4] = -rds * np.sin(np.deg2rad(self.par['az']))

        G_t[:, 0] = -tss * (0.5) * np.sin(2 * np.deg2rad(self.par['az']))
        G_t[:, 1] = tss * (0.5) * np.sin(2 * np.deg2rad(self.par['az']))
        # _t G[G_r:G_t, 1] =   0
        G_t[:, 2] = tss * np.cos(2 * np.deg2rad(self.par['az']))
        G_t[:, 3] = tds * np.sin(np.deg2rad(self.par['az']))
        G_t[:, 4] = -tds * np.cos(np.deg2rad(self.par['az']))

        G_tot = np.vstack((np.vstack((G_z, G_r)), G_t))

        return G_tot, G_z, G_r, G_t
    def get_window_obspy(self, seis_traces, epi, depth, time, npts):
        self.origin = seis_traces
        tt_P = self.get_P(
            epi, depth
        )  # Estimated P-wave arrival, based on the known velocity model
        tt_S = self.get_S(
            epi, depth
        )  # Estimated S-wave arrival, based on the known velocity model
        sec_per_sample = 1 / (seis_traces[0].meta.sampling_rate)
        #
        self.BW_stream = Stream()
        self.S_stream = Stream()
        self.P_stream = Stream()
        p_time = time.timestamp + tt_P
        s_time = time.timestamp + tt_S
        self.start_P = obspy.UTCDateTime(p_time - 5)
        self.start_S = obspy.UTCDateTime(s_time - 15)
        self.or_S_len = int(
            (self.start_S - time) / seis_traces.traces[0].stats.delta)
        self.or_P_len = int(
            (self.start_P - time) / seis_traces.traces[0].stats.delta)
        end_time_p = obspy.UTCDateTime(p_time + 20)
        end_time_s = obspy.UTCDateTime(s_time + 35)

        for i, trace in enumerate(seis_traces.traces):
            P_trace = Trace.slice(trace, self.start_P, end_time_p)
            self.P_len = len(P_trace)
            S_trace = Trace.slice(trace, self.start_S, end_time_s)
            self.S_len = len(S_trace)
            stream_add = P_trace.__add__(S_trace,
                                         fill_value=0,
                                         sanity_checks=True)
            zero_trace = Trace(np.zeros(npts),
                               header={
                                   "starttime": self.start_P,
                                   'delta': trace.meta.delta,
                                   "station": trace.meta.station,
                                   "network": trace.meta.network,
                                   "location": trace.meta.location,
                                   "channel": trace.meta.channel
                               })
            if 'T' in trace.meta.channel:
                total_trace = zero_trace.__add__(S_trace,
                                                 method=0,
                                                 interpolation_samples=0,
                                                 fill_value=S_trace.data,
                                                 sanity_checks=True)
                total_s_trace = total_trace.copy()
            else:
                total_trace = zero_trace.__add__(stream_add,
                                                 method=0,
                                                 interpolation_samples=0,
                                                 fill_value=stream_add.data,
                                                 sanity_checks=True)
                total_s_trace = zero_trace.__add__(S_trace,
                                                   method=0,
                                                   interpolation_samples=0,
                                                   fill_value=S_trace.data,
                                                   sanity_checks=True)
                total_p_trace = zero_trace.__add__(P_trace,
                                                   method=0,
                                                   interpolation_samples=0,
                                                   fill_value=P_trace.data,
                                                   sanity_checks=True)
                self.P_stream.append(total_p_trace)
            self.S_stream.append(total_s_trace)
            self.BW_stream.append(total_trace)
            self.S_stream = self.BW_filter(self.S_stream)
            self.P_stream = self.BW_filter(self.P_stream)
            self.BW_stream = self.BW_filter(self.BW_stream)
Example #6
0
    def get_window_obspy(self, seis_traces, epi, depth, or_time, npts):
        tt_P = self.get_P(
            epi, depth
        )  # Estimated P-wave arrival, based on the known velocity model
        tt_S = self.get_S(
            epi, depth
        )  # Estimated S-wave arrival, based on the known velocity model
        sec_per_sample = 1 / (seis_traces[0].meta.sampling_rate)

        total_stream = Stream()
        s_stream = Stream()
        p_stream = Stream()

        p_time = or_time.timestamp + tt_P
        s_time = or_time.timestamp + tt_S
        start_time_p = obspy.UTCDateTime(
            p_time - 5)  # -10 , + 44.2 --> PAPER: STAHLER & SIGLOCH
        end_time_p = obspy.UTCDateTime(p_time + 20)
        start_time_s = obspy.UTCDateTime(s_time - 15)
        end_time_s = obspy.UTCDateTime(s_time + 35)

        for i, trace in enumerate(seis_traces.traces):
            P_trace = Trace.slice(trace, start_time_p, end_time_p)
            # P_trace.detrend(type='demean')
            S_trace = Trace.slice(trace, start_time_s, end_time_s)
            # S_trace.detrend(type='demean')
            stream_add = P_trace.__add__(S_trace,
                                         fill_value=0,
                                         sanity_checks=True)
            zero_trace = Trace(np.zeros(npts),
                               header={
                                   "starttime": start_time_p,
                                   'delta': trace.meta.delta,
                                   "station": trace.meta.station,
                                   "network": trace.meta.network,
                                   "location": trace.meta.location,
                                   "channel": trace.meta.channel
                               })
            if 'T' in trace.meta.channel:
                total_trace = zero_trace.__add__(S_trace,
                                                 method=0,
                                                 interpolation_samples=0,
                                                 fill_value=S_trace.data,
                                                 sanity_checks=True)
                total_s_trace = total_trace.copy()
            else:
                total_trace = zero_trace.__add__(stream_add,
                                                 method=0,
                                                 interpolation_samples=0,
                                                 fill_value=stream_add.data,
                                                 sanity_checks=True)
                total_s_trace = zero_trace.__add__(S_trace,
                                                   method=0,
                                                   interpolation_samples=0,
                                                   fill_value=S_trace.data,
                                                   sanity_checks=True)
                total_p_trace = zero_trace.__add__(P_trace,
                                                   method=0,
                                                   interpolation_samples=0,
                                                   fill_value=P_trace.data,
                                                   sanity_checks=True)
                p_stream.append(total_p_trace)
            s_stream.append(total_s_trace)
            total_stream.append(total_trace)
            s_stream = self.BW_filter(s_stream)
            p_stream = self.BW_filter(p_stream)
            total_stream = self.BW_filter(total_stream)
        return total_stream, p_stream, s_stream, start_time_p, start_time_s