def test_timeseries(self): """ Tests timeseries Web service interface. Examples are inspired by https://service.iris.edu/irisws/timeseries/1/. """ client = Client() # 1 t1 = UTCDateTime("2005-001T00:00:00") t2 = UTCDateTime("2005-001T00:01:00") # no filter st1 = client.timeseries("IU", "ANMO", "00", "BHZ", t1, t2) # instrument corrected st2 = client.timeseries("IU", "ANMO", "00", "BHZ", t1, t2, filter=["correct"]) # compare results self.assertEqual(st1[0].stats.starttime, st2[0].stats.starttime) self.assertEqual(st1[0].stats.endtime, st2[0].stats.endtime) self.assertEqual(st1[0].data[0], 24) self.assertAlmostEqual(st2[0].data[0], -2.8373747e-06)
os.chdir('RAW') #download sac file & instrument responce if process_stage <= 2: for sta_name in sta_list: for chn_name in chn_list: #loop over sta/channels sac_name = 'SAC.' + ymd_list[0] + ymd_list[1] + ymd_list[ 2] + '.' + net_name + '.' + sta_name + '.' + chn_name pz_name = net_name + '.' + sta_name + '.pz' t0 = UTCDateTime(item["time"]) client = Client() client.timeseries(net_name, sta_name, "", chn_name, t0 - 60, t0 + 5 * 60, filename=sac_name, output='sacbb') client.sacpz(net_name, sta_name, "", chn_name, t0, filename=pz_name) if process_stage <= 3: #get station location in pz file #meanwhile delete 1 zeros, overwrite the file for sta_name in sta_list:
#from obspy.core import read from obspy.clients.iris import Client from obspy import core stat = 'AAM' # Station Code net = 'US' # Station Network ch = ['BHZ', 'BH1', 'BH2'] # Channel loc = '00' # Location # These 4 parameter identify the trace to download start = core.UTCDateTime("2017-09-19T18:14:38") end = core.UTCDateTime(start + 1800) client = Client( ) # Not sure what this does but its gets rid of the "self" error message str = core.stream.Stream() for x in range(0, 3): str += client.timeseries(network=net, station=stat, channel=ch[x], location=loc, starttime=start, endtime=end) ## Plot Traces start_plot = start + 222 #Manipulate starttime to get a nicer plot end_plot = start_plot + 960 str.plot(size=[800, 600], starttime=start_plot, endtime=end_plot, type='relative')
inv = read_inventory('NV_ONC.xml', format="STATIONXML") plotting_flag = 1 if plotting_flag == 1: from obspy.clients.iris import Client client = Client(timeout=100) from obspy import UTCDateTime import pandas as pd import matplotlib.pyplot as plt start_t = UTCDateTime("2018-01-10T03:00:00") end_t = start_t + 60 * 30 st_e = client.timeseries(network='NV', station='NC89', location=None, channel='HHE', starttime=start_t, endtime=end_t, filter=['decimate=5.0']) st_e_noresponse = st_e.remove_response(inventory=inv, output='ACC') st_e_noresponse.write('E_honduras_correct_response.dat', format='TSPAIR') st_n = client.timeseries(network='NV', station='NC89', location=None, channel='HHN', starttime=start_t, endtime=end_t, filter=['decimate=5.0']) st_n_noresponse = st_n.remove_response(inventory=inv, output='ACC') st_n_noresponse.write('N_honduras_correct_response.dat', format='TSPAIR')