コード例 #1
0
ファイル: crandall_test.py プロジェクト: niosh-mining/obsplus
 def _download_crandall(self):
     """download waveform/station info for dataset."""
     bank = WaveBank(self.waveform_path)
     domain = CircularDomain(
         self.latitude,
         self.longitude,
         minradius=0,
         maxradius=kilometers2degrees(self.max_dist),
     )
     cat = obspy.read_events(str(self.source_path / "events.xml"))
     df = events_to_df(cat)
     for _, row in df.iterrows():
         starttime = row.time - self.time_before
         endtime = row.time + self.time_after
         restrictions = Restrictions(
             starttime=UTC(starttime),
             endtime=UTC(endtime),
             minimum_length=0.90,
             minimum_interstation_distance_in_m=100,
             channel_priorities=["HH[ZNE]", "BH[ZNE]"],
             location_priorities=["", "00", "01", "--"],
         )
         kwargs = dict(
             domain=domain,
             restrictions=restrictions,
             mseed_storage=str(self.waveform_path),
             stationxml_storage=str(self.station_path),
         )
         MassDownloader(providers=[self._download_client]).download(
             **kwargs)
         # ensure data have actually been downloaded
         bank.update_index()
         assert not bank.read_index(starttime=starttime,
                                    endtime=endtime).empty
コード例 #2
0
ファイル: wavecache.py プロジェクト: niowniow/obsplus
 def __init__(self, waveform_client: obsplus.WaveBank):
     assert hasattr(waveform_client, "read_index")
     # dicts that will be used as caches for processed/unprocessed streams
     self._stream_cache = {}
     self._processed_cache = {}
     # list of callables that should take a single waveforms and return
     self._stream_processors = defaultdict(list)
     # load all of the bank index into memory
     self.bank = waveform_client
     self.index = waveform_client.read_index()
     # make a column of callables for getting waveforms
     self.index["st_call"] = self.index.apply(self._make_st_calls, axis=1)
     # get a column that identifies rows that have the same resource
     self.index.rename(columns={"path": "unique_key"}, inplace=True)