def crandall_data_array(crandall_fetcher): """ return a data array (with attached picks) of crandall dataset. """ cat = crandall_fetcher.event_client.get_events() st_dict = crandall_fetcher.get_event_waveforms(10, 50) dar = obsplus.obspy_to_array_dict(st_dict)[40] dar.ops.attach_events(cat) return dar
def test_one_trace(self): """ ensure a single trace is valid input """ tr = obspy.read()[0] out = obspy_to_array_dict(tr) assert isinstance(out, dict) assert len(out) and 100 in out dar = out[100] assert max(dar.values.shape) == len(tr.data)
def array_dict_different_sr(self): """ return a data_array dict made from a waveforms with different sample rates""" st = obspy.read() out = {} for num, tr in enumerate(st): new_sr = num * tr.stats.sampling_rate + 100 tr.stats["sampling_rate"] = new_sr out[num] = obspy.Stream(traces=[tr]) return obspy_to_array_dict(out)
def test_crandall_arrays(self): """ Ensure the crandall canyon arrays can be converted back """ # create data arrays from crandall ds = obsplus.load_dataset("crandall") fetcher = ds.get_fetcher() st_dict = dict(fetcher.yield_event_waveforms(10, 50)) dars = list(obsplus.obspy_to_array_dict(st_dict).values()) assert len(dars), "only expected two sampling rates" # convert each data array back to a stream dict st_dict1 = dars[0].ops.to_stream() st_dict2 = dars[1].ops.to_stream() # create stream dicts and recombine data array dicts for stream_id in set(st_dict1) & set(st_dict2): st1 = st_dict1[stream_id] + st_dict2[stream_id] st2 = st_dict[stream_id] if not self.equal_without_processing(st1, st2): self.equal_without_processing(st1, st2)
def array_dict_from_trace(self): """ create an array dict from a trace """ return obspy_to_array_dict({1: obspy.read()[0]})
def array_dict_from_trace_dict(self): """ create an array dict from a trace dict """ st = obspy.read() return obspy_to_array_dict({tr.id: tr for tr in st})
def array_dict_from_stream_dict(self, stream_dict): out = dict(stream_dict) out["new"] = obspy.read()[0] # add a trace to waveforms dict return obspy_to_array_dict(stream_dict)
def default_array_dict_from_stream(self): """ return the default waveforms converted to an array dict """ return obspy_to_array_dict(obspy.read())