class WavebankWrapper(AnxcorDatabase): def __init__(self, directory): super().__init__() self.bank = WaveBank( directory, name_structure='{network}.{station}.{channel}.{time}') self.bank.update_index() def get_waveforms(self, **kwargs): stream = self.bank.get_waveforms(**kwargs) traces = [] for trace in stream: data = trace.data[:-1] header = { 'delta': trace.stats.delta, 'station': trace.stats.station, 'starttime': trace.stats.starttime, 'channel': trace.stats.channel, 'network': trace.stats.network } traces.append(Trace(data, header=header)) return Stream(traces=traces) def get_stations(self): df = self.bank.get_availability_df() uptime = self.bank.get_uptime_df() def create_seed(row): network = row['network'] station = row['station'] return network + '.' + station df['seed'] = df.apply(lambda row: create_seed(row), axis=1) unique_stations = df['seed'].unique().tolist() return unique_stations
class WavebankWrapper(AnxcorDatabase): def __init__(self, directory): super().__init__() self.bank = WaveBank( directory, name_structure='{network}.{station}.{channel}.{time}') self.bank.update_index() def get_waveforms(self, **kwargs): stream = self.bank.get_waveforms(**kwargs) traces = [] for trace in stream: data = trace.data[:-1] if isinstance(data, np.ma.MaskedArray): data = np.ma.filled(data, fill_value=np.nan) if 'z' in trace.stats.channel.lower(): channel = 'z' elif 'n' in trace.stats.channel.lower(): channel = 'n' elif 'e' in trace.stats.channel.lower(): channel = 'e' header = { 'delta': trace.stats.delta, 'station': trace.stats.station, 'starttime': trace.stats.starttime, 'channel': channel, 'network': trace.stats.network } trace = Trace(data, header=header) coordinate_dict = {'latitude': 0, 'longitude': 1, 'elevation': 0} if trace.stats.station == '1': coordinate_dict['latitude'] = 50 coordinate_dict['longitude'] = 50 elif trace.stats.station == '2': coordinate_dict['latitude'] = 0 coordinate_dict['longitude'] = 50 else: coordinate_dict['latitude'] = 50 coordinate_dict['longitude'] = 0 trace.stats.coordinates = coordinate_dict traces.append(trace) return Stream(traces=traces) def get_stations(self): df = self.bank.get_availability_df() uptime = self.bank.get_uptime_df() def create_seed(row): network = row['network'] station = row['station'] return network + '.' + station df['seed'] = df.apply(lambda row: create_seed(row), axis=1) unique_stations = df['seed'].unique().tolist() return unique_stations