Beispiel #1
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.save_waveforms(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.save_waveforms(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)
Beispiel #2
0
 def test_save_waveform_compressed(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.save_waveforms(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.save_waveforms(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)
Beispiel #3
0
 def test_save_waveform_compressed(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.save_waveforms(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.save_waveforms(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)
Beispiel #4
0
 def test_save_waveform(self):
     """
     Default behavior is requesting data compressed and unpack on the fly.
     """
     # initialize client
     client = Client('*****@*****.**',
                     host="erde.geophysik.uni-muenchen.de",
                     port=18001)
     start = UTCDateTime(2008, 1, 1)
     end = start + 10
     # MiniSEED
     with NamedTemporaryFile(suffix='.bz2') as tf:
         mseedfile = tf.name
         client.save_waveforms(mseedfile, 'BW', 'MANZ', '', 'EHZ', start,
                               end)
         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.assertLessEqual(st[0].stats.starttime, start)
         self.assertGreaterEqual(st[0].stats.endtime, end)
         self.assertEqual(st[0].stats.network, 'BW')
         self.assertEqual(st[0].stats.station, 'MANZ')
         self.assertEqual(st[0].stats.location, '')
         self.assertEqual(st[0].stats.channel, 'EHZ')
     # Full SEED
     with NamedTemporaryFile(suffix='.bz2') as tf:
         fseedfile = tf.name
         client.save_waveforms(fseedfile,
                               'BW',
                               'MANZ',
                               '',
                               'EHZ',
                               start,
                               end,
                               format='FSEED')
         st = read(fseedfile)
         # Full SEED must start with Volume Index Control Headers (V)
         with open(fseedfile, 'rb') as fp:
             self.assertEqual(fp.read(8)[6:7], b"V")
         # ArcLink cuts on record base
         self.assertLessEqual(st[0].stats.starttime, start)
         self.assertGreaterEqual(st[0].stats.endtime, end)
         self.assertEqual(st[0].stats.network, 'BW')
         self.assertEqual(st[0].stats.station, 'MANZ')
         self.assertEqual(st[0].stats.location, '')
         self.assertEqual(st[0].stats.channel, 'EHZ')
Beispiel #5
0
 def test_save_waveform(self):
     """
     Default behavior is requesting data compressed and unpack on the fly.
     """
     # initialize client
     client = Client('*****@*****.**',
                     host="erde.geophysik.uni-muenchen.de", port=18001)
     start = UTCDateTime(2008, 1, 1)
     end = start + 10
     # MiniSEED
     with NamedTemporaryFile(suffix='.bz2') as tf:
         mseedfile = tf.name
         client.save_waveforms(mseedfile, 'BW', 'MANZ', '', 'EHZ', start,
                               end)
         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.assertLessEqual(st[0].stats.starttime, start)
         self.assertGreaterEqual(st[0].stats.endtime, end)
         self.assertEqual(st[0].stats.network, 'BW')
         self.assertEqual(st[0].stats.station, 'MANZ')
         self.assertEqual(st[0].stats.location, '')
         self.assertEqual(st[0].stats.channel, 'EHZ')
     # Full SEED
     with NamedTemporaryFile(suffix='.bz2') as tf:
         fseedfile = tf.name
         client.save_waveforms(fseedfile, 'BW', 'MANZ', '', 'EHZ', start,
                               end, format='FSEED')
         st = read(fseedfile)
         # Full SEED must start with Volume Index Control Headers (V)
         with open(fseedfile, 'rb') as fp:
             self.assertEqual(fp.read(8)[6:7], b"V")
         # ArcLink cuts on record base
         self.assertLessEqual(st[0].stats.starttime, start)
         self.assertGreaterEqual(st[0].stats.endtime, end)
         self.assertEqual(st[0].stats.network, 'BW')
         self.assertEqual(st[0].stats.station, 'MANZ')
         self.assertEqual(st[0].stats.location, '')
         self.assertEqual(st[0].stats.channel, 'EHZ')
Beispiel #6
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.save_waveforms(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.save_waveforms(fseedfile, "GE", "APE", "", "BHZ", start, end, format="FSEED")
         st = read(fseedfile)
         # Full SEED
         client.save_waveforms(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")
Beispiel #7
0
 def test_save_waveform_no_compression(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.save_waveforms(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.save_waveforms(fseedfile,
                               'GE',
                               'APE',
                               '',
                               'BHZ',
                               start,
                               end,
                               format='FSEED')
         st = read(fseedfile)
         # Full SEED
         client.save_waveforms(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')
Beispiel #8
0
 def test_save_waveform_no_compression(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.save_waveforms(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.save_waveforms(fseedfile, 'GE', 'APE', '', 'BHZ', start,
                               end, format='FSEED')
         st = read(fseedfile)
         # Full SEED
         client.save_waveforms(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')