Exemplo n.º 1
0
 def test_input_from_df(self, bing_pick_bulk, bingham_stream,
                        bingham_dataset):
     """ Ensure bulk can be formed from a dataframe. """
     st_client = bingham_dataset.waveform_client
     st_list = stream_bulk_split(bingham_stream, bing_pick_bulk)
     for st1, (_, ser) in zip(st_list, bing_pick_bulk.iterrows()):
         st2 = st_client.get_waveforms(*ser.to_list())
         assert_streams_almost_equal(st1, st2, allow_off_by_one=True)
Exemplo n.º 2
0
 def test_basic_stats_different(self, streams):
     """Ensure when basic stats are different streams are not almost equal."""
     st1, st2 = streams
     for tr in st1:
         tr.stats.station = "bob"
     with pytest.raises(AssertionError):
         assert_streams_almost_equal(st1, st2)
     with pytest.raises(AssertionError):
         assert_streams_almost_equal(st1, st2, basic_stats=False)
Exemplo n.º 3
0
 def test_processing_different(self, streams):
     """If processing of stats is different streams should be equal."""
     st1, st2 = streams
     st1.detrend("linear").detrend("linear")
     st2.detrend("linear")
     # This should not raise
     assert_streams_almost_equal(st1, st2)
     # but this should
     with pytest.raises(AssertionError):
         assert_streams_almost_equal(st1, st2, basic_stats=False)
Exemplo n.º 4
0
 def test_off_by_one_case1(self, bingham_dataset, bingham_stream):
     """coincidental off by one test case"""
     bank = bingham_dataset.waveform_client
     # get query parameters (these were found by accident)
     t1 = obspy.UTCDateTime(2013, 4, 11, 4, 58, 50, 259000)
     t2 = obspy.UTCDateTime(2013, 4, 11, 4, 58, 58, 281000)
     params = ["UU", "NOQ", "01", "HHN", t1, t2]
     # get waveforms from the wavebank and the streams
     st1 = bank.get_waveforms(*params)
     st2 = bingham_stream.get_waveforms(*params)
     # this should not raise
     assert_streams_almost_equal(st1, st2, allow_off_by_one=True)
Exemplo n.º 5
0
 def test_off_by_one(self):
     """Tests for allowing off by one errors"""
     st1 = obspy.read()
     # shorten each stream by 1
     st2 = obspy.read()
     for tr in st2:
         tr.data = tr.data[:-1]
     # off by one should make this not raise
     assert_streams_almost_equal(st1, st2, allow_off_by_one=True)
     # but without it it should raise
     with pytest.raises(AssertionError):
         assert_streams_almost_equal(st1, st2, allow_off_by_one=False)
Exemplo n.º 6
0
 def test_only_p_phases(self, event_dict_p, subbing_fetcher_with_processor):
     """make sure only stations that have p picks are returned"""
     stream = subbing_fetcher_with_processor.waveform_client.get_waveforms()
     df = subbing_fetcher_with_processor.picks_df
     for eve_id, st in event_dict_p.items():
         con1 = df["event_id"] == eve_id
         con2 = df["phase_hint"].str.upper() == "P"
         pick_df = df[con1 & con2]
         # iterate each pick, determine if it has data in the bank
         for ind, row in pick_df.iterrows():
             time = to_utc(row["time"])
             kwargs = dict(
                 starttime=time - self.time_before,
                 endtime=time + self.time_after,
                 station=row["station"],
             )
             st1 = stream.get_waveforms(**kwargs)
             st2 = st.get_waveforms(**kwargs)
             assert_streams_almost_equal(st1, st2, allow_off_by_one=True)
Exemplo n.º 7
0
 def test_no_params(self):
     """ No params should return a copy of stream. """
     st = obspy.read()
     assert_streams_almost_equal(st, st.get_waveforms())
Exemplo n.º 8
0
 def test_unequal_len(self, streams):
     """Traces are not equal if the number of traces is not equal."""
     st1, st2 = streams
     st2.traces = st2.traces[:-1]
     with pytest.raises(AssertionError):
         assert_streams_almost_equal(st1, st2)