def test_get_paz(self): """ Test for the Client.get_paz function. As reference the EHZ channel of MANZ is taken, the result is compared to the entries of the local response file of the Bavarian network. """ # reference values zeros = [0j, 0j] poles = [ -3.700400e-02 + 3.701600e-02j, -3.700400e-02 - 3.701600e-02j, -2.513300e+02 + 0.000000e+00j, -1.310400e+02 - 4.672900e+02j, -1.310400e+02 + 4.672900e+02j ] normalization_factor = 6.0077e+07 sensitivity = 2.5168e+09 # initialize client client = Client('*****@*****.**', host='erde.geophysik.uni-muenchen.de', port=18001) # fetch poles and zeros dt = UTCDateTime(2009, 1, 1) paz = client.get_paz('BW', 'MANZ', '', 'EHZ', dt) # compare instrument self.assertEqual(normalization_factor, paz.normalization_factor) self.assertEqual(poles, paz.poles) self.assertEqual(zeros, paz.zeros) self.assertAlmostEqual(sensitivity / 1e9, paz.sensitivity / 1e9, 4) # PAZ over multiple channels should raise an exception self.assertRaises(ArcLinkException, client.get_paz, 'BW', 'MANZ', '', 'EH*', dt)
def test_getPAZ(self): """ Test for the Client.get_paz function. As reference the EHZ channel of MANZ is taken, the result is compared to the entries of the local response file of the Bavarian network. """ # reference values zeros = [0j, 0j] poles = [ -3.700400e-02 + 3.701600e-02j, -3.700400e-02 - 3.701600e-02j, -2.513300e02 + 0.000000e00j, -1.310400e02 - 4.672900e02j, -1.310400e02 + 4.672900e02j, ] normalization_factor = 6.0077e07 sensitivity = 2.5168e09 # initialize client client = Client("erde.geophysik.uni-muenchen.de", 18001, user="******") # fetch poles and zeros dt = UTCDateTime(2009, 1, 1) paz = client.get_paz("BW", "MANZ", "", "EHZ", dt) # compare instrument self.assertEqual(normalization_factor, paz.normalization_factor) self.assertEqual(poles, paz.poles) self.assertEqual(zeros, paz.zeros) self.assertAlmostEqual(sensitivity / 1e9, paz.sensitivity / 1e9, 4) # PAZ over multiple channels should raise an exception self.assertRaises(ArcLinkException, client.get_paz, "BW", "MANZ", "", "EH*", dt)
def test_getPAZ2(self): """ Test for the Client.get_paz function for erde.geophysik.uni-muenchen.de. """ poles = [-3.700400e-02 + 3.701600e-02j, -3.700400e-02 - 3.701600e-02j] dt = UTCDateTime(2009, 1, 1) client = Client("erde.geophysik.uni-muenchen.de", 18001, user="******") # fetch poles and zeros paz = client.get_paz("BW", "MANZ", "", "EHZ", dt) self.assertEqual(len(poles), 2) self.assertEqual(poles, paz["poles"][:2])
def test_get_paz2(self): """ Test for the Client.get_paz function for erde.geophysik.uni-muenchen.de. """ poles = [-3.700400e-02 + 3.701600e-02j, -3.700400e-02 - 3.701600e-02j] dt = UTCDateTime(2009, 1, 1) client = Client('*****@*****.**', host='erde.geophysik.uni-muenchen.de', port=18001) # fetch poles and zeros paz = client.get_paz('BW', 'MANZ', '', 'EHZ', dt) self.assertEqual(len(poles), 2) self.assertEqual(poles, paz['poles'][:2])
def test_srl(self): """ Tests if example in ObsPy paper submitted to the Electronic Seismologist section of SRL is still working. The test shouldn't be changed because the reference gets wrong. """ paz = { 'gain': 60077000.0, 'poles': [(-0.037004000000000002 + 0.037016j), (-0.037004000000000002 - 0.037016j), (-251.33000000000001 + 0j), (-131.03999999999999 - 467.29000000000002j), (-131.03999999999999 + 467.29000000000002j)], 'sensitivity': 2516800000.0, 'zeros': [0j, 0j] } dat1 = np.array([288, 300, 292, 285, 265, 287, 279, 250, 278, 278]) dat2 = np.array([445, 432, 425, 400, 397, 471, 426, 390, 450, 442]) # Retrieve data via ArcLink client = Client('*****@*****.**', host='webdc.eu', port=18001) t = UTCDateTime("2009-08-24 00:20:03") st = client.get_waveforms("BW", "RJOB", "", "EHZ", t, t + 30) # original but deprecated call # poles_zeros = list(client.get_paz("BW", "RJOB", "", "EHZ", # t, t+30).values())[0] poles_zeros = client.get_paz("BW", "RJOB", "", "EHZ", t) self.assertEqual(paz['gain'], poles_zeros['gain']) self.assertEqual(paz['poles'], poles_zeros['poles']) self.assertEqual(paz['sensitivity'], poles_zeros['sensitivity']) self.assertEqual(paz['zeros'], poles_zeros['zeros']) self.assertEqual('BW', st[0].stats['network']) self.assertEqual('RJOB', st[0].stats['station']) self.assertEqual(200.0, st[0].stats['sampling_rate']) self.assertEqual(6001, st[0].stats['npts']) self.assertEqual('2009-08-24T00:20:03.000000Z', str(st[0].stats['starttime'])) np.testing.assert_array_equal(dat1, st[0].data[:10]) np.testing.assert_array_equal(dat2, st[0].data[-10:])
def test_SRL(self): """ Tests if example in ObsPy paper submitted to the Electronic Seismologist section of SRL is still working. The test shouldn't be changed because the reference gets wrong. """ paz = { "gain": 60077000.0, "poles": [ (-0.037004000000000002 + 0.037016j), (-0.037004000000000002 - 0.037016j), (-251.33000000000001 + 0j), (-131.03999999999999 - 467.29000000000002j), (-131.03999999999999 + 467.29000000000002j), ], "sensitivity": 2516800000.0, "zeros": [0j, 0j], } dat1 = np.array([288, 300, 292, 285, 265, 287, 279, 250, 278, 278]) dat2 = np.array([445, 432, 425, 400, 397, 471, 426, 390, 450, 442]) # Retrieve data via ArcLink client = Client(host="webdc.eu", port=18001, user="******") t = UTCDateTime("2009-08-24 00:20:03") st = client.get_waveforms("BW", "RJOB", "", "EHZ", t, t + 30) # original but deprecated call # poles_zeros = list(client.get_paz("BW", "RJOB", "", "EHZ", # t, t+30).values())[0] poles_zeros = client.get_paz("BW", "RJOB", "", "EHZ", t) self.assertEqual(paz["gain"], poles_zeros["gain"]) self.assertEqual(paz["poles"], poles_zeros["poles"]) self.assertEqual(paz["sensitivity"], poles_zeros["sensitivity"]) self.assertEqual(paz["zeros"], poles_zeros["zeros"]) self.assertEqual("BW", st[0].stats["network"]) self.assertEqual("RJOB", st[0].stats["station"]) self.assertEqual(200.0, st[0].stats["sampling_rate"]) self.assertEqual(6001, st[0].stats["npts"]) self.assertEqual("2009-08-24T00:20:03.000000Z", str(st[0].stats["starttime"])) np.testing.assert_array_equal(dat1, st[0].data[:10]) np.testing.assert_array_equal(dat2, st[0].data[-10:])
import numpy as np import matplotlib.pyplot as plt import obspy from obspy.clients.arclink import Client from obspy.signal.invsim import corn_freq_2_paz, simulate_seismometer # Retrieve data via ArcLink # please provide a valid email address for the keyword user client = Client(user="******") t = obspy.UTCDateTime("2009-08-24 00:20:03") st = client.get_waveforms('BW', 'RJOB', '', 'EHZ', t, t + 30) paz = client.get_paz('BW', 'RJOB', '', 'EHZ', t) # 1Hz instrument one_hertz = corn_freq_2_paz(1.0) # Correct for frequency response of the instrument res = simulate_seismometer(st[0].data.astype('float32'), st[0].stats.sampling_rate, paz, inst_sim=one_hertz) # Correct for overall sensitivity res = res / paz['sensitivity'] # Plot the seismograms sec = np.arange(len(res)) / st[0].stats.sampling_rate plt.subplot(211) plt.plot(sec, st[0].data, 'k') plt.title("%s %s" % (st[0].stats.station, t)) plt.ylabel('STS-2') plt.subplot(212) plt.plot(sec, res, 'k')
from math import log10 from obspy.clients.arclink import Client from obspy import UTCDateTime, read from obspy.geodetics import gps2dist_azimuth st = read("../data/LKBD.MSEED") paz_wa = {'sensitivity': 2800, 'zeros': [0j], 'gain': 1, 'poles': [-6.2832 - 4.7124j, -6.2832 + 4.7124j]} client = Client(user="******") t = st[0].stats.starttime paz_le3d5s = client.get_paz("CH", "LKBD", "", "EHZ", t) st.simulate(paz_remove=paz_le3d5s, paz_simulate=paz_wa, water_level=10) t = UTCDateTime("2012-04-03T02:45:03") st.trim(t, t + 50) tr_n = st.select(component="N")[0] ampl_n = max(abs(tr_n.data)) tr_e = st.select(component="E")[0] ampl_e = max(abs(tr_e.data)) ampl = max(ampl_n, ampl_e) sta_lat = 46.38703 sta_lon = 7.62714 event_lat = 46.218
from obspy.clients.arclink import Client from obspy import UTCDateTime, read from obspy.geodetics import gps2dist_azimuth st = read("../data/LKBD.MSEED") paz_wa = { 'sensitivity': 2800, 'zeros': [0j], 'gain': 1, 'poles': [-6.2832 - 4.7124j, -6.2832 + 4.7124j] } client = Client(user="******") t = st[0].stats.starttime paz_le3d5s = client.get_paz("CH", "LKBD", "", "EHZ", t) st.simulate(paz_remove=paz_le3d5s, paz_simulate=paz_wa, water_level=10) t = UTCDateTime("2012-04-03T02:45:03") st.trim(t, t + 50) tr_n = st.select(component="N")[0] ampl_n = max(abs(tr_n.data)) tr_e = st.select(component="E")[0] ampl_e = max(abs(tr_e.data)) ampl = max(ampl_n, ampl_e) sta_lat = 46.38703 sta_lon = 7.62714 event_lat = 46.218
import numpy as np import matplotlib.pyplot as plt import obspy from obspy.clients.arclink import Client from obspy.signal.invsim import corn_freq_2_paz, simulate_seismometer # Retrieve data via ArcLink # please provide a valid email address for the keyword user client = Client(user="******") t = obspy.UTCDateTime("2009-08-24 00:20:03") st = client.get_waveforms('BW', 'RJOB', '', 'EHZ', t, t + 30) paz = client.get_paz('BW', 'RJOB', '', 'EHZ', t) # 1Hz instrument one_hertz = corn_freq_2_paz(1.0) # Correct for frequency response of the instrument res = simulate_seismometer(st[0].data.astype('float32'), st[0].stats.sampling_rate, paz, inst_sim=one_hertz) # Correct for overall sensitivity res = res / paz['sensitivity'] # Plot the seismograms sec = np.arange(len(res)) / st[0].stats.sampling_rate plt.subplot(211) plt.plot(sec, st[0].data, 'k') plt.title("%s %s" % (st[0].stats.station, t)) plt.ylabel('STS-2') plt.subplot(212)