Exemple #1
0
    def test_getPAZ(self):
        """
        Test for the Client.getPAZ 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('erde.geophysik.uni-muenchen.de', 18001,
                        user='******')
        # fetch poles and zeros
        dt = UTCDateTime(2009, 1, 1)
        paz = client.getPAZ('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.getPAZ, 'BW', 'MANZ', '',
                          'EH*', dt)
Exemple #2
0
 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': 2516778600.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.getWaveform("BW", "RJOB", "", "EHZ", t, t + 30)
     poles_zeros = client.getPAZ("BW", "RJOB", "", "EHZ",
                                 t, t + 30).values()[0]
     self.assertEquals(paz['gain'], poles_zeros['gain'])
     self.assertEquals(paz['poles'], poles_zeros['poles'])
     self.assertEquals(paz['sensitivity'], poles_zeros['sensitivity'])
     self.assertEquals(paz['zeros'], poles_zeros['zeros'])
     self.assertEquals('BW', st[0].stats['network'])
     self.assertEquals('RJOB', st[0].stats['station'])
     self.assertEquals(200.0, st[0].stats['sampling_rate'])
     self.assertEquals(6001, st[0].stats['npts'])
     self.assertEquals('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:])
Exemple #3
0
 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': 2516778600.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.getWaveform("BW", "RJOB", "", "EHZ", t, t + 30)
     poles_zeros = client.getPAZ("BW", "RJOB", "", "EHZ",
                                 t, t + 30).values()[0]
     self.assertEquals(paz['gain'], poles_zeros['gain'])
     self.assertEquals(paz['poles'], poles_zeros['poles'])
     self.assertEquals(paz['sensitivity'], poles_zeros['sensitivity'])
     self.assertEquals(paz['zeros'], poles_zeros['zeros'])
     self.assertEquals('BW', st[0].stats['network'])
     self.assertEquals('RJOB', st[0].stats['station'])
     self.assertEquals(200.0, st[0].stats['sampling_rate'])
     self.assertEquals(6001, st[0].stats['npts'])
     self.assertEquals('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:])
Exemple #4
0
    def test_getPAZ(self):
        """
        Test for the Client.getPAZ 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('erde.geophysik.uni-muenchen.de', 18001)
        # fetch poles and zeros
        dt = UTCDateTime(2009, 1, 1)
        paz = client.getPAZ('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.getPAZ, 'BW', 'MANZ', '',
                          'EH*', dt)
Exemple #5
0
def stream_arklink_read(host="webdc.eu", port=18001, timeout=100,
                 start_time="2009-08-24 00:20:03", time_interval=30,
                 network_id="BW", station_id="RJOB", location_id="",
                 channel_id="EH*", get_paz=False):
    """ Arklink server client.

    For a detailed description of how it works refer to ObsPy website
    (obspy.org)

    """
    client = Client_arc(host, port, timeout)
    t = UTCDateTime(start_time)
    try:
        st = client.getWaveform(network_id, station_id, location_id, channel_id, \
                                t, t + time_interval)
        n_trace = len(st)

        if get_paz:
            paz = client.getPAZ(network_id, station_id, location_id, channel_id, \
                                t, t + time_interval)
            return st, paz, n_trace
        else:
            return st, n_trace
    except:
        print "An error occurred reading the data."
        st = []
        n_trace = 0
        paz = []
        if get_paz:
            return st, paz, n_trace
        else:
            return st, n_trace
Exemple #6
0
def save_all_paz():
    client = Client()
    paz = {}
    for st in 'PB01 PB02 PB03 PB04 PB05 PB06 PB07 PB08 PATCX HMBCX PSGCX MNMCX'.split():
        paz[st] = dict(client.getPAZ('CX', st, location, channel, t))
    print paz
    with open(PAZ_FILE % ('ALL', channel), 'w') as f:
        f.write(yaml.dump(paz))
Exemple #7
0
 def test_getPAZ2(self):
     """
     Test for the Client.getPAZ 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)
     # fetch poles and zeros
     paz = client.getPAZ('BW', 'MANZ', '', 'EHZ', dt)
     self.assertEqual(len(poles), 2)
     self.assertEqual(poles, paz['poles'][:2])
Exemple #8
0
import numpy as np
import matplotlib.pyplot as plt
from obspy.core import UTCDateTime
from obspy.arclink import Client
from obspy.signal import cornFreq2Paz, seisSim

# Retrieve data via ArcLink
# please provide a valid email address for the keyword user
client = Client(user="******")
t = UTCDateTime("2009-08-24 00:20:03")
st = client.getWaveform('BW', 'RJOB', '', 'EHZ', t, t + 30)
paz = client.getPAZ('BW', 'RJOB', '', 'EHZ', t)
paz = paz.values()[0]

# 1Hz instrument
one_hertz = cornFreq2Paz(1.0)
# Correct for frequency response of the instrument
res = seisSim(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)
Exemple #9
0
from obspy.core import read
from obspy.core.util.geodetics import gps2DistAzimuth
from obspy.arclink import Client
from math import log10

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.getPAZ("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
event_lon = 7.706

epi_dist, az, baz = gps2DistAzimuth(event_lat, event_lon, sta_lat, sta_lon)
import matplotlib.pyplot as plt
from obspy.core import UTCDateTime
from obspy.arclink import Client
from obspy.signal import cornFreq2Paz, seisSim

# Retrieve data via ArcLink
# please provide a valid email address for the keyword user
client = Client(user="******")
# t = UTCDateTime("2009-08-24 00:20:03")
# st = client.getWaveform('BW', 'RJOB', '', 'EHZ', t, t + 30)
# paz = client.getPAZ('BW', 'RJOB', '', 'EHZ', t)


t = UTCDateTime("2009-10-16 00:00:00")
st = client.getWaveform('', '', '', 'MHZ', t, t + 3600)
paz = client.getPAZ('', '', '', 'MHZ', t)


# 1Hz instrument
one_hertz = cornFreq2Paz(1.0)
# Correct for frequency response of the instrument
res = seisSim(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)
Exemple #11
0
from obspy.core.util.geodetics import gps2DistAzimuth
from obspy.arclink import Client
from math import log10

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.getPAZ("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
Exemple #12
0
def save_paz():
    client = Client()
    paz2 = client.getPAZ(network, station, location, channel, t)
    with open(PAZ_FILE % (station, channel), 'w') as f:
        f.write(yaml.dump(dict(paz2)))
import numpy as np
import matplotlib.pyplot as plt
from obspy.core import UTCDateTime
from obspy.arclink import Client
from obspy.signal import cornFreq2Paz, seisSim

# Retrieve data via ArcLink
# please provide a valid email address for the keyword user
client = Client(user="******")
t = UTCDateTime("2009-08-24 00:20:03")
st = client.getWaveform("BW", "RJOB", "", "EHZ", t, t + 30)
paz = client.getPAZ("BW", "RJOB", "", "EHZ", t, t + 30)
paz = paz.values()[0]

# 1Hz instrument
one_hertz = cornFreq2Paz(1.0)
# Correct for frequency response of the instrument
res = seisSim(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")
plt.xlabel("Time [s]")
plt.ylabel("1Hz CornerFrequency")