def test_disjointed_raises(self, disjointed_stream): """ A disjointed waveforms should raise """ with pytest.raises(ValueError) as e: trim_event_stream(disjointed_stream) assert "the following waveforms is disjointed" in str(e)
def test_trim_tolerance(self, stream_with_short_end): """ Ensure a value error is raised when the difference in start or end times exceeds the supplied trim tolerance. """ with pytest.raises(ValueError) as e: trim_event_stream(stream_with_short_end[0], trim_tolerance=2.0) assert "trim tolerance" in str(e.value.args[0])
def test_fragmented_stream(self, fragmented_stream): """ test with streams that are fragmented """ with pytest.warns(UserWarning) as w: st = trim_event_stream(fragmented_stream) assert "seconds long" in str(w[0].message) stations = {tr.stats.station for tr in st} assert "BOB" not in stations
def test_trimmed(self, stream_with_short_end): """ test that the max time on the waveforms is t2 """ st, t2 = stream_with_short_end st_new = trim_event_stream(st, required_len=None) max_endtime = max([tr.stats.endtime.timestamp for tr in st_new]) assert abs(max_endtime - t2.timestamp) < 0.1
def test_empty_stream(self): """ Ensure an empty stream returns an empty stream. """ st = obspy.Stream() out = trim_event_stream(st) assert isinstance(out, obspy.Stream) assert len(out) == 0
def test_stream_with_duplicates_merged(self): """ Duplicate streams should be merged. """ st = obspy.read() + obspy.read() out = trim_event_stream(st, merge=None) assert len(out) == 3