def test_can_put_to_empty_bank(self, tmpdir):
     """ An empty bank should be init'able created when an event is
     put into it """
     path = Path(tmpdir) / "new_bank"
     bank = EventBank(path)
     assert not path.exists()
     cat = obspy.read_events()
     bank.put_events(cat)
     assert path.exists()
     assert len(bank.read_index()) == 3
Esempio n. 2
0
def ebank_with_bad_files(tmpdir):
    """
    Create an event bank with bad files, ensure it doesn't choke indexer.
    """
    bank = EventBank(Path(tmpdir))
    cat = obspy.read_events()
    bank.put_events(cat)
    # add stream file
    st = obspy.read()
    stream_path = Path(bank.bank_path)
    st.write(str(stream_path / "not_an_event.xml"), "mseed")
    bank = EventBank(stream_path)
    # should issue warning
    with pytest.warns(UserWarning):
        bank.update_index()
    return bank
Esempio n. 3
0
 def test_from_path(self, tmpdir):
     """Put events should work with a path to a directory of events."""
     cat = obspy.read_events()
     event_path = Path(tmpdir) / "events.xml"
     bank1 = EventBank(event_path.parent / "catalog_dir1")
     bank2 = EventBank(event_path.parent / "catalog_dir2")
     # a slightly invalid uri is used, just ignore
     with suppress_warnings():
         cat.write(str(event_path), "quakeml")
     # test works with a Path instance
     bank1.put_events(event_path)
     assert Path(bank1.bank_path).exists()
     assert not bank1.read_index().empty
     # tests with a string
     bank2.put_events(str(event_path))
     assert Path(bank2.bank_path).exists()
     assert not bank2.read_index().empty
Esempio n. 4
0
def dateline_eventbank(dateline_catalog, tmp_path):
    """Add the dateline catalog to a temporary path."""
    ebank = EventBank(tmp_path)
    ebank.put_events(dateline_catalog)
    return ebank