def test_get_all_stations_and_nslc(self): """ Test `get_all_stations` and `get_all_nslc` methods """ # generate dummy SDS t = UTCDateTime() with TemporarySDSDirectory(year=None, doy=None, time=t) as temp_sds: client = Client(temp_sds.tempdir) expected_netsta = sorted([ (net, sta) for net in temp_sds.networks for sta in temp_sds.stations]) got_netsta = client.get_all_stations() self.assertEqual(expected_netsta, got_netsta) expected_nslc = sorted([ (net, sta, loc, cha) for net in temp_sds.networks for sta in temp_sds.stations for loc in temp_sds.locations for cha in temp_sds.channels]) got_nslc = client.get_all_nslc() self.assertEqual(expected_nslc, got_nslc) got_nslc = client.get_all_nslc(datetime=t) self.assertEqual(expected_nslc, got_nslc) # other dates that have no data should return empty list got_nslc = client.get_all_nslc(datetime=t + 2 * 24 * 3600) self.assertEqual([], got_nslc) got_nslc = client.get_all_nslc(datetime=t - 2 * 24 * 3600) self.assertEqual([], got_nslc)
import matplotlib import matplotlib.pyplot as plt from obspy.clients.filesystem.sds import Client from obspy.core import * from obspy.signal.trigger import * from mpl_toolkits import mplot3d import pandas as pd from sklearn import cluster sdsRoot = "/mnt/DATA/DATA" client = Client(sds_root=sdsRoot) client.nslc = client.get_all_nslc(sds_type="D") t = UTCDateTime("201602060356") stream = Stream() counter = 0 for net, sta, loc, chan in client.nslc: counter += 1 st = client.get_waveforms(net, sta, loc, chan, t, t + 60) try: print(net, sta, loc, chan) st.traces[0].stats.distance = counter stream += st except IndexError: pass # stream.normalize() # stream.detrend()