def download_event_waveforms( self, time_before_origin: float, time_after_origin: float, path: str = EVENT_WAVEFORM_PATH_STRUCTURE, ) -> None: """ Download waveforms corresponding to events in waveforms from client. Parameters ---------- time_before_origin The number of seconds before the reported origin to include in the event waveforms time_after_origin The number of seconds after the reported origin to include in the event waveforms path A string that specifies the directory structure. See the path_structure argument of :class: `~obsplus.Sbank` for more info. """ # setup banks and fetcher bank = WaveBank(path) # iter events and save to disk t1, t2 = time_before_origin, time_after_origin for event_id, stream in self.yield_event_waveforms(t1, t2): bank.put_waveforms(stream, name=event_id)
def download_waveforms( self, starttime: UTCDateTime, endtime: UTCDateTime, duration: float, overlap: float = 0, path: str = WAVEFORM_STRUCTURE, ) -> None: """ Download contiguous waveform data and save in directory. Parameters ---------- starttime The start time of the data to download endtime The end time of the data to download duration The duration of each chunk of data in seconds overlap The overlap, added to the end of each waveforms, for the data path A string that specifies the directory structure. See the path_structure argument of :class: `~obsplus.Sbank` for more info """ bank = WaveBank(path) # iter events and save to disk t1, t2 = starttime, endtime for stream in self.yield_waveforms(t1, t2, duration, overlap): bank.put_waveforms(stream)
def test_empty_bank_raises(self, tmpdir): """ Test that an empty bank can be inited, but that an error is raised when trying to read its index. """ path = Path(tmpdir) / "new" bank = WaveBank(path) # test that touching the index/meta data raises with pytest.raises(BankDoesNotExistError): bank.read_index() bank.put_waveforms(obspy.read()) assert len(bank.read_index()) == 3
def test_put_waveforms_to_crandall_copy(self, tmpdir): """ ran into issue in docs where putting data into the crandall copy didn't work. """ ds = obsplus.datasets.utils.copy_dataset(dataset="crandall", destination=Path(tmpdir)) bank = WaveBank(ds.waveform_client) bank.read_index() # this sets cache st = obspy.read() bank.put_waveforms(st) bank.update_index() df = bank.read_index(station="RJOB") assert len(df) == len(st) assert set(df.station) == {"RJOB"}