def test_resp(self): """ Tests resp Web service interface. Examples are inspired by https://service.iris.edu/irisws/resp/1/. """ client = Client() # 1 t1 = UTCDateTime("2005-001T00:00:00") t2 = UTCDateTime("2008-001T00:00:00") result = client.resp("IU", "ANMO", "00", "BHZ", t1, t2) self.assertIn(b'B050F03 Station: ANMO', result) # Exception: No response data available # 2 - empty location code # result = client.resp("UW", "LON", "", "EHZ") # self.assertIn(b'B050F03 Station: LON', result) # self.assertIn(b'B052F03 Location: ??', result) # 3 - empty location code via '--' # result = client.resp("UW", "LON", "--", "EHZ") # self.assertIn(b'B050F03 Station: LON', result) # self.assertIn(b'B052F03 Location: ??', result) # 4 dt = UTCDateTime("2010-02-27T06:30:00.000") result = client.resp("IU", "ANMO", "*", "*", dt) self.assertIn(b'B050F03 Station: ANMO', result) dt = UTCDateTime("2005-001T00:00:00") result = client.resp("AK", "RIDG", "--", "LH?", dt) self.assertIn(b'B050F03 Station: RIDG', result)
def test_sim_WA(self): """Test feeding both PAZ and seedresp.""" t1 = UTCDateTime("2010-09-3T16:30:00.000") t2 = UTCDateTime("2010-09-3T17:00:00.000") fdsn_client = Client('IRIS') st = fdsn_client.get_waveforms( network='NZ', station='BFZ', location='10', channel='HHZ', starttime=t1, endtime=t2, attach_response=True) tr = st[0] PAZ = {'poles': [-4.440 + 4.440j, -4.440 - 4.440j, -1.083 + 0.0j], 'zeros': [0.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0], 'sensitivity': 0.4, 'gain': 60077000.0} tr_safe = tr.copy() # Test with PAZ _sim_WA(trace=tr, PAZ=PAZ, seedresp=None, water_level=10) tr = tr_safe.copy() # Test without PAZ or seedresp _sim_WA(trace=tr, PAZ=None, seedresp=None, water_level=10) tr = tr_safe.copy() with NamedTemporaryFile() as tf: respf = tf.name old_iris_client = OldIris_Client() # fetch RESP information from "old" IRIS web service, see # obspy.fdsn for accessing the new IRIS FDSN web services old_iris_client.resp('NZ', 'BFZ', '10', 'HHZ', t1, t2, filename=respf) date = t1 seedresp = { 'filename': respf, 'date': date, 'network': tr.stats.network, 'station': tr.stats.station, 'channel': tr.stats.channel, 'location': tr.stats.location, 'units': 'DIS' } _sim_WA(trace=tr, PAZ=None, seedresp=seedresp, water_level=10)
def test_sim_WA(self): """Test feeding both PAZ and seedresp.""" from eqcorrscan.utils.mag_calc import _sim_WA from obspy.core.util import NamedTemporaryFile from obspy import UTCDateTime from obspy.clients.fdsn import Client from obspy.clients.iris import Client as OldIris_Client t1 = UTCDateTime("2010-09-3T16:30:00.000") t2 = UTCDateTime("2010-09-3T17:00:00.000") fdsn_client = Client('IRIS') st = fdsn_client.get_waveforms(network='NZ', station='BFZ', location='10', channel='HHZ', starttime=t1, endtime=t2, attach_response=True) tr = st[0] PAZ = {'poles': [-4.440 + 4.440j, -4.440 - 4.440j, -1.083 + 0.0j], 'zeros': [0.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0], 'sensitivity': 0.4, 'gain': 60077000.0} tr_safe = tr.copy() # Test with PAZ _sim_WA(trace=tr, PAZ=PAZ, seedresp=None, water_level=10) tr = tr_safe.copy() # Test without PAZ or seedresp _sim_WA(trace=tr, PAZ=None, seedresp=None, water_level=10) tr = tr_safe.copy() with NamedTemporaryFile() as tf: respf = tf.name old_iris_client = OldIris_Client() # fetch RESP information from "old" IRIS web service, see obspy.fdsn # for accessing the new IRIS FDSN web services old_iris_client.resp('NZ', 'BFZ', '10', 'HHZ', t1, t2, filename=respf) date = t1 seedresp = {'filename': respf, # RESP filename 'date': date, 'network': tr.stats.network, 'station': tr.stats.station, 'channel': tr.stats.channel, 'location': tr.stats.location, # Units to return response in ('DIS', 'VEL' or ACC) 'units': 'DIS' } _sim_WA(trace=tr, PAZ=None, seedresp=seedresp, water_level=10)
def test_resp(self): """ Tests resp Web service interface. Examples are inspired by https://service.iris.edu/irisws/resp/1/. """ client = Client() # 1 t1 = UTCDateTime("2005-001T00:00:00") t2 = UTCDateTime("2008-001T00:00:00") result = client.resp("IU", "ANMO", "00", "BHZ", t1, t2) self.assertIn(b'B050F03 Station: ANMO', result) # 2 - empty location code result = client.resp("UW", "LON", "", "EHZ") self.assertIn(b'B050F03 Station: LON', result) self.assertIn(b'B052F03 Location: ??', result) # 3 - empty location code via '--' result = client.resp("UW", "LON", "--", "EHZ") self.assertIn(b'B050F03 Station: LON', result) self.assertIn(b'B052F03 Location: ??', result) # 4 dt = UTCDateTime("2010-02-27T06:30:00.000") result = client.resp("IU", "ANMO", "*", "*", dt) self.assertIn(b'B050F03 Station: ANMO', result)
def test_resp(self): """ Tests resp Web service interface. Examples are inspired by http://www.iris.edu/ws/resp/. """ client = Client() # 1 t1 = UTCDateTime("2005-001T00:00:00") t2 = UTCDateTime("2008-001T00:00:00") result = client.resp("IU", "ANMO", "00", "BHZ", t1, t2) self.assertIn(b'B050F03 Station: ANMO', result) # 2 - empty location code result = client.resp("UW", "LON", "", "EHZ") self.assertIn(b'B050F03 Station: LON', result) self.assertIn(b'B052F03 Location: ??', result) # 3 - empty location code via '--' result = client.resp("UW", "LON", "--", "EHZ") self.assertIn(b'B050F03 Station: LON', result) self.assertIn(b'B052F03 Location: ??', result) # 4 dt = UTCDateTime("2010-02-27T06:30:00.000") result = client.resp("IU", "ANMO", "*", "*", dt) self.assertIn(b'B050F03 Station: ANMO', result)
def download_response(network, station, location, channel, start, end, respfile): ''' Download instrument response file from IRIS and save to .resp Input: network: String with network name station: String with station name location: String with location - can have * for wildcards channel: String with channel - can have * for wildcards start: String with start date and time: yyy-mm-ddThh:mm.sss end: String with end date and time: yyy-mm-ddThh:mm.sss Output: respfile: Prints instrument response to respfile ''' from obspy.clients.iris import Client from obspy import UTCDateTime # Set up client client = Client() # Define start and end date for resp file startdt = UTCDateTime(start) enddt = UTCDateTime(end) # Download resp data dlstring = 'downloading resp data for network ' + network + ', station ' \ + station + ', location and channel ' + location + ' ' + channel \ + ', \n for time ' + start + ' to ' + end print dlstring respdata = client.resp(network, station, location, channel, starttime=startdt, endtime=enddt) # Save to file: respf = open(respfile, 'w') respf.write(respdata) respf.close() # Print statement: print 'Saved resp to file ' + respfile
# MW 7.1 Darfield earthquake, New Zealand t1 = obspy.UTCDateTime("2010-09-3T16:30:00.000") t2 = obspy.UTCDateTime("2010-09-3T17:00:00.000") # Fetch waveform from IRIS FDSN web service into a ObsPy stream object fdsn_client = FDSN_Client("IRIS") st = fdsn_client.get_waveforms('NZ', 'BFZ', '10', 'HHZ', t1, t2) # Download and save instrument response file into a temporary file with NamedTemporaryFile() as tf: respf = tf.name old_iris_client = OldIris_Client() # fetch RESP information from "old" IRIS web service, see obspy.fdsn # for accessing the new IRIS FDSN web services old_iris_client.resp('NZ', 'BFZ', '10', 'HHZ', t1, t2, filename=respf) # make a copy to keep our original data st_orig = st.copy() # define a filter band to prevent amplifying noise during the deconvolution pre_filt = (0.005, 0.006, 30.0, 35.0) # this can be the date of your raw data or any date for which the # SEED RESP-file is valid date = t1 seedresp = {'filename': respf, # RESP filename # when using Trace/Stream.simulate() the "date" parameter can # also be omitted, and the starttime of the trace is then used. 'date': date,
def test_sim_WA(self): """Test feeding both PAZ and seedresp.""" t1 = UTCDateTime("2010-09-3T16:30:00.000") t2 = UTCDateTime("2010-09-3T17:00:00.000") fdsn_client = Client('IRIS') st = fdsn_client.get_waveforms(network='NZ', station='BFZ', location='10', channel='HHZ', starttime=t1, endtime=t2, attach_response=True) tr = st[0] PAZ = { 'poles': [-4.440 + 4.440j, -4.440 - 4.440j, -1.083 + 0.0j], 'zeros': [0.0 + 0.0j, 0.0 + 0.0j, 0.0 + 0.0], 'sensitivity': 0.4, 'gain': 60077000.0 } tr_safe = tr.copy() # Test with PAZ _sim_WA(trace=tr, PAZ=PAZ, seedresp=None, water_level=10) tr = tr_safe.copy() # Test without PAZ or seedresp _sim_WA(trace=tr, PAZ=None, seedresp=None, water_level=10) tr = tr_safe.copy() with open("Temp_resp", "w") as tf: respf = tf.name old_iris_client = OldIris_Client() # fetch RESP information from "old" IRIS web service, see # obspy.fdsn for accessing the new IRIS FDSN web services old_iris_client.resp('NZ', 'BFZ', '10', 'HHZ', t1, t2, filename=respf) # Hack around unit issues with open("Temp_resp", "r") as tf: resp_contents = [line for line in tf] corrected_contents = [] for line in resp_contents: if "COUNT" in line: line = line.replace("COUNT", "COUNTS") corrected_contents.append(line) with open("Temp_resp", "w") as tf: for line in corrected_contents: tf.write(line) date = t1 seedresp = { 'filename': respf, 'date': date, 'network': tr.stats.network, 'station': tr.stats.station, 'channel': tr.stats.channel, 'location': tr.stats.location, 'units': 'DIS' } _sim_WA(trace=tr, PAZ=None, seedresp=seedresp, water_level=10) os.remove(respf)
# MW 7.1 Darfield earthquake, New Zealand t1 = obspy.UTCDateTime("2010-09-3T16:30:00.000") t2 = obspy.UTCDateTime("2010-09-3T17:00:00.000") # Fetch waveform from IRIS FDSN web service into a ObsPy stream object fdsn_client = FDSN_Client("IRIS") st = fdsn_client.get_waveforms('NZ', 'BFZ', '10', 'HHZ', t1, t2) # Download and save instrument response file into a temporary file with NamedTemporaryFile() as tf: respf = tf.name old_iris_client = OldIris_Client() # fetch RESP information from "old" IRIS web service, see obspy.fdsn # for accessing the new IRIS FDSN web services old_iris_client.resp('NZ', 'BFZ', '10', 'HHZ', t1, t2, filename=respf) # make a copy to keep our original data st_orig = st.copy() # define a filter band to prevent amplifying noise during the deconvolution pre_filt = (0.005, 0.006, 30.0, 35.0) # this can be the date of your raw data or any date for which the # SEED RESP-file is valid date = t1 seedresp = { 'filename': respf, # RESP filename # when using Trace/Stream.simulate() the "date" parameter can # also be omitted, and the starttime of the trace is then used.