Exemple #1
0
 def test_traces_with_different_sampling_rates(self):
     """ traces with different sampling_rates should be left alone. """
     st1 = obspy.read()
     st2 = obspy.read()
     for tr in st2:
         tr.stats.sampling_rate = tr.stats.sampling_rate * 2
     st_in = st1 + st2
     st_out = merge_traces(st_in)
     assert st_out == st_in
Exemple #2
0
 def test_traces_with_overlap(self):
     """ Trace with overlap should be merged together. """
     st1 = obspy.read()
     st2 = obspy.read()
     for tr1, tr2 in zip(st1, st2):
         tr2.stats.starttime = tr1.stats.starttime + 10
     st_in = st1 + st2
     out = merge_traces(st_in)
     assert out == st_in.merge(1).split()
Exemple #3
0
 def test_adjacent_traces(self):
     """ Traces that are one sample away in time should be merged together. """
     # create stream with traces adjacent in time and merge together
     st1 = obspy.read()
     st2 = obspy.read()
     for tr1, tr2 in zip(st1, st2):
         tr2.stats.starttime = tr1.stats.endtime + 1.0 / tr2.stats.sampling_rate
     st_in = st1 + st2
     out = merge_traces(st_in)
     assert len(out) == 3
     # should be the same as merge and split
     assert out == st_in.merge(1).split()
Exemple #4
0
 def test_array_data_type(self):
     """ The array datatype should not change. """
     # test floats
     st1 = obspy.read()
     st2 = obspy.read()
     st_out1 = merge_traces(st1 + st2)
     for tr1, tr2 in zip(st_out1, st1):
         assert tr1.data.dtype == tr2.data.dtype
     # tests ints
     st3 = self.convert_stream_dtype(st1, np.int32)
     st4 = self.convert_stream_dtype(st1, np.int32)
     st_out2 = merge_traces(st3 + st4)
     for tr in st_out2:
         assert tr.data.dtype == np.int32
     # def test one int one float
     st_out3 = merge_traces(st1 + st3)
     for tr in st_out3:
         assert tr.data.dtype == np.float64
     # ensure order of traces doesn't mater for dtypes
     st_out4 = merge_traces(st3 + st1)
     for tr in st_out4:
         assert tr.data.dtype == np.float64
Exemple #5
0
 def _prep_output_stream(self,
                         st,
                         starttime=None,
                         endtime=None,
                         attach_response=False) -> obspy.Stream:
     """
     Prepare waveforms object for output by trimming to desired times,
     merging channels, and attaching responses.
     """
     if not len(st):
         return st
     starttime = starttime or min([x.stats.starttime for x in st])
     endtime = endtime or max([x.stats.endtime for x in st])
     # trim
     st.trim(starttime=UTCDateTime(starttime), endtime=UTCDateTime(endtime))
     if attach_response:
         st.attach_response(self.inventory)
     return merge_traces(st, inplace=True).sort()
Exemple #6
0
 def test_identical_streams(self):
     """ ensure passing identical streams performs de-duplication. """
     st = obspy.read()
     st2 = obspy.read() + st + obspy.read()
     st_out = merge_traces(st2)
     assert st_out == st