예제 #1
0
    def test_getWaveformInstrumentChange(self):
        """
        Check results of getWaveform if instrumentation has been changed.

        Sensitivity change for GE.SNAA..BHZ at 2003-01-10T00:00:00
        """
        client = Client(user='******')
        # one instrument in given time span
        dt = UTCDateTime("2003-01-09T00:00:00")
        st = client.getWaveform("GE", "SNAA", "", "BHZ", dt, dt + 10,
                                metadata=True)
        self.assertEquals(len(st), 1)
        self.assertEquals(st[0].stats.paz.sensitivity, 596224500.0)
        # two instruments in given time span
        dt = UTCDateTime("2003-01-09T23:59:00")
        st = client.getWaveform("GE", "SNAA", "", "BHZ", dt, dt + 120,
                                metadata=True)
        # results into two traces
        self.assertEquals(len(st), 2)
        # with different PAZ
        st.sort()
        self.assertEquals(st[0].stats.paz.sensitivity, 596224500.0)
        self.assertEquals(st[1].stats.paz.sensitivity, 588000000.0)
        # one instrument in given time span
        dt = UTCDateTime("2003-01-10T01:00:00")
        st = client.getWaveform("GE", "SNAA", "", "BHZ", dt, dt + 10,
                                metadata=True)
        self.assertEquals(len(st), 1)
        self.assertEquals(st[0].stats.paz.sensitivity, 588000000.0)
예제 #2
0
    def test_getWaveformInstrumentChange(self):
        """
        Check results of getWaveform if instrumentation has been changed.

        Sensitivity change for GE.SNAA..BHZ at 2003-01-10T00:00:00
        """
        client = Client()
        # one instrument in given time span
        dt = UTCDateTime("2003-01-09T00:00:00")
        st = client.getWaveform("GE", "SNAA", "", "BHZ", dt, dt + 10,
                                metadata=True)
        self.assertEquals(len(st), 1)
        self.assertEquals(st[0].stats.paz.sensitivity, 596224500.0)
        # two instruments in given time span
        dt = UTCDateTime("2003-01-09T23:59:00")
        st = client.getWaveform("GE", "SNAA", "", "BHZ", dt, dt + 120,
                                metadata=True)
        # results into two traces
        self.assertEquals(len(st), 2)
        # with different PAZ
        st.sort()
        self.assertEquals(st[0].stats.paz.sensitivity, 596224500.0)
        self.assertEquals(st[1].stats.paz.sensitivity, 588000000.0)
        # one instrument in given time span
        dt = UTCDateTime("2003-01-10T01:00:00")
        st = client.getWaveform("GE", "SNAA", "", "BHZ", dt, dt + 10,
                                metadata=True)
        self.assertEquals(len(st), 1)
        self.assertEquals(st[0].stats.paz.sensitivity, 588000000.0)
예제 #3
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)
예제 #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,
                        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)
예제 #5
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:])
예제 #6
0
 def test_issue311(self):
     """
     Testing issue #311.
     """
     client = Client("webdc.eu", 18001, user='******')
     t = UTCDateTime("2009-08-20 04:03:12")
     # 1
     st = client.getWaveform("BW",
                             "MANZ",
                             "",
                             "EH*",
                             t - 3,
                             t + 15,
                             metadata=False)
     self.assertEqual(len(st), 3)
     self.assertTrue('paz' not in st[0].stats)
     self.assertTrue('coordinates' not in st[0].stats)
     # 2
     st = client.getWaveform("BW",
                             "MANZ",
                             "",
                             "EH*",
                             t - 3,
                             t + 15,
                             metadata=True)
     self.assertEqual(len(st), 3)
     self.assertTrue('paz' in st[0].stats)
     self.assertTrue('coordinates' in st[0].stats)
예제 #7
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
예제 #8
0
 def test_getStations(self):
     """
     """
     # initialize client
     client = Client(user='******')
     # example 1
     start = UTCDateTime(2008, 1, 1)
     end = start + 1
     result = client.getStations(start, end, 'BW')
     self.assertTrue(
         AttribDict({
             'remark': '',
             'code': 'RWMO',
             'elevation': 763.0,
             'description': 'Wildenmoos, Bavaria, BW-Net',
             'start': UTCDateTime(2006, 7, 4, 0, 0),
             'restricted': False,
             'archive_net': '',
             'longitude': 12.729887,
             'affiliation': 'BayernNetz',
             'depth': None,
             'place': 'Wildenmoos',
             'country': ' BW-Net',
             'latitude': 47.744171,
             'end': None
         }) in result)
예제 #9
0
def getArclinkInst(station, usermail, pwdkeys):

    inst = 'no_instrument_available'

    #if station.loc == '' : station.loc='--'

    sn = station.net + '.' + station.sta + '.' + station.loc + '.' + station.comp
    print 'SN ', sn

    client = Client(user=usermail, dcid_keys=pwdkeys)
    inv = client.getInventory(station.net,
                              station.sta,
                              station.loc,
                              station.comp,
                              instruments=True)
    print 'INV: ', inv

    try:
        stats = inv[sn]
        print 'STATS ', stats

        t = stats[0]
        z = t['paz']
        inst = z['name']
        inst = inst.replace(' ', '_')

    except:
        inst = 'no_instrument_available'

    return inst
예제 #10
0
 def test_saveWaveformCompressed(self):
     """
     Tests saving compressed and not unpacked bzip2 files to disk.
     """
     mseedfile = NamedTemporaryFile(suffix='.bz2').name
     fseedfile = NamedTemporaryFile(suffix='.bz2').name
     try:
         # initialize client
         client = Client(user='******')
         start = UTCDateTime(2008, 1, 1, 0, 0)
         end = start + 1
         # MiniSEED
         client.saveWaveform(mseedfile, 'GE', 'APE', '', 'BHZ', start, end,
                             unpack=False)
         # check if compressed
         self.assertEquals(open(mseedfile, 'rb').read(2), 'BZ')
         # importing via read should work too
         read(mseedfile)
         # Full SEED
         client.saveWaveform(fseedfile, 'GE', 'APE', '', 'BHZ', start, end,
                             format="FSEED", unpack=False)
         # check if compressed
         self.assertEquals(open(fseedfile, 'rb').read(2), 'BZ')
         # importing via read should work too
         read(fseedfile)
     finally:
         os.remove(mseedfile)
         os.remove(fseedfile)
예제 #11
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:])
예제 #12
0
 def test_getWaveform(self):
     """
     Tests getWaveform method.
     """
     # example 1
     client = Client(user='******')
     start = UTCDateTime(2010, 1, 1)
     end = start + 1
     stream = client.getWaveform('BW', 'MANZ', '', 'EH*', start, end)
     self.assertEquals(len(stream), 3)
     for trace in stream:
         self.assertTrue(trace.stats.starttime <= start)
         self.assertTrue(trace.stats.endtime >= end)
         self.assertEquals(trace.stats.network, 'BW')
         self.assertEquals(trace.stats.station, 'MANZ')
         self.assertEquals(trace.stats.location, '')
         self.assertEquals(trace.stats.channel[0:2], 'EH')
     # example 2
     client = Client(user='******')
     start = UTCDateTime("2010-12-31T23:59:50.495000Z")
     end = start + 100
     stream = client.getWaveform('GE', 'APE', '', 'BHE', start, end)
     self.assertEquals(len(stream), 1)
     trace = stream[0]
     self.assertTrue(trace.stats.starttime <= start)
     self.assertTrue(trace.stats.endtime >= end)
     self.assertEquals(trace.stats.network, 'GE')
     self.assertEquals(trace.stats.station, 'APE')
     self.assertEquals(trace.stats.location, '')
     self.assertEquals(trace.stats.channel, 'BHE')
예제 #13
0
파일: get_paz.py 프로젝트: wangwu1991/sito
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))
예제 #14
0
 def test_getInventory2(self):
     """
     Bugfix for location and channel codes for new inventory schema
     """
     client = Client(user='******')
     # new schema
     inventory = client.getInventory('CH', 'GRYON')
     self.assertTrue('CH.GRYON..EHE' in inventory)
     # old schema
     inventory = client.getInventory('BW', 'MANZ')
     self.assertTrue('BW.MANZ..EHZ' in inventory)
예제 #15
0
def get_waveforms():
    events = get_events()
    client = ArcClient()
    wforms = Stream()
    for event in events:
        t = event.preferred_origin().time
        args = seed_id.split('.') + [t + 5 * 60, t + 14 * 60]
        wforms.extend(client.getWaveform(*args))
    wforms.decimate(int(round(wforms[0].stats.sampling_rate)) // 5,
                    no_filter=True)
    wforms.write(wavname, wavformat)
예제 #16
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])
예제 #17
0
 def test_getInventory2(self):
     """
     Bugfix for location and channel codes for new inventory schema
     """
     client = Client()
     # new schema
     inventory = client.getInventory('CH', 'GRYON')
     self.assertTrue('CH.GRYON..EHE' in inventory)
     # old schema
     inventory = client.getInventory('BW', 'MANZ')
     self.assertTrue('BW.MANZ..EHZ' in inventory)
예제 #18
0
 def test_getNetworks(self):
     """
     """
     # initialize client
     client = Client(user='******')
     # example 1
     start = UTCDateTime(2008, 1, 1)
     end = start + 1
     result = client.getNetworks(start, end)
     self.assertTrue('BW' in result.keys())
     self.assertEquals(result['BW']['code'], 'BW')
     self.assertEquals(result['BW']['description'], 'BayernNetz')
예제 #19
0
 def test_getNetworks(self):
     """
     """
     # initialize client
     client = Client()
     # example 1
     start = UTCDateTime(2008, 1, 1)
     end = start + 1
     result = client.getNetworks(start, end)
     self.assertTrue('BW' in result.keys())
     self.assertEquals(result['BW']['code'], 'BW')
     self.assertEquals(result['BW']['description'], 'BayernNetz')
예제 #20
0
 def test_getInventoryTwice(self):
     """
     Requesting inventory data twice should not fail.
     """
     client = Client(user='******')
     dt = UTCDateTime(2009, 1, 1)
     # station
     client.getInventory('BW', 'MANZ', starttime=dt, endtime=dt + 1)
     client.getInventory('BW', 'MANZ', starttime=dt, endtime=dt + 1)
     # network
     client.getInventory('BW', starttime=dt, endtime=dt + 1)
     client.getInventory('BW', starttime=dt, endtime=dt + 1)
예제 #21
0
 def test_delayedRequest(self):
     """
     """
     # initialize client with 0.1 delay
     client = Client(host='webdc.eu', port=18002, command_delay=0.1)
     start = UTCDateTime(2010, 1, 1)
     end = start + 100
     # getWaveform with 0.1 delay
     stream = client.getWaveform('GR', 'FUR', '', 'HHE', start, end)
     self.assertEquals(len(stream), 1)
     # getRouting with 0.1 delay
     results = client.getRouting('GR', 'FUR', start, end)
     self.assertTrue('GR...' in results)
예제 #22
0
 def test_getWaveformNoCompression(self):
     """
     Disabling compression during waveform request.
     """
     # initialize client
     client = Client()
     start = UTCDateTime(2011, 1, 1, 0, 0)
     end = start + 10
     stream = client.getWaveform('BW', 'MANZ', '', 'EH*', start, end,
                                 compressed=False)
     self.assertEquals(len(stream), 3)
     for trace in stream:
         self.assertEquals(trace.stats.network, 'BW')
         self.assertEquals(trace.stats.station, 'MANZ')
예제 #23
0
 def test_issue372(self):
     """
     Test case for issue #372.
     """
     dt = UTCDateTime("20120729070000")
     client = Client(user='******')
     st = client.getWaveform("BS", "JMB", "", "BH*", dt, dt + 7200,
                             metadata=True)
     for tr in st:
         self.assertTrue('paz' in tr.stats)
         self.assertTrue('coordinates' in tr.stats)
         self.assertTrue('poles' in tr.stats.paz)
         self.assertTrue('zeros' in tr.stats.paz)
         self.assertTrue('latitude' in tr.stats.coordinates)
예제 #24
0
 def test_getWaveformNoCompression(self):
     """
     Disabling compression during waveform request.
     """
     # initialize client
     client = Client(user='******')
     start = UTCDateTime(2011, 1, 1, 0, 0)
     end = start + 10
     stream = client.getWaveform('BW', 'MANZ', '', 'EH*', start, end,
                                 compressed=False)
     self.assertEquals(len(stream), 3)
     for trace in stream:
         self.assertEquals(trace.stats.network, 'BW')
         self.assertEquals(trace.stats.station, 'MANZ')
예제 #25
0
 def test_issue372(self):
     """
     Test case for issue #372.
     """
     dt = UTCDateTime("20120529070000")
     client = Client()
     st = client.getWaveform("BS", "JMB", "", "BH*", dt, dt + 7200,
                             metadata=True)
     for tr in st:
         self.assertTrue('paz' in tr.stats)
         self.assertTrue('coordinates' in tr.stats)
         self.assertTrue('poles' in tr.stats.paz)
         self.assertTrue('zeros' in tr.stats.paz)
         self.assertTrue('latitude' in tr.stats.coordinates)
예제 #26
0
 def test_saveResponse(self):
     """
     Fetches and stores response information as Dataless SEED volume.
     """
     tempfile = NamedTemporaryFile().name
     try:
         client = Client()
         start = UTCDateTime(2008, 1, 1)
         end = start + 1
         # Dataless SEED
         client.saveResponse(tempfile, 'BW', 'MANZ', '', 'EHZ', start, end)
         self.assertEquals(open(tempfile).read(8), "000001V ")
     finally:
         os.remove(tempfile)
예제 #27
0
 def test_getWaveformWithDCIDKey(self):
     """
     """
     # test server for encryption
     client1 = Client(host="webdc.eu", port=36000, user="******", dcid_keys={"BIA": "OfH9ekhi"})
     # public server
     client2 = Client(host="webdc.eu", port=18001, user="******")
     # request data
     start = UTCDateTime(2010, 1, 1, 10, 0, 0)
     end = start + 100
     stream1 = client1.getWaveform("GE", "APE", "", "BHZ", start, end)
     stream2 = client2.getWaveform("GE", "APE", "", "BHZ", start, end)
     # compare results
     np.testing.assert_array_equal(stream1[0].data, stream2[0].data)
     self.assertEqual(stream1[0].stats, stream2[0].stats)
예제 #28
0
def arclink_Request_obspy(station, begin, end, usermail, pwdkeys):

    sname = station.net + '.' + station.sta + '.' + station.loc + '.' + station.comp
    print 'STARTING ARCLINK REQUEST FOR STATION ' + sname

    output = sname + '-ARCLINK.dataless'
    client = Client(user=usermail, dcid_keys=pwdkeys, debug=False)
    info = ''

    if station.net == 'MN':
        info = arclinkRequest_sc(
            station, begin,
            end)  #hs : Kommt wohl nicht vor - wird immer von Iris geholt

    else:
        try:
            #           client.saveResponse (output, station.net, station.sta, station.loc, station.comp, begin, end) #hs

            #           mdict = getMetaInfo (output)                                  #hs
            #           inst  = getArclinkInst   (station, usermail, pwdkeys)         #hs
            sta2 = getArclinkInst_2(station, usermail, pwdkeys)  #hs
            #sta2.print1()

            if station.loc == '': station.loc = '--'

            form = '{0:3}{1:6}{2:3}{3:4}{4:12}{5:12}{6:10}{7:10}{8:10}{9:20}{10:50}'

            info = form.format(
                station.net.strip(),
                station.sta.strip(),
                station.loc.strip(),
                station.comp.strip(),
                #           mdict['lat'], mdict['lon'], mdict['ele'], mdict['dip'], mdict['azi'], mdict['gain'],inst)      #hs
                str(sta2.lat),
                str(sta2.lon),
                str(sta2.ele),
                str(sta2.dip),
                str(sta2.azi),  #hs \
                str(sta2.gain),
                str(sta2.inst))  #hs

            #logfile.red ('ARCLINK METAINFO FOR STATION %s' % (info))
            #           os.remove   (output)                        #hs
            print ARCLINK_META  #hs
            return info

        except:
            print 'Exception 1 in arclink_Request_obspy'
            info = ''
            return info
    try:
        return info
        os.remove(output)

    except:
        print 'Exception 2 in arclink_Request_obspy'
        pass

    print 'len=', len(info)
    return info
예제 #29
0
 def test_getStations(self):
     """
     """
     # initialize client
     client = Client(user='******')
     # example 1
     start = UTCDateTime(2008, 1, 1)
     end = start + 1
     result = client.getStations(start, end, 'BW')
     self.assertTrue(
         AttribDict({'remark': '', 'code': 'RWMO', 'elevation': 763.0,
                     'description': 'Wildenmoos, Bavaria',
                     'start': UTCDateTime(2006, 6, 4, 0, 0),
                     'restricted': False, 'archive_net': '',
                     'longitude': 12.729887, 'affiliation': '',
                     'depth': None, 'place': '', 'country': '',
                     'latitude': 47.744172, 'end': None}) in result)
예제 #30
0
 def test_saveWaveformNoCompression(self):
     """
     Explicitly disable compression during waveform request and save it
     directly to disk.
     """
     # initialize client
     client = Client(user='******')
     start = UTCDateTime(2010, 1, 1, 0, 0)
     end = start + 1
     # MiniSEED
     with NamedTemporaryFile(suffix='.bz2') as tf:
         mseedfile = tf.name
         client.saveWaveform(mseedfile,
                             'GE',
                             'APE',
                             '',
                             'BHZ',
                             start,
                             end,
                             compressed=False)
         st = read(mseedfile)
         # MiniSEED may not start with Volume Index Control Headers (V)
         with open(mseedfile, 'rb') as fp:
             self.assertNotEqual(fp.read(8)[6:7], b"V")
         # ArcLink cuts on record base
         self.assertEqual(st[0].stats.network, 'GE')
         self.assertEqual(st[0].stats.station, 'APE')
         self.assertEqual(st[0].stats.location, '')
         self.assertEqual(st[0].stats.channel, 'BHZ')
     # Full SEED
     with NamedTemporaryFile(suffix='.bz2') as tf:
         fseedfile = tf.name
         client.saveWaveform(fseedfile,
                             'GE',
                             'APE',
                             '',
                             'BHZ',
                             start,
                             end,
                             format='FSEED')
         st = read(fseedfile)
         # Full SEED
         client.saveWaveform(fseedfile,
                             'BW',
                             'MANZ',
                             '',
                             'EHZ',
                             start,
                             end,
                             format='FSEED')
         # ArcLink cuts on record base
         self.assertEqual(st[0].stats.network, 'GE')
         self.assertEqual(st[0].stats.station, 'APE')
         self.assertEqual(st[0].stats.location, '')
         self.assertEqual(st[0].stats.channel, 'BHZ')
예제 #31
0
 def test_issue311(self):
     """
     Testing issue #311.
     """
     client = Client("webdc.eu", 18001, user='******')
     t = UTCDateTime("2009-08-20 04:03:12")
     # 1
     st = client.getWaveform("BW", "MANZ", "", "EH*", t - 3, t + 15,
                             metadata=False)
     self.assertEqual(len(st), 3)
     self.assertTrue('paz' not in st[0].stats)
     self.assertTrue('coordinates' not in st[0].stats)
     # 2
     st = client.getWaveform("BW", "MANZ", "", "EH*", t - 3, t + 15,
                             metadata=True)
     self.assertEqual(len(st), 3)
     self.assertTrue('paz' in st[0].stats)
     self.assertTrue('coordinates' in st[0].stats)
예제 #32
0
def ARC_available(input_dics, event, target_path, event_number):
    """
    Check the availability of ArcLink stations
    """
    print "Check the availability of ArcLink stations"
    client_arclink = Client_arclink(user='******',
                                    timeout=input_dics['arc_avai_timeout'])
    Sta_arc = []
    try:
        inventories = client_arclink.getInventory(
            network=input_dics['net'],
            station=input_dics['sta'],
            location=input_dics['loc'],
            channel=input_dics['cha'],
            starttime=UTCDateTime(event['t1']),
            endtime=UTCDateTime(event['t2']),
            min_latitude=input_dics['mlat_rbb'],
            max_latitude=input_dics['Mlat_rbb'],
            min_longitude=input_dics['mlon_rbb'],
            max_longitude=input_dics['Mlon_rbb'])

        for inv_key in inventories.keys():
            netsta = inv_key.split('.')
            if len(netsta) == 4:
                sta = '%s.%s' % (netsta[0], netsta[1])
                if not inventories[sta]['depth']:
                    inventories[sta]['depth'] = 0.0
                Sta_arc.append([netsta[0], netsta[1], netsta[2], netsta[3],
                                inventories[sta]['latitude'],
                                inventories[sta]['longitude'],
                                inventories[sta]['elevation'],
                                inventories[sta]['depth']])

    except Exception as e:
        exc_file = open(os.path.join(target_path, 'info', 'exception'), 'a+')
        ee = 'arclink -- Event: %s --- %s\n' % (str(event_number+1), e)
        exc_file.writelines(ee)
        exc_file.close()
        print 'ERROR: %s' % ee

    if len(Sta_arc) == 0:
        Sta_arc.append([])
    Sta_arc.sort()
    return Sta_arc
예제 #33
0
 def test_getWaveformWrongPattern(self):
     """
     """
     # initialize client
     client = Client()
     # example 1
     start = UTCDateTime(2008, 1, 1)
     end = start + 1
     self.assertRaises(ArcLinkException, client.getWaveform, 'BW', 'MAN*',
                       '', '*', start, end)
예제 #34
0
 def test_getWaveformUnknownUser(self):
     """
     Unknown user raises an ArcLinkException: DENIED.
     """
     client = Client(host="webdc.eu", port=36000, user="******")
     # request data
     start = UTCDateTime(2010, 1, 1, 10, 0, 0)
     end = start + 100
     self.assertRaises(ArcLinkException, client.getWaveform, 'GE', 'APE',
                       '', 'BHZ', start, end)
예제 #35
0
 def test_getWaveformNoPassword(self):
     """
     No password raises a "EVPError: bad decrypt".
     """
     client = Client(host="webdc.eu", port=36000, user="******",
                     dcid_keys={'BIA': ''})
     # request data
     start = UTCDateTime(2010, 1, 1, 10, 0, 0)
     end = start + 100
     self.assertRaises(EVPError, client.getWaveform, 'GE', 'APE', '', 'BHZ',
                       start, end)
예제 #36
0
 def test_getWaveformWithDCIDKeyFile(self):
     """
     """
     with NamedTemporaryFile() as tf:
         dcidfile = tf.name
         with open(dcidfile, 'wt') as fh:
             fh.write('TEST=XYZ\r\nBIA=OfH9ekhi\r\n')
         # test server for encryption
         client1 = Client(host="webdc.eu", port=36000,
                          user="******", dcid_key_file=dcidfile)
         # public server
         client2 = Client(host="webdc.eu", port=18001,
                          user="******")
     # request data
     start = UTCDateTime(2010, 1, 1, 10, 0, 0)
     end = start + 100
     stream1 = client1.getWaveform('GE', 'APE', '', 'BHZ', start, end)
     stream2 = client2.getWaveform('GE', 'APE', '', 'BHZ', start, end)
     # compare results
     np.testing.assert_array_equal(stream1[0].data, stream2[0].data)
     self.assertEqual(stream1[0].stats, stream2[0].stats)
예제 #37
0
 def test_saveWaveform(self):
     """
     Default behavior is requesting data compressed and unpack on the fly.
     """
     mseedfile = NamedTemporaryFile().name
     fseedfile = NamedTemporaryFile().name
     try:
         # initialize client
         client = Client("erde.geophysik.uni-muenchen.de", 18001,
                         user='******')
         start = UTCDateTime(2008, 1, 1)
         end = start + 10
         # MiniSEED
         client.saveWaveform(mseedfile, 'BW', 'MANZ', '', 'EHZ', start, end)
         st = read(mseedfile)
         # MiniSEED may not start with Volume Index Control Headers (V)
         self.assertNotEquals(open(mseedfile).read(8)[6], "V")
         # ArcLink cuts on record base
         self.assertTrue(st[0].stats.starttime <= start)
         self.assertTrue(st[0].stats.endtime >= end)
         self.assertEquals(st[0].stats.network, 'BW')
         self.assertEquals(st[0].stats.station, 'MANZ')
         self.assertEquals(st[0].stats.location, '')
         self.assertEquals(st[0].stats.channel, 'EHZ')
         # Full SEED
         client.saveWaveform(fseedfile, 'BW', 'MANZ', '', 'EHZ', start, end,
                             format='FSEED')
         st = read(fseedfile)
         # Full SEED must start with Volume Index Control Headers (V)
         self.assertEquals(open(fseedfile).read(8)[6], "V")
         # ArcLink cuts on record base
         self.assertTrue(st[0].stats.starttime <= start)
         self.assertTrue(st[0].stats.endtime >= end)
         self.assertEquals(st[0].stats.network, 'BW')
         self.assertEquals(st[0].stats.station, 'MANZ')
         self.assertEquals(st[0].stats.location, '')
         self.assertEquals(st[0].stats.channel, 'EHZ')
     finally:
         os.remove(mseedfile)
         os.remove(fseedfile)
예제 #38
0
 def test_getWaveform(self):
     """
     Tests getWaveform method.
     """
     # example 1
     client = Client()
     start = UTCDateTime(2010, 1, 1)
     end = start + 1
     stream = client.getWaveform('BW', 'MANZ', '', 'EH*', start, end)
     self.assertEquals(len(stream), 3)
     for trace in stream:
         self.assertTrue(trace.stats.starttime <= start)
         self.assertTrue(trace.stats.endtime >= end)
         self.assertEquals(trace.stats.network, 'BW')
         self.assertEquals(trace.stats.station, 'MANZ')
         self.assertEquals(trace.stats.location, '')
         self.assertEquals(trace.stats.channel[0:2], 'EH')
     # example 2
     client = Client()
     start = UTCDateTime("2010-12-31T23:59:50.495000Z")
     end = start + 100
     stream = client.getWaveform('GE', 'APE', '', 'BHE', start, end)
     self.assertEquals(len(stream), 1)
     trace = stream[0]
     self.assertTrue(trace.stats.starttime <= start)
     self.assertTrue(trace.stats.endtime >= end)
     self.assertEquals(trace.stats.network, 'GE')
     self.assertEquals(trace.stats.station, 'APE')
     self.assertEquals(trace.stats.location, '')
     self.assertEquals(trace.stats.channel, 'BHE')
예제 #39
0
    def test_getInventoryInstrumentChange(self):
        """
        Check results of getInventory if instrumentation has been changed.

        Sensitivity change for GE.SNAA..BHZ at 2003-01-10T00:00:00
        """
        client = Client(user='******')
        # one instrument in given time span
        dt = UTCDateTime("2003-01-09T00:00:00")
        inv = client.getInventory("GE",
                                  "SNAA",
                                  "",
                                  "BHZ",
                                  dt,
                                  dt + 10,
                                  instruments=True,
                                  route=False)
        self.assertTrue(len(inv['GE.SNAA..BHZ']), 1)
        # two instruments in given time span
        dt = UTCDateTime("2003-01-09T23:59:59")
        inv = client.getInventory("GE",
                                  "SNAA",
                                  "",
                                  "BHZ",
                                  dt,
                                  dt + 10,
                                  instruments=True,
                                  route=False)
        self.assertTrue(len(inv['GE.SNAA..BHZ']), 2)
        # one instrument in given time span
        dt = UTCDateTime("2003-01-10T00:00:00")
        inv = client.getInventory("GE",
                                  "SNAA",
                                  "",
                                  "BHZ",
                                  dt,
                                  dt + 10,
                                  instruments=True,
                                  route=False)
        self.assertTrue(len(inv['GE.SNAA..BHZ']), 1)
예제 #40
0
 def test_saveWaveformCompressed(self):
     """
     Tests saving compressed and not unpacked bzip2 files to disk.
     """
     mseedfile = NamedTemporaryFile(suffix='.bz2').name
     fseedfile = NamedTemporaryFile(suffix='.bz2').name
     try:
         # initialize client
         client = Client()
         start = UTCDateTime(2008, 1, 1, 0, 0)
         end = start + 1
         # MiniSEED
         client.saveWaveform(mseedfile, 'GE', 'APE', '', 'BHZ', start, end,
                             unpack=False)
         # check if compressed
         self.assertEquals(open(mseedfile, 'rb').read(2), 'BZ')
         # importing via read should work too
         read(mseedfile)
         # Full SEED
         client.saveWaveform(fseedfile, 'GE', 'APE', '', 'BHZ', start, end,
                             format="FSEED", unpack=False)
         # check if compressed
         self.assertEquals(open(fseedfile, 'rb').read(2), 'BZ')
         # importing via read should work too
         read(fseedfile)
     finally:
         os.remove(mseedfile)
         os.remove(fseedfile)
예제 #41
0
 def test_saveWaveformCompressed(self):
     """
     Tests saving compressed and not unpacked bzip2 files to disk.
     """
     # initialize client
     client = Client(user='******')
     start = UTCDateTime(2008, 1, 1, 0, 0)
     end = start + 1
     # MiniSEED
     with NamedTemporaryFile(suffix='.bz2') as tf:
         mseedfile = tf.name
         client.saveWaveform(mseedfile, 'GE', 'APE', '', 'BHZ', start, end,
                             unpack=False)
         # check if compressed
         with open(mseedfile, 'rb') as fp:
             self.assertEqual(fp.read(2), b'BZ')
         # importing via read should work too
         read(mseedfile)
     # Full SEED
     with NamedTemporaryFile(suffix='.bz2') as tf:
         fseedfile = tf.name
         client.saveWaveform(fseedfile, 'GE', 'APE', '', 'BHZ', start, end,
                             format="FSEED", unpack=False)
         # check if compressed
         with open(fseedfile, 'rb') as fp:
             self.assertEqual(fp.read(2), b'BZ')
         # importing via read should work too
         read(fseedfile)
예제 #42
0
def get_waveforms():
    events = get_events()
    client = ArcClient(**client_kwargs)
    wforms = Stream()
    for i, event in enumerate(events):
        print('Fetch data for event no. %d' % (i + 1))
        t = event.preferred_origin().time
        for sta in stations:
            args = (net, sta, loc, cha, t - 10, t + 220)
            try:
                stream = client.getWaveform(*args)
            except:
                print('no data for %s' % (args,))
                continue
            sr = stream[0].stats.sampling_rate
            stream.decimate(int(sr) // 20, no_filter=True)
            for tr in stream:
                del tr.stats.mseed
            stream.merge()
            wforms.extend(stream)
    wforms.write(wavname, wavformat)
    return wforms
예제 #43
0
 def test_getWaveformWithDefaultDCIDKeyFile(self):
     """
     Use $HOME/dcidpasswords.txt.
     """
     dcidfile = DCID_KEY_FILE
     fh = open(dcidfile, 'wt')
     fh.write('TEST=XYZ\r\nBIA=OfH9ekhi\r\n')
     fh.close()
     # test server for encryption
     client1 = Client(host="webdc.eu", port=36000, user="******")
     # public server
     client2 = Client(host="webdc.eu", port=18001, user="******")
     # clean up dcid file
     os.remove(dcidfile)
     # request data
     start = UTCDateTime(2010, 1, 1, 10, 0, 0)
     end = start + 100
     stream1 = client1.getWaveform('GE', 'APE', '', 'BHZ', start, end)
     stream2 = client2.getWaveform('GE', 'APE', '', 'BHZ', start, end)
     # compare results
     np.testing.assert_array_equal(stream1[0].data, stream2[0].data)
     self.assertEqual(stream1[0].stats, stream2[0].stats)
예제 #44
0
def get_waveforms():
    events = get_events()
    client = ArcClient(**client_kwargs)
    wforms = Stream()
    for i, event in enumerate(events):
        print('Fetch data for event no. %d' % (i + 1))
        t = event.preferred_origin().time
        for sta in stations:
            args = (net, sta, loc, cha, t - 10, t + 220)
            try:
                stream = client.getWaveform(*args)
            except:
                print('no data for %s' % (args, ))
                continue
            sr = stream[0].stats.sampling_rate
            stream.decimate(int(sr) // 20, no_filter=True)
            for tr in stream:
                del tr.stats.mseed
            stream.merge()
            wforms.extend(stream)
    wforms.write(wavname, wavformat)
    return wforms
예제 #45
0
    def test_getInventoryInstrumentChange(self):
        """
        Check results of getInventory if instrumentation has been changed.

        Sensitivity change for GE.SNAA..BHZ at 2003-01-10T00:00:00
        """
        client = Client(user='******')
        # one instrument in given time span
        dt = UTCDateTime("2003-01-09T00:00:00")
        inv = client.getInventory("GE", "SNAA", "", "BHZ", dt, dt + 10,
                                  instruments=True, route=False)
        self.assertTrue(len(inv['GE.SNAA..BHZ']), 1)
        # two instruments in given time span
        dt = UTCDateTime("2003-01-09T23:59:59")
        inv = client.getInventory("GE", "SNAA", "", "BHZ", dt, dt + 10,
                                  instruments=True, route=False)
        self.assertTrue(len(inv['GE.SNAA..BHZ']), 2)
        # one instrument in given time span
        dt = UTCDateTime("2003-01-10T00:00:00")
        inv = client.getInventory("GE", "SNAA", "", "BHZ", dt, dt + 10,
                                  instruments=True, route=False)
        self.assertTrue(len(inv['GE.SNAA..BHZ']), 1)
예제 #46
0
 def test_getWaveformNoRouting(self):
     """
     Tests routing parameter of getWaveform method.
     """
     # 1 - requesting BW data w/o routing on webdc.eu
     client = Client()
     start = UTCDateTime(2008, 1, 1)
     end = start + 1
     self.assertRaises(ArcLinkException, client.getWaveform, 'BW', 'MANZ',
                       '', 'EH*', start, end, route=False)
     # 2 - requesting BW data w/o routing directly from BW ArcLink node
     client = Client(host='erde.geophysik.uni-muenchen.de', port=18001)
     start = UTCDateTime(2008, 1, 1)
     end = start + 1
     stream = client.getWaveform('BW', 'MANZ', '', 'EH*', start, end,
                                 route=False)
     for trace in stream:
         self.assertTrue(trace.stats.starttime <= start)
         self.assertTrue(trace.stats.endtime >= end)
         self.assertEquals(trace.stats.network, 'BW')
         self.assertEquals(trace.stats.station, 'MANZ')
         self.assertEquals(trace.stats.location, '')
         self.assertEquals(trace.stats.channel[0:2], 'EH')
예제 #47
0
 def test_getNotExistingWaveform(self):
     """
     """
     # initialize client
     client = Client()
     # example 1
     start = UTCDateTime(2008, 1, 1)
     end = start + 1
     self.assertRaises(ArcLinkException, client.getWaveform, 'AA', 'AAAAA',
                       '', '*', start, end)
     # example 2
     start = UTCDateTime(2038, 1, 1)
     end = start + 1
     self.assertRaises(ArcLinkException, client.getWaveform, 'BW', 'MANZ',
                       '', '*', start, end)
예제 #48
0
 def test_getInventoryTwice(self):
     """
     Requesting inventory data twice should not fail.
     """
     client = Client()
     dt = UTCDateTime(2009, 1, 1)
     # station
     client.getInventory('BW', 'MANZ', starttime=dt, endtime=dt + 1)
     client.getInventory('BW', 'MANZ', starttime=dt, endtime=dt + 1)
     # network
     client.getInventory('BW', starttime=dt, endtime=dt + 1)
     client.getInventory('BW', starttime=dt, endtime=dt + 1)
예제 #49
0
 def test_getWaveformWithDCIDKeyFile(self):
     """
     Tests various DCID key file formats (with space or equal sign). Also
     checks if empty lines or comment lines are ignored.
     """
     # 1 - using = sign between username and password
     with NamedTemporaryFile() as tf:
         dcidfile = tf.name
         with open(dcidfile, 'wt') as fh:
             fh.write('#Comment\n\n\nTEST=XYZ\r\nBIA=OfH9ekhi\r\n')
         # test server for encryption
         client1 = Client(host="webdc.eu", port=36000,
                          user="******", dcid_key_file=dcidfile)
         # public server
         client2 = Client(host="webdc.eu", port=18001,
                          user="******")
     # request data
     start = UTCDateTime(2010, 1, 1, 10, 0, 0)
     end = start + 100
     stream1 = client1.getWaveform('GE', 'APE', '', 'BHZ', start, end)
     stream2 = client2.getWaveform('GE', 'APE', '', 'BHZ', start, end)
     # compare results
     np.testing.assert_array_equal(stream1[0].data, stream2[0].data)
     self.assertEqual(stream1[0].stats, stream2[0].stats)
     # 2 - using space between username and password
     with NamedTemporaryFile() as tf:
         dcidfile = tf.name
         with open(dcidfile, 'wt') as fh:
             fh.write('TEST XYZ\r\nBIA OfH9ekhi\r\n')
         # test server for encryption
         client1 = Client(host="webdc.eu", port=36000,
                          user="******", dcid_key_file=dcidfile)
         # public server
         client2 = Client(host="webdc.eu", port=18001,
                          user="******")
     # request data
     start = UTCDateTime(2010, 1, 1, 10, 0, 0)
     end = start + 100
     stream1 = client1.getWaveform('GE', 'APE', '', 'BHZ', start, end)
     stream2 = client2.getWaveform('GE', 'APE', '', 'BHZ', start, end)
     # compare results
     np.testing.assert_array_equal(stream1[0].data, stream2[0].data)
     self.assertEqual(stream1[0].stats, stream2[0].stats)
예제 #50
0
    def test_saveResponse(self):
        """
        Fetches and stores response information as Dataless SEED volume.
        """
        client = Client(user='******')
        start = UTCDateTime(2008, 1, 1)
        end = start + 1
        with NamedTemporaryFile() as tf:
            tempfile = tf.name
            # Dataless SEED
            client.saveResponse(tempfile, 'BW', 'MANZ', '', 'EHZ', start, end)
            self.assertEqual(open(tempfile).read(8), "000001V ")

        # Try again but write to a StringIO instance.
        file_object = StringIO.StringIO()
        client = Client(user='******')
        start = UTCDateTime(2008, 1, 1)
        end = start + 1
        # Dataless SEED
        client.saveResponse(file_object, 'BW', 'MANZ', '', 'EHZ', start, end)
        file_object.seek(0, 0)
        self.assertEqual(file_object.read(8), "000001V ")
예제 #51
0
 def test_saveWaveformNoCompression(self):
     """
     Explicitly disable compression during waveform request and save it
     directly to disk.
     """
     mseedfile = NamedTemporaryFile().name
     fseedfile = NamedTemporaryFile().name
     try:
         # initialize client
         client = Client(user='******')
         start = UTCDateTime(2010, 1, 1, 0, 0)
         end = start + 1
         # MiniSEED
         client.saveWaveform(mseedfile, 'GE', 'APE', '', 'BHZ', start, end,
                             compressed=False)
         st = read(mseedfile)
         # MiniSEED may not start with Volume Index Control Headers (V)
         self.assertNotEquals(open(mseedfile).read(8)[6], "V")
         # ArcLink cuts on record base
         self.assertEquals(st[0].stats.network, 'GE')
         self.assertEquals(st[0].stats.station, 'APE')
         self.assertEquals(st[0].stats.location, '')
         self.assertEquals(st[0].stats.channel, 'BHZ')
         # Full SEED
         client.saveWaveform(fseedfile, 'GE', 'APE', '', 'BHZ', start, end,
                             format='FSEED')
         st = read(fseedfile)
         # Full SEED
         client.saveWaveform(fseedfile, 'BW', 'MANZ', '', 'EHZ', start, end,
                             format='FSEED')
         # ArcLink cuts on record base
         self.assertEquals(st[0].stats.network, 'GE')
         self.assertEquals(st[0].stats.station, 'APE')
         self.assertEquals(st[0].stats.location, '')
         self.assertEquals(st[0].stats.channel, 'BHZ')
     finally:
         os.remove(mseedfile)
         os.remove(fseedfile)
예제 #52
0
 def test_saveWaveformNoCompression(self):
     """
     Explicitly disable compression during waveform request and save it
     directly to disk.
     """
     # initialize client
     client = Client(user='******')
     start = UTCDateTime(2010, 1, 1, 0, 0)
     end = start + 1
     # MiniSEED
     with NamedTemporaryFile(suffix='.bz2') as tf:
         mseedfile = tf.name
         client.saveWaveform(mseedfile, 'GE', 'APE', '', 'BHZ', start, end,
                             compressed=False)
         st = read(mseedfile)
         # MiniSEED may not start with Volume Index Control Headers (V)
         with open(mseedfile, 'rb') as fp:
             self.assertNotEqual(fp.read(8)[6:7], b"V")
         # ArcLink cuts on record base
         self.assertEqual(st[0].stats.network, 'GE')
         self.assertEqual(st[0].stats.station, 'APE')
         self.assertEqual(st[0].stats.location, '')
         self.assertEqual(st[0].stats.channel, 'BHZ')
     # Full SEED
     with NamedTemporaryFile(suffix='.bz2') as tf:
         fseedfile = tf.name
         client.saveWaveform(fseedfile, 'GE', 'APE', '', 'BHZ', start, end,
                             format='FSEED')
         st = read(fseedfile)
         # Full SEED
         client.saveWaveform(fseedfile, 'BW', 'MANZ', '', 'EHZ', start, end,
                             format='FSEED')
         # ArcLink cuts on record base
         self.assertEqual(st[0].stats.network, 'GE')
         self.assertEqual(st[0].stats.station, 'APE')
         self.assertEqual(st[0].stats.location, '')
         self.assertEqual(st[0].stats.channel, 'BHZ')
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)