Coverage for /opt/obspy/update-docs/src/obspy/obspy/arclink/tests/test_client : 84%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- The obspy.arclink.client test suite. """
""" Test cases for obspy.arclink.client.Client. """ """ Tests getWaveform method. """ # example 1 # example 2
""" Tests routing parameter of getWaveform method. """ # 1 - requesting BW data w/o routing on webdc.eu '', 'EH*', start, end, route=False) # 2 - requesting BW data w/o routing directly from BW ArcLink node route=False)
""" """ # initialize client with 0.1 delay # getWaveform with 0.1 delay # getRouting with 0.1 delay
""" Tests getRouting method on various ArcLink nodes. """ # 1 - BW network via erde.geophysik.uni-muenchen.de:18001 {'BW...': [{'end': None, 'host': 'webdc.eu', 'port': 18002, 'priority': 2, 'start': UTCDateTime(1980, 1, 1, 0, 0)}, {'end': None, 'host': 'erde.geophysik.uni-muenchen.de', 'port': 18001, 'priority': 1, 'start': UTCDateTime(1980, 1, 1, 0, 0)}]}) # 2 - BW network via webdc:18001 client = Client(host="webdc.eu", port=18001) results = client.getRouting('BW', 'RJOB', dt, dt + 1) self.assertEquals(results, {'BW...': [{'end': None, 'host': 'webdc.eu', 'port': 18002, 'priority': 2, 'start': UTCDateTime(1980, 1, 1, 0, 0)}, {'end': None, 'host': 'erde.geophysik.uni-muenchen.de', 'port': 18001, 'priority': 1, 'start': UTCDateTime(1980, 1, 1, 0, 0)}]}) # 3 - BW network via webdc:18002 client = Client(host="webdc.eu", port=18002) results = client.getRouting('BW', 'RJOB', dt, dt + 1) self.assertEquals(results, {'BW...': [{'end': None, 'host': 'webdc.eu', 'port': 18002, 'priority': 2, 'start': UTCDateTime(1980, 1, 1, 0, 0)}, {'end': None, 'host': 'erde.geophysik.uni-muenchen.de', 'port': 18001, 'priority': 1, 'start': UTCDateTime(1980, 1, 1, 0, 0)}]}) # 4 - IV network via webdc.eu:18001 client = Client(host="webdc.eu", port=18001) results = client.getRouting('IV', '', dt, dt + 1) self.assertEquals(results, {'IV...': [{'priority': 1, 'start': UTCDateTime(1980, 1, 1, 0, 0), 'host': 'eida.rm.ingv.it', 'end': None, 'port': 18002}]}) # 5 - IV network via webdc.eu:18002 client = Client(host="webdc.eu", port=18002) results = client.getRouting('IV', '', dt, dt + 1) self.assertEquals(results, {'IV...': [{'priority': 1, 'start': UTCDateTime(1980, 1, 1, 0, 0), 'host': 'eida.rm.ingv.it', 'end': None, 'port': 18002}]}) # 6 - GE.APE via webdc.eu:18001 client = Client(host="webdc.eu", port=18001) results = client.getRouting('GE', 'APE', dt, dt + 1) self.assertEquals(results, {'GE...': [{'priority': 1, 'start': UTCDateTime(1980, 1, 1, 0, 0), 'host': 'webdc.eu', 'end': None, 'port': 18002}]}) # 7 - GE.APE via webdc.eu:18002 client = Client(host="webdc.eu", port=18002) results = client.getRouting('GE', 'APE', dt, dt + 1) self.assertEquals(results, {'GE...': [{'priority': 1, 'start': UTCDateTime(1980, 1, 1, 0, 0), 'host': 'webdc.eu', 'end': None, 'port': 18002}]}) # 8 - unknown network 00 via webdc.eu:18002 client = Client(host="webdc.eu", port=18002) results = client.getRouting('00', '', dt, dt + 1) self.assertEquals(results, {})
""" Tests getInventory method on various ArcLink nodes. """ # 1 - GE network # 2 - GE network endtime=dt + 1, instruments=True) # 3 - BW network endtime=dt + 1) # 4 - BW network endtime=dt + 1, instruments=True) # 5 - unknown network 00 via webdc.eu:18002 starttime=dt, endtime=dt + 1) # 6 - get channel gain without PAZ self.assertTrue('gain' in result['BW.MANZ..EHE'][0]) self.assertTrue('paz' not in result['BW.MANZ..EHE'][0]) # 7 - history of instruments # GE.SNAA sometimes needs a while therefore we use command_delay=0.1 client = Client(command_delay=0.1) result = client.getInventory('GE', 'SNAA', '', 'BHZ', start, end, instruments=True) self.assertTrue('GE' in result) self.assertTrue('GE.SNAA' in result) self.assertTrue('GE.SNAA..BHZ' in result) self.assertEquals(len(result['GE.SNAA..BHZ']), 4) # sort channel results channel = result['GE.SNAA..BHZ'] channel = sorted(channel, key=operator.itemgetter('starttime')) # check for required attributes self.assertEquals(channel[0].starttime, UTCDateTime("1997-03-03")) self.assertEquals(channel[0].endtime, UTCDateTime("1999-10-11")) self.assertEquals(channel[0].gain, 596224500.0) self.assertEquals(channel[1].starttime, UTCDateTime("1999-10-11")) self.assertEquals(channel[1].endtime, UTCDateTime("2003-01-10")) self.assertEquals(channel[1].gain, 596224500.0) self.assertEquals(channel[2].starttime, UTCDateTime("2003-01-10")) self.assertEquals(channel[2].endtime, UTCDateTime(2011, 1, 15, 9, 56)) self.assertEquals(channel[2].gain, 588000000.0)
""" Requesting inventory data twice should not fail. """ # station # network
""" Bugfix for location and channel codes for new inventory schema """ # new schema # old schema
""" """ # initialize client # example 1 metadata=True) 'network': 'BW', '_format': 'MSEED', 'paz': AttribDict({ 'normalization_factor': 60077000.0, 'name': 'LMU:STS-2/N/g=1500', 'sensitivity': 2516778600.0, 'normalization_frequency': 1.0, 'sensor_manufacturer': 'Streckeisen', 'sensitivity_unit': 'M/S', 'sensitivity_frequency': 0.02, 'poles': [(-0.037004 + 0.037016j), (-0.037004 - 0.037016j), (-251.33 + 0j), (-131.04 - 467.29j), (-131.04 + 467.29j)], 'gain': 60077000.0, 'zeros': [0j, 0j], 'sensor_model': 'STS-2/N'}), 'mseed': AttribDict({ 'record_length': 512, 'encoding': 'STEIM1', 'filesize': 30720L, 'dataquality': 'D', 'number_of_records': 60L, 'byteorder': '>'}), 'coordinates': AttribDict({ 'latitude': 47.737167, 'elevation': 860.0, 'longitude': 12.795714}), 'delta': 0.005, 'station': 'RJOB', 'location': '', 'starttime': UTCDateTime(2010, 8, 1, 12, 0), 'endtime': UTCDateTime(2010, 8, 1, 12, 0, 6, 845000), 'npts': 1370, 'calib': 1.0, 'sampling_rate': 200.0, 'channel': 'EHZ'} # example 2 client = Client() st = client.getWaveform("CZ", "VRAC", "", "BHZ", t, t + 60, metadata=True) results = { 'network': 'CZ', '_format': 'MSEED', 'paz': AttribDict({ 'normalization_factor': 60077000.0, 'name': 'GFZ:CZ1980:STS-2/N/g=20000', 'sensitivity': 8200000000.0, 'normalization_frequency': 1.0, 'sensor_manufacturer': 'Streckeisen', 'sensitivity_unit': 'M/S', 'sensitivity_frequency': 0.02, 'zeros': [0j, 0j], 'gain': 60077000.0, 'poles': [(-0.037004 + 0.037016j), (-0.037004 - 0.037016j), (-251.33 + 0j), (-131.04 - 467.29j), (-131.04 + 467.29j)], 'sensor_model': 'STS-2/N'}), 'mseed': AttribDict({ 'record_length': 512, 'encoding': 'STEIM1', 'filesize': 3584L, 'dataquality': 'D', 'number_of_records': 7L, 'byteorder': '>'}), 'coordinates': AttribDict({ 'latitude': 49.3084, 'elevation': 470.0, 'longitude': 16.5933}), 'delta': 0.025, 'station': 'VRAC', 'location': '', 'starttime': UTCDateTime(2010, 8, 1, 11, 59, 59, 993400), 'endtime': UTCDateTime(2010, 8, 1, 12, 0, 59, 993400), 'npts': 2401, 'calib': 1.0, 'sampling_rate': 40.0, 'channel': 'BHZ'} self.assertEquals(st[0].stats, results)
""" """ # initialize client # example 1 '', '*', start, end) # example 2 '', '*', start, end)
""" """ # initialize client # example 1 '', '*', start, end)
""" """ # initialize client # example 1
""" """ # initialize client # example 1 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)
""" Default behavior is requesting data compressed and unpack on the fly. """ # initialize client # MiniSEED # MiniSEED may not start with Volume Index Control Headers (V) # ArcLink cuts on record base # Full SEED format='FSEED') # Full SEED must start with Volume Index Control Headers (V) # ArcLink cuts on record base finally:
""" Disabling compression during waveform request. """ # initialize client compressed=False)
""" Explicitly disable compression during waveform request and save it directly to disk. """ # initialize client # MiniSEED compressed=False) # MiniSEED may not start with Volume Index Control Headers (V) # ArcLink cuts on record base # Full SEED format='FSEED') # Full SEED format='FSEED') # ArcLink cuts on record base finally:
""" Tests saving compressed and not unpacked bzip2 files to disk. """ # initialize client # MiniSEED unpack=False) # check if compressed # importing via read should work too # Full SEED format="FSEED", unpack=False) # check if compressed # importing via read should work too finally:
""" 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 -2.513300e+02 + 0.000000e+00j, -1.310400e+02 - 4.672900e+02j, -1.310400e+02 + 4.672900e+02j] # initialize client # fetch poles and zeros # compare instrument # PAZ over multiple channels should raise an exception 'EH*', dt)
""" Test for the Client.getPAZ function for erde.geophysik.uni-muenchen.de. """ # fetch poles and zeros
""" Fetches and stores response information as Dataless SEED volume. """ # Dataless SEED finally:
""" 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. """ '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]} # Retrieve data via ArcLink t, t + 30).values()[0] 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:])
""" Testing issue #311. """ # 1 metadata=False) # 2 metadata=True)
""" Test case for issue #372. """ metadata=True) 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)
""" Check results of getInventory if instrumentation has been changed.
Sensitivity change for GE.SNAA..BHZ at 2003-01-10T00:00:00 """ # one instrument in given time span instruments=True, route=False) # two instruments in given time span instruments=True, route=False) # one instrument in given time span instruments=True, route=False)
""" Check results of getWaveform if instrumentation has been changed.
Sensitivity change for GE.SNAA..BHZ at 2003-01-10T00:00:00 """ # one instrument in given time span metadata=True) # two instruments in given time span metadata=True) # results into two traces # with different PAZ # one instrument in given time span metadata=True)
if __name__ == '__main__': unittest.main(defaultTest='suite') |