本文整理汇总了Python中obspy.arclink.Client类的典型用法代码示例。如果您正苦于以下问题:Python Client类的具体用法?Python Client怎么用?Python Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Client类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_saveWaveformCompressed
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='[email protected]')
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)
示例2: test_SRL
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='[email protected]')
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:])
示例3: test_getPAZ
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='[email protected]')
# 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: stream_arklink_read
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
示例5: test_getWaveformInstrumentChange
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='[email protected]')
# 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)
示例6: test_getWaveform
def test_getWaveform(self):
"""
Tests getWaveform method.
"""
# example 1
client = Client(user='[email protected]')
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='[email protected]')
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')
示例7: save_all_paz
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))
示例8: get_waveforms
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)
示例9: test_getInventory2
def test_getInventory2(self):
"""
Bugfix for location and channel codes for new inventory schema
"""
client = Client(user='[email protected]')
# 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)
示例10: test_getPAZ2
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])
示例11: test_getNetworks
def test_getNetworks(self):
"""
"""
# initialize client
client = Client(user='[email protected]')
# 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')
示例12: test_getInventoryTwice
def test_getInventoryTwice(self):
"""
Requesting inventory data twice should not fail.
"""
client = Client(user='[email protected]')
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)
示例13: test_delayedRequest
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)
示例14: test_saveResponse
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)
示例15: test_issue372
def test_issue372(self):
"""
Test case for issue #372.
"""
dt = UTCDateTime("20120729070000")
client = Client(user='[email protected]')
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)